• Keine Ergebnisse gefunden

24.2 Naive Backtracking Malte Helmert

N/A
N/A
Protected

Academic year: 2022

Aktie "24.2 Naive Backtracking Malte Helmert"

Copied!
6
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)Foundations of Artificial Intelligence April 14, 2021 — 24. Constraint Satisfaction Problems: Backtracking. Foundations of Artificial Intelligence. 24.1 CSP Algorithms. 24. Constraint Satisfaction Problems: Backtracking. 24.2 Naive Backtracking Malte Helmert. 24.3 Variable and Value Orders. University of Basel. April 14, 2021. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24.4 Summary. April 14, 2021. 1 / 22. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24. Constraint Satisfaction Problems: Backtracking. April 14, 2021. 2 / 22. CSP Algorithms. Constraint Satisfaction Problems: Overview. Chapter overview: constraint satisfaction problems: I 22.–23. Introduction I 24.–26. Basic Algorithms. 24.1 CSP Algorithms. I 24. Backtracking I 25. Arc Consistency I 26. Path Consistency. I 27.–28. Problem Structure. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 3 / 22. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 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: I search: check partial assignments systematically I backtracking: discard inconsistent partial assignments I inference: derive equivalent, but tighter constraints to reduce the size of the search space. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24. Constraint Satisfaction Problems: Backtracking. April 14, 2021. 5 / 22. Naive Backtracking. Naive Backtracking (= Without Inference). M. Helmert (University of Basel). 24. Constraint Satisfaction Problems: Backtracking. 6 / 22. Naive Backtracking. Consider the constraint network for the following graph coloring instance:. 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: α0 := α ∪ {v 7→ d} α00 := NaiveBacktracking(C, α0 ) if α00 6= inconsistent: return α00 return inconsistent. v1. v7. b, g, r. b, r. v2. v6. b, g. g, r, y b, g. b, r v3. b, r. v5. v4. input: constraint network C and partial assignment α for C (first invocation: empty assignment α = ∅) result: solution of C or inconsistent Foundations of Artificial Intelligence. April 14, 2021. Naive Backtracking: Example. function NaiveBacktracking(C, α): hV , dom, (Ruv )i := C. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 7 / 22. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 8 / 22.

(3) 24. Constraint Satisfaction Problems: Backtracking. Naive Backtracking. Naive Backtracking: Example. We have already seen this algorithm: Backtracking corresponds to depth-first search (Chapter 12) with the following state space: I states: partial assignments. I alphabetical order of the values. v7. r. v4. b. r. b r. b. g. v6. g. r. v3. I for each non-total consistent assignment α, choose variable v = select(α) that is unassigned in α. y. assign. r. b. v2. I actions: assignv ,d assigns value d ∈ dom(v ) to variable v I action costs: all 0 (all solutions are of equal quality) I transitions:. r. b. v5. M. Helmert (University of Basel). I initial state: empty assignment ∅ I goal states: consistent total assignments. g. b b. Naive Backtracking. Is This a New Algorithm?. search tree for naive backtracking with I fixed variable order v1 , v7 , v4 , v5 , v6 , v3 , v2. v1. 24. Constraint Satisfaction Problems: Backtracking. b. Foundations of Artificial Intelligence. 24. Constraint Satisfaction Problems: Backtracking. v ,d I transition α −−−−− → α ∪ {v 7→ d} for each d ∈ dom(v ). g. April 14, 2021. 9 / 22. Naive Backtracking. Why Depth-First Search?. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 24. Constraint Satisfaction Problems: Backtracking. 10 / 22. Naive Backtracking. Naive Backtracking: Discussion. I Naive backtracking often has to exhaustively explore similar search paths (i.e., partial assignments that are identical except for a few variables). I “Critical” variables are not recognized and hence considered for assignment (too) late. I Decisions that necessarily lead to constraint violations are only recognized when all variables involved in the constraint have been assigned.. Depth-first search is particularly well-suited for CSPs: I path length bounded (by the number of variables) I solutions located at the same depth (lowest search layer) I state space is directed tree, initial state is the root no duplicates (Why?) Hence none of the problematic cases for depth-first search occurs.. more intelligence by focusing on critical decisions and by inference of consequences of previous decisions. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 11 / 22. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 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, α): hV , dom, (Ruv )i := C if α is inconsistent with C: return inconsistent. 24.3 Variable and Value Orders. if α is a total assignment: return α select some variable v for which α is not defined for each d ∈ dom(v ) in some order: α0 := α ∪ {v 7→ d} α00 := NaiveBacktracking(C, α0 ) if α00 6= inconsistent: return α00 return inconsistent. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24. Constraint Satisfaction Problems: Backtracking. April 14, 2021. 13 / 22. Variable and Value Orders. Variable Orders. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24. Constraint Satisfaction Problems: Backtracking. April 14, 2021. 14 / 22. Variable and Value Orders. Value Orders. I Backtracking does not specify in which order the values of the selected variable v are considered. I This is not as important because it does not matter in subtrees without a solution. (Why not?) I If there is a solution in the subtree, then ideally a value that leads to a solution should be chosen. (Why?). I Backtracking does not specify in which order variables are considered for assignment. I Such orders can strongly influence the search space size and hence the search performance. example: exercises German: Variablenordnung. German: Werteordnung. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 15 / 22. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 16 / 22.

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

(6) 24. Constraint Satisfaction Problems: Backtracking. Summary. Summary: Backtracking. I Variable orders influence the performance of backtracking significantly. I goal: critical decisions as early as possible. I Value orders influence the performance of backtracking on solvable constraint networks significantly.. I depth-first search particularly well-suited because state space is directed tree and all solutions at same (known) depth. Foundations of Artificial Intelligence. Summary. Summary: Variable and Value Orders. basic search algorithm for constraint networks: backtracking I extends the (initially empty) partial assignment step by step until an inconsistency or a solution is found I is a form of depth-first search. M. Helmert (University of Basel). 24. Constraint Satisfaction Problems: Backtracking. I goal: most promising assignments first. April 14, 2021. 21 / 22. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 14, 2021. 22 / 22.

(7)

Referenzen

ÄHNLICHE DOKUMENTE

We have already seen this algorithm: Backtracking corresponds to depth-first search Chapter 12 with the following state space: states: partial assignments initial state:

used to traverse explicated tree from root node to a leaf maps decision nodes to a probability distribution over actions (usually as a function over a decision node and its

We have already seen this algorithm: Backtracking corresponds to depth-first search Chapter 12 with the following state space: states: consistent partial assignments initial

→ Correctness of the transformation along a path: If the value of a variable is accessed, this variable is necessarily live. The value of dead variables thus is irrelevant :-).

• IBM PC/XT compatible keyboard, monochrome adaptor card and monochrome monitor.. • IBM PC/XT compatible keyboard, color adaptor card and color

model-theoretic challenge: how to show that some class is not elementary or not even

The exploration of adduct compounds based on copper halides and neutral or low-charged molecules of Group 15 and Group 16 elements has led to new insight into the coordination

Variante 2 : Die Seiteneffekte werden beim Backtracking rückgängig gemacht, deshalb kann die graphische Markierung gefundener Knoten direkt in die Regel eingebracht werden,