Restructured fdsolver api and made first test succeed
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@423 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
a15626ac3b
commit
2b4ad89e72
18 changed files with 600 additions and 57 deletions
|
@ -1,8 +1,8 @@
|
|||
package jrummikub.ai.fdsolver;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import jrummikub.ai.fdsolver.constraint.LessThan;
|
||||
import jrummikub.ai.fdsolver.constraint.LessThanConst;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -11,18 +11,20 @@ public class SolverTest {
|
|||
public void test() {
|
||||
Solver solver = new Solver();
|
||||
|
||||
Var<Integer> x = new Var<Integer>(solver, Arrays.asList(1, 2, 3));
|
||||
Var<Integer> y = Var.range(solver, 1,13);
|
||||
Var<Integer> x = solver.makeVar(1, 2, 3);
|
||||
Var<Integer> y = solver.makeRangeVar(1, 13);
|
||||
|
||||
Constraints.lessThan(solver, y, x);
|
||||
|
||||
while(solver.solve()) {
|
||||
solver.push();
|
||||
Constraints.lessThan(solver, x, x.getValue());
|
||||
solver.addConstraint(new LessThan<Integer>(false, y, x));
|
||||
|
||||
int lastx = 0, lasty = 0;
|
||||
while (solver.solve()) {
|
||||
lastx = x.getValue();
|
||||
lasty = y.getValue();
|
||||
System.out.println("x = " + lastx + ", y = " + lasty);
|
||||
solver.addConstraint(new LessThanConst<Integer>(false, x, x.getValue()));
|
||||
}
|
||||
solver.pop();
|
||||
|
||||
assertEquals(2, (int)x.getValue());
|
||||
assertEquals(1, (int)y.getValue());
|
||||
|
||||
assertEquals(2, lastx);
|
||||
assertEquals(1, lasty);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue