24 1 csp algorithms
play

24.1 CSP Algorithms 22.23. Introduction 24.26. Basic Algorithms - PowerPoint PPT Presentation

Foundations of Artificial Intelligence April 8, 2020 24. Constraint Satisfaction Problems: Backtracking Foundations of Artificial Intelligence 24.1 CSP Algorithms 24. Constraint Satisfaction Problems: Backtracking 24.2 Naive Backtracking


  1. Foundations of Artificial Intelligence April 8, 2020 — 24. Constraint Satisfaction Problems: Backtracking Foundations of Artificial Intelligence 24.1 CSP Algorithms 24. Constraint Satisfaction Problems: Backtracking 24.2 Naive Backtracking Malte Helmert and Thomas Keller 24.3 Variable and Value Orders University of Basel April 8, 2020 24.4 Summary M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 1 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 2 / 22 24. Constraint Satisfaction Problems: Backtracking CSP Algorithms Constraint Satisfaction Problems: Overview Chapter overview: constraint satisfaction problems: 24.1 CSP Algorithms ◮ 22.–23. Introduction ◮ 24.–26. Basic Algorithms ◮ 24. Backtracking ◮ 25. Arc Consistency ◮ 26. Path Consistency ◮ 27.–28. Problem Structure M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 3 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 4 / 22

  2. 24. Constraint Satisfaction Problems: Backtracking CSP Algorithms 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking CSP Algorithms In the following chapters, we consider algorithms for solving constraint networks. 24.2 Naive Backtracking basic concepts: ◮ search: check partial assignments systematically ◮ backtracking: discard inconsistent partial assignments ◮ inference: derive equivalent, but tighter constraints to reduce the size of the search space M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 5 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 6 / 22 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking Naive Backtracking (= Without Inference) Is This a New Algorithm? function NaiveBacktracking( C , α ): We have already seen this algorithm: � V , dom , ( R uv ) � := C Backtracking corresponds to depth-first search (Chapter 12) if α is inconsistent with C : with the following state space: return inconsistent ◮ states: consistent partial assignments if α is a total assignment: ◮ initial state: empty assignment ∅ return α select some variable v for which α is not defined ◮ goal states: consistent total assignments for each d ∈ dom( v ) in some order: ◮ actions: assign v , d assigns value d ∈ dom( v ) to variable v α ′ := α ∪ { v �→ d } ◮ action costs: all 0 (all solutions are of equal quality) α ′′ := NaiveBacktracking( C , α ′ ) if α ′′ � = inconsistent : ◮ transitions: ◮ for each non-total assignment α , return α ′′ return inconsistent choose variable v = select( α ) that is unassigned in α assign v , d ◮ transition α − − − − − → α ∪ { v �→ d } for each d ∈ dom( v ) input: constraint network C and partial assignment α for C (first invocation: empty assignment α = ∅ ) result: solution of C or inconsistent M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 7 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 8 / 22

  3. 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking Why Depth-First Search? Naive Backtracking: Example Consider the constraint network for the following graph coloring problem: Depth-first search is particularly well-suited for CSPs: v 1 v 7 ◮ path length bounded (by the number of variables) b, g, r b, r ◮ solutions located at the same depth (lowest search layer) v 2 v 6 ◮ state space is directed tree, initial state is the root g, r, y b, g � no duplicates (Why?) Hence none of the problematic cases for depth-first search occurs. b, r b, g b, r v 3 v 5 v 4 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 9 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 10 / 22 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking 24. Constraint Satisfaction Problems: Backtracking Naive Backtracking Naive Backtracking: Example Naive Backtracking: Discussion search tree for naive backtracking with ◮ fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 ◮ Naive backtracking often has to exhaustively explore ◮ alphabetical order of the values similar search paths (i.e., partial assignments that are identical except for a few variables). ◮ “Critical” variables are not recognized v 1 and hence considered for assignment (too) late. v 7 ◮ Decisions that necessarily lead to constraint violations are only recognized when all variables involved v 4 in the constraint have been assigned. v 5 � more intelligence by focusing on critical decisions v 6 and by inference of consequences of previous decisions v 3 v 2 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 11 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 12 / 22

  4. 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders Naive Backtracking function NaiveBacktracking( C , α ): � V , dom , ( R uv ) � := C if α is inconsistent with C : 24.3 Variable and Value Orders return inconsistent if α is a total assignment: return α select some variable v for which α is not defined for each d ∈ dom( v ) in some order: α ′ := α ∪ { v �→ d } α ′′ := NaiveBacktracking( C , α ′ ) if α ′′ � = inconsistent : return α ′′ return inconsistent M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 13 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 14 / 22 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders Variable Orders Value Orders ◮ Backtracking does not specify in which order ◮ Backtracking does not specify in which order the values of the selected variable v are considered. variables are considered for assignment. ◮ This is not as important because it does not matter ◮ Such orders can strongly influence the search space size in subtrees without a solution. (Why not?) and hence the search performance. ◮ If there is a solution in the subtree, then ideally � example: exercises a value that leads to a solution should be chosen. (Why?) German: Variablenordnung German: Werteordnung M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 15 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 16 / 22

  5. 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders Static vs. Dynamic Orders Variable Orders we distinguish: two common variable ordering criteria: ◮ static orders (fixed prior to search) ◮ minimum remaining values: prefer variables that have small domains ◮ dynamic orders (selected variable or value order ◮ intuition: few subtrees � smaller tree depends on the search state) ◮ extreme case: only one value � forced assignment comparison: ◮ most constraining variable: prefer variables contained in many nontrivial constraints ◮ dynamic orders obviously more powerful ◮ intuition: constraints tested early ◮ static orders � no computational overhead during search � inconsistencies recognized early � smaller tree The following ordering criteria can be used statically, but are more combination: use minimum remaining values criterion, effective combined with inference ( � later) and used dynamically. then most constraining variable criterion to break ties M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 17 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 18 / 22 24. Constraint Satisfaction Problems: Backtracking Variable and Value Orders 24. Constraint Satisfaction Problems: Backtracking Summary Value Orders Definition (conflict) Let C = � V , dom , ( R uv ) � be a constraint network. For variables v � = v ′ and values d ∈ dom( v ), d ′ ∈ dom( v ′ ), 24.4 Summary the assignment v �→ d is in conflict with v ′ �→ d ′ if � d , d ′ � / ∈ R vv ′ . value ordering criterion for partial assignment α and selected variable v : ◮ minimum conflicts: prefer values d ∈ dom( v ) such that v �→ d causes as few conflicts as possible with variables that are unassigned in α M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 19 / 22 M. Helmert, T. Keller (University of Basel) Foundations of Artificial Intelligence April 8, 2020 20 / 22

Recommend


More recommend