Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Help using CPLEX with Python

    Posted 06/19/13 05:43 AM

    Originally posted by: veronicads


    Hello!

    I'm implementing a Mip problem using the Python interface for cplex 12.4. I see that it's not quite common and the documentation is not really helpful to me. There are two things in particular that I've not been able to do:

    - set the right parameter to switch off all the cuts cplex adds independently while performing the branch and cut algorithm

    - pass as arguments the data of the problem to a callback. That is, I define a LazyConstraintCallback as this:

    class MyLazy(LazyConstraintCallback):

               def  __call__(self):

                          #code

    but inside the call function I also need the data of the problem and simply writing def __call__(self, data) I get an error like this:

    CPLEX Error  1006: Error during callback.

    ...

    TypeError: __call__() takes exactly 2 arguments (1 given)

     

    thanks a lot for your help!

    Veronica


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Help using CPLEX with Python

    Posted 06/19/13 06:08 AM

    In the programming APIs there is no equivalent to the interactives 'set mip cuts all -1' to switch of all cuts. So you need to switch off all cuts individually. Alternatively, you can set CPX_PARAM_CUTPASS to -1 for the root node.

    Most of the problem data you would need in a lazy constraint callback should be available through the callback's member function, see the reference documentation. If you need to create fields in the callback instance then look at the mipex4.py example shipped with CPLEX. There you have among other things

            timelim_cb = c.register_callback(TimeLimitCallback)
            timelim_cb.starttime = time.time()
            timelim_cb.timelimit = 1
            timelim_cb.acceptablegap = 10
            timelim_cb.aborted = 0

    This creates and registers a new callback and creates instance fields starttime, timelimit, acceptablegap, aborted in the newly created callback instance. In the callback's __call__ method you can then access them via self.starttime etc.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Help using CPLEX with Python

    Posted 06/19/13 09:04 AM

    Originally posted by: veronicads


    Thanks a lot for your reply! It was really helpful!


    #CPLEXOptimizers
    #DecisionOptimization