You are on page 1of 26

Week 2

State Space Search


Knowledge Representation And
Search (Conventional AI)

Memory
ALU

Knowledge
Base

CONTROL

ALGORITHMS
For
• Search
• Inference I/O
Problem Solving Agent
• A particular goal based agent that decides
what to do by searching sequences of
actions that lead to goal state.
• The simple problem solving agent does
three things:
– Formulates problem and goal description
– Searches for the sequence of actions that
would solve the problem
– Executes the actions one at a time
Problem Formulation
• INITIAL STATE/ Other STATES :The initial
state that the agent starts in it could be any state
• ACTIONS available to the agent at state s,
STATE
ACTIONS(s) SPACE
• TRANSITION MODEL : A description of what
each action does; specified by a function
RESULT(s, a)
• PATH : A path in the state space is a sequence
of states connected by a sequence of actions.
• GOAL TEST The goal test, which determines
whether a given state is a goal state. Agent
Actions
• PATH COST:A path cost function that assigns a
numeric cost to each path. OPTIMAL SOLUTION
STATE SPACE
• STATE SPACE Together, the initial state,
actions, and transition model implicitly
define the state space of the problem
State Space
• A “State Space” is a graphical
representation of the problems.
• State Space includes all possible states of
the problems including the solution state
as “Nodes”
• Arcs between nodes denotes the legal
moves, for node to node transaction.
• State Space is also known as Solution
Space or Problem Space.
Example (Vacuum Cleaner)
Example (Vacuum Cleaner)
• States: 2 × 22 = 8 A larger environment with n
locations has n ・ 2n states.
• Initial state: Any state can be designated as the
initial state.
• Actions: In each state just three actions: Left,
Right, and Suck. Up and Down.
• Transition model: The actions have their
expected effects,
• Goal test: This checks whether all the squares
are clean.
• Path cost: Each step costs 1, so the path cost is
the number of steps in the path.
8-Puzzle Problem

1 4 3 1 1 2
7 6 3 4 5
5 8 2 6 7 8

Start State Goal State


State Space Examples
1 4 3
7 6
5 8 2
Up Right
Left Down
1 3 1 4 3 1 4 3 1 4 3
7 4 6 7 6 7 8 6 7 6
5 8 2 5 8 2 5 2 5 8 2

1 3 1 3
7 4 6 7 4 6
5 8 2 5 8 2
8-Puzzle Problem
• The 8-puzzle belongs to the family
SLIDING-BLOCK of sliding-block
puzzles, known to be NP-
complete,
• The 8-puzzle has 9!/2=181, 440
reachable states and is easily
solved.
• The 15-puzzle (on a 4×4 board)
has around 1.3 trillion states,
• The 24-puzzle (on a 5 × 5 board)
has around 1025 states, and
random instances take several
hours to solve optimally.
8-QUEENS PROBLEM
• 8-QUEENS PROBLEM The goal of the 8-
queens problem is to place eight queens
on a chessboard such that no queen
attacks any other.
• A queen attacks any piece in the same
row, column or diagonal
8-QUEENS PROBLEM

• States: Any arrangement of 0 to 8 queens on the board is a state.


• Initial state: No queens on the board.
• Actions: Add a queen to any empty square.
• Transition model: Returns the board with a queen added to the
specified square.
• Goal test: 8 queens are on the board, none attacked.
State Space Examples
100 B
A

75 50
125 125
75

100
125
E C

50 100
D
State Space
A
Examples
B 100
C E
150 D
C D
250 E
D 275 E
C

300 325
Complete State Space of the traveling
E Sales person problem will assure the
D E
Optimal solution of the problem. Where
375 425 Results are stored in the leaves of the tree.

A A A
BUT
State Space Examples
State Space for TIC TAC TOE

X 0
X
0 X
State Space Examples
State Space for TIC TAC TOE

X X X
X
X

X X X OX X
O O O
O
Homework Draw State
Space 5 Levels?
Start : Goal A
B
D C
A B C D

Rules:
• Pick or Place one Block from the top of the given stacks
• You have to use given three stacks to achieve the Goal.
Search Algorithms
• Having formulated the problem, we now
need to solve them. A solution is an action
sequence, so search algorithms work by
considering various possible action
sequences. Which lead to Initial State to
Goal State
• The SEARCH TREE possible action
sequences starting at the initial state form
a search tree with the initial state NODE
at the root;
Strategies for Search
• Data Driven Search
– Forward Chaining
– Start from Available Data
– Search for Goal
• Goal Driven Search
– Backward Chaining
– Start from Goal
– Generate Sub Goals, until it arrive at current
State
Generating State space
• LEAF NODE: Expanded nodes after one
action
• FRONTIER point is called the
frontier/open list: List of All expanded
nodes
• Explored set (also known CLOSED LIST
which remembers every expanded node.
Graph of Romania

Start
State

Goal
State
State Space
State Space
State Space
Coloring Method
• Coloring method is also used in spite
of Open & Closed Lists

You might also like