You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides an interface from the Java programming language to the SCIP solver software.
How to build a model using JSCIPOpt
There are several examples provided in the examples folder. These display some functionality of the interface and can
serve as an entry point for writing more complex code. The following steps are always required when using the interface:
It is necessary to add
import jscip.*;
to the beginning of your Java file. This imports all needed classes to use the interfaces.
Create a solver instance and initialize the internal C data structures with
Scip scip = new SCIP();
scip.create("Example");
This is the equivalent to calling SCIPcreate(&scip) and SCIPcreateProbBasic(scip, "Example") in C.
The most important classes are Scip.java, Variable.java, Constraint.java, and Solution.java. They represent the C
data structs SCIP, SCIP_VAR, SCIP_CONS,SCIP_SOL and provide some basic functionality. Using the Java classes
works similar to C , e.g.,
which creates two variables, a linear constraint, adds it to SCIP, solves the problem and finally frees it.
How to extend the interface
The package already contains an interface to SCIP created with the Simplified Wrapper and Interface Generator
SWIG. Extending the interface requires to install SWIG. The following steps are necessary to add
a new function to the interface:
Add the signature of an interface function to src/scipjni.i, e.g.,
SCIP_Real SCIPfeastol(SCIP* scip);
Implement the function, depending on its signature, in java/jscip/{Scip,Variable,Constraint,Solution}.java, e.g.,
public class Scip
{
private SWIGTYPE_p_SCIP _scipptr;
...
public double feastol()
{
return SCIPJNI.SCIPfeastol(_scipptr);
}
}
Follow the steps in INSTALL.md to compile JSCIPOpt.
Note that each of the four mentioned classes hold their own C pointer in a class generated by SWIG. The object of this
class needs to be passed to the new implemented interface function.
After all previous steps it is now possible to call the function via