Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Is it possible to implement two separate Incumbent callback

    Posted 06/16/19 10:50 PM

    Originally posted by: ORA17


    Hello Experts,

    I have implemented two separate Incumbent callbacks in .NET concert to support a very complex constraint:

    internal class MyCallback1 : Cplex.IncumbentCallback

     {

     }

     

    internal class MyCallback2 : Cplex.IncumbentCallback

     {

     }

     

    Then I called both in the following way :

    Cplex model = new Cplex();

    mode.Use(new MyCallback1(arg1, arg2));

    mode.Use(new MyCallback2(arg3, arg4));

     

    But problem is that during solve cplex only caling latest added callback i.e. MyCallback2. How can I make Cplex to call both callbacks?

    Also is it possible to call one callbacks i.e. MyCallback1 multiple times with different arguments?

     

    Thanks in advance!

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Is it possible to implement two separate Incumbent callback

    Posted 06/17/19 03:13 PM

    You cannot use two callbacks of the same type. If you attach callback1 and then callback2 (same type), callback1 is ignored and callback2 is used. So what you need to do is merge the logic of the two callbacks into a single callback.

    As far as "different arguments" goes, I assume you are referring to arguments to the constructor, not arguments in the main method. Again, the answer is no (same reason as before -- the second call will remove the callback from the first call), but I don't see any reason why you would need to do so. Just using a single class MyCallback, pass all four arguments to the constructor and merge the logic. So when the main method is called, it first does whatever MyCallback1 was going to do, then (if still relevant) does whatever MyCallback2 was going to do.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Is it possible to implement two separate Incumbent callback

    Posted 06/24/19 08:02 AM

    Expanding on Paul's answer: what you probably want to have is a single callback class with multiple member functions that perform whatever is necessary. Then you can call these members from the callback's main() as many times as you please.


    #CPLEXOptimizers
    #DecisionOptimization