1 / 27

CSP Hybrid algorithms = search + incomplete inference

CSP Hybrid algorithms = search + incomplete inference. Pedro Meseguer IIIA-CSIC Bellaterra, Spain. Overview. Incomplete Inference Motivation: solving subnetworks Node consistency Arc consistency Constraint propagation Generalized arc consistency Hybrid algorithms

vickiking
Download Presentation

CSP Hybrid algorithms = search + incomplete inference

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSPHybrid algorithms = search + incomplete inference Pedro Meseguer IIIA-CSIC Bellaterra, Spain

  2. Overview Incomplete Inference • Motivation: solving subnetworks • Node consistency • Arc consistency • Constraint propagation • Generalized arc consistency Hybrid algorithms • Forward checking • Maintaining arc consistency CSP: Incomplete Inference

  3. Inference: P P’ Inference legal operations on variables, domains, constraints • P’ is equivalent to P: Sol(P) = Sol(P’) • P’ is presumablyeasier to solve than P • smaller search space • constraints are more explicit Inference can be: • complete: produces the solutionadaptive consistency • incomplete: requires further searcharc consistency CSP: Incomplete Inference

  4. Incomplete Inference: Local Consistency • P constraint network of n variables: Is P solvable ? • Simpler problem: • P1i, P2j, P3k,…subnetworks of P of 1, 2, 3,…variables • Are they solvable? • YES, but there are values that do not appear in any solution they can be removed from P • NO, P has no solution • #vars in subnet: 1 2 3 ……. • node arc path consistency consistency consistency • Empty domain: P has no solution !! CSP: Incomplete Inference

  5. Unitary constraint on xi NC Algorithm: procedure NC-1 (X,D,C) forall xiX do forall a Dido if a Rithen Di:= Di-{a}; Di := DiRi i: 1,…, n Node Consistency (NC) NC: • Variable xiis node consistent iff every value of Di is allowed by Ri • P is NC iff every variable is NC CSP: Incomplete Inference

  6. Binary Arc Consistency (AC) AC: • Constraint Cij is directional arc consistent (ij) iff for all aDi there is bDj such that (a, b)Rij • Constraint Cij is AC iff it is directional AC in both directions • A problem is AC iff every constraint is AC CSP: Incomplete Inference

  7. Microstructure: permitted Xk c a b AC ¬AC ¬AC AC Xi Xj a a b b c c AC ¬AC AC: Example CSP: Incomplete Inference

  8. Example: X1 X2 blue, red ≠ blue ≠ ≠ blue,red,green X3 X4 blue, green ≠ Filtering by Arc Consistency • If for aDi there not exists bDj such that (a, b)Rij,a can be removed from Di (a will not be in any sol) • Domain filtering: • Remove arc-inconsistent values • Until no changes CSP: Incomplete Inference

  9. function revise (i,j variable): bool; change := FALSE; for all aDido if ¬$bDj st (a,b)Rij then Di :=Di - {a}; change :=TRUE; return change; Function revise(i,j) • Functionrevise(i,j): • Rij becomes directional arc-consistent • it may remove values of Di • iterate over other constraints Complexity: O(d2) CSP: Incomplete Inference

  10. 1 2 3 x1x2x3 1 2 3 1 2 3 1 2 3 x1x2x3 x1x2x3 x1x2x3 Example: 3-queens c12 is not arc-consistent because value 2 of d1 c21 is not arc-consistent because value 2 of d2 c32 is not arc-consistent because value 2 of d3 CSP: Incomplete Inference

  11. AC Constraint Propagation • AC(c): procedure to make c arc consistent • To make P arc-consistent, process each constraint ? c1c2 … cr c1c2 … cr c1c2 … cr c1c2 … cr • But AC(c) may render other constraints arc-inconsistent • To make P arc-consistent, iterate: • Apply AC on {c1,c2,…,cr } • Until no changes in domains: fix point CSP: Incomplete Inference

  12. 1 2 3 1 2 3 1 2 3 x1x2x3 x1x2x3 x1x2x3 1 2 3 1 2 3 1 2 3 this makes c13 arc-inconsistent x1x2x3 x1x2x3 x1x2x3 domain d1 empty no solution !! Example: 3-queens value 2 of d3 was removed(to make c23 arc-consistent) c13 is not arc-consistent because value 1 of d1 c13 is not arc-consistent because value 3 of d1 CSP: Incomplete Inference

  13. x + y = 9 2x + 4y = 24 x + y = 9 x + y = 9 x + y = 9 x + y = 9 x + y = 9 2x + 4y = 24 2x + 4y = 24 2x + 4y = 24 2x + 4y = 24 2x + 4y = 24 2x + 4y = 24 x + y = 9 x 0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 y 0 1 2 3 4 5 6 7 8 9 y 0 1 2 3 4 5 6 7 8 9 y 0 1 2 3 4 5 6 7 8 9 y 0 1 2 3 4 5 6 7 8 9 y 0 1 2 3 4 5 6 7 8 9 y 0 1 2 3 4 5 6 7 8 9 x + y = 9 2x + 4y = 24 x + y = 9 2x + 4y = 24 Example: Equations on Integers fix point CSP: Incomplete Inference

  14. revise(k,m)removes a b Xm Xp revise(k,m) procedure AC-3 (G) Q := {(i,j)|(i,j)arc(G)i≠j} while Q≠Ø do pop arc (k,m) from Q if revise(k,m) then Q:=Q{(i,k)|(i,k)arc(G)i≠k,i≠m} a, b, c, . . Xk Xq Xr AC-3: AC Algorithm • Arcs to revisit?Arcs no longer AC because a, b removal • If arc was AC, after revise(k,m) • (k,_): it remains AC • (_,k): it may not be AC • Complexity: d 2ed2 : O(ed3) • times per constraint #constraints revise CSP: Incomplete Inference

  15. Local Consistency Levels • Nogood: forbidden tuple of values • In the initial constraints • Discovered during search / local consistency process Local consistency levels: nogood size • Node consistency: 1-consistency 0 • Arc consistency: 2-consistency 1 • Path consistency: 3-consistency 2 • ….. • K-consistency: K-1 removes values from domains discovers forbidden value pairs discovers forbidden value combinations CSP: Incomplete Inference

  16. domain filtering inference • If P is arc-consistent P has solution Generalized Arc Consistency • c is arc-consistent iff: every possible value of every variable in var (c) appears in rel(c) • If c is not arc-consistent because a Dx : • a will not be in any solution • a can be removed: DxDx – {a} • if Dx becomes empty, P has no solution • P is arc-consistent iff: every constraint is arc-consistent incompleteinference !! CSP: Incomplete Inference

  17. Hybrids: Search + Incomplete Inference Idea: • Search: backtracking(could be non-chronological) • Inference: at each node, incomplete inference on some constraints • New nogoods (implicit constraints) discovered • If nogood in current branch  backtrack Effect: • Search tree reduced: less nodes to explore • Inference at each node: more work per node • Trade-off to find the right balance CSP: Search + Inference

  18. Hybrids: Search + AC Idea: • Search: backtracking(could be non-chronological) • Inference: at each node, AC on some constraints • AC discovers nogoods of size 1 • Values not AC are eliminated Effect: • Future domains reduced: less nodes to explore • AC at each node: more work per node • Very beneficial: reduces thrashing CSP: Search + Inference

  19. Forward Checking FC is a combination of: • Search: backtracking • Inference: at each node, AC on constraints with assigned and unassigned variables When a domain becomes empty : • No solutions following current branch • Prune current branch and backtrack Caution: • Values removed by AC at level i, have to be restored when bactracking at level i or above CSP: Search + Inference

  20. 1 2 3 4 1 2 3 4 1 2 3 4 Q Q Q Q Q Q x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 Q Q Q Q Q Q Q Q Q Q Q Q x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 Q Q Q Q Q 2 1 Q Q 4 3 4 1 2 3 4 1 2 3 4 1 2 Q Q Q Q x1 x2 x3 x4 x1 x2 x3 x4 Q 3 solution 8 nodes Example: FC on 4-queens x1 x2 x3 x4 CSP: Search + Inference

  21. Lex variableordering Binary Forward Checking: Code function FC (i,Past,[Di,…,Dn]): bool; for all aDi do xi:=a; if i=n then return TRUE; else C’:={Cij|CijC, i<j}; NewD:=AC({xi,..,xn},[{a},Di+1,..,Dn],C’); if ØNewD then if FC(i+1,Past{xi},NewD) return TRUE; return FALSE; CSP: Search + Inference

  22. Maintaining Arc Consistency MAC is a combination of: • Search: backtracking • Inference: at each node, AC on all constraints • Preprocess: subproblems are AC When a domain becomes empty : • No solutions following current branch • Prune current branch and backtrack Caution: • Values removed by AC at level i, have to be restored when bactracking at level i or above CSP: Search + Inference

  23. Q Q Q empty domain Q MAC vs FC: AC on futures AC (2,3) AC (2,3) AC (3,4) CSP: Search + Inference

  24. x1 x2 x3 x4 2 1 4 Q Q Q Q Q 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 Q Q Q Q Q Q Q Q Q Q Q x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 x1 x2 x3 x4 3 5 nodes solution Example: MAC on 4-queens x1 x2 x3 x4 CSP: Search + Inference

  25. Example: x =a x≠a y=b y≠b z=c z≠c z=d z≠d y=f y≠f MAC: Binary Search Tree Binary tree of subproblems: • at each level • variable x, two options: x= a (assignment)x ≠ a (refutation) • DFS traversal: at each node, AC of current subproblem • you can change variable without exhausting values! CSP: Search + Inference

  26. Q x1 1 x1 1 x1 2 x2 4 Q Q x3 1 Q Q Q Q x4 3 Q Q Q solution Q Example: MAC on 4-queens Q CSP: Search + Inference

  27. Lex variableordering MAC: Code function MAC (i, [D1,…,Dn]): bool; for j:=i+1,..,n do D’j:=Dj; for all aDi do /* xi:=a */ D’i:={a}; if i=n then return TRUE else NewD:=AC(X,[D1,..,Di-1,D’i,..,D’n],C); if ØNewD then if MAC(i+1,NewD) return TRUE; Di := Di - {a}; /* xi:≠a */ D’i:= Di; NewD:=AC(X,[D1,..,Di-1,D’i,..,D’n],C); if Ø  NewD then exit loop else for j:=i+1,..,n do D’j:=NewD[j]; return FALSE; CSP: Search + Inference

More Related