Decision Optimization

Decision Optimization

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

 View Only
  • 1.  How to add Benders cut and simultaneously give an incubment to CPLEX?

    Posted Tue October 20, 2020 10:26 AM
    Dear all,

    I am developing my own benders decomposition method. I used a lazyconstraintbacllback to add Benders cuts when an inteter solution was found.
    If the subproblem corresonding to the solution is infeasible, I will add a feasibility cut.
    If the subproblem is feasible, I will add an optimality cut. But at the same time, I may find an incumbent. So how to give this incumbent to CPLEX? I rember that CPLEX will accept an integer solution only when we did nothing in the lazyconstraintcallback

    Thanks,

    Xiangyong

    ------------------------------
    Xiangyong
    ------------------------------

    #DecisionOptimization


  • 2.  RE: How to add Benders cut and simultaneously give an incubment to CPLEX?

    Posted Tue October 20, 2020 04:00 PM
    Using legacy callbacks (which you appear to be doing), you have to attach a heuristic callback as well as the lazy constraint callback, and create a solution stack (or queue or similar memory structure) in your memory space. When the lazy constraint callback finds a solution, it pushes it on the stack. When the heuristic callback is invoked, it checks the stack, and if the stack is not empty the callback pops solutions from the stack and adds them as candidates.

    Using the newer generic callback model, it's simpler. You can post a new candidate solution directly from the "incumbent" context, which is where the lazy constraints (cuts) are generated.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: How to add Benders cut and simultaneously give an incubment to CPLEX?

    Posted Sun October 25, 2020 10:18 AM
    Dear Prof. Rubin,

    Thanks a lot. 
    As you suggested, I developed a generic callback. Only when contextid == CPX_CALLBACKCONTEXT_CANDIDATE, I added my Benders cut and possible incumbnet in the generic callback. 
    While implementing my code,  I saw strage iteration results. At some iteration, CPLEX did call the generic callback, but did not iterate from the first line of code in the generic callback. Actually the first-line code just printed some information, e.g., "Start generic callback".  Sometimes, CPLEX implemented twice one line of code in the generic callback.

    Can you give me some suggestions for figuring out this issue.

    Thanks,

    Xiangyong

    ------------------------------
    Xiangyong Li
    ------------------------------



  • 4.  RE: How to add Benders cut and simultaneously give an incubment to CPLEX?

    Posted Sun October 25, 2020 12:06 PM
    I am not sure I fully understand what you are saying, but if there is a problem, it is almost certainly in your code. Once CPLEX calls the invoke() method of your callback, it has no control over program flow until the invoke() method returns. I suggest you run your code in a debugger, with a breakpoint set at the first executable line of invoke(), and see if you can trace program flow and find the problem.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 5.  RE: How to add Benders cut and simultaneously give an incubment to CPLEX?

    Posted Mon October 26, 2020 07:37 AM
    Dear Prof. Rubin,

    As you suggested, I ran my code in a debugger. I saw CPLEX did execeute some line of code twice. I printed the thread ID and saw the same code was called by different threads twice.
    I am not sure if this influences the correctness of the branch-and-Benders-cut apprach.

    Thanks,

    Xiangyong

    ------------------------------
    Xiangyong Li
    ------------------------------



  • 6.  RE: How to add Benders cut and simultaneously give an incubment to CPLEX?

    Posted Mon October 26, 2020 12:13 PM
    With generic callbacks, the author of the callback (you) is now responsible for thread safety. (I wrote a blog post on this a while back.) Multiple threads executing the same line of code concurrently comes as no surprise. Whether that is a problem depends on whether you have made your code thread-safe.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------