41 namespace Test {
namespace Int {
59 :
Test(
"Circuit::" +
str(ipl) +
"::" +
str(n) +
"::" +
str(off),
60 n,min,max,false,ipl), offset(off) {
66 for (
int i=x.
size();
i--; )
67 if ((x[
i] < 0) || (x[
i] > x.
size()-1))
72 for (
int i=x.
size();
i--; ) {
73 j=x[j]; reachable |= (1 << j);
76 for (
int i=x.
size();
i--; )
77 if (!(reachable & (1 <<
i)))
102 :
Test(
"Path::" +
str(ipl) +
"::" +
str(n) +
"::" +
str(off),
103 n+2,min,max,false,ipl), offset(off) {
109 int n = x.
size() - 2;
112 if ((s < 0) || (s > n) || (e < 0) || (e > n) || (x[e] != n))
115 if ((
i != e) && ((x[
i] < 0) || (x[
i] > n)))
117 int reachable = (1 << s);
120 for (
int i=n;
i--; ) {
121 j=x[j]; reachable |= (1 << j);
125 if (!(reachable & (1 <<
i)))
131 int n = x.
size() - 2;
156 n+1,min,max,false,ipl), offset(off) {
164 if ((x[
i] < 0) || (x[
i] > n-1))
169 for (
int i=n;
i--; ) {
170 j=x[j]; reachable |= (1 << j);
174 if (!(reachable & (1 <<
i)))
186 for (
int i=0;
i<
n;
i++)
187 for (
int j=0; j<
n; j++)
195 for (
int i=0;
i<
n;
i++)
211 n+3,min,max,false,ipl), offset(off) {
217 int n = x.
size() - 3;
221 if ((s < 0) || (s > n) || (e < 0) || (e > n) || (x[e] != n))
224 if ((
i != e) && ((x[
i] < 0) || (x[
i] > n)))
226 int reachable = (1 << s);
229 for (
int i=n;
i--; ) {
230 j=x[j]; reachable |= (1 << j);
234 if (!(reachable & (1 <<
i)))
245 for (
int i=0;
i<
n;
i++)
246 for (
int j=0; j<
n; j++)
252 path(home, c, offset, y,
253 expr(home, x[n]+offset),
254 expr(home, x[n+1]+offset),
257 for (
int i=0;
i<
n;
i++)
259 path(home, c, y, x[n], x[n+1], x[n+2],
ipl);
273 :
Test(
"Circuit::FullCost::" +
str(ipl)+
"::"+
str(n)+
"::"+
str(off),
274 2*n+1,min,max,false,ipl), offset(off) {
280 int n=(x.
size()-1) / 2;
282 if ((x[
i] < 0) || (x[
i] > n-1))
287 for (
int i=n;
i--; ) {
288 j=x[j]; reachable |= (1 << j);
292 if (!(reachable & (1 <<
i)))
295 if ((x[
i]/2) != x[n+
i])
305 int n=(x.
size()-1)/2;
307 for (
int i=0;
i<
n;
i++)
308 for (
int j=0; j<
n; j++)
311 for (
int i=0;
i<
n;
i++) {
319 for (
int i=0;
i<
n;
i++)
331 for (
int i=1;
i<=6;
i++) {
337 for (
int i=1;
i<=4;
i++) {
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Create(void)
Perform creation and registration.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
Simple test for circuit constraint with full cost information.
int size(void) const
Return size of array (number of elements)
const FloatNum max
Largest allowed float value.
int size(void) const
Return number of variables.
Help class to create and register tests.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntPropLevel ipl)
Post propagator such that x forms a Hamiltonian path.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
void circuit(Home home, int offset, const IntVarArgs &x, IntPropLevel ipl)
Post propagator such that x forms a circuit.
Simple test for path constraint with total cost.
ConTestLevel contest
Whether to test for certain consistency.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
Circuit(int n, int min, int max, int off, Gecode::IntPropLevel ipl)
Create and register test.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Simple test for Hamiltonian path constraint.
CircuitFullCost(int n, int min, int max, int off, Gecode::IntPropLevel ipl)
Create and register test.
void path(Home home, const IntArgs &c, const IntVarArgs &x, IntVar s, IntVar e, IntVar z, IntPropLevel ipl)
Post propagator such that x forms a Hamiltonian path with cost z.
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post path constraint on x.
Simple test for circuit constraint with total cost.
Gecode::IntPropLevel ipl
Propagation level.
Passing integer variables.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
Passing integer arguments.
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
bool testfix
Whether to perform fixpoint test.
IntPropLevel
Propagation levels for integer propagators.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Post propagator for SetVar SetOpType SetVar y
Node * x
Pointer to corresponding Boolean expression node.
Base class for assignments
PathCost(int n, int min, int max, int off, Gecode::IntPropLevel ipl)
Create and register test.
Domain propagation Options: basic versus advanced propagation.
Gecode toplevel namespace
Path(int n, int min, int max, int off, Gecode::IntPropLevel ipl)
Create and register test.
void circuit(Home home, const IntArgs &c, const IntVarArgs &x, IntVar z, IntPropLevel ipl)
Post propagator such that x forms a circuit with cost z.
CircuitCost(int n, int min, int max, int off, Gecode::IntPropLevel ipl)
Create and register test.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Simple test for circuit constraint.