450 likes | 715 Views
Towards theoretical frameworks for comparing constraint satisfaction models and algorithms Peter van Beek, University of Waterloo CP 2001 · Paphos, Cyprus November 2001. Acknowledgements. Joint work with: Fahiem Bacchus Xinguang Chen Grzegorz Kondrak Toby Walsh.
E N D
Towards theoretical frameworks for comparing constraint satisfaction models and algorithmsPeter van Beek, University of WaterlooCP 2001 · Paphos, CyprusNovember 2001
Acknowledgements • Joint work with: • Fahiem Bacchus • Xinguang Chen • Grzegorz Kondrak • Toby Walsh 2
Constraint programming methodology • Model problem • specify in terms of constraints on acceptable solutions • define/choose constraint model: variables, domains, constraints • Solve model • define/choose algorithm • define/choose heuristics • Verify and analyze solution 3
Previous work • Many models, algorithms, and heuristics proposed • Choice of model, algorithm, and heuristic can greatly influence efficiency • (e.g., Nadel, 1990; Ginsberg et al., 1990; Frost and Dechter, 1994; Tsang et al., 1995 Smith et al., 2000; Beacham et al., 2001) 4
Empirical studies benchmark sets random problems Theoretical studies worst case average case (e.g. Brown & Purdom, 1981; Nadel, 1983; Wilf, 1984) pair-wise comparisons partial orders bounded worse Performance measures nodes visited constraint checks CPU time How to compare? 5
Part I • Comparing backtracking algorithms 6
Some backtracking algorithms • Chronological Backtracking (BT) • Backjumping (BJ) (Gaschnig, 1978) • Conflict-Directed Backjumping (CBJ) (Prosser, 1993) • Forward Checking (FC) (Haralick & Elliott, 1980; McGregor, 1979) • Maintaining arc consistency (MAC) (Haralick & Elliott, 1980; McGregor, 1979; Sabin & Freuder, 1994) 7
x1 x2 x3 x4 1 2 3 4 Example: 4-queens xi xjand | xi - xj | | i- j| 8
Search tree for 4-queens x1 1 2 3 4 x2 x3 x4 (1,1,1,1) (2,4,1,3) (3,1,4,2) (4,4,4,4) 9
x1 x2 x3 x4 1 2 {x1 1} 3 {x1 1,x2 3 ,x4 2} 4 {x1 1,x2 3} Backjumping Q x1 Q x2 x1 Q x2 x3 10
“New” algorithms: BJ1, …, BJn • BJk : • allowed to backjump at most k times from a leaf • after that it must chronologically backtrack • Special cases: • BJ1 equivalent to BJ • BJn equivalent to CBJ 11
x1 x2 x3 x4 1 2 3 4 k-consistency • Given • any k-1 distinct variables, • any consistent assignment to those variables, • any additional variable x • there exists a consistent assignment to x 1-consistent ? Q yes 2-consistent ? yes 3-consistent ? Q no strongly 2-consistent 12
Induced CSP Unary constraints x3 1, 3, 4 x4 1, 2, 4 x1 x2 x3 x4 1 Binary constraints x3 x4 |x3 - x4| 1 2 3 4 Maintaining consistency { x1 1,x2 4 } Q Q 13
{ x1 1,x2 4 } Unary constraints x3 1, 3, 4 x4 1, 2, 4 x1 x2 x3 x4 1 Binary constraints x3 x4 |x3 - x4| 1 2 3 4 Maintaining consistency FC: strong 1-consistency Q Q 14
{ x1 1,x2 4 } Unary constraints x3 1, 3, 4 x4 1, 2, 4 x1 x2 x3 x4 1 Binary constraints x3 x4 |x3 - x4| 1 2 3 4 Maintaining consistency MAC: strong 2-consistency Q Q Q Q 15
“New” algorithms: MC1, …, MCn • MCk : • maintains strong k-consistency on induced CSP at each node in backtrack tree • Special cases: • MC1 equivalent to FC • MC2equivalent to MAC for binary CSPs 16
Proposal: for all CSP models for all variable orderings algorithm a1 algorithm a2 Desirable features: still holds if use best possible CSP model for a2 still holds if use best possible variable ordering for a2 Comparing backtracking algorithms 17
Theoretical methodology • Using local consistency concepts: • formulate necessary and sufficient conditions for a node to be visited by a backtracking algorithm • Using conditions: • construct partial orders of the algorithms 18
x1 x2 x3 x4 1 {x1 1} 2 3 {x1 1,x2 4} ? 4 Example sufficient condition: FC • If a node is consistent and its parent is strongly 1-consistent, then FC visits the node Q Q 19
x1 x2 x3 x4 1 {x1 1} 2 3 {x1 1,x2 4} ? 4 Example necessary condition: MAC-CBJ • If MAC-CBJ visits a node, then it is consistent and its parent is strongly 2-consistent Q 20
Example conclusion: MAC-CBJ vs FC MAC-CBJ visits p p is consistent and parent(p) strongly 2-consistent p is consistent and parent(p) strongly 1-consistent FC visits p 21
MCk-CBJ MCk BJk BJk+1 MCk+1-CBJ MCk+1 BT MC1-CBJ MC1 BJ1 MCn-CBJ BJn MCn . . . . . . Partial order for nodes visited . . . . . . . . . . . . 22 less than or equal
MCk-CBJ BJk MCk+1-CBJ MCk+1 MC1-CBJ MC1 BJ1 BT MCn-CBJ BJn MCn . . . . . . Partial order for nodes visited . . . . . . BJk+1 MCk . . . . . . 23 incomparable
. . . . . . BJk+1 MCk+1 BJk MCk+1-CBJ MCk MCk-CBJ . . . . . . BT MC1-CBJ BJ1 MC1 MCn-CBJ BJn MCn . . . . . . Partial order for nodes visited 24 incomparable
BJk MCk+1 BT BJ1 MC1 MCn BJn . . . . . . Partial order for nodes visited MCn-CBJ . . . . . . BJk+1 MCk+1-CBJ MCk MCk-CBJ . . . . . . MC1-CBJ 25 incomparable
MCk-CBJ MCk+1-CBJ MCk+1 MC1-CBJ MC1 BT MCn-CBJ MCn CBJ . . . . . . Partial order for nodes visited . . . MCk . . . 26
MAC-CBJ MAC BJ2 CBJ FC-CBJ FC BT Closer look: nodes visited, binary CSPs less than or equal BJ 27
MAC-CBJ MAC BJ2 CBJ BJ FC-CBJ FC BT Closer look: constraint checks, binary CSPs less than or equal at most O(f) more O(n2d2) O(nd) O(nd) 28
O(nd) MAC Path O(nd) O(nd) FC BT Experiments: lookahead 29
x2 x1 xn Example: FC vs MAC variables: x1, …, xn, n odd Odd-even relation domains: {1, 2, 3, 4} ... FC: 2n+1 - 4 MAC: 4 Adapted from J. Ullman (1988); suggested by D. De Haan 30
MC3 MC4 MC2 MC1 Increasing lookahead Time (sec.) to solve 6 x 6 puzzles 31
FC-CBJ FC Experiments: lookback 32
MAC-CBJ MAC O(nd) O(nd) FC-CBJ FC CBJ BT Experiments: lookahead vs lookback • Increasing the level of consistency decreases effectiveness of CBJ • Prosser (1993) • Bacchus & van Run (1995) • Bessiere & Regin (1996) • MAC muchbetter than FC-CBJ • MAC better than MAC-CBJ “CBJ becomes useless” • Jussien, Debruyne, Boizumault (2000) • MAC-DBT muchbetter than MAC (binary) • Chen & van Beek (2001) • MGAC-CBJ muchbetter than MAC (non-binary) 33
BJk+1 MCk-CBJ BJk MCk+1-CBJ MCk+1 MCk Theory: lookahead vs lookback BJk+1 better only if there exists a (k+1)-level backjump that is not a chronological backtrack Number of (k+1)-level backjumps number of k-level backjumps Therefore, as k increases, effectiveness of backjumping decreases 34
Part II • Comparing CSP models 35
Conversion to binary • Any non-binary CSP can be converted into one with only binary constraints • dual graph method • (Dechter & Pearl, 1989; Rossi et al. 1989) • hidden variable method • (Peirce, 1933; Rossi et al. 1989; Dechter 1990) 36
Crossword puzzles 1 2 3 4 5 a aardvark aback abacus abaft abalone abandon ... Mona Lisa monarch monarchy monarda ... zymurgy zyrian zythum 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 37
Non-binary model (original) • variables: one for each unknown letter (cell) • domains: ‘a’, …, ‘z’ • constraints: contiguous letters must form words in dictionary 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 38
Dual model (binary) • variables: one for each unknown word across and down • domains: words from dictionary • constraints intersecting words must agree on common letter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 39
Hidden model (binary) • variables: one for each unknown letter (cell) and one for each unknown word across and down • domains: letters, words • constraints: letter and word variable must agree 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 40
One proposal: for all backtracking algorithms for all variable orderings model m1 model m2 Objections: effectiveness of a model is algorithm dependent models may contain different variables • Another proposal: given backtrack algorithm for all v2 for m2 there exists a v1 for m1 s. t. model m1 model m2 Comparing models • Desirable features: • meets objections • still holds if use best possible variable ordering for m2 41
Theoretical methodology • Bound difference in number of nodes visited • compare pruning power of local consistencies of alternative models (e.g., Debruyne & Bessiere, 1997; Stergiou & Walsh, 1999; Prosser et al., 2000; Walsh, 2000) • establish correspondence between nodes • Bound difference in cost at each node: • local consistency • variable ordering 42
Some relationships MGAC-hidden MGAC-orig MGAC-dual FC-hidden FC-orig FC-dual BT-hidden BT-orig BT-dual 43 polynomial not polynomial
Part III • Comparing variable ordering heuristics Future work 44
Conclusion • Technical: • comparing backtracking algorithms • partial order • comparing CSP models • bounded worse relation on algorithm-model combinations • Big picture: • theory can guide, inform experimentation 45