2020-06-10 14:36:44 +02:00
|
|
|
package com.google.ortools.contrib;
|
|
|
|
|
|
2020-09-11 21:17:23 +02:00
|
|
|
import com.google.ortools.Loader;
|
2016-04-14 13:23:00 +02:00
|
|
|
import com.google.ortools.linearsolver.MPConstraint;
|
|
|
|
|
import com.google.ortools.linearsolver.MPObjective;
|
|
|
|
|
import com.google.ortools.linearsolver.MPSolver;
|
|
|
|
|
import com.google.ortools.linearsolver.MPVariable;
|
|
|
|
|
|
|
|
|
|
public class Issue173 {
|
|
|
|
|
public static void breakit() {
|
|
|
|
|
for (int i = 0; i < 50000; i++) {
|
|
|
|
|
solveLP();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void solveLP() {
|
2021-12-01 13:20:14 +01:00
|
|
|
MPSolver solver = MPSolver.createSolver("CBC");
|
|
|
|
|
if (solver == null) {
|
|
|
|
|
System.out.println("Could not create solver CBC");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-10-31 16:18:18 +01:00
|
|
|
MPVariable x = solver.makeNumVar(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, "x");
|
2016-04-14 13:23:00 +02:00
|
|
|
|
|
|
|
|
final MPObjective objective = solver.objective();
|
|
|
|
|
objective.setMaximization();
|
|
|
|
|
objective.setCoefficient(x, 1);
|
|
|
|
|
|
|
|
|
|
MPConstraint constraint = solver.makeConstraint(0, 5);
|
|
|
|
|
constraint.setCoefficient(x, 1);
|
|
|
|
|
|
|
|
|
|
solver.solve();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
2020-09-11 21:17:23 +02:00
|
|
|
Loader.loadNativeLibraries();
|
2016-04-14 13:23:00 +02:00
|
|
|
breakit();
|
|
|
|
|
}
|
|
|
|
|
}
|