340 likes | 505 Views
Constraint Satisfaction Problems and Consistency Restoration. Florent Launay Undergraduate student at FIT. Summary. Focused interest in time point-sequencing problem. What are CSP’s ? Crossword Problem. Dealing with consistency. 1. Finding and storing consistent relations
E N D
Constraint Satisfaction Problems and Consistency Restoration Florent Launay Undergraduate student at FIT
Summary • Focused interest in time point-sequencing problem. • What are CSP’s ? • Crossword Problem. • Dealing with consistency. • 1. Finding and storing consistent relations • 2. Finding a “minimal set to remove inconsistency” • Linking the algorithms • Questions, comments. • The Program
Focus interest Relation from {<, >, =, <>, <=, >=, <=>} • Here, we can see that some constraints between the set of points {P1, P2, P3} exist : • P1 < P2 • P2 < P3 P1 P2 P3
What are CSP’s ? • Constraints X >= 5 X <> 9 X < 12
What are CSP’s ? • Example : Common names from English vocabulary beginning with a ‘c’, ending with a ‘t’, but that doesn’t contain any ‘e’… Valid set : {‘count’, ‘cart’, ‘chat’, ‘court’, …}
What are CSP’s ? • Valid regions and ‘Box’ X > 3 X >= 5 X <> 9 X < 12 X < 15 3 5 9 12 15 Valid regions = {[5,5], [5,9], [9,12]}
What are CSP’s ? • Inconsistencies X >= 5 X <> 9 X < 12 X > 13 5 9 12 13 No valid region => The system is inconsistent
The crossword problem • Constraints Definition, Size of the world, across or down, eventual existing letters. Definition 13 : Part of the human body, beginning with an ‘H’ (ambiguous) W O H A N D A N D ? E A D ? A I R N O T • Valid Set {[HEAD], [HAND], [HAIR]} • Inconsistency Definition 14 : Negation
Dealing with consistency • Within a set of relations, some relation can conflict with other relations in a system, making the whole system inconsistent. Let’s have a look to the following example.
A simple example Let s consider a point P1 on a time line basis :
A simple example P2>P1 • P3<P1 and P3>P2 Valid region P1 P2 No valid region can be found for P3 !!!
Dealing with consistency • With that kind of inconsistency, two interesting questions arise: • Which are the relations that make the system inconsistent ? • What would be a minimal set to remove to make the system consistent ?
1. Finding and storing inconsistent relations System of relations Consistent NO Store inconsistent relations YES Finish Finish (Call the 2nd algorithm)
Inconsistent relations • FIND MULTIPLE EQUALITY =>Store inconsistent relations • VERIFY CONSISTENCY IN CASE OF UNIQUE EQUALITY =>Store inconsistent relations • FIND THE BOX: PRE-PROCESSING =>Store inconsistent relations • FIND VALID REGIONS =>If no inconsistency has been found
Inconsistent relations • FIND MULTIPLE EQUALITY If Pnew = P3 And Pnew = P6 The system is inconsistent since P3<>P6 P1 P2 P3 P4 P5 P6 Pnew Pnew
Inconsistent relations • VERIFY CONSISTENCY IN CASE OF UNIQUE EQUALITY If Pnew = P3 And Pnew < P2 The system is inconsistent P1 P2 P3 P4 P5 P6 Pnew
Inconsistent relations • FIND THE BOX: PRE-PROCESSING If If we found that a valid region for Pnew was {[P3,P4], [P4,P5]} Then, no other relation should forbid that : ex Pnew > P6, Or the system becomes inconsistent P1 P2 P3 P4 P5 P6
Inconsistent relations • FIND VALID REGIONS =>If no inconsistency has been found A valid region region could be : {[P2,P3], [P3,P3], [P3,P4], [P4,P5], [P5,P5], [P5,P6]} P1 P2 P3 P4 P5 P6
Inconsistent relations End of the first algorithm…
2. Finding a minimal set to remove to make the system consistent SET OF RELATIONS MAKING THE SYSTEM INCONSISTENT Algorithm MINIMUM SET OF RELATIONS MAKING THE SYSTEM INCONSISTENT MAXIXMUM SET OF CONSISTENT RELATIONS
2. Finding a minimal set to remove to make the system consistent This short algorithm finds a minimal set. We will illustrate this with an other example. But first, we have to introduce the notion of “degree of inconsistency”.
Degree of inconsistency Here, if we want to add a new point Pnew such that: Pnew < P1, Pnew > P5 Pnew < P2, Pnew > P6 Pnew < P3, Pnew < P4, P1 P2 P3 P4 P5 P6
Degree of inconsistency From here, we can see that : Pnew < P1 conflicts with Pnew > P5 Pnew < P3 conflicts with Pnew > P5 Pnew < P1 conflicts with Pnew > P6 Pnew < P3 conflicts with Pnew > P6 Pnew < P2 conflicts with Pnew > P5 Pnew < P4 conflicts with Pnew > P5 Pnew < P2 conflicts with Pnew > P6 Pnew < P4 conflicts with Pnew > P6 P1 P2 P3 P4 P5 P6
Algorithm • Var: S = set of all relations making the system inconsistent nS = number of relations in S R = Temporary relation with highest degree of inconsistency in S mR = degree of inconsistency of R I = a set of minimal relation to remove in order to make the system consistent
Algorithm • Initialize I to be empty; While (nS != 0) { * Find the relation R with highest inconsistent degree m; * nS = nS – mR; * Remove 1 from every inconsistent degree from every relation conflicting with R; * Record R in I; * Remove every inconsistent relation conflicting with R from S; * Remove R from S; }
Example • Let us consider the last example. Here are the variables of the algorithm. S 2 Pinc < P1 * Pinc > P5 4 S= {P1,P2, P3, P4, P5, P6} 2Pinc < P1 * Pinc > P6 4 mR = 0 2Pinc < P2 * Pinc > P5 4 R = {} 2Pinc < P2 * Pinc > P6 4 nS relations nS = 8 2 Pinc < P3 * Pinc > P5 4 I = {} 2 Pinc < P3 * Pinc > P6 4 2 Pinc < P4 * Pinc > P5 4 2 Pinc < P4 * Pinc > P6 4 Degree of inconsistency
Example • One relation with highest inconsistency degree is : Pinc > P5. S 2 Pinc < P1 * Pinc > P5 4 1 S= {P1,P2, P3, P4, P5, P6} 2Pinc < P1 * Pinc > P6 4 1 mR = 0 4 2Pinc < P2 * Pinc > P5 4 1 {Pinc>P5} R = {} 2Pinc < P2 * Pinc > P6 4 1 nS = 8 8 – 4 = 4 2 Pinc < P3 * Pinc > P5 4 1 I = {} {Pinc>P5} 2 Pinc < P3 * Pinc > P6 4 1 2 Pinc < P4 * Pinc > P5 4 1 2 Pinc < P4 * Pinc > P6 4 1 Remove 1 from every inconsistent degree from every relation conflicting with R Remove every inconsistent relation conflicting with R from S Find the relation R with highest inconsistency degree Remove R from S Record R in I nS = nS – mR
Example • The variables are now : The relation with highest inconsistency degree is now Pinc>P6. S= {P1,P2, P3, P4, P6} S mR = 4 4 {Pinc>P6} R = {Pinc>P5} 1Pinc < P1 * Pinc > P6 4 0 nS = 4 4 – 4 = 0 1Pinc < P2 * Pinc > P6 4 0 I = {Pinc>P5} {Pinc>P5 , Pinc>P6} 1 Pinc < P3 * Pinc > P6 4 0 1 Pinc < P4 * Pinc > P6 4 0 n = 0, the system is now consistent, and a minimal set to remove is found : I = {Pinc>P5, Pinc>P6} Remove 1 from every inconsistent degree from every relation conflicting with R nS = nS – mR Remove every inconsistent relation conflicting with R from S Find the relation R with highest inconsistency degree Remove R from S Record R in I
Linking the algorithms Choose input Set constraints Perform algorithm Consistent ? Yes Store Input No Find Set of inconsistent relations S Find minimal set to remove to make the system consistent I
”Constraint programming represents one of the closest approaches computer science has yet made to the Holy Grail of programming: the user states the problem, the computer solves it.” Eugene C. Freuder, CONSTRAINTS, April 1997