Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Problem with MIP start solution --> "optimal" solution is not optimal!

  • 1.  Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed May 09, 2012 05:58 AM

    Originally posted by: Seb-Seb


    Hi,
    I have a question concerning CPLEX 12.4 under C#:

    I want to solve an MIP with CPLEX to optimality (i.e., gap = 0.0%). To help CPLEX, I want to start with an initial starting solution. There seem to be two different concepts, namely "SetVectors" as well as "AddMIPStart", and I'm not sure which one is the right one to use. Anyway, I have checked both of them:

    1. method: cplex.SetVectors(values, null, variables, null, null, null);

    2. method: cplex.AddMIPStart(variables, values);

    where variables are of type INumVar[ ] and values are of type double[ ].
    And now, here comes my problem:
    Both methods seem to work. At least, CPLEX indeed starts with a solution that has the same objective value as in my given start solution. But then, CPLEX stops very quickly and claims to have found an optimal solution with this objective value. However, this cannot be true because the start solution is NOT optimal. If I solve the same MIP with CPLEX just without a given start solution, CPLEX indeed finds a strictly better solution. But with a given start solution, CPLEX returns a non-optimal solution and claims it is optimal. What happened here?

    In my opinion, if gap = 0.0%, CPLEX should ALWAYS compute an optimal solution, whether I start it with a (either feasible or even non-feasible) start solution or not. But apparently, it doesn't.

    Does anybody know the reason? Did I do something wrong? And, by the way, which of the above methods is the right one to start an MIP with a given solution? Thank you very much for your help!

    PS: Just one more remark: In my case, the optimal objective function value might be negative, but this should not be a problem, should it? I start CPLEX with a start solution with positive objective value 61, the first lower bound provided by CPLEX is -48.000, and then it returns 61 as optimal objective value. The true optimum, however, is 57 (in a minimization problem).
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed May 09, 2012 06:13 AM

    Originally posted by: SystemAdmin


    Easy things first: You should use AddMIPStart() instead of SetVectors() for MIP. SetVectors() basically does the same but the MIP start API is more flexible. For example, it allows you to add multiple MIP starts, change MIP starts, control the effort level etc.

    Adding a MIP start to jump-start CPLEX should of course not lead to invalid claims of optimality. To figure out what is going on we would need more details. Could you post the CPLEX output (the log) of both cases here?
    Even better, could you add these lines to your code right before you call cplex.Solve():
    cplex.WriteMIPStarts("model.mst");
    cplex.WriteParam("model.prm");
    cplex.ExportModel("model.sav");
    

    and attach the three generated files here? Or if you don't want to reveal the files here send them to me at daniel(dot)junglas(at)de(dot)ibm(dot)com?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed May 09, 2012 07:30 AM

    Originally posted by: Seb-Seb


    Hi,
    thanks a lot for this very fast answer. Ok, I will send you all files by email.

    Just one more remark which I just found out: If I use

    cplex.AddMIPStart(variables, values, Cplex.MIPStartEffort.CheckFeas);

    instead of only

    cplex.AddMIPStart(variables, values);

    the first line in the log file is: "Warning: No solution found from 1 MIP starts."

    To me, this sounds as if the given start solution is infeasible. In my opinion, it should be feasible, but ok, maybe I should check this again. Nevertheless, the problem remains the same. Even if my start solution is infeasible, CPLEX should still find an optimal solution.

    Thanks again for any ideas.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed May 09, 2012 07:37 AM

    Originally posted by: Seb-Seb


    oh, one more remark:

    If I use any of the following lines

    cplex.AddMIPStart(variables, values, Cplex.MIPStartEffort.CheckFeas);
    cplex.AddMIPStart(variables, values, Cplex.MIPStartEffort.SolveFixed);

    CPLEX does not start with my start solution, but it finds a true optimal solution.


    If I use any of the following lines

    cplex.AddMIPStart(variables, values, Cplex.MIPStartEffort.Auto);
    cplex.AddMIPStart(variables, values, Cplex.MIPStartEffort.Repair);
    cplex.AddMIPStart(variables, values, Cplex.MIPStartEffort.SolveMIP);

    CPLEX does start with my start solution, but it returns a non-optimal solution.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed August 29, 2012 07:36 AM

    Originally posted by: SystemAdmin


    Hi !
    I don't quite get it. I'm trying to add a MIP start to my problem and thought that, in such a method, we had to fix integer variables (beacause they are obviously the hard ones to find for cplx). But there is only a addMIPStart(IloNumVarArray, IloNumArray) method...

    Is that possible to give cplex a MIP solution so that it could start from that one ?

    More exactly, if I computed a feasible (or nearly one) solution, I would like cplex to try to repair it if it is not feasible then return it.

    Thanks for your help

    Adrian
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed August 29, 2012 07:43 PM

    Originally posted by: SystemAdmin


    > AdriBoillot wrote:
    > I don't quite get it. I'm trying to add a MIP start to my problem and thought that, in such a method, we had to fix integer variables (beacause they are obviously the hard ones to find for cplx). But there is only a addMIPStart(IloNumVarArray, IloNumArray) method...
    >
    I'm not sure what your concern is, but if it's the fact that the first argument is IloNumVarArray rather than IloBoolVarArray or IloIntVarArray, keep in mind that integer and boolean variables are subspecies of numeric variables. So you can include integer variables within the array in the first argument.

    As far as repairing the solution (including fixing the integer variables and solving for continuous variables), that's controlled by the effort argument to addMIPStart.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Thu August 30, 2012 02:47 AM

    Originally posted by: SystemAdmin


    Hi,
    Thanks for your quick answer and your nice quotation,

    The fact is that if I add an MIP start fixing my integer variables with IloNumVarArray, then I receive an error saying that my integer variables are integer/boolean and that the model cannot be launched...
    (I use an IloOplModelSource by the way... I don't know if that count for something)

    So I am blocked with my integer variables that have to be fixed as so, otherwise the model crashes...
    Is my issue clear enough ?

    Thanks !
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Thu August 30, 2012 04:25 AM
    Hi,

    are you aware of the example that is in

    opl\examples\opl\warmstart

    and that shows how to do warmstart within OPL ?

    Regards
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Thu September 13, 2012 02:27 AM

    Originally posted by: SystemAdmin


    Hi Alex,

    Yes, I was aware of the warmstart.mod file, but my issue is different.
    I launch an OPL model with C++ API and, thanks to a heuristic, I create a solution that I want to give as a warmstart.
    So I am closer to a C++ warmstart.
    But I am facing big troubles giving CPLEX my solution because of, as I said upper, the type of the variables.

    Thanks for your concern,

    Adrian
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed September 19, 2012 03:14 AM

    Originally posted by: SystemAdmin


    Do I understand correctly: You call addMIPStart() with an instance of IloIntVarArray and get an exception?
    Could you post the code that sets up the IloIntVarArray and calls addMIPStart()?
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Wed September 19, 2012 03:25 AM

    Originally posted by: SystemAdmin


    Here is the code :

    
    IloEnv                             envMIPS; IloOplErrorHandler             handlerMIPS     (envMIPS, cout); IloOplModelSource              modelSourceMIPS (envMIPS, MODEL_PATH ); IloOplSettings                  settingsMIPS    (envMIPS, handlerMIPS); IloOplModelDefinition           defMIPS         (modelSourceMIPS, settingsMIPS); IloCplex                       cplexMIPS       (envMIPS); IloOplModel                  oplMIPS         (defMIPS, cplexMIPS); IloOplDataSource          dataSourceMIPS  (envMIPS, DATA_PATH );   oplMIPS.addDataSource(dataSourceMIPS);   oplMIPS.generate(); IloNumVarMap    Xvar    = oplMIPS.getElement(
    "X").asNumVarMap(); IloTupleSet Index   = oplMIPS.getElement(
    "Index").asTupleSet(); IloIntMap        Group   = oplMIPS.getElement(
    "Groupe").asIntMap(); IloTupleBuffer    buf; IloTuple   indexTuple; IloNumVarArray startVar(envMIPS, NbUs); IloNumArray    startVal(envMIPS, NbUs); 
    
    int k = 0; 
    
    for(IloInt t = 1; t <= Ttot ; t++)
    { 
    
    for(IloInt u = 1 ; u <= NbUs; u++)
    { IloInt Gr =  Group[t].get(u); 
    
    for(IloInt g = 1; g <= Gr; g++)
    { buf = Index.makeTupleBuffer(-1); buf.setIntValue(
    "t", t); buf.setIntValue(
    "u", u); buf.setIntValue(
    "g", g); buf.commit(); indexTuple = Index.find(buf); 
    
    assert( k < NbUs ); startVar[k] = Xvar.get(indexTuple); startVal[k] = Xvalues[ConvertIndex(t,u,g)]; k++; 
    } 
    } 
    } 
    
    assert( k == NbUs ); cplexMIPS.addMIPStart(startVar, startVal);
    


    As I told before, X is actually an Integer variable, but as assMIPStart does not provide Integer type, I changed it to Num...

    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Problem with MIP start solution --> "optimal" solution is not optimal!

    Posted Thu September 20, 2012 03:34 AM

    Originally posted by: SystemAdmin


    Hm, that is beyond by OPL capabilities :-( Can you please turn to the OPL Forum and ask your question there?
    #CPLEXOptimizers
    #DecisionOptimization