Decision Optimization

 View Only
Expand all | Collapse all

how to properly create a range object in the branch callback

  • 1.  how to properly create a range object in the branch callback

    Posted Wed June 24, 2020 05:46 AM
    Edited by System Fri January 20, 2023 04:41 PM
    hi

    I want to create an IloRange object inside the branch callback, so that I can invoke the makeBranch() method which uses an IloRange argument.

    to create an IloRange object or an IloNumExpr,  looks like I need an IloCplex object, so that I can do this :

    IloCplex cplex =  new IloCplex ();
    cplex.importModel( MIP_FILENAME);  
    cplex.use (myBranchcallback);

    //inside the callback or anywhere else
    IloNumExpr expr= cplex.numExpr();
    IloRange rng = cplex,le ( expr, 0 );

    the problem is that the branch callback needs to be passed the IloCplex object for which it is the branch callback, so that I can use the IloCplex object inside the branch callback to create the IloRange object.
    This does not seem correct. Is there a better way to do this.

    Possibly there should be an example java file included with cplex which shows how to do this. Please say which one.

    Thank you !


    ------------------------------
    srinivas tamvada
    ------------------------------
    #DecisionOptimization


  • 2.  RE: how to properly create a range object in the branch callback

    Posted Wed June 24, 2020 07:13 AM
    Yes, you have to pass the IloCplex class to the callback in the constructor or some other appropriate place. Look at the examples that separate cuts or lazy constraints, such as AdMIPex5.java. Note that these upcast the class to IloModeler (or IloMPModeler) because the methods of this factory class are the only methods that are safe to use from within a callback.

    ------------------------------
    Daniel Junglas
    ------------------------------