Search in sources :

Example 1 with IStateInt

use of org.chocosolver.memory.IStateInt in project scheduler by btrplace.

the class WorstFit method canStay.

/**
 * Check if a VM can stay on its current node.
 *
 * @param vm the VM
 * @return {@code true} iff the VM can stay
 */
private boolean canStay(VM vm) {
    Mapping m = rp.getSourceModel().getMapping();
    if (m.isRunning(vm)) {
        int curPos = rp.getNode(m.getVMLocation(vm));
        if (!rp.getVMAction(vm).getDSlice().getHoster().contains(curPos)) {
            return false;
        }
        IStateInt[] loads = load(curPos);
        return loadWith(curPos, loads, vm) <= 1.0;
    }
    return false;
}
Also used : IStateInt(org.chocosolver.memory.IStateInt) Mapping(org.btrplace.model.Mapping)

Example 2 with IStateInt

use of org.chocosolver.memory.IStateInt in project scheduler by btrplace.

the class WorstFit method selectValue.

@Override
public int selectValue(IntVar v) {
    VM vm = vmMap.get(v);
    if (stayFirst && canStay(vm)) {
        return rp.getNode(rp.getSourceModel().getMapping().getVMLocation(vm));
    }
    // Get the load
    int leastId = v.getLB();
    double minLoad = 2;
    IStateInt[] loads = new IStateInt[rcs.size()];
    for (int nId = v.getLB(); nId <= v.getUB(); nId = v.nextValue(nId)) {
        for (int d = 0; d < rcs.size(); d++) {
            loads[d] = packing.assignedLoad()[d][nId];
        }
        double global = loadWith(nId, loads, vm);
        if (global < minLoad) {
            leastId = nId;
            minLoad = global;
        }
    }
    return leastId;
}
Also used : VM(org.btrplace.model.VM) IStateInt(org.chocosolver.memory.IStateInt)

Aggregations

IStateInt (org.chocosolver.memory.IStateInt)2 Mapping (org.btrplace.model.Mapping)1 VM (org.btrplace.model.VM)1