Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  An issue on defining new variables for CUTCALLBACK

    Posted 03/15/12 08:16 PM

    Originally posted by: Soheilmn


    Hi all,

    I am solving a mixed-integer program using CPLEX. I have a set of valid inequalities that I want to add them to the branch-and-bound tree whenever an integer solution is found. I am using ILOCUTCALLBACKn macros. The form of the cuts that I add, is defined as follows:

    "If x \in X, then f(x)>=c", where X is a box in R^n, and f is a linear function.

    In order to linearize this constraint, I need to define some binary variables in the body of ILOCUTCALLBACKn whenever I find a new cut to be added to the problem. So the big picture is this: in addition to the linearized form of the above cut, I have to also add some extra constraints (e.g., McCormick constraints) that are defined in terms of the newly introduced binary variables in the body of callback.

    Now my issue is that I am tracking my code line by line, and it successfully defines new binary variables, but then when it reaches to a line that adds a constraint containing any newly introduced binary variables, it suddenly jumps out of the callback, and it doesn't get to the next immediate line at all.

    I was wondering if anyone has experienced this?
    Thanks for your help.

    Soheil
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/16/12 02:17 AM

    Originally posted by: SystemAdmin


    Did you try catching exceptions?
    If I understand correctly, what you do is creating new instances of IloNumVar in your callback and then add constraints that are defined on these new instances? Adding new variables to a model from a callback is not supported and you will get an exception as soon as you try to do so.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/16/12 11:40 AM

    Originally posted by: Soheilmn


    Hi Daniel,

    Thanks for your reply. I used try/catch block, and I got the following exception message: "The referenced IloExtractable has not been extracted by the IloAlgorithm" when the code attempts to add a cut that is defined on newly introduced binary variables. Does this have anything to do with the fact that I am using macros, not callback classes directly?!

    I started to think of something else to cope with the issue. I tried to make a huge array of binary decision variables before calling cplex.solve(), and I added a trivial constraint (say, the sum of all those variables are bigger than -1) to make sure that they are extracted to the model. Then, I used them one by one when necessary in the callback.

    Oddly enough, now I get an integer point, and I make the cut (and I know, from my other implementation that does not use callback, the inequality must cut the point off), but CPLEX keeps generating the same point forever, i.e., the inequality does not seem to be added to the model, or it's not working.

    I don't know if you think posting my code here will help, but do you think that I am missing something?

    Best regards,
    Soheil
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/16/12 02:39 PM

    Originally posted by: Soheilmn


    One more question: Does Cplex support adding multiple valid inequalities in the body of one callback? Because that's exactly what I do; First I add some McCormick defining inequalities, and then I add my own valid inequality, and all these should be done in the body of exactly one callback.

    Thanks,
    Soheil
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/17/12 03:45 AM

    Originally posted by: SystemAdmin


    Yes, multiple cuts from the same callback invocation are supported.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/19/12 04:38 PM

    Originally posted by: Soheilmn


    Thanks, Daniel. Finally I could get my code to work; so what I did is to make a huge array of binary decision variables before cplex.use(...) command, and to use them on the fly in the body of Callback.
    Their initial values may be zero (and in fact, they are fixed at zero at the beginning), but that is fine, as they will be set with the desired values later on, depending on the values of other decision variables in the node.

    Regards,
    Soheil
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/17/12 03:44 AM

    Originally posted by: SystemAdmin


    > Thanks for your reply. I used try/catch block, and I got the following exception message: "The referenced IloExtractable has not been extracted by the IloAlgorithm" when the code attempts to add a cut that is defined on newly introduced binary variables. Does this have anything to do with the fact that I am using macros, not callback classes directly?!
    >
    Using macros should not be a problem here. I think the exception is exactly what I suspected: You use newly created variables in your cuts and that is not supported.

    > I started to think of something else to cope with the issue. I tried to make a huge array of binary decision variables before calling cplex.solve(), and I added a trivial constraint (say, the sum of all those variables are bigger than -1) to make sure that they are extracted to the model. Then, I used them one by one when necessary in the callback.
    >
    I am not sure that this works as expected. My guess is that CPLEX presolve will fix all these variables to 0. Is this going to be a problem?

    >
    > Oddly enough, now I get an integer point, and I make the cut (and I know, from my other implementation that does not use callback, the inequality must cut the point off), but CPLEX keeps generating the same point forever, i.e., the inequality does not seem to be added to the model, or it's not working.
    >
    Did you check whether your cuts are violated by the current solution? And if they are, by how much are they violated? It might be that they are only violated marginally and CPLEX therefore treats them as non-violated.
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: An issue on defining new variables for CUTCALLBACK

    Posted 03/19/12 04:41 PM

    Originally posted by: Soheilmn


    Soheilmn's post on Mar. 19, 2012 04:38:24 PM summarizes the solution to the issue.
    #CPLEXOptimizers
    #DecisionOptimization