forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Issue173.java
39 lines (29 loc) · 995 Bytes
/
Issue173.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.google.ortools.contrib;
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 {
static {
System.loadLibrary("jniortools");
}
public static void breakit() {
for (int i = 0; i < 50000; i++) {
solveLP();
}
}
private static void solveLP() {
MPSolver solver =
new MPSolver("test", MPSolver.OptimizationProblemType.CBC_MIXED_INTEGER_PROGRAMMING);
MPVariable x = solver.makeNumVar(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, "x");
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 {
breakit();
}
}