Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  how to access cplex infeasibility message

    Posted 04/21/10 05:49 AM

    Originally posted by: ChristopheV


    Dear all,

    I am solving a model which is (for certain parameter values) infeasible. The fact that the model is infeasible is correct and the desired behavior. The logging (half my own logging and half CPLEX logging) looks as follows:

    ---
    ...
    Cplex version 12.1.0
    MIP display parameter: 2
    Starting CPLEX attempt 1 out of 1.
    Row '(RL2-505) : Gelimiteerde capaciteit voor de gieterijen_0' infeasible, all entries at implied bounds.
    Presolve time = 0.00 sec.
    ...
    ---

    Cplex has thus detected that a certain row is infeasible, and logged this. Now it would be interesting for me to be able to access this message (e.g. from the cplex object), f.i. to show it in the GUI of the user (so that the user does not need to look in the log file).

    Is there any clean way to access this message?

    Thanks in advance!
    Christophe

    PS: In certain other cases, when no solution is found, an IloException is thrown (I guess such an exception is thrown once we are after the presolve step?). Using the getMessage() method, I can then extract an error message to show in the GUI, similar to what I also want to do in the case described above when no exception is thrown.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: how to access cplex infeasibility message

    Posted 04/21/10 08:31 AM

    Originally posted by: SystemAdmin


    I don't know about accessing the specific message, but if your intent is to communicate to users why their model is infeasible, it might be more productive to use IloCplex.refineConflict followed by IloCplex.getConflict. The error message indicates where the infeasibility ultimately manifested itself, but the source of the infeasibility will typically be some combination of constraints and bounds, not a single constraint.

    /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


  • 3.  Re: how to access cplex infeasibility message

    Posted 04/21/10 08:41 AM

    Originally posted by: SystemAdmin


    If you only want to present the message (and not the conflict itself) to the user you can try to use IloCplex::setOut(), setWarning() and setError() to capture the messages CPLEX issues and present everything you want to the user.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: how to access cplex infeasibility message

    Posted 04/22/10 11:14 AM

    Originally posted by: ChristopheV


    Thank you for your answer! I've chosen for the quick (and in my opinion slightly dirty) option to capture the logging stream and "parse" it (I just take the last few lines). This information is then sent to my GUI. It is still a pity, however, that I cannot access the message in a cleaner way...

    I had already considered the option given by Paul of using the refineConflict/getConflict, but as I don't want the IloConstraintArray (needed for the refineConflict method) to be constructed except if the model turns out to be infeasible, it didn't seem clear to me how to do this. In other words, I am not aware of a method to construct the IloConstraintArray easily after the model was built and the cplex object was already extracted (if this is even possible).

    Again,
    thanks to both (Paul and Daniel) for the helpful answers!
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: how to access cplex infeasibility message

    Posted 04/22/10 11:30 AM

    Originally posted by: SystemAdmin


    If parsing the message is too ugly for you, why don't you just check the return status of CPLEX and report "infeasible" to the user in the GUI.
    The constraint shown in the infeasibility message will not necessarily be helpful to the user as it is just a part of the conflict and the user might not be able to identify the conflict from this single conflict.
    I'd go with Paul's suggestion to use refineConflict(). To build up the constraint array use the model iterator:
    IloConstraintArray allConstraints(env);
    for (IloModel::Iterator it(cplex.getModel()); it.ok(); ++it) {
       IloExtractable ex =  *it;
       if (ex.isConstraint()) {
          allConstraints.add(ex.asConstraint());
       } else if (ex.isVariable()) {
          IloNumVar v = ex.asVariable();
          if (v.getLB() > -IloInfinity)
             allConstraints.add(IloBound(v, IloBound::Lower));
          if (v.getUB() < IloInfinity)
             allConstraints.add(IloBound(v, IloBound::Upper));
       }
    }
    

    Note that I also added the bounds of variables to the constraint array so that they may be part of the conflict.
    Function refineConflict() may take some time so you may want to ask the user if the conflict should be computed or not.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: how to access cplex infeasibility message

    Posted 04/22/10 12:09 PM

    Originally posted by: SystemAdmin


    > ChristopheV wrote:
    > I had already considered the option given by Paul of using the refineConflict/getConflict, but as I don't want the IloConstraintArray (needed for the refineConflict method) to be constructed except if the model turns out to be infeasible, it didn't seem clear to me how to do this. In other words, I am not aware of a method to construct the IloConstraintArray easily after the model was built and the cplex object was already extracted (if this is even possible).

    If you are reading in a model (LP or MPS format, for instance), you would need to run an iterator over it to identify the constraints. If you are building the model using one of the Concert APIs, though, this should be pretty trivial. The methods used to add constraints to a model typically return a pointer to the constraint; you just have to store all those pointers in an array. Note that the array will not waste much storage, since it just contains pointers, not the constraints themselves.

    /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: how to access cplex infeasibility message

    Posted 04/23/10 02:43 AM

    Originally posted by: ChristopheV


    Thank you both again for the feedback! I'll certainly try using the iterators and the conflictRefinement, and i will let you know how it worked for my case. Thanks!
    #CPLEXOptimizers
    #DecisionOptimization