Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

addRows leads to unfeasible model, but assigning A,lhs,rhs directly doesn't

  • 1.  addRows leads to unfeasible model, but assigning A,lhs,rhs directly doesn't

    Posted Fri January 20, 2012 09:02 AM

    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


  • 2.  Re: addRows leads to unfeasible model, but assigning A,lhs,rhs directly doesn't

    Posted Sat January 21, 2012 08:34 AM

    Originally posted by: SystemAdmin


    The first step to analyze this behavior should be the same as suggested in the thread you quoted: Create the model with both of the two methods and then export them to an LP file. Then compare the two LP files. Do you see any differences? What are the differences that you can see in the two files? If methods A and B indeed create the same problem then the two LP files should be identical.
    Do you observe any differences between the two LP files?
    If not, then please repeat the same exercise but export to SAV files instead. Are these two files still the same? (Note that SAV files are binary and you will need a tool that can compare binary files, like 'diff' for example).
    #CPLEXOptimizers
    #DecisionOptimization