use of org.btrplace.scheduler.choco.extensions.TaskScheduler in project scheduler by btrplace.
the class DefaultCumulatives method beforeSolve.
/**
* Build the constraint.
*
* @return the resulting constraint
*/
@Override
@SuppressWarnings("squid:S3346")
public boolean beforeSolve(ReconfigurationProblem rp) {
super.beforeSolve(rp);
if (rp.getSourceModel().getMapping().getNbNodes() == 0 || capacities.isEmpty()) {
return true;
}
int nbDims = capacities.size();
int nbRes = capacities.get(0).size();
// We get the UB of the node capacity and the LB for the VM usage.
int[][] capas = new int[nbRes][nbDims];
int d = 0;
for (List<IntVar> capaDim : capacities) {
assert capaDim.size() == nbRes;
for (int j = 0; j < capaDim.size(); j++) {
capas[j][d] = capaDim.get(j).getUB();
}
d++;
}
assert cUsages.size() == nbDims;
int nbCHosts = cUsages.get(0).length;
int[][] cUses = new int[nbCHosts][nbDims];
d = 0;
for (int[] cUseDim : cUsages) {
assert cUseDim.length == nbCHosts;
for (int i = 0; i < nbCHosts; i++) {
cUses[i][d] = cUseDim[i];
}
d++;
}
assert dUsages.size() == nbDims;
int nbDHosts = dUsages.get(0).length;
int[][] dUses = new int[nbDHosts][nbDims];
d = 0;
for (IntVar[] dUseDim : dUsages) {
assert dUseDim.length == nbDHosts;
for (int j = 0; j < nbDHosts; j++) {
dUses[j][d] = dUseDim[j].getLB();
}
d++;
}
symmetryBreakingForStayingVMs(rp);
IntVar[] earlyStarts = rp.getNodeActions().stream().map(NodeTransition::getHostingStart).toArray(IntVar[]::new);
IntVar[] lastEnd = rp.getNodeActions().stream().map(NodeTransition::getHostingEnd).toArray(IntVar[]::new);
rp.getModel().post(new TaskScheduler(earlyStarts, lastEnd, capas, cHosts, cUses, cEnds, dHosts, dUses, dStarts, associations));
return true;
}
Aggregations