16
State Space State Space Search Search Classic AI Classic AI

State Space Search

Embed Size (px)

DESCRIPTION

State Space Search. Classic AI. 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. Solution Path. - PowerPoint PPT Presentation

Citation preview

Page 1: State Space Search

State Space SearchState Space Search

Classic AIClassic AI

Page 2: State Space Search

State Space representation of a State Space representation of a problem is a graphproblem is a graph

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

processprocess One node corresponds to an initial One node corresponds to an initial

statestate One node corresponds to a goal stateOne node corresponds to a goal state

Page 3: State Space Search

Solution PathSolution Path

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

Page 4: State Space Search

Search AlgorithmSearch Algorithm

Finds a solution path through a state Finds a solution path through a state spacespace

Page 5: State Space Search

The Water Jug ProblemThe Water Jug Problem

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

gallon juggallon jug

Page 6: State Space Search

RepresentationRepresentation

State SpaceState Space Node on the graph is an ordered pair Node on the graph is an ordered pair

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

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

Page 7: State Space Search

RulesRules1.1. if x < 4, fill x : (x,y) if x < 4, fill x : (x,y) (4,y) (4,y)2.2. if y < 3, fill y : (x,y) if y < 3, fill y : (x,y) (x,3) (x,3)3.3. if x > 0, empty x : (x,y) if x > 0, empty x : (x,y) (0,y) (0,y)4.4. if y > 0, empty y : (x,y) if y > 0, empty y : (x,y) (x,0) (x,0)5.5. if (x+y) >= 4 and y > 0if (x+y) >= 4 and y > 0

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

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

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

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

Page 8: State Space Search

Is there a solution path?Is there a solution path?

Initial State: (0,0)Initial State: (0,0)

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

Page 9: State Space Search

Breadth First SearchBreadth 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

Depth FirstDepth 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

Backward/Forward ChainingBackward/Forward Chaining

Search can proceedSearch can proceed

1.1. From data to goalFrom data to goal

2.2. From goal to dataFrom goal to data

Either could result in a successful Either could result in a successful search path, but one or the other search path, but one or the other might require examining more might require examining more nodes depending on the nodes depending on the circumstancescircumstances

Page 12: State Space Search

Data to goal is called forward chaining Data to goal is called forward chaining for data driven searchfor data driven search

Goal to data is called backward Goal to data is called backward chaining or goal driven searchchaining or goal driven search

Page 13: State Space Search

ExamplesExamples

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

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

produce this goalproduce this goal– Follow these rules backwards to the Follow these rules backwards to the

start statestart state

Page 14: State Space Search

ObjectObject

Reduce the size of the search spaceReduce the size of the search space

Page 15: State Space Search

Use Goal DrivenUse Goal Driven

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

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

Page 16: State Space Search

Use Data DrivenUse Data Driven IfIf

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

For example: DENDRAL, an expert system For example: DENDRAL, an expert system that finds molecular structure of organic that finds molecular structure of organic compounds based on spectrographic data. compounds based on spectrographic data. There are lots of final possibilities, but There are lots of final possibilities, but only a few ways to use the initial dataonly a few ways to use the initial data

Said another way: initial data constrains Said another way: initial data constrains searchsearch