Search in sources :

Example 1 with SolutionStatistics

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();
}
Also used : SolutionStatistics(org.btrplace.scheduler.choco.runner.SolutionStatistics)

Example 2 with SolutionStatistics

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();
}
Also used : LifeCycleViolationException(org.btrplace.scheduler.choco.LifeCycleViolationException) ChocoView(org.btrplace.scheduler.choco.view.ChocoView) Ready(org.btrplace.model.constraint.Ready) MeasuresRecorder(org.chocosolver.solver.search.measure.MeasuresRecorder) SchedulerException(org.btrplace.scheduler.SchedulerException) Node(org.btrplace.model.Node) OptConstraint(org.btrplace.model.constraint.OptConstraint) ContradictionException(org.chocosolver.solver.exception.ContradictionException) Callable(java.util.concurrent.Callable) SolvingStatistics(org.btrplace.scheduler.choco.runner.SolvingStatistics) CObjective(org.btrplace.scheduler.choco.constraint.CObjective) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) VM(org.btrplace.model.VM) Running(org.btrplace.model.constraint.Running) SchedulerModelingException(org.btrplace.scheduler.SchedulerModelingException) Measures(org.chocosolver.solver.search.measure.Measures) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) IMonitorSolution(org.chocosolver.solver.search.loop.monitors.IMonitorSolution) SearchState(org.chocosolver.solver.search.SearchState) ChocoMapper(org.btrplace.scheduler.choco.constraint.ChocoMapper) SatConstraint(org.btrplace.model.constraint.SatConstraint) Model(org.btrplace.model.Model) Sleeping(org.btrplace.model.constraint.Sleeping) Constraint(org.btrplace.model.constraint.Constraint) Collection(java.util.Collection) SolutionStatistics(org.btrplace.scheduler.choco.runner.SolutionStatistics) Set(java.util.Set) ChocoConstraint(org.btrplace.scheduler.choco.constraint.ChocoConstraint) Cause(org.chocosolver.solver.Cause) Parameters(org.btrplace.scheduler.choco.Parameters) IntVar(org.chocosolver.solver.variables.IntVar) List(java.util.List) Killed(org.btrplace.model.constraint.Killed) Metrics(org.btrplace.scheduler.choco.runner.Metrics) ChocoViews(org.btrplace.scheduler.choco.view.ChocoViews) Solution(org.chocosolver.solver.Solution) Optional(java.util.Optional) Instance(org.btrplace.model.Instance) Metrics(org.btrplace.scheduler.choco.runner.Metrics) LifeCycleViolationException(org.btrplace.scheduler.choco.LifeCycleViolationException) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) SolutionStatistics(org.btrplace.scheduler.choco.runner.SolutionStatistics) IntVar(org.chocosolver.solver.variables.IntVar) IMonitorSolution(org.chocosolver.solver.search.loop.monitors.IMonitorSolution) Solution(org.chocosolver.solver.Solution) MeasuresRecorder(org.chocosolver.solver.search.measure.MeasuresRecorder)

Example 3 with SolutionStatistics

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();
}
Also used : SolutionStatistics(org.btrplace.scheduler.choco.runner.SolutionStatistics)

Example 4 with SolutionStatistics

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) Instance(org.btrplace.model.Instance) SatConstraint(org.btrplace.model.constraint.SatConstraint) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) SolutionStatistics(org.btrplace.scheduler.choco.runner.SolutionStatistics) ArrayList(java.util.ArrayList) MinMTTR(org.btrplace.model.constraint.MinMTTR) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Metrics(org.btrplace.scheduler.choco.runner.Metrics) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

SolutionStatistics (org.btrplace.scheduler.choco.runner.SolutionStatistics)4 ArrayList (java.util.ArrayList)2 Instance (org.btrplace.model.Instance)2 Model (org.btrplace.model.Model)2 SatConstraint (org.btrplace.model.constraint.SatConstraint)2 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)2 Parameters (org.btrplace.scheduler.choco.Parameters)2 Metrics (org.btrplace.scheduler.choco.runner.Metrics)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 DefaultModel (org.btrplace.model.DefaultModel)1 Node (org.btrplace.model.Node)1 VM (org.btrplace.model.VM)1 Constraint (org.btrplace.model.constraint.Constraint)1 Killed (org.btrplace.model.constraint.Killed)1 MinMTTR (org.btrplace.model.constraint.MinMTTR)1