Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Detaching Callbacks (Java API)

    Posted Mon May 23, 2016 02:51 PM

    Hi all,

    I've been poring over the Java API docs, and the only way I can find to detach a callback from an instance of IloCplex is to invoke IloCplex.clearCallbacks(), which detaches all the callbacks, and then reattach all the other ones. Did I miss something? This looks like the programming equivalent of "throwing out the baby with the bath water", particularly if the block of code where you want to detach a callback does not know/have easy access to a list of all the other attached callbacks.

    Paul

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Detaching Callbacks (Java API)

    Posted Mon May 23, 2016 07:19 PM

    I don't think you are missing anything, Paul.  As a possible workaround, you can (re)set the callback, of the particular type you're done with, to a no-op version of the callback.  Alternatively, set a boolean inside of your callback that makes it behave as a no-op.  I hacked a version of AdMIPex5.java to play with this and it seems to do the trick (see attachment).


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Detaching Callbacks (Java API)

    Posted Mon May 23, 2016 07:38 PM

    Thanks, Ryan. I thought of something like this, but there's one problem with it: if you are trying to remove a control callback by substituting a no-op version, any changes triggered by the presence of a control callback (disabling dynamic search, disabling some dual fixing stuff if it's a lazy constraint callback, ...) will persist, right?


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Detaching Callbacks (Java API)

    Posted Mon May 23, 2016 07:49 PM

    Yes, I agree; those (undesirable) things would persist.  I will check with others to see if there's some better solution.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Detaching Callbacks (Java API)

    Posted Mon May 23, 2016 07:57 PM


  • 6.  Re: Detaching Callbacks (Java API)

    Posted Wed May 25, 2016 11:10 AM

    Paul, I have received confirmation.  It is possible to remove/unregister a single callback in the C++ API,  C Callable Library and the Python API.  It is missing in the Java API.  I've created a ticket for this so that the functionality can be added in a future release.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Detaching Callbacks (Java API)

    Posted Wed May 25, 2016 11:41 AM

    Ryan: Seriously, Python got it before Java did?? You guys just keep picking on us Java users! ;-)


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Detaching Callbacks (Java API)

    Posted Tue February 07, 2017 06:51 PM

    FYI: you can now remove/unregister a single callback in the Java and .NET APIs with CPLEX 12.7 (e.g., see the documentation here).


    #CPLEXOptimizers
    #DecisionOptimization