diff --git a/src/Cuts/BlackBox/cplex.jl b/src/Cuts/BlackBox/cplex.jl index bc37068..cf2bdaa 100644 --- a/src/Cuts/BlackBox/cplex.jl +++ b/src/Cuts/BlackBox/cplex.jl @@ -82,7 +82,7 @@ function collect( cuts_rhs = Float64[] 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)))) end @@ -92,7 +92,11 @@ function collect( c = constraint_object(conRef) cset = MOI.get(conRef.model.moi_backend, MOI.ConstraintSet(), conRef.index) 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 push!(cuts_rhs, cset.upper) offset += 1 diff --git a/test/Cuts/BlackBox/test_cplex.jl b/test/Cuts/BlackBox/test_cplex.jl index 7b97e50..2ea9175 100644 --- a/test/Cuts/BlackBox/test_cplex.jl +++ b/test/Cuts/BlackBox/test_cplex.jl @@ -15,9 +15,7 @@ function test_cuts_blackbox_cplex() # Read HDF5 file h5 = Hdf5Sample(h5_filename) - lhs = h5.get_sparse("cuts_cpx_lhs") rhs = h5.get_array("cuts_cpx_rhs") h5.file.close() - @test lhs.shape == (22, 100) @test length(rhs) == 22 end