use of org.chocosolver.solver.Model in project scheduler by btrplace.
the class CSync method inject.
@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
Model csp = rp.getModel();
// Get all migrations involved
for (VM vm : sec.getInvolvedVMs()) {
VMTransition vt = rp.getVMAction(vm);
if (vt instanceof RelocatableVM) {
migrationList.add((RelocatableVM) vt);
}
}
for (int i = 0; i < migrationList.size(); i++) {
for (int j = i + 1; j < migrationList.size(); j++) {
RelocatableVM vm1 = migrationList.get(i);
RelocatableVM vm2 = migrationList.get(j);
// Sync the start or end depending of the migration algorithm
// TODO: support VMs that are not necessarily moving
IntVar firstMigSync = vm1.usesPostCopy() ? vm1.getStart() : vm1.getEnd();
IntVar secondMigSync = vm2.usesPostCopy() ? vm2.getStart() : vm2.getEnd();
csp.post(csp.arithm(firstMigSync, "=", secondMigSync));
}
}
return true;
}
use of org.chocosolver.solver.Model in project scheduler by btrplace.
the class DisjointTest method disjointMultipleTest.
@Test
public void disjointMultipleTest() {
IntVar[][] groups = new IntVar[3][3];
Model s = new Model();
for (int g = 0; g < groups.length; g++) {
for (int i = 0; i < groups[g].length; i++) {
groups[g][i] = s.intVar("G" + g + "-" + i, 0, 2, false);
}
}
s.post(new DisjointMultiple(groups, 3));
for (int g = 1; g < groups.length; g++) {
s.post(s.arithm(groups[g - 1][2], "<=", groups[g][2]));
}
// SMF.log(s, true, true);
// SMF.logContradiction(s);
s.getSolver().findAllSolutions();
}
use of org.chocosolver.solver.Model in project scheduler by btrplace.
the class FastIFFEqTest method test2.
@Test
public void test2() {
Model csp = new Model();
BoolVar b = csp.boolVar("b");
IntVar x = csp.intVar("x", 0, 3, false);
int c = 2;
csp.post(new FastIFFEq(b, x, c));
Assert.assertEquals(4, csp.getSolver().findAllSolutions().size());
}
use of org.chocosolver.solver.Model in project scheduler by btrplace.
the class FastIFFEqTest method test6.
@Test
public void test6() {
Model csp = new Model();
BoolVar b = csp.boolVar(false);
IntVar x = csp.intVar("x", 0, 3, true);
int c = 2;
csp.post(new FastIFFEq(b, x, c));
Assert.assertEquals(3, csp.getSolver().findAllSolutions().size());
}
use of org.chocosolver.solver.Model in project scheduler by btrplace.
the class FastIFFEqTest method test3.
@Test
public void test3() {
Model csp = new Model();
BoolVar b = csp.boolVar("b");
IntVar x = csp.intVar("x", 0, 2, true);
int c = 3;
csp.post(new FastIFFEq(b, x, c));
Assert.assertEquals(3, csp.getSolver().findAllSolutions().size());
}
Aggregations