use of org.chocosolver.solver.search.measure.MeasuresRecorder in project scheduler by btrplace.
the class InstanceSolverRunner method call.
@Override
// for the LifeCycleViolationException
@SuppressWarnings("squid:S1166")
public SolvingStatistics call() throws SchedulerException {
stats = new SingleRunnerStatistics(params, instance, System.currentTimeMillis());
rp = null;
// Build the core problem
long d = -System.currentTimeMillis();
try {
rp = buildRP();
} catch (@SuppressWarnings("unused") LifeCycleViolationException ex) {
// If there is a violation of the cycle it is not a bug that should be propagated
// it it just indicating there is no solution
stats.setCompleted(true);
stats.setMetrics(new Metrics());
return stats;
} finally {
d += System.currentTimeMillis();
stats.setCoreBuildDuration(d);
}
stats.setNbManagedVMs(rp.getManageableVMs().size());
// Customize the core problem
d = -System.currentTimeMillis();
if (!specialise()) {
d += System.currentTimeMillis();
stats.setSpecialisationDuration(d);
stats.setCompleted(true);
return getStatistics();
}
d += System.currentTimeMillis();
stats.setSpecialisationDuration(d);
// statistics
stats.setMetrics(new Metrics(rp.getSolver().getMeasures()));
rp.getLogger().debug(stats.toString());
// The solution monitor to store the measures at each solution
rp.getSolver().plugMonitor((IMonitorSolution) () -> {
Solution solution = new Solution(rp.getModel());
solution.record();
ReconfigurationPlan plan = rp.buildReconfigurationPlan(solution, origin);
views.forEach(v -> v.insertActions(rp, solution, plan));
MeasuresRecorder m = rp.getSolver().getMeasures();
SolutionStatistics st = new SolutionStatistics(new Metrics(m), plan);
IntVar o = rp.getObjective();
if (o != null) {
st.setObjective(solution.getIntVal(o));
}
stats.addSolution(st);
params.solutionListeners().forEach(c -> c.accept(rp, plan));
});
setVerbosity();
// The actual solving process
rp.solve(params.getTimeLimit(), params.doOptimize());
return getStatistics();
}
use of org.chocosolver.solver.search.measure.MeasuresRecorder in project scheduler by btrplace.
the class StagedSolvingStatisticsTest method testSingle.
@Test
public void testSingle() {
SingleRunnerStatistics s = new SingleRunnerStatistics(ps, i, st);
MeasuresRecorder mr = new MeasuresRecorder("");
s.setMetrics(new Metrics(mr));
StagedSolvingStatistics stats = new StagedSolvingStatistics(s);
Assert.assertEquals(stats.getSolutions().size(), 0);
Assert.assertEquals(stats.getStage(0), s);
Assert.assertEquals(stats.getNbManagedVMs(), -1);
Assert.assertEquals(stats.getStart(), st);
Assert.assertEquals(stats.getInstance(), i);
Assert.assertEquals(stats.getNbStages(), 1);
Assert.assertEquals(stats.getCoreBuildDuration(), -1);
Assert.assertEquals(stats.getSpecializationDuration(), -1);
Assert.assertEquals(stats.completed(), false);
}
Aggregations