0

Is it possible to solve a model that has a callback using model.solve(url=url, key=api)? I am trying an example similar to this but callback has no effect when called on dropsolve.

ooo
  • 512
  • 1
  • 7
  • 27

1 Answers1

2

If that would be possible, it would be a performance disaster: for every invocation of the callback, the solve would have to call back from the cloud into your machine to invoke the callback. Since callbacks are usually invoked frequently, this would result in a lot of runtime overhead.

What you can do instead is to submit your Python script using docplex to the DOcplexcloud. The full script is then executed on the cloud. In that case the callback will be invoked. You can find an example for this in the DOcplexcloud documentation Python API example.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22
  • Same question asked here: https://developer.ibm.com/answers/questions/531431/docplex-with-callback-in-dropsolve.html Please don't cross post. And if you feel you have to do it then please link the questions so that people don't answer in two places. – Daniel Junglas Mar 19 '20 at 06:01
  • I have observed that in docplexcloud callback method for tsp is taking more time than simple MTZ constrain can you explain the reason for it, or there is error in my observation. – ooo Mar 19 '20 at 21:23
  • If you inject all constraints up front then CPLEX can use them in presolve. This is not possible if they are separated in a callback. Moreover, if you use lazy constraints then certain presolve reductions cannot be applied because CPLEX does not see the full model. This can cause a performanc degradation as well. Finally, invoking callbacks of cours incurs some runtime overhead. – Daniel Junglas Mar 20 '20 at 06:01