Lecture 2 Problem Solving As Search, State Space Search
Lecture 2 Problem Solving As Search, State Space Search
Representation
Dr. Basma M. Hassan
2022/2023
Lecture 3
Resourcesforthislecture
This lecture covers the following chapters:
• Chapter 3 (Solving Problems by Searching; only sections 3.1,
3.2, & 3.3) from Stuart J. Russell and Peter Norvig, "Artificial
Intelligence: A Modern Approach," Third Edition (2010), by
Pearson Education Inc.
.. AND ..
• Part II (pages 41 to 45) and Chapter 3 (Structures and
Strategies for State Space Search; only sections 3.0, 3.1, and
• 3.2) from George F. Luger, "Artificial Intelligence: Structures
and strategies for complex problem solving, " Fifth Edition
• to solving a problem.
X X X
X X X
X X X
O O O
X X X O X X O X X X
O O O
Example:MechanicalFaultDiagnosing
Start ask:
What is the problem?
Engine trouble
ask:
Transmission
ask:………
breaks
ask: ……
…
Does the car start?
Yes No
Yes No battery
Yes
ok
Turn over Won’t turn over ask: No
ask: …….. Do lights come on? battery
dead
HowHumanBeingsThink
..?
• Human beings do not search the entire
state space (exhaustive search).
• Only alternatives that experience has
shown to be effective are explored.
• Human problem solving is based on
judgmental rules that limit the
exploration of search space to those
portions of state space that seem
somehow promising.
Goal State
Search
Initial state
o Arad
Actions
o Go from one city to another
Transition Model
o If you go from city A to
city B, you end up in city B
Goal State
o Bucharest
Path Cost
o Sum of edge costs (total distance traveled)
StateSpace
The initial state, actions, and transition model define the state
space of the problem;
• The set of all states reachable from initial state by any
sequence of actions.
• Can be represented as a directed graph where the
nodes are states and links between nodes are actions.
Riverbank 1
4
River
Island 1 1 Island 2
Riverbank 2
StateSpace
• A state space is represented by four-tuple [N, A, S, GD].
• N, is the set of nodes or states of the graph. These
• correspond to the states in the problem-solving process.
• A, is the set of arcs between nodes. These correspond to the steps in a
problem-solving process.
• S, a nonempty subset of N, contains the start-state (s) of
• the problem.
• GD, a nonempty subset of N, contains the goal-state(s) of the problem.
The states in GD are described using either:
• A measurable property of the states encountered in
• the search.
• A property of the solution path developed in the search (a solution
path is a path through this graph from a node in S to a node in GD).
Example:VacuumWorld
• States:
• Agent location and dirt location
• How many possible states?
• What if there are n possible locations?
• oThe size of the state space grows
exponentially with the “size” of
the world!
• Actions:
• Left, right, suck.
• Transition Model .. ?
Example:VacuumWorldStateSpaceGraph
o Transition Model:
Example:the8-Puzzle
• States
• Locations of tiles
• o 8-puzzle: 181,440 states (9!/2)
• 15-puzzle: ~10 trillion states
• 24-puzzle: ~1025 states
• Actions
• Move blank left, right, up, down
• Path Cost
• 1 per move
Example:RobotMotionPlanning
o States
o Real-valued joint parameters (angles, displacements).
o Actions
o Continuous motions of robot joints.
o Goal State
o Configuration in which object is grasped.
o Path Cost
o Time to execute, smoothness of path, etc.
• Nodes(N): all the different
configuration of Xs and Os that the
game can have.
• Arcs (A): generated by legal moves by
Example:Tic- placing an X or an O in unused location.
Tac-Toe • Start state (S): an empty board.
• Goal states (GD): a board state
having three Xs in a row, column, or
diagonal.
• The arcs are directed, then no cycles
in the state space,
• directed acyclic graph (DAG).
• Complexity: 9! Different paths can be
generated.
Example:TravelingSalesperson
A salesperson has five cites to visit and ten must return home.
• Nodes(N): represent 5 cites.
•Arcs(A): labeled with weight indicating the cost of traveling
between connected cites.
• Start state(S): a home city.
• Goal states(GD): an entire path contains a complete circuit
with minimum cost.
•Complexity: (n-1)! Different cost-weighted paths can be
generated.
StateSpaceSearchStrategies
There are two distinct ways for searching a state space graph:
Start
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Search:Basicidea
Starting
SearchTree(theWhat-iftree) State
frontier.
TreeSearchExample
Start: Arad
Goal: Bucharest
TreeSearchExample
Start: Arad
Goal: Bucharest
TreeSearchExample
Start: Arad
Goal: Bucharest
HandlingRepeated
States
• Initialize the frontier using the starting state
• While the frontier is not empty
• Choose a frontier node according to search
strategy
• and take it off the frontier.
• If the node contains the goal state, return solution
Else expand the node and add
its children to the frontier.
Start
Node
State List (SL): lists the states in the current path being tried. If the
goal is found, then it contains the solution path.
• The following are two problems that can be solved using state-
space search techniques. You should:
• Suggest a suitable representation for the problem state.
• State what the initial and final states are in this
representation.
• State the available operators/rules for getting from one
state to the next, giving any conditions on when they may
be applied.
• Draw the first two levels of the directed state-
• space graph for the given problem.