use of org.chocosolver.solver.search.measure.Measures in project scheduler by btrplace.
the class InstanceSolverRunner method getStatistics.
/**
* Get the statistics about the solving process.
*
* @return the statistics
*/
public SingleRunnerStatistics getStatistics() {
if (rp != null) {
Measures m = rp.getSolver().getMeasures();
stats.setMetrics(new Metrics(m));
stats.setCompleted(m.getSearchState().equals(SearchState.TERMINATED) || m.getSearchState().equals(SearchState.NEW));
}
return stats;
}
use of org.chocosolver.solver.search.measure.Measures 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();
}
Aggregations