Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

How to access current solution of LP at each iteration?

  • 1.  How to access current solution of LP at each iteration?

    Posted Tue December 15, 2015 10:57 AM

    Originally posted by: bebulo


    I see that ILOSIMPLEXCALLBACK is called at end of each iteration. I can access the status and objective value in the callback, but how can I access the current solution?

    edit:

    static ILOBARRIERCALLBACK2(MyCallback, IloCplex, cplex, IloNumVarArray, x) {
        cout << "Iteration " << getNiterations() << ": ";
        if (isFeasible()) {
            cout << "Objective = " << getObjValue() << endl;
            //cout << "x[0] = " << (float)cplex.getValue(x[0]) << endl;  

            //Concert exception caught: CPLEX Error  1217: No solution exists.
        }
        else {
            cout << "Infeasibility measure = " << getInfeasibility() << endl;
        }
    }


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to access current solution of LP at each iteration?

    Posted Wed December 16, 2015 03:50 AM

    Originally posted by: RWunderling


    This information is not available from within a callback.  In general, only the methods of the callback classes can be used within a callback, but not the methods of the cplex object currently being optimized.

    You can, however, set an iteration limit of 1 and call the Simplex optimizer from within a loop.  Note, that this will not reproduce the same solution path as calling Simplex without limit and performance will suffer.

    Roland


    #CPLEXOptimizers
    #DecisionOptimization