Originally posted by: Khronum
I have noticed that when using the CPLEX MATLAB Class API to solve binary linear programming problems where constraints may be added iteratively, I get different results depending on how I re-redefine the constraints. More specifically:
1) Say I define a model as follows:
cplex_obj = Cplex(); ... cplex_obj.Model.A = A_1; cplex_obj.Model.lhs = lhs_1; cplex_obj.Model.rhs = rhs_1; cplex_obj.solve(); ...
2) Say that I now want to add a new set of constraints to my model (just one extra inequality). I can do this using
Method A or
Method B below
Method A:
cplex_obj.addRows(lhs_2, A_2, rhs_2); cplex_obj.solve();
Method B:
A_new = [A_1; A_2]; lhs_new = [lhs_1; lhs_2]; rhs_new = [rhs_1; rhs_2]; cplex_obj.Model.A = A_new; cplex_obj.Model.lhs = lhs_new; cplex_obj.Model.rhs = rhs_new; cplex_obj.solve()
It turns out that for some of my models,
Method A leads to an
unfeasible model (which I know it's wrong after I carefully analyzed the model theoretically), whereas
Method B leads to a
feasible model that I am highly confident is the
correct one.
I have reproduced the above multiple times. For some other problems
Method_A above leads to a
suboptimal solution, whereas
Method_B leads to the correct fully optimal solution (as I reported before
here)
This is with MATLAB on Windows 64 bit with CPLEX 12.3.
#CPLEXOptimizers#DecisionOptimization