use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.
the class FastImpliesEqTest method test7.
@Test
public void test7() {
Model s = new Model();
BoolVar b = s.boolVar(false);
IntVar x = s.intVar("x", 0, 2, true);
int c = 3;
s.post(new FastImpliesEq(b, x, c));
Assert.assertEquals(3, s.getSolver().findAllSolutions().size());
}
use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.
the class FastImpliesEqTest method test1.
@Test
public void test1() {
Model s = new Model();
// SMF.log(s, true, true);
BoolVar b = s.boolVar("b");
IntVar x = s.intVar("x", 0, 3, true);
int c = 2;
s.post(new FastImpliesEq(b, x, c));
Assert.assertEquals(5, s.getSolver().findAllSolutions().size());
}
use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.
the class PrecedencesTest method dummyTest.
/**
* Ends variables are already instantiated.
* Just a simple test.
*/
@Test
public void dummyTest() {
Model s = new Model();
IntVar[] ends = new IntVar[5];
int[] others = new int[5];
others[0] = 0;
ends[0] = s.intVar(1);
others[1] = 0;
ends[1] = s.intVar(3);
others[2] = 1;
ends[2] = s.intVar(2);
others[3] = 1;
ends[3] = s.intVar(4);
others[4] = 2;
ends[4] = s.intVar(5);
IntVar host = s.intVar("host", 0, 2, false);
IntVar start = s.intVar("start", 0, 5, true);
/*
If host == 0, consume = 3,4,5
If host == 1, consume = 4,5
If host == 2, consume = 5
=> 6 solutions
*/
Precedences p = new Precedences(host, start, others, ends);
s.post(p);
Assert.assertEquals(6, s.getSolver().findAllSolutions().size());
}
use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.
the class RoundedUpDivisionTest method test1.
@Test
public void test1() {
Model s = new Model();
IntVar a = s.intVar("a", 0, 5, true);
IntVar b = s.intVar("b", 0, 5, true);
double q = 1;
s.post(new RoundedUpDivision(a, b, q));
Assert.assertEquals(6, s.getSolver().findAllSolutions().size());
// Assert.assertEquals(s.getNbSolutions(), 6);
}
use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.
the class DefaultReconfigurationProblem method addContinuousResourceCapacities.
private void addContinuousResourceCapacities() {
TIntArrayList cUse = new TIntArrayList();
List<IntVar> iUse = new ArrayList<>();
for (int j = 0; j < getVMs().size(); j++) {
VMTransition a = vmActions.get(j);
if (a.getDSlice() != null) {
iUse.add(csp.intVar(1));
}
if (a.getCSlice() != null) {
cUse.add(1);
}
}
ChocoView v = getView(Cumulatives.VIEW_ID);
if (v == null) {
throw SchedulerModelingException.missingView(model, Cumulatives.VIEW_ID);
}
((Cumulatives) v).addDim(getNbRunningVMs(), cUse.toArray(), iUse.toArray(new IntVar[iUse.size()]));
}
Aggregations