fix examples

This commit is contained in:
Laurent Perron
2016-01-26 13:58:53 +01:00
parent 4c390b3d3a
commit 19b7b29194
5 changed files with 38 additions and 35 deletions

View File

@@ -27,17 +27,18 @@ import com.google.ortools.linearsolver.MPVariable;
public class IntegerProgramming {
static { System.loadLibrary("jniortools"); }
private static MPSolver createSolver (String solverType)
throws java.lang.IllegalArgumentException {
return new MPSolver("IntegerProgrammingExample",
MPSolver.OptimizationProblemType.valueOf(solverType));
private static MPSolver createSolver (String solverType) {
try {
return new MPSolver("IntegerProgrammingExample",
MPSolver.OptimizationProblemType.valueOf(solverType));
} catch (java.lang.IllegalArgumentException e) {
throw new Error(e);
}
}
private static void runIntegerProgrammingExample(String solverType) {
MPSolver solver = null;
try {
solver = createSolver(solverType);
} catch (java.lang.IllegalArgumentException e) {
MPSolver solver = createSolver(solverType);
if (solver == null) {
System.out.println("Could not create solver " + solverType);
return;
}