Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

  • 1.  solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Tue January 07, 2025 09:12 AM

    I am trying to solve a small setcover problem with cplex.

    What I don't understand is how it is possible that solve() returns false while getCplexStatus() and getStatus() show Optimal. 

    What is the cause of this?

    This is the output of cplex:

    Tried aggregator 1 time.
    MIP Presolve eliminated 274 rows and 296 columns.
    All rows and columns eliminated.
    Presolve time = 0.00 sec. (0.16 ticks)
    
    Root node processing (before b&c):
      Real time             =    0.00 sec. (0.20 ticks)
    Parallel b&c, 12 threads:
      Real time             =    0.00 sec. (0.00 ticks)
      Sync time (average)   =    0.00 sec.
      Wait time (average)   =    0.00 sec.
                              ------------
    Total (root+branch&cut) =    0.00 sec. (0.20 ticks)

    From what I understand the problem was "simple" and was solved in the presolve step. 

    Is this a possible explanation for the behavior described above?

    How do I get the values of the variables? If i call getValues() i get an exception.



    ------------------------------
    Leonardo Parisi
    ------------------------------


  • 2.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Tue January 07, 2025 10:34 AM

    Hi Leonardo,

    That looks unexpected.
    Could you share your model or a minimal example such that we can take a look ?
    Which cplex version do you use ?



    ------------------------------
    Cédric Doens
    ------------------------------



  • 3.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Tue January 07, 2025 10:45 AM

    Hi Cédric,

    i am using the version version 22.1.0
    there is a way to export the model or anything that might be useful?
    my program is written in C/C++

    thanks



    ------------------------------
    Leonardo Parisi
    ------------------------------



  • 4.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Tue January 07, 2025 11:06 AM

    You may  cplex.exportModel("model.lp")

    or post directly your model code



    ------------------------------
    Cédric Doens
    ------------------------------



  • 5.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Wed January 08, 2025 09:25 AM
      |   view attached

    Hi Cédric,

    this is the exported model.

    I hope i can be helpful



    ------------------------------
    Leonardo Parisi
    ------------------------------

    Attachment(s)

    lp
    model.lp   18 KB 1 version


  • 6.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Thu January 09, 2025 01:31 PM

    Hello,

    removing the '?' in your file, I have no problem with the same cplex version, with the following code, do you?

    
          IloObjective   obj;
          IloNumVarArray var(env);
          IloRangeArray  rng(env);
          cplex.importModel(model, "model.lp" , obj, var, rng);
          cplex.extract(model);
          cplex.solve();
    
          IloNumArray vals(env);
          cplex.getValues(vals, var);
          env.out() << "Solution status = " << cplex.getStatus() << endl;
          env.out() << "Solution value  = " << cplex.getObjValue() << endl;
          env.out() << "Values          = " << vals << endl;


    ------------------------------
    Olivier Lhomme
    ------------------------------



  • 7.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Fri January 10, 2025 06:29 AM

    Hello Olivier
    what do you mean by "removing the '?' in your file"?



    ------------------------------
    Leonardo Parisi
    ------------------------------



  • 8.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Fri January 10, 2025 09:02 AM

    In the model you sent, the objective begins as follows, you do not have it? or maybe there is a meaning of the "?" that I am not aware of?

    obj1: - ? x1 - ? x2 + 1.21658980540257 x3 - ? x4 - ? x5 + 0.543968849921459 x6
           - ? x7 + 0.502788189871249 x8 - ? x9 + 1.71027162985521 x10 - ? x11


    ------------------------------
    Olivier Lhomme
    ------------------------------



  • 9.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Fri January 10, 2025 09:09 AM

    it's my first time exporting a model and I don't know what either the "?" means or much of what's written in the file



    ------------------------------
    Leonardo Parisi
    ------------------------------



  • 10.  RE: solve() returns false but getCplexStatus() shows Optimal - All rows and columns eliminated

    Posted Fri January 10, 2025 09:51 AM

    The variables in the objective have "?" in their name which makes them different from the variables in the constraints.

    The objective function is thus deconnected from the constraints and presolve can remove any constaints. Removing the "?" in the .lp file connects the objective variables and the ones in the constraints. The model can thus be solved to optimality an a solution is available. It seems that this gives the model you want and you need to check the variables you create for that model in the code that generates it.