Search in sources :

Example 26 with Model

use of org.chocosolver.solver.Model in project scheduler by btrplace.

the class FastImpliesEqTest method test2.

@Test
public void test2() {
    Model s = new Model();
    BoolVar b = s.boolVar("b");
    IntVar x = s.intVar("x", 0, 3, false);
    int c = 2;
    s.post(new FastImpliesEq(b, x, c));
    Assert.assertEquals(5, s.getSolver().findAllSolutions().size());
}
Also used : Model(org.chocosolver.solver.Model) IntVar(org.chocosolver.solver.variables.IntVar) BoolVar(org.chocosolver.solver.variables.BoolVar) Test(org.testng.annotations.Test)

Example 27 with Model

use of org.chocosolver.solver.Model in project scheduler by btrplace.

the class FastImpliesEqTest method test5.

@Test
public void test5() {
    Model s = new Model();
    BoolVar b = s.boolVar(true);
    IntVar x = s.intVar("x", 0, 3, true);
    int c = 2;
    s.post(new FastImpliesEq(b, x, c));
    Assert.assertEquals(1, s.getSolver().findAllSolutions().size());
}
Also used : Model(org.chocosolver.solver.Model) IntVar(org.chocosolver.solver.variables.IntVar) BoolVar(org.chocosolver.solver.variables.BoolVar) Test(org.testng.annotations.Test)

Example 28 with Model

use of org.chocosolver.solver.Model in project scheduler by btrplace.

the class FastImpliesEqTest method test3.

@Test
public void test3() {
    Model s = new Model();
    BoolVar b = s.boolVar("b");
    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());
}
Also used : Model(org.chocosolver.solver.Model) IntVar(org.chocosolver.solver.variables.IntVar) BoolVar(org.chocosolver.solver.variables.BoolVar) Test(org.testng.annotations.Test)

Example 29 with Model

use of org.chocosolver.solver.Model in project scheduler by btrplace.

the class FastImpliesEqTest method test4.

@Test
public void test4() {
    Model s = new Model();
    BoolVar b = s.boolVar(true);
    IntVar x = s.intVar("x", 0, 2, true);
    int c = 3;
    s.post(new FastImpliesEq(b, x, c));
    Assert.assertEquals(0, s.getSolver().findAllSolutions().size());
}
Also used : Model(org.chocosolver.solver.Model) IntVar(org.chocosolver.solver.variables.IntVar) BoolVar(org.chocosolver.solver.variables.BoolVar) Test(org.testng.annotations.Test)

Example 30 with Model

use of org.chocosolver.solver.Model in project scheduler by btrplace.

the class PrecedencesTest method simpleTest.

/**
 * Ends variables vary between 1 and 2 + index of the host
 * Just a simple test.
 */
@Test
public void simpleTest() {
    Model s = new Model();
    IntVar[] ends = new IntVar[3];
    int[] others = new int[3];
    others[0] = 0;
    ends[0] = s.intVar("ends[0]", 1, 2, true);
    others[1] = 0;
    ends[1] = s.intVar("ends[1]", 1, 3, true);
    others[2] = 0;
    ends[2] = s.intVar("ends[2]", 1, 4, true);
    /*
         on host 0, 2 * 2 * 2 -> 8
         on host 1, 2 * 2 -> 4

         on host 2, 4 * 4 * 2 -> 32
         16 * 9 * 16 + 27 * 4 * 16 + 32 * 4 * 9
         */
    IntVar host = s.intVar(0, 0);
    IntVar start = s.intVar(0, 5, true);
    Precedences p = new Precedences(host, start, others, ends);
    s.post(p);
    // TODO: A way to check if it is correct ? :D
    Assert.assertEquals(s.getSolver().findAllSolutions().size(), 75);
}
Also used : Model(org.chocosolver.solver.Model) IntVar(org.chocosolver.solver.variables.IntVar) Test(org.testng.annotations.Test)

Aggregations

Model (org.chocosolver.solver.Model)38 IntVar (org.chocosolver.solver.variables.IntVar)32 Test (org.testng.annotations.Test)20 BoolVar (org.chocosolver.solver.variables.BoolVar)17 Node (org.btrplace.model.Node)7 VM (org.btrplace.model.VM)7 ArrayList (java.util.ArrayList)6 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)4 TIntArrayList (gnu.trove.list.array.TIntArrayList)3 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)3 HashSet (java.util.HashSet)2 SchedulerModelingException (org.btrplace.scheduler.SchedulerModelingException)2 Task (org.chocosolver.solver.variables.Task)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 Among (org.btrplace.model.constraint.Among)1 SplitAmong (org.btrplace.model.constraint.SplitAmong)1 Parameters (org.btrplace.scheduler.choco.Parameters)1