JSCIPOpt icon indicating copy to clipboard operation
JSCIPOpt copied to clipboard

Add lazy constraints at runtime

Open lmores opened this issue 2 years ago • 3 comments

Hi everyone, I would like to try out and experiment with SCIP using the Java API. However, it is unclear to me whether the Java API allows to add user defined cuts and/or lazy constraints while SCIP is solving a model.

E.g.: could I solve a simple Travelling Salesmann Problem starting from an incomplete model with just "flow constraints" and add Subtour Elimination Constraints and/or Connectivity Constraints manually at runtime?

Thank you a lot!

lmores avatar Dec 20 '23 13:12 lmores

At this time, no. But it can be added, though I do not have the time to do so myself at the moment.

How you would go at it is:

  1. figure out the C APIs that you need (or if, as for the constraint handlers, they involve callbacks, the C++ objscip wrappers with the callback classes),
  2. add them to scipjni.i (for the callback classes, see how I did it for ObjMessagehdlr),
  3. add them to the object-oriented Java wrapper classes in the java/jscip folder, and
  4. when done, submit a pull request to this repository (thereby acknowledging and authorizing that the code will be released under the MIT License as shipped in the LICENSE file).

kkofler avatar Dec 20 '23 13:12 kkofler

Thanks a lot for the hints. Being the very first time time I am using SCIP I hoped I could use Java to avoid the complexity of C and C++ that requires manual memory management and longer implementation times. If I find some spare time I will try my best and (if I succeed) I will open a PR.

lmores avatar Dec 20 '23 14:12 lmores

The good thing about JSCIP is that the hard part of doing the C/C++ to Java binding is done by the SWIG binding generator.

kkofler avatar Dec 20 '23 14:12 kkofler