Search in sources :

Example 41 with VMTransition

use of org.btrplace.scheduler.choco.transition.VMTransition in project scheduler by btrplace.

the class CSplit method injectContinuous.

private boolean injectContinuous(ReconfigurationProblem rp, List<List<VM>> vmGroups) {
    if (!cstr.isSatisfied(rp.getSourceModel())) {
        rp.getLogger().error("The constraint '{}' must be already satisfied to provide a continuous restriction", cstr);
        return false;
    }
    // Each VM on a group, can not go to a node until all the VMs from the other groups have leaved
    // So, for each group of VM, we create a list containing the c^end and the c^host variable of all
    // the VMs in the other groups then we establish precedences constraints.
    TIntArrayList[] otherPositions = new TIntArrayList[vmGroups.size()];
    @SuppressWarnings("unchecked") List<IntVar>[] otherEnds = new List[vmGroups.size()];
    for (int i = 0; i < vmGroups.size(); i++) {
        otherPositions[i] = new TIntArrayList();
        otherEnds[i] = new ArrayList<>();
    }
    fullfillOthers(rp, otherPositions, otherEnds, vmGroups);
    // Now, we just have to put way too many precedences constraint, one per VM.
    for (int i = 0; i < vmGroups.size(); i++) {
        List<VM> grp = vmGroups.get(i);
        for (VM vm : grp) {
            if (rp.getFutureRunningVMs().contains(vm)) {
                VMTransition a = rp.getVMAction(vm);
                IntVar myPos = a.getDSlice().getHoster();
                IntVar myStart = a.getDSlice().getStart();
                rp.getModel().post(new Precedences(myPos, myStart, otherPositions[i].toArray(), otherEnds[i].toArray(new IntVar[otherEnds[i].size()])));
            }
        }
    }
    return true;
}
Also used : Precedences(org.btrplace.scheduler.choco.extensions.Precedences) VM(org.btrplace.model.VM) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IntVar(org.chocosolver.solver.variables.IntVar) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Aggregations

VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)41 VM (org.btrplace.model.VM)34 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)23 Node (org.btrplace.model.Node)22 IntVar (org.chocosolver.solver.variables.IntVar)22 ArrayList (java.util.ArrayList)18 Model (org.btrplace.model.Model)17 HashSet (java.util.HashSet)16 Mapping (org.btrplace.model.Mapping)16 Slice (org.btrplace.scheduler.choco.Slice)16 DefaultModel (org.btrplace.model.DefaultModel)12 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)12 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)12 StayAwayVM (org.btrplace.scheduler.choco.transition.StayAwayVM)12 Test (org.testng.annotations.Test)12 BootVM (org.btrplace.scheduler.choco.transition.BootVM)11 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)11 KillVM (org.btrplace.scheduler.choco.transition.KillVM)11 ResumeVM (org.btrplace.scheduler.choco.transition.ResumeVM)11 ShutdownVM (org.btrplace.scheduler.choco.transition.ShutdownVM)11