![Page 1: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/1.jpg)
Last bit on A*-search.
![Page 2: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/2.jpg)
8 Puzzle I
Heuristic: Number of tiles misplaced
Why is it admissible?
h(start) =
This is a relaxed-problem heuristic
8 Average nodes expanded when optimal path has length…
…4 steps …8 steps …12 steps
UCS 112 6,300 3.6 x 106
TILES 13 39 227
![Page 3: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/3.jpg)
8 Puzzle II
What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?
Total Manhattan distance
Why admissible?
h(start) =
3 + 1 + 2 + …
= 18
Average nodes expanded when optimal path has length…
…4 steps …8 steps …12 steps
TILES 13 39 227
MANHATTAN 12 25 73[demo: eight-puzzle]
![Page 4: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/4.jpg)
8 Puzzle III
How about using the actual cost as a heuristic? Would it be admissible? Would we save on nodes expanded? What’s wrong with it?
With A*: a trade-off between quality of estimate and work per node!
![Page 5: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/5.jpg)
Trivial Heuristics, Dominance
Dominance: ha ≥ hc if
Heuristics form a semi-lattice: Max of admissible
![Page 6: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/6.jpg)
Graph Search
![Page 7: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/7.jpg)
Tree Search: Extra Work!
Failure to detect repeated states can cause exponentially more work. Why?
![Page 8: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/8.jpg)
Graph Search
In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
![Page 9: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/9.jpg)
Graph Search
Very simple fix: never expand a state twice
![Page 10: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/10.jpg)
Graph Search
Idea: never expand a state twice
How to implement: Tree search + list of expanded states (closed list) Expand the search tree node-by-node, but… Before expanding a node, check to make sure its state is new
Python trick: store the closed list as a set, not a list
Can graph search wreck completeness? Why/why not?
How about optimality?
![Page 11: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/11.jpg)
Consistency
A
CS
1
1h = 4
h = 1h = 6
What went wrong? Taking a step must not reduce f value!
B
h = 0
Gh = 11 2 3
![Page 12: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/12.jpg)
Consistency
Stronger than admissability Definition:
C(A→C)+h(C) h(A)≧ C(A→C) h(A)-h(C)≧
Consequence: The f value on a path never
decreases A* search is optimal
A
G
1
h = 4
h = 0
Ch = 1 3
![Page 13: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/13.jpg)
Optimality of A* Graph Search
Proof: New problem (with graph instead of tree search):
nodes on path to G* that would have been in queue aren’t, because some worse n’ for the same state as some n was dequeued and expanded first (disaster!)
Take the highest such n in tree Let p be the ancestor which was on the queue
when n’ was expanded Assume f(p) f(n) ≦ (consistency!) f(n) < f(n’) because n’ is suboptimal p would have been expanded before n’ So n would have been expanded before n’, too Contradiction!
![Page 14: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/14.jpg)
Optimality
Tree search: A* optimal if heuristic is admissible (and non-negative) UCS is a special case (h = 0)
Graph search: A* optimal if heuristic is consistent UCS optimal (h = 0 is consistent)
Consistency implies admissibility
In general, natural admissible heuristics tend to be consistent
![Page 15: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/15.jpg)
Summary: A*
A* uses both backward costs and (estimates of) forward costs
A* is optimal with admissible heuristics
Heuristic design is key: often use relaxed problems
![Page 16: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/16.jpg)
Quiz 2 : A* search
T/F: A* is optimal with any h(). False T/F: A* is complete with any h(). True T/F: A* with the zero heuristic is UCS. True T/F: Admissibility implies consistency. False T/F: If n’ is a sub-optimal path to n, then f(n)<f(n’) for any
heuristic. True h(n)=h(n’) but g(n)<g(n’) T/F: Admissibility is necessary for Graph-Search to be
optimal. True
(All heuristics are are non-negative and bounded by some B, i.e. h(x) B.)≦
![Page 17: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/17.jpg)
Search Recap
Uniform Cost Search / BFS
Greedy Search / DFS
A* Search
![Page 18: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/18.jpg)
A* applications
http://pacman.elstonj.com/index.cgi?dir=videos&num=&perpage=§ion=
http://www.youtube.com/watch?feature=player_embedded&v=JnkMyfQ5YfY#!
![Page 19: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/19.jpg)
CSE 511A: Artificial IntelligenceSpring 2013
Lecture 4: Constraint Satisfaction Programming
Jan 29, 2012
Robert Pless, slides from Kilian Weinberger, Ruoyun Huang, adapted from Dan Klein, Stuart Russell or Andrew Moore
![Page 20: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/20.jpg)
Announcements
Projects: Project 1 out. Due Thursday 10 days from now,
midnight.
21
![Page 21: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/21.jpg)
1.What is a CSP?
![Page 22: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/22.jpg)
What is Search For?
Models of the world: single agents, deterministic actions, fully observed state, discrete state space
Planning: sequences of actions The path to the goal is the important thing Paths have various costs, depths Heuristics to guide, fringe to keep backups
Identification: assignments to variables The goal itself is important, not the path All paths at the same depth (for some formulations) CSPs are specialized for identification problems
23
![Page 23: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/23.jpg)
Search Problems
A search problem consists of:
A state space
A successor function
A start state and a goal test
A cost function (for now we set cost=1 for all steps) A solution is a sequence of actions (a plan)
which transforms the start state to a goal state
“N”, 1.0
“E”, 1.0
![Page 24: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/24.jpg)
One Example
Schedule Lectures at Washburn University
Time-table:
Lop101 Jolley 305
9:0010:0011:0012:0013:0014:00
Courses:-A: Intro to AI-B: Bioinformatics-C: Computational Geometry-D: Discrete Math
Constraints:-Only one course per room / slot-Each course meets one two hours slot-A can only be in Jelly 204-B must be scheduled before noon-D must be in the afternoon
![Page 25: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/25.jpg)
Search Problem
State Space: (partially filled in) time schedule
Successor Function: Assign time slot to unassigned course
Start State: Empty schedule
Goal test: All constraints are met All courses scheduled
Time-table:
Lap101 Jelly 204
9:0010:0011:0012:0013:0014:00
AABB
CCDD
![Page 26: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/26.jpg)
Naïve Search Tree
AAAA
AABB
BBBB
BBBB
BBAA AA AATree is gigantic!Depth?Width?Where is a solution?
![Page 27: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/27.jpg)
Constraint Satisfaction Problems Standard search problems:
State is a “black box”: arbitrary data structure Goal test: any function over states Successor function can be anything
Constraint satisfaction problems (CSPs): A special subset of search problems State is defined by variables Xi with values from a
domain D (sometimes D depends on i) Goal test is a set of constraints specifying
allowable combinations of values for subsets of variables
Path cost irrelevant!
Simple example of a formal representation language
Allows useful general-purpose algorithms with more power than standard search algorithms
28
CSPsSearch
Problems
![Page 28: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/28.jpg)
Example 1: Map-Coloring Variables:
Domain:
Constraints: adjacent regions must have different colors
Solutions are assignments satisfying all constraints, e.g.:
29
Implicit:
Explicit:
-or-
![Page 29: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/29.jpg)
Constraint Graphs
Binary CSP: each constraint relates (at most) two variables
Binary constraint graph: nodes are variables, arcs show constraints
General-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an independent subproblem!
30
![Page 30: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/30.jpg)
Example 2: Cryptarithmetic
Variables:
Domains:
Constraints (boxes):
31
![Page 31: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/31.jpg)
Example 2: Cryptarithmetic II
Variables:
Domains:
Constraints:
32
T, W, O, F, U, R
(T * 100 + W * 10 + O) * 2= F * 1000 + O * 100 + U * 10 + R
![Page 32: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/32.jpg)
Example 3: N-Queens
Formulation 1: Variables: Domains: Constraints
33
![Page 33: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/33.jpg)
Example 3: N-Queens
Formulation 1.5: Variables:
Domains:
Constraints:
… there’s an even better way! What is it?
Implicit:
Explicit:
-or-
![Page 34: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/34.jpg)
Example 3: N-Queens
Formulation 2: Variables:
Domains:
Constraints:
Implicit:
Explicit:
-or-
![Page 35: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/35.jpg)
Example 4: Sudoku
Variables: Each (open) square
Domains: {1,2,…,9}
Constraints:
9-way alldiff for each row
9-way alldiff for each column
9-way alldiff for each region
Check out Peter Norvig’s homepage http://norvig.com/sudoku.html
![Page 36: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/36.jpg)
Example 5: The Waltz Algorithm The Waltz algorithm is for interpreting line drawings of
solid polyhedra An early example of a computation posed as a CSP
First, look at all intersections
?
37
Four types of junctions:L, fork, T, arrow
![Page 37: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/37.jpg)
Waltz on Simple Scenes
3 Types of Lines: Boundary line (edge of an
object) () with right hand of arrow denoting “solid” and left hand denoting “space”
Interior convex edge (+) Interior concave edge (-)
4 types of junctions L, fork, T, arrow
Adjacent intersections impose constraints on each other
38
All the valid conjunction labeling:
![Page 38: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/38.jpg)
Waltz on Simple Scenes
Variable (edges): (AB, AC, AE, BA, BD, …, )
Domain: {+,-,,} Constraints (both ends have the same label):
arrow (AC, AE, AB), fork(BA, BF, BD), L(CA, CD), arrow(DG, DC, DB), …
L Junctions
fork Junctions
fork Junctions
arrow Junctions
All the valid conjunction labeling
![Page 39: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/39.jpg)
Waltz on Simple Scenes
At least 4 valid labeling choices
![Page 40: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/40.jpg)
Example 6: Temporal Logic Reasoning
Problem: The meeting ran non-stop the whole day. Each person stayed at the meeting for a continuous period of time. Ms White arrived after the meeting has began. In turn, Director Smith was also present but he arrived after Jones had left. Mr. Brown talked to Ms. White in presence of Smith. Could possibly Jones and White have talked during this meeting?
42
![Page 41: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/41.jpg)
Possible Relations:before, meets, overlap,
start, during, finish, equal
truly-overlap()= overlaps + overlaps-by + starts + started-by + during + contains+ finishes+ finished-by + equal
43
Example 6: Temporal Logic Reasoning
![Page 42: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/42.jpg)
Example 6: Temporal Logic Reasoning
1. Ms White arrived after the meeting has began.
during(W,M) or finishes(W,M) or equals(W,M)
2. Director Smith was also present but he arrived after Jones had left.
after(S, J)
3. Mr. Brown talked to Ms. White in presence of Smith.
truly-overlap(B,M), truly-overlap(B,S), truly-overlap(W,S)
4. Could possibly Jones and White have talked during this meeting?
truly-overlap(J,W)
Event(s) Variable(s)
The duration of the meeting M
The period Jones, Brown, Smith, White was present J, B, S, W
44
![Page 43: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/43.jpg)
Real-World CSPs
Assignment problems: e.g., who teaches what class Timetabling problems: e.g., which class is offered when
and where? Hardware configuration/verification Transportation scheduling Factory scheduling Floorplanning Fault diagnosis … lots more!
Many real-world problems involve real-valued variables…
45
![Page 44: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/44.jpg)
Varieties of CSPs Discrete Variables
Finite domains (Most cases!) Size d means O(dn) complete assignments E.g., Boolean CSPs, including Boolean satisfiability (NP-complete)
Infinite domains (integers, strings, etc.) E.g., our temporal logic reasoning Linear constraints solvable, nonlinear undecidable
Continuous variables E.g., start/end times for Hubble Telescope observations Linear constraints solvable in polynomial time by LP methods
(see ESE505 Operation Research for a bit of this theory)
There might be objective functions: Branch-and-Bound method
46
![Page 45: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/45.jpg)
Varieties of Constraints Varieties of Constraints
Unary constraints involve a single variable (equiv. to shrinking domains):
Binary constraints involve pairs of variables:
Higher-order constraints involve 3 or more variables: e.g., 9-way different constraints in sudoku
Preferences (soft constraints): E.g., red is better than green Often representable by a cost for each variable assignment Gives constrained optimization problems (We’ll ignore these until we get to Bayes’ nets)
47
![Page 46: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/46.jpg)
2. How can we solve CSPs fast?
By taking advantage of their specific structure!
![Page 47: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/47.jpg)
Standard Search Formulation
Standard search formulation of CSPs (incremental)
Let's start with the straightforward, dumb approach, then fix it
States are defined by the values assigned so far Initial state: the empty assignment, {} Successor function: assign a value to an unassigned variable Goal test: the current assignment is complete and satisfies all
constraints
Simplest CSP ever: two bits, constrained to be equal
51
![Page 48: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/48.jpg)
Search Methods
What does BFS do?
What does DFS do?
What’s the obvious problem here? The order of assignment does not matter.
What’s the other obvious problem? We are checking constraints too late.
52
![Page 49: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/49.jpg)
Backtracking Search Idea 1: Only consider a single variable at each point
Variable assignments are commutative, so fix ordering I.e., [WA = red then NT = green] same as [NT = green then WA = red] Only need to consider assignments to a single variable at each step How many leaves are there?
Idea 2: Only allow legal assignments at each point I.e. consider only values which do not conflict previous assignments Might have to do some computation to figure out whether a value is ok “Incremental goal test”
Depth-first search for CSPs with these two improvements is called backtracking search (useless name, really)
Backtracking search is the basic uninformed algorithm for CSPs
Can solve n-queens for n 25 54
![Page 50: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/50.jpg)
Backtracking Example
55 What are the choice points?
![Page 51: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/51.jpg)
Improving Backtracking
General-purpose ideas can give huge gains in speed: Which variable should be assigned next? In what order should its values be tried? Can we detect inevitable failure early? Can we take advantage of problem structure?
56
WASA
NT Q
NSW
V
![Page 52: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/52.jpg)
Which Variable: Minimum Remaining Values
Minimum remaining values (MRV): Choose the variable with the fewest legal values
Why min rather than max? Also called “most constrained variable” “Fail-fast” ordering
57
![Page 53: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/53.jpg)
Which Variable: Degree Heuristic
Tie-breaker among MRV variables Degree heuristic:
Choose the variable participating in the most constraints on remaining variables
Why most rather than fewest constraints?58
![Page 54: Last bit on A*-search.. 8 Puzzle I Heuristic: Number of tiles misplaced Why is it admissible? h(start) = This is a relaxed- problem heuristic](https://reader035.vdocuments.site/reader035/viewer/2022070410/56649f0c5503460f94c204bc/html5/thumbnails/54.jpg)
Which Value: Least Constraining Value
Given a choice of variable: Choose the least constraining
value The one that rules out the fewest
values in the remaining variables Note that it may take some
computation to determine this!
Why least rather than most?
Combining these heuristics makes 1000 queens feasible
59
Better choice