Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Heuristic Callback - Incumbent Solution Missing

    Posted 09/14/12 05:15 AM

    Originally posted by: SystemAdmin


    Hi,

    I am developing an heuristic that improves the first Incumbent solution that CPLEX finds.
    So I check if there is such a solution (+hasIncumbent()+) and if so I give my heuristic builder the IloOplModel in order to get back data and most of all my variables values. But when I try to read those ones :

    IloIntMap X;
    try{
            X = oplModel.getElement("X").asIntMap();
    }
    catch(IloException & e ) {
            cout << "### CONCERT exception: ";
            e.print(cout);
    }
    

    I receive an exception saying that no solution is available.

    Can anyone help me on that one ?
    I do not get why I cannot get my incumbent solution!

    Thanks,
    Adrian
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Heuristic Callback - Incumbent Solution Missing

    Posted 09/19/12 05:50 AM

    Originally posted by: SystemAdmin


    Do you want to get the incumbent from within a callback, or only after the solving process (e.g., with a solution limit of 1) returns?

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Heuristic Callback - Incumbent Solution Missing

    Posted 09/19/12 07:15 AM

    Originally posted by: SystemAdmin


    Hi,

    In fact, I'd like to be able to do both.
    To get an only one solution when working with a constructive heuristic,
    Or the current best one (within potential others) with an improving one...

    In fact, I could get back an incumbent solution with getIncumbentValues but I still find strange that the above code gives back an exception...

    Is there a better way to get a similar result?
    And why does that exception happen ?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Heuristic Callback - Incumbent Solution Missing

    Posted 10/15/12 09:56 AM

    Originally posted by: SystemAdmin


    After having finished the cplex.solve(), your code should work (does it?).
    But from within a callback, the current incumbent solution is not yet attached to the original model, hence your code will say that no solution exists.
    The reason is that the unpresolve operation (to convert the solution, expressed in the presolved model, into a solution of the original model) happens only at the very end of the solve() call. Thus, from a callback, you need to use getIncumbentValues().

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Heuristic Callback - Incumbent Solution Missing

    Posted 10/16/12 02:56 AM

    Originally posted by: SystemAdmin


    Ok, so with getIncumbent() I have the best solution so far, but is it possible to get back the best bound (relaxed solution) ?
    Like for example, just at the begining of branch and bound, get from cplex, the lp solution (relaxed solution) ?
    (without having to change the model...)
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Heuristic Callback - Incumbent Solution Missing

    Posted 10/16/12 04:49 AM

    Originally posted by: SystemAdmin


    Did you implement your callback as a sub-class of IloCplex::ControlCallbackI (or one of its child classes)? If so, you would just use IloCplex::ControlCallbackI.getValue() or getValues().

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Heuristic Callback - Incumbent Solution Missing

    Posted 10/16/12 05:49 AM

    Originally posted by: SystemAdmin


    The dual bound is available via getBestObjValue() in callbacks.
    To get the variable values in the solution to the relaxation at the current node use getValue() (like Tobias said).
    To get that information for the root node just use a branch callback and store away the information when the branch callback is invoked for the first time.
    #CPLEXOptimizers
    #DecisionOptimization