Search in sources :

Example 1 with Disjoint

use of org.btrplace.scheduler.choco.extensions.Disjoint in project scheduler by btrplace.

the class CLonely method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) {
    // Remove non future-running VMs
    List<IntVar> myHosts = new ArrayList<>();
    List<IntVar> otherHosts = new ArrayList<>();
    Collection<VM> vms = new HashSet<>();
    Set<VM> otherVMs = new HashSet<>();
    for (VM vm : rp.getFutureRunningVMs()) {
        IntVar host = rp.getVMAction(vm).getDSlice().getHoster();
        if (cstr.getInvolvedVMs().contains(vm)) {
            myHosts.add(host);
            vms.add(vm);
        } else {
            otherHosts.add(host);
            otherVMs.add(vm);
        }
    }
    // Link the assignment variables with the set
    Model s = rp.getModel();
    s.post(new Disjoint(myHosts.toArray(new IntVar[myHosts.size()]), otherHosts.toArray(new IntVar[otherHosts.size()]), rp.getNodes().size()));
    if (cstr.isContinuous()) {
        continuousRestriction(rp, vms, otherVMs);
    }
    return true;
}
Also used : VM(org.btrplace.model.VM) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) Model(org.chocosolver.solver.Model) Disjoint(org.btrplace.scheduler.choco.extensions.Disjoint) IntVar(org.chocosolver.solver.variables.IntVar) HashSet(java.util.HashSet)

Aggregations

TIntArrayList (gnu.trove.list.array.TIntArrayList)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 VM (org.btrplace.model.VM)1 Disjoint (org.btrplace.scheduler.choco.extensions.Disjoint)1 Model (org.chocosolver.solver.Model)1 IntVar (org.chocosolver.solver.variables.IntVar)1