Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex Callbacks in Java

    Posted 03/03/19 01:09 PM

    Originally posted by: Farouk HAMMAMI


    Hello,

    I am trying to solve a MIP using Java and CPLEX and i need some informations about how to ask CPLEX to add a contraint (cut) each time it finds a feasible solution (i.e. i want CPLEX to verify if this solution respects some specific contraint C1 not included in the MIP)???

    My second question is about how to add these constraints (C2, C3, ...), for example: Imagine i am solving a vehicle routing problem and i want CPLEX, each time a solution is finded to verify a constraint (let's call it C1) then to add new constraints (C2, C3,...) if the solution does not respect C1.

    Thank you.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex Callbacks in Java

    Posted 03/03/19 02:32 PM

    You can implement this either with a lazy constraint callback (see the examples at the bottom of this page) or by using the CANDIDATE context of the generic callback (see here).


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex Callbacks in Java

    Posted 03/03/19 02:53 PM

    Originally posted by: Farouk HAMMAMI


    Thank you for your quick reply however i still don't understand well which function how to say "if a feasible solution is found" then call a function called...

     

    Thanks for your help.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex Callbacks in Java

    Posted 03/03/19 09:32 PM

    Originally posted by: Lessi


     

    Lazy constraint callback is activated only when CPLEX finds a feasible solution to your model. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex Callbacks in Java

    Posted 03/08/19 07:38 PM

    Originally posted by: Farouk HAMMAMI


    Thank you all, one last question. What is the difference between this 2 expressions:

    cplex.le(IloLinearNumExpr, Bound); and add(cplex.addLe(IloLinearNumExpr, Bound)); ?

    In my case, i'am looking to add a constraint each time a condition is not verified when lazycallback is called.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex Callbacks in Java

    Posted 03/09/19 02:04 PM

    IloCplex.le() creates a constraint (instance of IloRange) but does not add it to the model (or to the cut pool). IloCplex.addLe() creates an IloRange and adds it to the model. This is appropriate when you are building the model but should not be used inside a callback. (Trying to modify a model while it is being solved will cause an exception, crash or implosion of the universe). Finally, IloCplex.LazyConstraintCallback.add() and IloCplex.UserCutCallback.add() add an IloRange instance to the lazy constraint pool or user cut pool, respectively. This is safe because the new cut/constraint is not actually added to the model itself, but rather kept in a separate pool. All the methods also return a pointer to the IloRange instance.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex Callbacks in Java

    Posted 03/10/19 01:39 AM

    Note that using add(addLe(...)) (what you posted in your question) is wrong. This will add the constraint twice! Moreover, calling addLe() from a callback is forbidden.

    In order to add a lazy constraint or user cut from a callback use add(le(...)).


    #CPLEXOptimizers
    #DecisionOptimization