On Testing Constraint
Programs
Nadjib LAZAAR*, Arnaud GOTLIEB*, Yahia LEBBAH**
*INRIA Rennes Bretagne Atlantique ** Université d'Oran Es-Senia
1
CP’2010 St-Andrews, Scotland 08 september
/21
Motivations Numerous CP modeling languages and platforms have been - - PowerPoint PPT Presentation
On T esting C onstraint P rograms Nadjib LAZAAR* , Arnaud GOTLIEB*, Yahia LEBBAH** *INRIA Rennes Bretagne Atlantique ** Universit d'Oran Es-Senia CP2010 St -Andrews, Scotland 08 september 1 /21 Motivations Numerous CP modeling
Nadjib LAZAAR*, Arnaud GOTLIEB*, Yahia LEBBAH**
*INRIA Rennes Bretagne Atlantique ** Université d'Oran Es-Senia
1
CP’2010 St-Andrews, Scotland 08 september
/21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
2 /21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
CP programs begin to be used in business-critical systems (e.g., combinatorial
auctions)
2 /21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
CP programs begin to be used in business-critical systems (e.g., combinatorial
auctions)
Refinement in CP
2 /21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
CP programs begin to be used in business-critical systems (e.g., combinatorial
auctions)
Refinement in CP
2
SPEC
/21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
CP programs begin to be used in business-critical systems (e.g., combinatorial
auctions)
Refinement in CP
2
SPEC
/21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
CP programs begin to be used in business-critical systems (e.g., combinatorial
auctions)
Refinement in CP
2
SPEC
/21
Numerous CP modeling languages and platforms have been developed
(OPL, SICStus Prolog, ZINC, GECODE, CHOCO…) for solving combinatorial problems that arise in optimization, planning, scheduling…
CP programs begin to be used in business-critical systems (e.g., combinatorial
auctions)
Refinement in CP
2
SPEC
/21
3 /21
3 /21
using CP; int m=...; dvar int x[1..m] in 0..m*m; minimize x[m]; subject to { (1) forall (i in 1..m-1) x[i] < x[i+1]; (2) forall (i in 1..m, j in 1..m, k in 1..m, l in 1..m: (i < j, k < l)) x[j] - x[i] != x[l] - x[k]; }
4 /21
using CP; int m=...; dvar int x[1..m] in 0..m*m; minimize x[m]; subject to { (1) forall (i in 1..m-1) x[i] < x[i+1]; (2) forall (i in 1..m, j in 1..m, k in 1..m, l in 1..m: (i < j, k < l)) x[j] - x[i] != x[l] - x[k]; } using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) x[2] <= x[m]-x[m-1]; (6) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (7) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (8) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
4 /21
using CP; int m=...; dvar int x[1..m] in 0..m*m; minimize x[m]; subject to { (1) forall (i in 1..m-1) x[i] < x[i+1]; (2) forall (i in 1..m, j in 1..m, k in 1..m, l in 1..m: (i < j, k < l)) x[j] - x[i] != x[l] - x[k]; } using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) x[2] <= x[m]-x[m-1]; (6) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (7) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (8) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
Does P conform to M
4 /21
using CP; int m=...; dvar int x[1..m] in 0..m*m; minimize x[m]; subject to { (1) forall (i in 1..m-1) x[i] < x[i+1]; (2) forall (i in 1..m, j in 1..m, k in 1..m, l in 1..m: (i < j, k < l)) x[j] - x[i] != x[l] - x[k]; } using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) x[2] <= x[m]-x[m-1]; (6) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (7) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (8) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
Does P conform to M
4
m=8 X= [0 1 3 6 10 26 27 28]
/21
using CP; int m=...; dvar int x[1..m] in 0..m*m; minimize x[m]; subject to { (1) forall (i in 1..m-1) x[i] < x[i+1]; (2) forall (i in 1..m, j in 1..m, k in 1..m, l in 1..m: (i < j, k < l)) x[j] - x[i] != x[l] - x[k]; } using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) x[2] <= x[m]-x[m-1]; (6) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (7) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (8) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
Does P conform to M
4
m=8 X= [0 1 3 6 10 26 27 28] 1 1 Fault detected in P !
/21
5 /21
Model- Oracle
Mx(k)
6 /21
Model- Oracle
Mx(k)
CPUT Pz(k)
6 /21
Model- Oracle
Mx(k)
CPUT Pz(k) Conformity Relation
6 /21
One Solution (conf k
7 /21
One Solution (conf k
7
non-conform
/21
M: solutions set of M P: solutions set of P
One Solution (conf k
7
non-conform
/21
M: solutions set of M P: solutions set of P
One Solution (conf k
7
non-conform
/21
M: solutions set of M P: solutions set of P
One Solution (conf k
7
non-conform
/21
M: solutions set of M P: solutions set of P
One Solution (conf k
7
conform
/21
M: solutions set of M P: solutions set of P
All Solutions (conf k
all)
8 /21
9 /21
9 /21
9 /21
9 /21
9 /21
9 /21
10 /21
10 /21
10
non-conform
/21
M: set of global minima BM: bounds set of M BP: bounds set of P
10
non-conform
/21
M: set of global minima BM: bounds set of M BP: bounds set of P
10
non-conform
/21
M: set of global minima BM: bounds set of M BP: bounds set of P
10
conform
/21
M: set of global minima BM: bounds set of M BP: bounds set of P
10 /21
10 /21
10 /21
Model- Oracle Mx(k) CPUT Px(k)
Conformity Relation
11 /21
Model- Oracle Mx(k) CPUT Px(k)
Conformity Relation
11 /21
Model- Oracle Mx(k) CPUT Px(k)
Conformity Relation
11 /21
The one_negated purpose requires that:
12
One solution:
/21
The one_negated purpose requires that:
12
One solution:
/21
The one_negated purpose requires that:
12
One solution:
/21
The one_negated purpose requires that:
12
One solution:
/21
The one_negated purpose requires that:
12
One solution:
/21
13 /21
13 /21
Projection
13 /21
Projection Constraint negation
14 /21
dvar int x,y,z; subject to { x-y != x-z; x-y != y-z; x-z != y-z; }
dvar int x,y,z; dvar int d[1..3]; subject to { C1: x-y == d[1]; C2: x-z == d[2]; C3: y-z == d[3]; C4: AllDifferent( d ); }
Equivalent
14 /21
dvar int x,y,z; subject to { x-y != x-z; x-y != y-z; x-z != y-z; }
dvar int x,y,z; dvar int d[1..3]; subject to { C1: x-y == d[1]; C2: x-z == d[2]; C3: y-z == d[3]; C4: AllDifferent( d ); }
Equivalent
15 /21
15 /21
15 /21
inverse(all[R](i in R) g[i], all[S](j in S) f[j]); forall(i in S) g[f[i]]==i; forall(j in R) f[g[j]]==j;
15 /21
inverse(all[R](i in R) g[i], all[S](j in S) f[j]); forall(i in S) g[f[i]]==i; forall(j in R) f[g[j]]==j;
g[f[i]]!=i;
f[g[j]]!=j;
16 /21
17 /21
Manual fault injection
18
using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) allDifferent(all(ind in indexes1 ) (d[ind])); (6) x[2] <= x[m]-x[m-1]; (7) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (8) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (9) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
/21
Manual fault injection
18
using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) allDifferent(all(ind in indexes1 ) (d[ind])); (6) x[2] <= x[m]-x[m-1]; (7) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (8) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (9) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
/21
Manual fault injection
18
using CP; int m=...; tuple indexerTuple {int i; int j;} {indexerTuple} indexes1 = {<i, j> | ordered i,j in 1..m}; {indexerTuple} indexes2 = {<i, j> | ordered i,j in 1..m div 2}; dvar int x[1..m] in 0..m*m; dvar int d[indexes1]; minimize x[m]; subject to { (1) x[1]==0; (2) forall (i in (1)..m-1) x[i] < x[i+1]; (3) forall(ind in indexes1) d[ind] == x[ind.i]-x[ind.j]; (4) x[m] >= (m * (m - 1)) / 2; (5) allDifferent(all(ind in indexes1 ) (d[ind])); (6) x[2] <= x[m]-x[m-1]; (7) forall(ind1,ind2,ind3:(ind1.i==ind2.i)&&(ind2.j==ind3.i)&& (ind1.j==ind3.j)&&( ind1.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]; (8) forall(ind1,ind2,ind3,ind4 in indexes2 : (ind1.i==ind2.i)&&(ind1.j==ind3.j)&&(ind2.j==ind4.j) &&(ind3.i==ind4.i)&&(ind1.i<m-1)&&(3<ind1.j<m+1) &&(2<ind2.j<m)&&(1<ind3.i<m-1)&& (ind1.i < ind3.i < ind2.j < ind1.j)) d[ind1]==d[ind2]+d[ind3]-d[ind4]; (9) forall(ind in indexes2, k in 1..m div 2) x[ind.i+1]==x[ind.i]+k => x[ind.j+1] != x[ind.j]+k; }
/21
cc10: forall(i in m..3*m) Count(all(j in indexes1)d[j],i)==1;
19
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
/21
timeout = 5 400s
19
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
/21
timeout = 5 400s
19
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
/21
timeout = 5 400s
20
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
timeout = 5 400s
/21
20
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
timeout = 5 400s
/21
20
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
timeout = 5 400s
/21
20
Intel Core 2 Duo CPU, 2.39 GHz, 2.00 Go RAM
timeout = 5 400s
/21
conformities automatically and quickly detected !
(one_negated)
21 /21
conformities automatically and quickly detected !
(one_negated)
21 /21
conformities automatically and quickly detected !
(one_negated)
21 /21
Syntax checking
Host’s language debuggers
Post-mortem trace analyzers
Mercury,[Jahier02], ILOG Gentra4CP[Deransart 04], [Jussien96] Jpalm/Jchoco …)
Trace visualization
The one_negated purpose requires that:
One solution: All solutions: Bounds: