Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Lazy Constraint Callback

    Posted Wed November 02, 2011 07:17 AM

    Originally posted by: KTAT_Leonardo_Lamorgese


    Hi,
    I am having problems with implementing a callback for adding lazy constraints in integer branching nodes.

    In my model i have two sets of variables: S (continous variables) and Y (Integer variables), and two sets of constraints (A with only S var's and B with both S and Y).
    I start the optimization with a core problem of all and only constraints belonging to A.

    As CPLEX branches, when it finds an integer solution, I implemented a callback which verifies if the solution is feasible. If not, I want to add the (lazy) constraints in B (so both S and Y variables) that are violated, hence narrowing the feasible region.
    By reading some posts I was under the impression that the best way to do so is by using a LazyConstraintCallback, so I tried to follow the Benders cut implementation.

    I implement an extension of LazyConstraintCallback and create an instance of this class in the main method, with the instruction cplex.use(LazyConsCallback(.....), which in my understanding should tell CPLEX to use the callback in every integer node.

    What happens when CPLEX solves is that it only finds the optimal solution to the core problem (not feasible in the master problem), as if it didnt add any LazyConstraints.
    In my debugging attempt it seems to me as if the main() method in my LazyConstraintCallback extension is never called by CPLEX (I simply tried inserting a System.out object in the main() but nothing is printed in output).
    On the otherhand the new instance of LazyConstraintCallback is definetly created.

    Is there something I'm missing? To add the IloConstraint objects don't

    I hope I was clear enough, thank you for your help

    Leo
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Lazy Constraint Callback

    Posted Wed November 02, 2011 07:19 AM

    Originally posted by: KTAT_Leonardo_Lamorgese


    sorry didnt finish writing third line to the end:

    to add the IloConstraint objects donn't I simply have to use the add(IloConstraint) method in the LazyConstraintCallback main() ?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Lazy Constraint Callback

    Posted Thu November 03, 2011 12:54 PM

    Originally posted by: KTAT_Leonardo_Lamorgese


    to be more specific with my question:

    What is "unusual" about this model is that at the first branching node there are only constraints (A) with continuous variables, while constraints including (also) integer variables (they are big-M constraints) are added later on in the branching tree (precisely in nodes corrisponding to integer solutions).

    Clearly the ideal thing would be to use column generation for these integer variables (Y) in the branching process, so i would not run the "risk" of not using some of these variables, but this is not allowed by CPLEX.

    So as a loophole I tried to initialise them all, and then use a variable only if its corrisponding row is generated. Out of the entire set of integer variables (Y) only a small subset is infact actually used.

    What I'm wondering is if the reason the LazyConstraintCallback main() is never called is for some CPLEX preprocessing routine that eliminates all these integer variables (even though I have set the presolve parameter to false).

    These are the parameter instructions I give CPLEX in the main method:

    cplex.setParam(IloCplex.BooleanParam.PreInd, false);
    cplex.setParam(IloCplex.IntParam.Threads, 1);
    cplex.setParam(IloCplex.IntParam.MIPSearch, IloCplex.MIPSearch.Traditional);
    cplex.setParam(IloCplex.IntParam.Reduce, 0);

    Are they correct? do you think that this procedure should work?

    thank you for any much appreciated help
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Lazy Constraint Callback

    Posted Thu November 03, 2011 06:28 PM

    Originally posted by: SystemAdmin


    If you are worried that CPLEX is eliminating the integer variables, try adding to the original problem a constraint that the sum of the integer variables is less than or equal to some liberal upper bound. See if that corrects things.

    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


  • 5.  Re: Lazy Constraint Callback

    Posted Tue November 08, 2011 07:24 AM

    Originally posted by: KTAT_Leonardo_Lamorgese


    Thank you Professor that indeed did the trick, I guess CPLEX always eliminates variables that are not in any constraints.

    There is one more question I would like to ask:

    is it possible to add the same IloNumVar[] object to different IloCplex objects?
    Because in my separation oracle (which in Benders ATSP example is denoted as Worker LP), once I identify the violated lazy constraint, to create such a constraint (I follow the example) I add it to a the Worker LP IloCplex object (lets call it "cplex" different from the IloCplex object the master works on, lets call it "CPLEX").

    If I use the same variables used in "CPLEX" to add the constraint to "cplex", the IloRange object that comes out is null.
    If I use new variables, then the original "CPLEX" does not recognize them.

    In Benders ATSP example, variables initialised by the master IloCplex object (x[i][j]) seem to be added in the Worker IloCplex Object, it is not clear to me how this is done.

    Thank you for your time
    #CPLEXOptimizers
    #DecisionOptimization