0

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();
 }
}
beserious
  • 101
  • 1
  • 8
  • Is there a jscip.dll or libjscip.so with your distro? This path needs to be included as part of java.library.path, which you can set in launch config. – emilles Feb 24 '19 at 15:23
  • I can't find one. These are apparently the "instructions" for launching it, but I can't figure it out or how to run it from eclipse: https://github.com/SCIP-Interfaces/JSCIPOpt/blob/master/INSTALL.md – beserious Feb 24 '19 at 23:13
  • The instructions refer to scip.dll and this issue at the very end. – emilles Feb 25 '19 at 00:16
  • Sorry if my commends are really basic. I am getting this option at the cmake .. line. The C compiler identification is unknown The CXX compiler identification is unknown CMake Error at CMakeLists.txt:6 (project): The CMAKE_C_COMPILER: cl is not a full path and was not found in the PATH. To use the NMake generator with Visual C++, cmake must be run from a shell that can use the compiler cl from the command line. This environment is unable to invoke the cl compiler. To fix this problem, run cmake from the Visual Studio Command Prompt (vcvarsall.bat). – beserious Feb 25 '19 at 05:59
  • Visual Studio comes with a command-line environment. It may be in Start Menu > Visual Studio 2xxx > Visual Studio Tools > Visual Studio Command Prompt. This is just a shortcut to vcvarsall.bat that is referenced in the error message. You can open the command console and make/cmake/nmake your native code. – emilles Feb 25 '19 at 18:36

0 Answers0