16
State Space Search

State Space Search. State Space representation of a problem is a graph Nodes correspond to problem states Arcs correspond to steps in a solution process

Embed Size (px)

Citation preview

Page 1: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

State Space Search

Page 2: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

State Space representation of a problem is a graph

Nodes correspond to problem states Arcs correspond to steps in a solution

process One node corresponds to an initial

state One node corresponds to a goal state

Page 3: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Solution Path

An ordered sequence of nodes from the initial state to the goal state

Page 4: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Search Algorithm

Finds a solution path through a state space

Page 5: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

The Water Jug Problem

Suppose we have An empty 4 gallon jug An empty 3 gallon jug A source of water A task: put 2 gallons of water in the 4

gallon jug

Page 6: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Representation

State Space Node on the graph is an ordered pair

(x,y)– X is the contents of the 4 gallon jug– Y is the contents of the 3 gallon jug

Intitial State: (0,0) Goal State: (2,N) N ε {0, 1, 2, 3}

Page 7: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Rules1. if x < 4, fill x : (x,y) (4,y)2. if y < 3, fill y : (x,y) (x,3)3. if x > 0, empty x : (x,y) (0,y)4. if y > 0, empty y : (x,y) (x,0)5. if (x+y) >= 4 and y > 0

fill the 4 gallon jug from the 3 gallon jug(x,y) (4, y – (4 – x))

6. if (x+y) >= 3 and x > 0Fill the 3 gallon jug from the 4 gallon jug(x,y) (x –(3 – y), 3))

7. if (x+y) <= 4 and y > 0 Pour the 3 gallon jug into the 4 gallon jug: (x,y) (x+y), 0)

8. if (x+y) <= 3 and x > 0pour the 4 gallon jug into the 3 gallon jug: (x,y) (0, x + y)

Page 8: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Is there a solution path?

Initial State: (0,0)Goal State: (2,N)

Page 9: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Breadth First Search

(0,3)

(0,3)

(4,0)

(4,3) (1,3)(3,0)

(0,3)

1

2

2

6 7

etc

Page 10: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Depth First

(3,0)

(3,3)

(0,3)

(4,0)

(4,3)

(0,0)

12

3

7

2

Etc. and without visiting already visited states

Page 11: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Backward/Forward Chaining

Search can proceed1. From data to goal2. From goal to dataEither could result in a successful

search path, but one or the other might require examining more nodes depending on the circumstances

Page 12: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Data to goal is called forward chaining for data driven search

Goal to data is called backward chaining or goal driven search

Page 13: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Examples

Water jug was data driven Grandfather problem was goal driven To make water jug goal driven:

– Begin at (2,y)– Determine how many rules could

produce this goal– Follow these rules backwards to the

start state

Page 14: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Object

Reduce the size of the search space

Page 15: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Use Goal Driven

if– Goal is clearly stated – Many rules match the given facts

For example: the number of rules that conlude a given theorem is much smaller than the number that may be applied to the entire axiom set

Page 16: State Space Search. State Space representation of a problem is a graph  Nodes correspond to problem states  Arcs correspond to steps in a solution process

Use Data Driven If

– Most data is given at the outset– Only a few ways to use the facts– Difficult to form an initial hypothesis

Water Jug: could go either way, but the presence of only a few rules, data existing in only a handful of states, and the difficulty of forming a hypothesis suggests data driven

Said another way: initial data constrains search