Search in sources :

Example 1 with StayAwayVM

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

the class CSequentialVMTransitions method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    List<VM> seq = cstr.getInvolvedVMs();
    List<VMTransition> ams = new ArrayList<>();
    for (VM vmId : seq) {
        VMTransition am = rp.getVMAction(vmId);
        // Avoid VMs with no action model or Transition that do not denotes a state transition
        if (am == null || am instanceof StayAwayVM || am instanceof RelocatableVM) {
            continue;
        }
        ams.add(am);
    }
    if (ams.size() > 1) {
        Iterator<VMTransition> ite = ams.iterator();
        VMTransition prev = ite.next();
        Model csp = rp.getModel();
        while (ite.hasNext()) {
            VMTransition cur = ite.next();
            csp.post(csp.arithm(prev.getEnd(), "<=", cur.getStart()));
            prev = cur;
        }
    }
    return true;
}
Also used : StayAwayVM(org.btrplace.scheduler.choco.transition.StayAwayVM) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) VM(org.btrplace.model.VM) StayAwayVM(org.btrplace.scheduler.choco.transition.StayAwayVM) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) ArrayList(java.util.ArrayList) Model(org.chocosolver.solver.Model) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM)

Aggregations

ArrayList (java.util.ArrayList)1 VM (org.btrplace.model.VM)1 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)1 StayAwayVM (org.btrplace.scheduler.choco.transition.StayAwayVM)1 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)1 Model (org.chocosolver.solver.Model)1