Intelligent Search for Artificial Intelligence (CIS 479)
(some diagrams are included in the word document that are not posted on the web page, the diagrams did not convert all that great)
State Space Search
This is used in the following situations
2. Branch & Bound (2)
3. Generate & Test
Problem
You have a four-gallon jug and a three-gallon jug and the goal is to come up with exactly two gallons of water.
Directed Graph (This is the best way to show the solution for this problem)
(0 0) à (4 0) (0 3))
(4 0) à (( 4 3) (0 0) (1 3))
(0 3) à ((4 3) (3 0) (0 0))
(1 3) à (1 0) (4 3))
Knowledge Representation !
Problem
There are four items a farmer, wold, goose, and corn. The farmer can only take one item across the river at a time.
Rules
F = Farmer
W = Wolf
G = Goose
C = Corn
R = River
Step One: F - W G - C R
Step Two: W C R F G
Step Three: F W C R G
Step Four: C R F W G
Step Five: F C G R W
Or
Step Four: W R F G C
Step Five: F G W R C
Step Six: G R F W C
Step Seven: F G R W C
Step Eight: R F W G C
Control Strategy
Heuristics trade speed for completeness
Any path?
Shortest path?
Any Path?
S à A,B
A à S,B,F
B à S,A,C
F à A,C
C à B,F
Depth First Search
If the first queue element equals the goal do nothing
Else remove the first queue element and add its children to the front of the queue of the partial paths
((S))
((A S) (B S))
((B A S) (F A S) (B S))
(( C B A S) (F A S) (B S))
(( F C B A S) (F A S) (B S))
(S A B C F)
Breath First Search
If the first queue element equals the goal do nothing
Else remove the first queue element and add its children to the rear of the queue of the partial paths
((S))
((A S) (B S))
((B S) (B A S) (F A S))
((B A S) ( F A S) (A B S) (C B S))
((F A S) (A B S) (C B S) (C B A S))
(S A F)
When this works and when it does not?
Hill Climbing
If the first queue element equals the goal do nothing
Else remove the first queue element and sort and add its children to the front of the queue of the partial paths
(3) If the goal is attained success will be announced, if failure it will be announced
((S))
((A S) (B S))
((F A S) (B A S) (B S))
(S A F)
Weakness
(sort `(1 2 3 4) ` >)
(4 3 2 1)
(sort (1 2 3 4) <)
(sort (1 2 3 4) (closerp)) ; line 113 on code handout
Beam Search
Look at n best paths to the goal. ( you pick any number you want for n)
In this example we picked the number three. Here we look at the first level from left to right all the way across and then move to the next level and then the next.
((S))
((A S) (B S))
((F A S) (C B S) (A B S) (B A S)
(S A F)
Best First Search
If front (Q) equals goal then do nothing
Else remove first node and add the children to the front and then sort the queue by the remaining distance.
((S))
((A S) (B S))
((F A S) (B A S) (B S))
(S A F)
Optimal Solutions
British museum search
Branch & Bound
If front (Q) equals goal then do nothing
Else remove the first node and sort the queue by cost
((S))
((A S) (B S))
((B S) (B A S) (F A S))
((A B S) (F A S) (C B S) (B A S))
((B A S) (F A S) (C B S) (F A B S))
((F A S) (F C B S) (F A B S) (C B A S))
(S A F)
Branch & Bound With Under Estimator
If front (Q) equals goal then do nothing
Else remove first root and add the children to the front sort queue by the cost estimator
Else failure
((S))
((A S) (B S))
((F A S) (B S) (B A S))
(S A F)
Branch & Bound with Dynamic Programming and Remove Duplicates
If front (Q) equals goal then do nothing
Else remove first root and add the children to the front sort queue and use the cost estimator and remove duplicates
Else failure
((S))
((A S) (B S))
((B S) (F A S))
((A B S) (F A S) (C B S))
((C B S) (F A S))
((F A S))
((S A F))
A*
Branch & Bound with Dynamic Programming, Under Estimator and Remove Duplicates
If front (Q) equals goal then do nothing
Else remove first root and add the children to the front sort queue using cost estimation and remove duplicate paths
Else failure
((S))
((A S) (B S))
((F A S) (B S))
((F A S))
Heuristic Search Summary