• 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 8, 2019 — 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 8, 2019. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24.4 Summary. April 8, 2019. 1 / 21. M. Helmert (University of Basel). Foundations of Artificial Intelligence. 24. Constraint Satisfaction Problems: Backtracking. April 8, 2019. 2 / 21. 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 8, 2019. 3 / 21. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 4 / 21.

(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 8, 2019. 5 / 21. Naive Backtracking. Naive Backtracking (= Without Inference). April 8, 2019. 24. Constraint Satisfaction Problems: Backtracking. 6 / 21. Naive Backtracking. We have already seen this algorithm: Backtracking corresponds to depth-first search (Chapter 12) with the following state space: I states: consistent partial assignments. if α is inconsistent with C: return inconsistent if α is a total assignment: return α. I initial state: empty assignment ∅ I goal states: consistent total assignments. 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. 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: I for each non-total assignment α, choose variable v = select(α) that is unassigned in α assign. v ,d I transition α −−−−− → α ∪ {v 7→ 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 Foundations of Artificial Intelligence. Foundations of Artificial Intelligence. Is This a New Algorithm?. function NaiveBacktracking(C, α): hV , dom, (Ruv )i := C. M. Helmert (University of Basel). M. Helmert (University of Basel). April 8, 2019. 7 / 21. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 8 / 21.

(3) 24. Constraint Satisfaction Problems: Backtracking. Naive Backtracking. Why Depth-First Search?. 24. Constraint Satisfaction Problems: Backtracking. Naive Backtracking. Naive Backtracking: Example Consider the constraint network for the following graph coloring problem:. 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.. v1. v7. b, g, r. b, r. v2. v6. b, g. g, r, y b, g. b, r b, r. v3. v5. v4. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 24. Constraint Satisfaction Problems: Backtracking. 9 / 21. Naive Backtracking. Naive Backtracking: Example. v7. g. b r. April 8, 2019. 24. Constraint Satisfaction Problems: Backtracking. 10 / 21. Naive Backtracking. 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.. r. b. r. v4. r. b. v5. g. g. b. v6. r. y. r. y. v3. r. r. b. b. v2. b. b. b. b. M. Helmert (University of Basel). Foundations of Artificial Intelligence. Naive Backtracking: Discussion. search tree for naive backtracking with I fixed variable order v1 , v7 , v4 , v5 , v6 , v3 , v2 I alphabetical order of the values (without inconsistent nodes; continued at goal nodes). v1. M. Helmert (University of Basel). Foundations of Artificial Intelligence. more intelligence by focusing on critical decisions and by inference of consequences of previous decisions. April 8, 2019. 11 / 21. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 12 / 21.

(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 8, 2019. 13 / 21. Variable and Value Orders. Variable and Value Orders. 24. Constraint Satisfaction Problems: Backtracking. April 8, 2019. 14 / 21. Variable and Value Orders. we distinguish: I static orders (fixed prior to search) I dynamic orders (selected variable or value order depends on the search state) comparison: I dynamic orders obviously more powerful I static orders no computational overhead during search. 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?) German: Werteordnung Foundations of Artificial Intelligence. Foundations of Artificial Intelligence. Static vs. Dynamic Orders. variable orders: 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. M. Helmert (University of Basel). M. Helmert (University of Basel). April 8, 2019. The following ordering criteria can be used statically, but are more effective combined with inference ( later) and used dynamically.. 15 / 21. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 16 / 21.

(5) 24. Constraint Satisfaction Problems: Backtracking. Variable and Value Orders. Variable Orders. Variable and Value Orders. Value Orders. two common variable ordering criteria: I minimum remaining values: prefer variables that have small domains. 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 .. I intuition: few subtrees smaller tree I extreme case: only one value forced assignment. I most constraining variable: prefer variables contained in many nontrivial constraints I intuition: constraints tested early inconsistencies recognized early. 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 α. smaller tree. combination: use minimum remaining values criterion, then most constraining variable criterion to break ties. M. Helmert (University of Basel). 24. Constraint Satisfaction Problems: Backtracking. Foundations of Artificial Intelligence. April 8, 2019. 24. Constraint Satisfaction Problems: Backtracking. 17 / 21. Summary. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 24. Constraint Satisfaction Problems: Backtracking. 18 / 21. Summary. Summary: Backtracking. 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. 24.4 Summary. I depth-first search particularly well-suited because state space is directed tree and all solutions at same (known) depth. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 19 / 21. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 20 / 21.

(6) 24. Constraint Satisfaction Problems: Backtracking. Summary. Summary: Variable and Value Orders. 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 goal: most promising assignments first. M. Helmert (University of Basel). Foundations of Artificial Intelligence. April 8, 2019. 21 / 21.

(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:

basic concepts: I search: check partial assignments systematically I backtracking: discard inconsistent partial assignments I inference: derive equivalent, but tighter constraints

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

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,

→ 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