예제 #1
0
 @Test(groups = "1s")
 public void testregExp8() {
   Solver solver = new Solver();
   IntVar[] CS = VF.enumeratedArray("CS", 3, new int[] {43, 59, 117}, solver);
   solver.post(ICF.regular(CS, new FiniteAutomaton("<43><59><117>")));
   solver.set(ISF.lexico_LB(CS));
   solver.findAllSolutions();
   Assert.assertEquals(solver.getMeasures().getSolutionCount(), 1);
 }
예제 #2
0
 @Test(groups = "1s")
 public void testJL2() {
   for (int k = 0; k < 50; k++) {
     Solver s = new Solver();
     final IntVar i = VF.enumerated("i", -2, 2, s);
     final IntVar j = VF.enumerated("j", -2, 2, s);
     // Chatterbox.showDecisions(s);
     // Chatterbox.showSolutions(s);
     s.set(ISF.random_value(new IntVar[] {i, j}));
     s.post(new Constraint("Constraint", new PropTestDM1(i, j), new PropTestDM2(i, j)));
     s.findAllSolutions();
   }
 }
예제 #3
0
  @Test(groups = "1s")
  public void testJL() {
    Solver solver = new Solver();
    final SetVar s0 = VF.set("s0", 0, 1, solver);
    final BoolVar b0 = VF.bool("b0", solver);
    final BoolVar b1 = VF.bool("b1", solver);
    final IntVar i0 = VF.bool("i0", solver);
    solver.set(ISF.lexico_LB(i0));
    solver.post(SCF.bool_channel(new BoolVar[] {b0, b1}, s0, 0));
    solver.post(SCF.cardinality(s0, VF.fixed(0, solver)));

    solver.findSolution();
    solver.getSearchLoop().reset();
    solver.findSolution();
  }
예제 #4
0
 @Test(groups = "1s")
 public void testregExp7() {
   Solver solver = new Solver();
   IntVar[] CS = VF.enumeratedArray("CS", 10, 0, 2, solver);
   solver.post(ICF.regular(CS, new FiniteAutomaton("0*(1{2,4}0{0,2}0)*0*")));
   Chatterbox.showSolutions(
       solver,
       () -> {
         for (int i = 0; i < 10; i++) {
           System.out.printf("%d", CS[i].getValue());
         }
         //            System.out.printf("\n");
         return "";
       });
   solver.set(ISF.lexico_LB(CS));
   //        Chatterbox.showDecisions(solver);
   solver.findAllSolutions();
   Assert.assertEquals(solver.getMeasures().getSolutionCount(), 84);
 }