use of org.btrplace.scheduler.choco.runner.SolutionStatistics in project scheduler by btrplace.
the class UCC15 method duration.
/*@Test
public void go() throws Exception {
StringBuilder res = new StringBuilder("SIZE;DURATION\n");
int nb = 1;
for (int i = 0; i < nb; i++) {
res.append("x1;" + duration(decommissioning_10gb()) + "\n");
}
for (int i = 0; i < nb; i++) {
res.append("x2;" + duration(decommissioning_20gb()) + "\n");
}
for (int i = 0; i < nb; i++) {
res.append("x4;" + duration(decommissioning_40gb()) + "\n");
}
for (int i = 0; i < nb; i++) {
res.append("x10;" + duration(decommissioning_100gb()) + "\n");
}
System.err.println(res);
}*/
public double duration(SolvingStatistics s) {
SolutionStatistics x = s.getSolutions().get(0);
System.out.println(s);
return x.getMetrics().timeCount() * 1000 + s.getCoreBuildDuration() + s.getSpecializationDuration();
}
use of org.btrplace.scheduler.choco.runner.SolutionStatistics 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.btrplace.scheduler.choco.runner.SolutionStatistics in project scheduler by btrplace.
the class SingleRunnerStatistics method toString.
@Override
public String toString() {
StringBuilder b = new StringBuilder();
int nbNodes = instance.getModel().getMapping().getNbNodes();
int nbVMs = instance.getModel().getMapping().getNbVMs();
int nbConstraints = instance.getSatConstraints().size();
b.append(nbNodes).append(" node(s)").append("; ").append(nbVMs).append(" VM(s)");
if (nbManagedVMs != nbVMs) {
b.append(" (").append(nbManagedVMs).append(" managed)");
}
b.append("; ").append(nbConstraints).append(" constraint(s)");
if (params.doOptimize()) {
b.append("; optimize");
} else {
b.append("; satisfy");
}
if (params.getTimeLimit() > 0) {
b.append("; timeout: ").append(params.getTimeLimit()).append("s");
}
b.append("\nBuilding duration: ").append(coreRPBuildDuration).append("ms (core) + ").append(speRPDuration).append("ms (specialization)");
b.append("\nAfter ").append(metrics.timeCount()).append("ms of search");
if (completed) {
b.append(" (terminated)");
} else {
b.append(" (timeout)");
}
b.append(": ").append(metrics.toString()).append(", ").append(solutions.size()).append(" solution(s)");
if (!solutions.isEmpty()) {
b.append(":\n");
} else {
b.append('.');
}
int i = 1;
for (SolutionStatistics st : solutions) {
b.append('\t').append(i).append(')').append(st.toString()).append("\n");
i++;
}
return b.toString();
}
use of org.btrplace.scheduler.choco.runner.SolutionStatistics in project scheduler by btrplace.
the class SingleRunnerStatisticsTest method testInstantiate.
@Test
public void testInstantiate() {
Parameters ps = new DefaultParameters();
Model mo = new DefaultModel();
long st = System.currentTimeMillis();
List<SatConstraint> cstrs = new ArrayList<>();
Instance i = new Instance(mo, cstrs, new MinMTTR());
SingleRunnerStatistics stats = new SingleRunnerStatistics(ps, i, st);
Assert.assertEquals(stats.getStart(), st);
Assert.assertEquals(stats.getCoreBuildDuration(), -1);
Assert.assertEquals(stats.getSpecializationDuration(), -1);
Assert.assertEquals(stats.getInstance(), i);
Assert.assertEquals(stats.getNbManagedVMs(), -1);
Assert.assertEquals(stats.getParameters(), ps);
Assert.assertEquals(stats.getSolutions().size(), 0);
Assert.assertEquals(stats.completed(), false);
Assert.assertEquals(stats.getMetrics(), null);
stats.setCoreBuildDuration(12);
stats.setSpecialisationDuration(17);
stats.setNbManagedVMs(18);
stats.setCompleted(true);
Assert.assertEquals(stats.getCoreBuildDuration(), 12);
Assert.assertEquals(stats.getSpecializationDuration(), 17);
Assert.assertEquals(stats.getNbManagedVMs(), 18);
Assert.assertEquals(stats.completed(), true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
SolutionStatistics sol = new SolutionStatistics(new Metrics(), plan);
stats.addSolution(sol);
Assert.assertEquals(stats.getSolutions().size(), 1);
Assert.assertEquals(stats.getSolutions().get(0), sol);
}
Aggregations