
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@423 72836036-5685-4462-b002-a69064685172
30 lines
754 B
Java
30 lines
754 B
Java
package jrummikub.ai.fdsolver;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import jrummikub.ai.fdsolver.constraint.LessThan;
|
|
import jrummikub.ai.fdsolver.constraint.LessThanConst;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class SolverTest {
|
|
@Test
|
|
public void test() {
|
|
Solver solver = new Solver();
|
|
|
|
Var<Integer> x = solver.makeVar(1, 2, 3);
|
|
Var<Integer> y = solver.makeRangeVar(1, 13);
|
|
|
|
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()));
|
|
}
|
|
|
|
assertEquals(2, lastx);
|
|
assertEquals(1, lasty);
|
|
}
|
|
}
|