41 namespace Test {
namespace Int {
59 :
Test(
"Circuit::" +
str(icl) +
"::" +
str(n) +
"::" +
str(off),
60 n,min,max,false,icl), offset(off) {
65 for (
int i=x.
size();
i--; )
66 if ((x[
i] < 0) || (x[
i] > x.
size()-1))
71 for (
int i=x.
size();
i--; ) {
72 j=x[j]; reachable |= (1 << j);
75 for (
int i=x.
size();
i--; )
76 if (!(reachable & (1 <<
i)))
101 :
Test(
"Path::" +
str(icl) +
"::" +
str(n) +
"::" +
str(off),
102 n+2,min,max,false,icl), offset(off) {
107 int n = x.
size() - 2;
110 if ((s < 0) || (s > n) || (e < 0) || (e > n) || (x[e] != n))
113 if ((
i != e) && ((x[
i] < 0) || (x[
i] > n)))
115 int reachable = (1 << s);
118 for (
int i=n;
i--; ) {
119 j=x[j]; reachable |= (1 << j);
123 if (!(reachable & (1 <<
i)))
129 int n = x.
size() - 2;
154 n+1,min,max,false,icl), offset(off) {
161 if ((x[
i] < 0) || (x[
i] > n-1))
166 for (
int i=n;
i--; ) {
167 j=x[j]; reachable |= (1 << j);
171 if (!(reachable & (1 <<
i)))
183 for (
int i=0;
i<
n;
i++)
184 for (
int j=0; j<
n; j++)
192 for (
int i=0;
i<
n;
i++)
208 n+3,min,max,false,icl), offset(off) {
213 int n = x.
size() - 3;
217 if ((s < 0) || (s > n) || (e < 0) || (e > n) || (x[e] != n))
220 if ((
i != e) && ((x[
i] < 0) || (x[
i] > n)))
222 int reachable = (1 << s);
225 for (
int i=n;
i--; ) {
226 j=x[j]; reachable |= (1 << j);
230 if (!(reachable & (1 <<
i)))
241 for (
int i=0;
i<
n;
i++)
242 for (
int j=0; j<
n; j++)
248 path(home, c, offset, y,
249 expr(home, x[n]+offset),
250 expr(home, x[n+1]+offset),
253 for (
int i=0;
i<
n;
i++)
255 path(home, c, y, x[n], x[n+1], x[n+2],
icl);
269 :
Test(
"Circuit::FullCost::" +
str(icl)+
"::"+
str(n)+
"::"+
str(off),
270 2*n+1,min,max,false,icl), offset(off) {
275 int n=(x.
size()-1) / 2;
277 if ((x[
i] < 0) || (x[
i] > n-1))
282 for (
int i=n;
i--; ) {
283 j=x[j]; reachable |= (1 << j);
287 if (!(reachable & (1 <<
i)))
290 if ((x[
i]/2) != x[n+
i])
300 int n=(x.
size()-1)/2;
302 for (
int i=0;
i<
n;
i++)
303 for (
int j=0; j<
n; j++)
306 for (
int i=0;
i<
n;
i++) {
314 for (
int i=0;
i<
n;
i++)
326 for (
int i=1;
i<=6;
i++) {
332 for (
int i=1;
i<=4;
i++) {
PathCost(int n, int min, int max, int off, Gecode::IntConLevel icl)
Create and register test.
Create(void)
Perform creation and registration.
IntConLevel
Consistency levels for integer propagators.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
Simple test for circuit constraint with full cost information.
const FloatNum max
Largest allowed float value.
Help class to create and register tests.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
Value propagation or consistency (naive)
Path(int n, int min, int max, int off, Gecode::IntConLevel icl)
Create and register test.
CircuitCost(int n, int min, int max, int off, Gecode::IntConLevel icl)
Create and register test.
void path(Home home, const IntArgs &c, const IntVarArgs &x, IntVar s, IntVar e, IntVar z, IntConLevel icl)
Post propagator such that x forms a Hamiltonian path with cost z.
Simple test for path constraint with total cost.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntConLevel icl)
Post propagator such that x forms a Hamiltonian path.
Circuit(int n, int min, int max, int off, Gecode::IntConLevel icl)
Create and register test.
ConTestLevel contest
Whether to test for certain consistency.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
void circuit(Home home, const IntArgs &c, const IntVarArgs &x, IntVar z, IntConLevel icl)
Post propagator such that x forms a circuit with cost z.
static std::string str(Gecode::ExtensionalPropKind epk)
Map extensional propagation kind to string.
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.
Gecode::IntConLevel icl
Consistency level.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post path constraint on x.
Simple test for circuit constraint with total cost.
Passing integer variables.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post circuit constraint on x.
Passing integer arguments.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
CircuitFullCost(int n, int min, int max, int off, Gecode::IntConLevel icl)
Create and register test.
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
Node * x
Pointer to corresponding Boolean expression node.
Base class for assignments
Gecode toplevel namespace
virtual bool solution(const Assignment &x) const
Check whether x is solution.
void circuit(Home home, int offset, const IntVarArgs &x, IntConLevel icl)
Post propagator such that x forms a circuit.
int size(void) const
Return size of array (number of elements)
int size(void) const
Return number of variables.
Domain propagation or consistency.
Simple test for circuit constraint.