Solving problems by searching

State spaces

Formulates the example problems (Romania, the vacuum world, the 8-puzzle, robot motion planning) as search problems, draws their state spaces, lists what the successor function returns for any state, and grows a breadth-first or uniform-cost search outward from the start state.

  • Lecture reference: Solving Problems by Searching · slides 2–26
  • Lecture reference: Uninformed Search · slide 40

Types of agents

Lecture reference: Solving Problems by Searching · slide 2

Reflex agent

Consider how the world IS

  • Choose action based on current percept
  • Do not consider the future consequences of actions

Planning agent

Consider how the world WOULD BE

  • Decisions based on (hypothesized) consequences of actions
  • Must have a model of how the world evolves in response to actions
  • Must formulate a goal

Can a reflex agent be rational?

Show answer
Search
  • Goal-based agents in fully observable, deterministic, discrete, known environments.
  • The agent must find a sequence of actions that reaches the goal.
  • The performance measure is defined by (a) reaching the goal and (b) how “expensive” the path to the goal is.
  • While executing the solution, the agent can safely ignore its percepts (open-loop system).
Lecture reference: Solving Problems by Searching · slides 3–4

Search problem components

Lecture reference: Solving Problems by Searching · slide 5
  1. Initial state
  2. Actions
  3. Transition model What state results from performing a given action in a given state? Called Successor.
  4. Goal state
  5. Path cost Assume that it is a sum of nonnegative step costs.

The optimal solution is the sequence of actions that gives the lowest path cost for reaching the goal.

Example: Romania

Lecture reference: Solving Problems by Searching · slide 6

On vacation in Romania; currently in Arad. Flight leaves tomorrow from Bucharest.

States
The city the agent is in (not listed on the slide)
Initial state
Arad
Actions
Go from one city to another
Transition model
If you go from city A to city B, you end up in city B
Goal state
Bucharest
Path cost
Sum of edge costs (total distance traveled)

Not listed on the slide.

Successor function of Arad

Lecture reference: Solving Problems by Searching · slide 14
Successors of Arad
ActionSuccessor stateStep cost
Go to Sibiu 140
Go to Timisoara 118
Go to Zerind 75

Select a state here or in the state space; select a successor to apply the successor function to it.

We usually don’t have a full representation of the state space. Instead, a successor function captures the transition model: given a state, apply all applicable actions and generate a list of the resulting (successor) states.

State space 20 states · 23 roads

Lecture reference: Solving Problems by Searching · slide 7
Selected state Its successors Goal state

The initial state, actions, and transition model define the state space of the problem: the set of all states reachable from the initial state by any sequence of actions. It can be represented as a directed graph where the nodes are states and the links between nodes are actions.

What is the state space for the Romania problem?

Show answer

Search: basic idea BFS from Arad

Lecture reference: Solving Problems by Searching · slides 13–26
  1. Begin at the start state and expand it by making a list of all possible successor states (with the successor function).
  2. Maintain a frontier: a list of unexpanded states.
  3. At each step, pick a state from the frontier to expand.
  4. Keep going until you reach a goal state.
  5. Try to expand as few states as possible.
Step 1 of 10
Initialize the frontier with Arad.
  • On the frontier
  • Goal state

Frontier

1 node FIFO queue

Explored set

0 states

Empty

Graph search: a state enters the explored set when it is expanded and is not put on the frontier again. Lecture reference: Solving Problems by Searching · slide 36

With focus in the search: ← → previous and next step, Home End first and last step, Space play or pause.

Why not build the state space and use Dijkstra’s algorithm?

Lecture reference: Solving Problems by Searching · slide 12

Given the initial state, actions, transition model, goal state, and path cost: how do we find the optimal solution? How about building the state space and then using Dijkstra’s shortest path algorithm?

  • Complexity of Dijkstra’s algorithm is O(E + V log V), where V is the size of the state space (and E the number of actions).
  • The state space may be huge: the table lists the example problems.

Uniform-cost search is equivalent to Dijkstra’s algorithm in general Lecture reference: Uninformed Search · slide 40, but it generates states with the successor function only when it expands them, and stops when it takes a goal state off the frontier.

State-space sizes: states V, actions E, and E + V log₂ V
ProblemStates VActions EE + V log₂ V
Vacuum world, 2 squares824~48
Romania2046 (23 roads, both ways)~132
Vacuum world, 10 squares10,24030,720~167,137
8-puzzle181,440483,840~3.7 million
15-puzzle~1.3 trillion3.9 trillion~56.2 trillion
24-puzzle~10²⁵3.2 × 10²⁵~8.6 × 10²⁶
Robot motion planningInfinite (continuous)Infinite∞