mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 08:28:52 -06:00
Fix indices
This commit is contained in:
@@ -82,7 +82,7 @@ function collect(
|
|||||||
cuts_rhs = Float64[]
|
cuts_rhs = Float64[]
|
||||||
cuts_var_names = String[]
|
cuts_var_names = String[]
|
||||||
|
|
||||||
for i in 0:(nvars-1)
|
for i in 1:nvars
|
||||||
push!(cuts_var_names, name(VariableRef(model, MOI.VariableIndex(i))))
|
push!(cuts_var_names, name(VariableRef(model, MOI.VariableIndex(i))))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -92,7 +92,11 @@ function collect(
|
|||||||
c = constraint_object(conRef)
|
c = constraint_object(conRef)
|
||||||
cset = MOI.get(conRef.model.moi_backend, MOI.ConstraintSet(), conRef.index)
|
cset = MOI.get(conRef.model.moi_backend, MOI.ConstraintSet(), conRef.index)
|
||||||
for (key, val) in c.func.terms
|
for (key, val) in c.func.terms
|
||||||
cuts_lhs[offset, key.index.value] = val
|
idx = key.index.value
|
||||||
|
if (idx < 1 || idx > nvars)
|
||||||
|
error("invalid index: $idx")
|
||||||
|
end
|
||||||
|
cuts_lhs[offset, idx - 1] = val
|
||||||
end
|
end
|
||||||
push!(cuts_rhs, cset.upper)
|
push!(cuts_rhs, cset.upper)
|
||||||
offset += 1
|
offset += 1
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ function test_cuts_blackbox_cplex()
|
|||||||
|
|
||||||
# Read HDF5 file
|
# Read HDF5 file
|
||||||
h5 = Hdf5Sample(h5_filename)
|
h5 = Hdf5Sample(h5_filename)
|
||||||
lhs = h5.get_sparse("cuts_cpx_lhs")
|
|
||||||
rhs = h5.get_array("cuts_cpx_rhs")
|
rhs = h5.get_array("cuts_cpx_rhs")
|
||||||
h5.file.close()
|
h5.file.close()
|
||||||
@test lhs.shape == (22, 100)
|
|
||||||
@test length(rhs) == 22
|
@test length(rhs) == 22
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user