Search in sources :

Example 61 with IntVar

use of org.chocosolver.solver.variables.IntVar 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 62 with IntVar

use of org.chocosolver.solver.variables.IntVar 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 63 with IntVar

use of org.chocosolver.solver.variables.IntVar 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)

Example 64 with IntVar

use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.

the class RoundedUpDivisionTest method test2.

@Test
public void test2() {
    Model s = new Model();
    IntVar a = s.intVar("a", 0, 32, true);
    IntVar b = s.intVar("b", 0, 48, true);
    double q = 1.5;
    s.post(new RoundedUpDivision(a, b, q));
    Assert.assertEquals(s.getSolver().findAllSolutions().size(), 49);
// Assert.assertEquals(s.getNbSolutions(), 33);
}
Also used : Model(org.chocosolver.solver.Model) IntVar(org.chocosolver.solver.variables.IntVar) Test(org.testng.annotations.Test)

Example 65 with IntVar

use of org.chocosolver.solver.variables.IntVar in project scheduler by btrplace.

the class VectorPackingTest method test2DGuillaume.

@Test(sequential = true)
public void test2DGuillaume() {
    modelPack2D(2, 100, 3, 30);
    IntVar margeLoad = s.intVar("margeLoad", 0, 50, true);
    s.post(s.element(margeLoad, loads[0], bins[0], 0));
    testPack(2);
}
Also used : IntVar(org.chocosolver.solver.variables.IntVar) Test(org.testng.annotations.Test)

Aggregations

IntVar (org.chocosolver.solver.variables.IntVar)78 VM (org.btrplace.model.VM)35 Model (org.chocosolver.solver.Model)32 Test (org.testng.annotations.Test)30 Node (org.btrplace.model.Node)29 ArrayList (java.util.ArrayList)23 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)22 BoolVar (org.chocosolver.solver.variables.BoolVar)17 Mapping (org.btrplace.model.Mapping)16 Model (org.btrplace.model.Model)15 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)13 HashSet (java.util.HashSet)11 Slice (org.btrplace.scheduler.choco.Slice)10 DefaultModel (org.btrplace.model.DefaultModel)9 TIntArrayList (gnu.trove.list.array.TIntArrayList)8 ShareableResource (org.btrplace.model.view.ShareableResource)8 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)8 Constraint (org.chocosolver.solver.constraints.Constraint)8 List (java.util.List)7 Set (java.util.Set)7