I'm trying to set up the SCIP optimization solver https://scip.zib.de/index.php
I use Windows and prefer Java with eclipse. I see there is a Java wrapper and example files, e.g., https://github.com/SCIP-Interfaces/JSCIPOpt/blob/master/examples/Linear.java
I see this previous thread here: Install SCIP on Eclipse
I have the scip.jar file linked correctly in my project.
However, the compiler seems to have a lot of issues, starting with the line Scip scip = new Scip(); in the following example.
edit: The first compilation error is "Scip cannot be resolved to a type"
edit: The newest 6.0.1 download does not seem to have an "scip.jar" file https://scip.zib.de/download.php?fname=scip-6.0.1.tgz
edit: The download with the "scip.jar" was linked in earlier post and may be outdated (it is for version 3.2.1): https://scip.zib.de/download.php?fname=scipjni-3.2.1.win.x86_64.msvc.opt.spx.zip
edit2: I fixed some issues. Now I have no compilation issues, but this issue at runtime:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jscip in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at jscip.Linear.main(Linear.java:12)
import jscip.*;
/** Example how to create a problem with linear constraints. */
public class Linear
{
public static void main(String args[])
{
// load generated C-library
System.loadLibrary("jscip");
Scip scip = new Scip();
// set up data structures of SCIP
scip.create("LinearExample");
// create variables (also adds variables to SCIP)
Variable x = scip.createVar("x", 2.0, 3.0, 1.0, SCIP_Vartype.SCIP_VARTYPE_CONTINUOUS);
Variable y = scip.createVar("y", 0.0, scip.infinity(), -3.0, SCIP_Vartype.SCIP_VARTYPE_INTEGER);
// create a linear constraint
Variable[] vars = {x, y};
double[] vals = {1.0, 2.0};
Constraint lincons = scip.createConsLinear("lincons", vars, vals, -scip.infinity(), 10.0);
// add constraint to SCIP
scip.addCons(lincons);
// release constraint (if not needed anymore)
scip.releaseCons(lincons);
// set parameters
scip.setRealParam("limits/time", 100.0);
scip.setRealParam("limits/memory", 10000.0);
scip.setLongintParam("limits/totalnodes", 1000);
// solve problem
scip.solve();
// print all solutions
Solution[] allsols = scip.getSols();
for( int s = 0; allsols != null && s < allsols.length; ++s )
System.out.println("solution (x,y) = (" + scip.getSolVal(allsols[s], x) + ", " + scip.getSolVal(allsols[s], y) + ") with objective value " + scip.getSolOrigObj(allsols[s]));
// release variables (if not needed anymore)
scip.releaseVar(y);
scip.releaseVar(x);
// free SCIP
scip.free();
}
}