foundations of artificial intelligence
play

Foundations of Artificial Intelligence 24. Constraint Satisfaction - PowerPoint PPT Presentation

Foundations of Artificial Intelligence 24. Constraint Satisfaction Problems: Backtracking Malte Helmert and Thomas Keller University of Basel April 8, 2020 CSP Algorithms Naive Backtracking Variable and Value Orders Summary Constraint


  1. Foundations of Artificial Intelligence 24. Constraint Satisfaction Problems: Backtracking Malte Helmert and Thomas Keller University of Basel April 8, 2020

  2. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Constraint Satisfaction Problems: Overview Chapter overview: constraint satisfaction problems: 22.–23. Introduction 24.–26. Basic Algorithms 24. Backtracking 25. Arc Consistency 26. Path Consistency 27.–28. Problem Structure

  3. CSP Algorithms Naive Backtracking Variable and Value Orders Summary CSP Algorithms

  4. CSP Algorithms Naive Backtracking Variable and Value Orders Summary CSP Algorithms In the following chapters, we consider algorithms for solving constraint networks. 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

  5. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking

  6. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking (= Without Inference) function NaiveBacktracking( C , α ): � V , dom , ( R uv ) � := C if α is inconsistent with C : 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 input: constraint network C and partial assignment α for C (first invocation: empty assignment α = ∅ ) result: solution of C or inconsistent

  7. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Is This a New Algorithm? We have already seen this algorithm: Backtracking corresponds to depth-first search (Chapter 12) with the following state space: states: consistent partial assignments initial state: empty assignment ∅ goal states: consistent total assignments actions: assign v , d assigns value d ∈ dom( v ) to variable v action costs: all 0 (all solutions are of equal quality) transitions: for each non-total assignment α , choose variable v = select( α ) that is unassigned in α assign v , d transition α − − − − − → α ∪ { v �→ d } for each d ∈ dom( v )

  8. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Why Depth-First Search? Depth-first search is particularly well-suited for CSPs: path length bounded (by the number of variables) solutions located at the same depth (lowest search layer) state space is directed tree, initial state is the root � no duplicates (Why?) Hence none of the problematic cases for depth-first search occurs.

  9. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example Consider the constraint network for the following graph coloring problem: v 1 v 7 b, g, r b, r v 2 v 6 g, r, y b, g b, g b, r b, r v 3 v 5 v 4

  10. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 v 7 v 4 v 5 v 6 v 3 v 2

  11. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r b v 4 r b v 5 v 6 v 3 v 2

  12. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r b v 4 r b v 5 v 6 v 3 v 2

  13. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r b v 4 r b v 5 v 6 v 3 v 2

  14. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r b v 4 r b v 5 v 6 v 3 v 2

  15. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r b v 4 r b v 5 v 6 v 3 v 2

  16. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r b v 5 v 6 v 3 v 2

  17. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 v 6 v 3 v 2

  18. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 v 6 v 3 v 2

  19. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 v 6 v 3 v 2

  20. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 v 3 v 2

  21. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 v 3 v 2

  22. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 g r y v 3 v 2

  23. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 g r y v 3 v 2

  24. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 g r y v 3 b r v 2

  25. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 g r y v 3 b r v 2

  26. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Example search tree for naive backtracking with fixed variable order v 1 , v 7 , v 4 , v 5 , v 6 , v 3 , v 2 alphabetical order of the values v 1 g b v 7 r r b b v 4 r r b b v 5 g b v 6 g r y v 3 b r v 2 g b

  27. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking: Discussion Naive backtracking often has to exhaustively explore similar search paths (i.e., partial assignments that are identical except for a few variables). “Critical” variables are not recognized and hence considered for assignment (too) late. Decisions that necessarily lead to constraint violations are only recognized when all variables involved in the constraint have been assigned. � more intelligence by focusing on critical decisions and by inference of consequences of previous decisions

  28. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Variable and Value Orders

  29. CSP Algorithms Naive Backtracking Variable and Value Orders Summary Naive Backtracking function NaiveBacktracking( C , α ): � V , dom , ( R uv ) � := C if α is inconsistent with C : 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend