Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  add cuts dynamically in docplex

    Posted 11/28/18 04:50 PM

    Originally posted by: Hesamddin


    Hi,

    I have a problem adding the cut set inequalities to my main MIP model dynamically. what I did so far is as follows :

    I wrote the MIP model in python and solved the model with docplex . Then solved the LP relaxation of the model, save the solution in json file, then use the json file as an input to the min-cut formulation and solve the model with docplex and get the result which define the sets of S and Sbar for my separation problem.

    Now, I need to add the corresponding inequality constraint to the main MIP model in the dynamic way. What I mean is add the inequality constraint, solve the LP-relaxation of MIP model, get the result, use the result as an input to separation problem, then solve  the separation problem and define the new set of s and sbar and then add the corresponding inequality constraint to the main problem and do the same process until get the best lower bound.

    My problem is I couldn't find the cplex callback to do this process dynamically.

    I read the documentation about usercut callback but it seems to me that for using this callback we need to define the pool of constraints at first and then use them in optimization process which is not my case, because I do not know all constraints from beginning.

    Does any one have suggestion ?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: add cuts dynamically in docplex

    Posted 11/29/18 04:03 AM

    For the user cut callback you don't have to define the constraints in advance. The purpose of this callback is to support exactly what you plan to do: dynamically generate cuts.

    However, I am a bit confused since as far as I know, docplex does not have a user cut callback. So how exactly are you invoking that callback? Or do you use the CPLEX Python API? Or do you use a Mixin class for docplex that implements the user cut callback there?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: add cuts dynamically in docplex

    Posted 11/29/18 08:01 PM

    Originally posted by: Hesamddin


    Thank you for your response.

    I tried using Mixin class as you stated for one of the questions in the forum for LazyConstraintsCallback. I think I can use UserCutCallback in the same way yes?

    But when I run the code it gives me an error : ImportError: No module named callbacks.cb_mixin

    How can I fix this error? 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: add cuts dynamically in docplex

    Posted 12/06/18 10:26 AM

    What version of docplex do you use? You need a sufficiently recent. Can you try to upgrade to the most recent one?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: add cuts dynamically in docplex

    Posted 02/22/19 12:21 PM

    Originally posted by: Hesamddin


    I started to write my code in cplex python API format to better use callbacks. then in order to use the usercut callback, I used the example 'Bendersatsp.py' provided by IBM but I have a problem. when I want to get the value of the variable I want to use in my cuts 'named w' with the code self.get_values(w[i]) in my callback section, as it is in bendersatsp example, it returns nothing. However, I know that my masterILP model is feasible and I can solve it optimally and get w[i] variables when running the code separately. so, I do not know where is the problem. Can I send my code to you so that help me find out the problem ?

    Thanks.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: add cuts dynamically in docplex

    Posted 02/25/19 12:23 AM

    What do you mean by 'it returns nothing'? Do you mean it returns None? That would be odd since the method should return either a value or raise an exception.

    Can you show your code?


    #CPLEXOptimizers
    #DecisionOptimization