When I tried to use Java to call CPLEX and use callback functions to solve a VRP problem with branch-and-cut, some problems emerged.

I took out the subtour elimination constraint from the original problem, and used it as usercut and lazyconstraint. When I only used it as a lazyconstraint, the algorithm worked out very well, but when I used it as both usercut and lazyconstraint Java program couldn't stop, it kept calling usercutCallback at node0 and wouldn't make branch. I really don't know what the problem is.

Does CPLEX loop calling usercutCallback at each non-integer node until no usercut are violated, and then make branch? If so, can I set the maximum number of calls at each node? Maybe just one time is ok.

Another problem is why it kept generating the same cut. I think when cut A has been already added, even if I generate A again in the next loop, it should have been satisfied so that no usercut is violated and the loop should be stopped.

  • $\begingroup$ May I ask whether you figure out how to resolve the problem? I have exactly the same problem? $\endgroup$
    – Sam
    Mar 16, 2021 at 16:47

1 Answer 1


This question was also asked and answered on a CPLEX forum and on my blog.

Update: The gist of the answer is that when you add a cut in a callback, CPLEX updates the node solution to reflect that cut and then invokes the callback again (still at the same node) to see if you have more cuts to add. To let CPLEX move on to another node, your callback needs to exit without adding another cut. In particular, if you add the same cut each time the callback is invoked at the same node, you will create an indefinite loop.

  • $\begingroup$ This answer currently being discussed on Meta. $\endgroup$ Jan 6, 2020 at 11:41
  • $\begingroup$ Could you add the answer here as well? In particular, IBM has notoriously bad websites with many links going stale over time. $\endgroup$ Mar 16, 2021 at 17:14
  • 1
    $\begingroup$ @JorisKinable: Done. $\endgroup$
    – prubin
    Mar 17, 2021 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.