-
Notifications
You must be signed in to change notification settings - Fork 36
Description
When optimizing multiple models one after another in the same jvm process, I noticed the time taken for optimization increases massively after the time limit parameter's time has passed.
On my machine, the first couple of optimizations take approximately 10 - 40 ms. In the test below I'm using a ten second time limit for SCIP, so the solution should be found well within the time limit. After each optimization I let the thread sleep for a second just to waste some time. On the 9th or 10th iteration, however, the time taken for an optimization suddenly jumps to 450 to 500 ms.
By changing the time limit parameter to 5 seconds the error occurs earlier and by removing the line setting the time limit, the error disappears (probably because the default time limit is infinite).
I'm using SCIP version 9.2.0 with the binary distribution. The issue occurs both on Windows and Linux machines.
Java file for reproducing the issue:
import jscip.Scip;
public class DegradingPerformanceTest {
public static void main(final String... args) {
System.loadLibrary("jscip");
for (int i = 0; i != 20; ++i) {
final long timeTaken = optimizeAndTime();
if (i > 2) { // the first couple of iterations are for JVM warmup
if (timeTaken > 300L) {
throw new IllegalStateException("Optization took <" + timeTaken + " ms> on iteration <" + i + ">");
}
}
System.out.println("Optimization <" + i + "> took <" + timeTaken + " ms>");
// sleeping to waste time until the time limit passes
sleep(1000L);
}
}
private static void sleep(final long millis) {
try {
Thread.sleep(millis);
} catch (final InterruptedException e) {
throw new IllegalStateException("Sleeping interrupted", e);
}
}
private static long optimizeAndTime() {
final Scip scip = buildAndParameterizeScip();
scip.readProb("scipPerformanceDegradation.lp");
final long start = System.currentTimeMillis();
scip.solve();
final long duration = System.currentTimeMillis() - start;
scip.free();
return duration;
}
private static Scip buildAndParameterizeScip() {
final Scip scip = new Scip();
scip.create("scipProblem");
scip.setRealParam("numerics/epsilon", 1.0e-9);
scip.setRealParam("numerics/sumepsilon", 1.0e-6);
scip.setRealParam("numerics/feastol", 1.0e-6);
// The time limit seems to be the culprit. Removing the following line, the error never appears. Probably
// because the time limit is infinite.
scip.setRealParam("limits/time", 10);
scip.setRealParam("limits/gap", 1.0e-4);
scip.setRealParam("limits/absgap", 1.0e-4);
scip.setIntParam("limits/solutions", -1);
scip.setLongintParam("limits/nodes", 10000);
return scip;
}
}
The only workaround right now, I see is to not use a time limit parameter. See attached zip file for the required lp file.
performanceDegradation.zip