Search in sources :

Example 1 with Parameters

use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.

the class Bench method main.

/**
 * Launcher
 *
 * @param args the CLI arguments
 * @throws IOException
 */
@SuppressWarnings("squid:S1166")
public static void main(String[] args) throws IOException {
    opts = new Options();
    // Parse the cmdline arguments
    CmdLineParser cli = new CmdLineParser(opts);
    try {
        cli.getProperties().withUsageWidth(80);
        cli.parseArgument(args);
    } catch (@SuppressWarnings("unused") CmdLineException ex) {
        cli.printUsage(System.err);
        System.exit(1);
    }
    Runtime runtime = Runtime.getRuntime();
    int mb = 1024 * 1024;
    out(1, "Total Memory: %d%n", runtime.totalMemory() / mb);
    out(1, "Max Memory: %d%n", runtime.maxMemory() / mb);
    Parameters ps = opts.parameters();
    Iterator<LabelledInstance> ite = opts.instances().iterator();
    while (ite.hasNext()) {
        LabelledInstance i = ite.next();
        solve(i, ps);
    }
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 2 with Parameters

use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.

the class CMinMigrations method placeVMs.

/*
     * Try to place the VMs associated on the actions in a random node while trying first to stay on the current node
     */
private void placeVMs(Parameters ps, List<AbstractStrategy<?>> strategies, List<VMTransition> actions, OnStableNodeFirst schedHeuristic, Map<IntVar, VM> map) {
    IntValueSelector rnd = new WorstFit(map, rp, new BiggestDimension());
    if (!useResources) {
        rnd = new RandomVMPlacement(rp, map, true, ps.getRandomSeed());
    }
    IntVar[] hosts = dSlices(actions).map(Slice::getHoster).filter(v -> !v.isInstantiated()).toArray(IntVar[]::new);
    if (hosts.length > 0) {
        strategies.add(new IntStrategy(hosts, new HostingVariableSelector(rp.getModel(), schedHeuristic), rnd));
    }
}
Also used : Slice(org.btrplace.scheduler.choco.Slice) OnStableNodeFirst(org.btrplace.scheduler.choco.constraint.mttr.OnStableNodeFirst) SchedulerException(org.btrplace.scheduler.SchedulerException) Transition(org.btrplace.scheduler.choco.transition.Transition) StrategiesSequencer(org.chocosolver.solver.search.strategy.strategy.StrategiesSequencer) Solver(org.chocosolver.solver.Solver) Search(org.chocosolver.solver.search.strategy.Search) CObjective(org.btrplace.scheduler.choco.constraint.CObjective) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) IntDomainMin(org.chocosolver.solver.search.strategy.selectors.values.IntDomainMin) TObjectIntMap(gnu.trove.map.TObjectIntMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) VM(org.btrplace.model.VM) FirstFail(org.chocosolver.solver.search.strategy.selectors.variables.FirstFail) Mapping(org.btrplace.model.Mapping) WorstFit(org.btrplace.scheduler.choco.constraint.mttr.WorstFit) Map(java.util.Map) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) StartOnLeafNodes(org.btrplace.scheduler.choco.constraint.mttr.StartOnLeafNodes) CShareableResource(org.btrplace.scheduler.choco.view.CShareableResource) MinMigrations(org.btrplace.model.constraint.MinMigrations) LinkedList(java.util.LinkedList) RandomVMPlacement(org.btrplace.scheduler.choco.constraint.mttr.RandomVMPlacement) Model(org.btrplace.model.Model) BiggestDimension(org.btrplace.scheduler.choco.constraint.mttr.load.BiggestDimension) Iterator(java.util.Iterator) MovementGraph(org.btrplace.scheduler.choco.constraint.mttr.MovementGraph) HostingVariableSelector(org.btrplace.scheduler.choco.constraint.mttr.HostingVariableSelector) Set(java.util.Set) MyInputOrder(org.btrplace.scheduler.choco.constraint.mttr.MyInputOrder) Parameters(org.btrplace.scheduler.choco.Parameters) Collectors(java.util.stream.Collectors) VMPlacementUtils(org.btrplace.scheduler.choco.constraint.mttr.VMPlacementUtils) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Objects(java.util.Objects) IntVar(org.chocosolver.solver.variables.IntVar) List(java.util.List) Stream(java.util.stream.Stream) IntStrategy(org.chocosolver.solver.search.strategy.strategy.IntStrategy) ShareableResource(org.btrplace.model.view.ShareableResource) IntValueSelector(org.chocosolver.solver.search.strategy.selectors.values.IntValueSelector) Instance(org.btrplace.model.Instance) AbstractStrategy(org.chocosolver.solver.search.strategy.strategy.AbstractStrategy) IntDomainMax(org.chocosolver.solver.search.strategy.selectors.values.IntDomainMax) Collections(java.util.Collections) BiggestDimension(org.btrplace.scheduler.choco.constraint.mttr.load.BiggestDimension) IntStrategy(org.chocosolver.solver.search.strategy.strategy.IntStrategy) HostingVariableSelector(org.btrplace.scheduler.choco.constraint.mttr.HostingVariableSelector) Slice(org.btrplace.scheduler.choco.Slice) WorstFit(org.btrplace.scheduler.choco.constraint.mttr.WorstFit) RandomVMPlacement(org.btrplace.scheduler.choco.constraint.mttr.RandomVMPlacement) IntVar(org.chocosolver.solver.variables.IntVar) IntValueSelector(org.chocosolver.solver.search.strategy.selectors.values.IntValueSelector)

Example 3 with Parameters

use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.

the class CMinMTTR method placeVMs.

/*
     * Try to place the VMs associated on the actions in a random node while trying first to stay on the current node
     */
private void placeVMs(Parameters ps, List<AbstractStrategy<?>> strategies, List<VMTransition> actions, OnStableNodeFirst schedHeuristic, Map<IntVar, VM> map) {
    IntValueSelector rnd = new WorstFit(map, rp, new BiggestDimension());
    if (!useResources) {
        rnd = new RandomVMPlacement(rp, map, true, ps.getRandomSeed());
    }
    IntVar[] hosts = dSlices(actions).map(Slice::getHoster).filter(v -> !v.isInstantiated()).toArray(IntVar[]::new);
    if (hosts.length > 0) {
        strategies.add(new IntStrategy(hosts, new HostingVariableSelector(rp.getModel(), schedHeuristic), rnd));
    }
}
Also used : Slice(org.btrplace.scheduler.choco.Slice) SchedulerException(org.btrplace.scheduler.SchedulerException) Transition(org.btrplace.scheduler.choco.transition.Transition) StrategiesSequencer(org.chocosolver.solver.search.strategy.strategy.StrategiesSequencer) Solver(org.chocosolver.solver.Solver) Search(org.chocosolver.solver.search.strategy.Search) CObjective(org.btrplace.scheduler.choco.constraint.CObjective) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) IntDomainMin(org.chocosolver.solver.search.strategy.selectors.values.IntDomainMin) TObjectIntMap(gnu.trove.map.TObjectIntMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) VM(org.btrplace.model.VM) FirstFail(org.chocosolver.solver.search.strategy.selectors.variables.FirstFail) Mapping(org.btrplace.model.Mapping) Map(java.util.Map) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) CShareableResource(org.btrplace.scheduler.choco.view.CShareableResource) LinkedList(java.util.LinkedList) Model(org.btrplace.model.Model) BiggestDimension(org.btrplace.scheduler.choco.constraint.mttr.load.BiggestDimension) Iterator(java.util.Iterator) Set(java.util.Set) Parameters(org.btrplace.scheduler.choco.Parameters) Collectors(java.util.stream.Collectors) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Objects(java.util.Objects) IntVar(org.chocosolver.solver.variables.IntVar) MinMTTR(org.btrplace.model.constraint.MinMTTR) List(java.util.List) Stream(java.util.stream.Stream) IntStrategy(org.chocosolver.solver.search.strategy.strategy.IntStrategy) ShareableResource(org.btrplace.model.view.ShareableResource) IntValueSelector(org.chocosolver.solver.search.strategy.selectors.values.IntValueSelector) Instance(org.btrplace.model.Instance) AbstractStrategy(org.chocosolver.solver.search.strategy.strategy.AbstractStrategy) IntDomainMax(org.chocosolver.solver.search.strategy.selectors.values.IntDomainMax) Collections(java.util.Collections) BiggestDimension(org.btrplace.scheduler.choco.constraint.mttr.load.BiggestDimension) IntStrategy(org.chocosolver.solver.search.strategy.strategy.IntStrategy) Slice(org.btrplace.scheduler.choco.Slice) IntVar(org.chocosolver.solver.variables.IntVar) IntValueSelector(org.chocosolver.solver.search.strategy.selectors.values.IntValueSelector)

Example 4 with Parameters

use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.

the class BootVMTest method testBootSequence.

/**
 * Test that check when the action is shorter than the end of
 * the reconfiguration process.
 * In practice, 2 boot actions have to be executed sequentially
 */
@Test
public void testBootSequence() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    final VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addReadyVM(vm1);
    map.addReadyVM(vm2);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.BootVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), map.getAllVMs(), new HashSet<>(), new HashSet<>()).build();
    BootVM m1 = (BootVM) rp.getVMActions().get(rp.getVM(vm1));
    BootVM m2 = (BootVM) rp.getVMActions().get(rp.getVM(vm2));
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
    rp.getModel().post(rp.getModel().arithm(m2.getStart(), ">=", m1.getEnd()));
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Iterator<Action> ite = p.iterator();
    org.btrplace.plan.event.BootVM b1 = (org.btrplace.plan.event.BootVM) ite.next();
    org.btrplace.plan.event.BootVM b2 = (org.btrplace.plan.event.BootVM) ite.next();
    Assert.assertEquals(vm1, b1.getVM());
    Assert.assertEquals(vm2, b2.getVM());
    Assert.assertTrue(b1.getEnd() <= b2.getStart());
    Assert.assertEquals(5, b1.getEnd() - b1.getStart());
    Assert.assertEquals(5, b2.getEnd() - b2.getStart());
}
Also used : Action(org.btrplace.plan.event.Action) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 5 with Parameters

use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.

the class ForgeVMTest method testResolution.

@Test
public void testResolution() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    m.addOnlineNode(n1);
    mo.getAttributes().put(vm1, "template", "small");
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.ForgeVM.class, new ConstantActionDuration<>(7));
    dev.register(ShutdownNode.class, new ConstantActionDuration<>(20));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
    // Force the node to get offline
    ShutdownableNode n = (ShutdownableNode) rp.getNodeAction(n1);
    n.getState().instantiateTo(0, Cause.Null);
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getDuration(), 20);
    for (Action a : p) {
        if (a instanceof org.btrplace.plan.event.ForgeVM) {
            org.btrplace.plan.event.ForgeVM action = (org.btrplace.plan.event.ForgeVM) a;
            Assert.assertTrue(p.getResult().getMapping().isReady(vm1));
            Assert.assertEquals(action.getVM(), vm1);
            Assert.assertEquals(action.getEnd(), 7);
            Assert.assertEquals(action.getStart(), 0);
        }
    }
}
Also used : Action(org.btrplace.plan.event.Action) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Aggregations

Parameters (org.btrplace.scheduler.choco.Parameters)36 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)31 Test (org.testng.annotations.Test)31 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)29 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)28 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)28 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)27 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)14 HashSet (java.util.HashSet)13 Model (org.btrplace.model.Model)12 Mapping (org.btrplace.model.Mapping)11 VM (org.btrplace.model.VM)11 ShutdownNode (org.btrplace.plan.event.ShutdownNode)10 BootNode (org.btrplace.plan.event.BootNode)9 DefaultModel (org.btrplace.model.DefaultModel)8 Action (org.btrplace.plan.event.Action)8 Node (org.btrplace.model.Node)7 MigrateVM (org.btrplace.plan.event.MigrateVM)7 ArrayList (java.util.ArrayList)5 Instance (org.btrplace.model.Instance)5