Switching Solvers

Java Solver allows you to easily switch between underlying off-the-shelf solvers without changing anything in your optimization model. There are many Constraint and Linear solvers (open source and commercial) which can be utilized by Java Solver.  Constraint solvers can represent almost any problem while linear solvers are limited to linear constraints only. Linear solvers usually can find optimal solutions for problems of very large size faster in situations when constraint solvers stop short.

By default Java Solver used an open source constraint solver “Constrainer” that is included in the standard download. Java Solver samples show you how to switch an underlying solver by changing one setting in the batch file. For instanse, the introductory example uses the batch file “runZoo.bat” to run the model with Constrainer. You can switch to a linear solver such as another open source product “SCIP”. To do that you just need to change the batch file “runZoo.bat”:

As you can see, we commented out CONSTRAINER, and set SOLVER=SCIP.

Actually, this change simply replaces CONSTRAINER’s jar-files to SCIP’s jar-files in the project classpath – you may see how it’s done in the standard batch file “com.javasolver/run.bat“.

.