Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problem Adding Multiple Usercuts

    Posted 07/05/13 10:40 AM

    Originally posted by: BirolYuceoglu


    Hello,

    I am writing a branch-and-cut algorithm using Cplex 12.2. I have several classes of valid inequalities that I want to use. However, when I add them to the model only one of them works. I add constraints as follows (I am not sure if it is the correct way) and I know they are working:

    IloExpr cutLhs(env);

    cutLhs += x[i][j];

    ......
    add(cutLhs <= lhs).end();
    cutLhs.end();

     

    However, in the main body when I add the separators only the last one is called (in this case Separator2):

    cplex.use(Separator1...);

    cplex.use(Separator2...);

     

    I am a beginner in Cplex, I tried to search the forum but could not find any similar issues. 

    Thanks and regards,

    Birol.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Problem Adding Multiple Usercuts

    Posted 07/05/13 01:34 PM

    You cannot have multiple callbacks of the same type. Calling IloCplex::use() with an instance of UserCutCallback will overwrite any previously registered UserCutCallback.

    The most straightforward way to separate multiple types of cuts is to add all the separation routines to the main() function of one subclass of UserCutCallback().

    Another, more sophisticated but cleaner/nicer solution is as follows:

    1. Create a subclass MyCallback of UserCutCallback. In that subclass make functions getValue(), getValues(), add(), etc. public.
    2. Implement your separators so that they take an instance of MyCallback as argument and use that classes (now public) getValues() and add() methods to separate cuts and add separated cuts.
    3. Pass a list of separator instances to the constructor of MyCallback.
    4. Function MyCallback::main() then goes through the list of separators passed to the constructor and invokes each separator -- passing itself as argument to the separator.

    #CPLEXOptimizers
    #DecisionOptimization