0% found this document useful (0 votes)
34 views

1 Problem Formulation Searching State Space

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

1 Problem Formulation Searching State Space

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

PROBLEM SOLVING BY SEARCHING

PROBLEM FORMULATION
SEARCH TREES
SEARCH STRATEGIES
COMPARING SEARCH ALGORITHMS
Performance measure –
simplified by the indication of a
goal Goal Based
Agents

Problem Planning
solving agents Agents
Searching algorithms are used to select the most
appropriate answers States have structured representation (states –
States are atomic collection of properties)
Problem Solving By Searching
Problem Definition, Solutions
◦ Problems considered have solution which is a fixed
sequence of actions
◦ Environment - Observable, Discrete, Known, Deterministic
◦ Example
◦ 8 puzzle
◦ 8 queens problem (chess)
◦ Traversal of a graph of cities

ABSTRACTION: CONSIDERATIONS LEFT OUT FROM THE STATE / ACTIONS FOR A


SIMPLIFIED REPRESENTATION OF PROBLEM
Steps in Problem Solving by Searching
Problem Definition – Problem Formulation, Goal Formulation
◦ Problem – States + Initial state +Actions + Transition model (Path cost for
the paths between states) +Goal test
Search
◦ Looking for a sequence of actions that take the state from initial to goal
(also called solution) is called search
Execution
◦ Carrying out the actions as per the solution
◦ Agent is open loop (i.e) ignores percept when choosing an action (while
execution) (environments are more of static in nature)
Problem Definition -
Examples
TOY AND REAL WORLD PROBLEMS
Sliding block puzzle – Eg. 8-puzzle
1. Initial state
4. Goal test Solution

https://deniz.co/8-puzzle-solver/
8 – puzzle problem definition
https://www.geeksforgeeks.org/check-instance-8-puzzle-
solvable/
N-Queens problem –
E.g 8 queens problem
FORMULATION 1

64 ・ 63 ・ ・ ・ 57 ≈ 1.8×1014
Possible sequences to investigate
FORMULATION 2 (IMPROVING FORMULATION 1)

State space reduced to 2057


Knuth problem (Infinite state space)
Knuth conjectured that, starting with the number 4, a sequence of factorial, square root, and floor
operations will reach any desired positive integer
Example
Real World Problems
Route finding problem
Data structure used for Problem Solving by Searching - Search Tree
Tree with
◦ Nodes – representing states
◦ Branches – Actions
◦ Root node – Initial state
Node expansion
◦ Applying all legal actions to the state and deriving the
child nodes
Leaf Nodes
◦ Nodes that are not expanded
Frontier
◦ Set of leaf nodes available for expansion
◦ Also called open list
SEARCH TREE – EXPANDING
THE FRONTIER
Data structure used for Problem Solving
by Searching - Search Tree contd..
Search Process
◦ Expanding nodes till the goal is reached

Search strategy
◦ Which node to choose to expand from the
frontier is decided by the strategy

Loopy Path
◦ Travelling to and forth between two states

Redundant Path
◦ Loopy paths are a special case of the more
REDUNDANT PATH general concept of redundant
paths, which exist whenever there is more than
one way to get from one state to another.
Consider the paths

Eg. Arad–Sibiu (140 km long) and Arad–Zerind–


Oradea–Sibiu (297 km long).
Approaches based on the redundancy in
search
Tree Search – Redundant paths – Forgets the Graph Search – Remembers visited nodes –
visited nodes – Additional Space not required Less redundant paths
for remembering the visited nodes
function TREE-SEARCH(problem) function GRAPH-SEARCH(problem)
returns a solution, or failure returns a solution, or failure
initialize the frontier using the initial state of problem initialize the frontier using the initial state of problem
loop do initialize the explored set to be empty
if the frontier is empty then loop do
return failure if the frontier is empty then
choose a leaf node, remove it from frontier return failure
if the node contains a goal state then choose a leaf node, remove it from frontier
return the corresponding solution if the node contains a goal state then
expand the chosen node, return the corresponding solution
adding the resulting nodes to the frontier add the node to the explored set
expand the chosen node,
adding the resulting nodes to the frontier
only if not in the frontier or explored set
Tree search - Rectangular Grid
Rectangular grid - Widely used in
computer games
Each state has four successors, so a search tree of
depth d that includes repeated states has 4d
leaves; but there are only about 2d2 distinct states
within d steps of any given state.
For d = 20, this means about a trillion nodes but
only about 800 distinct states. Thus, following
redundant paths can cause a tractable problem to
become intractable. This is true even for
algorithms that know how to avoid infinite loops.
Graph Search – Avoiding Redundant
Paths
Data structure used to avoid redundant paths
– Explored set
Graph Search – Separation Property
Frontier – Separate the explored and
unexplored sets
Search
Algorithms -
Infrastructure
Structure of a node
State: 203456718
State Parent: Pointer to node 253406718
Action: Up
Parent Path cost: 3 (Parent cost + 1 in this case)
Action
Path cost
Data structures for Frontier and Explored
set
Frontier
◦ Queue – with isEmpty, Push, Pop functions to get a node for
expansion
Explored Set
◦ Hash
◦ Values in canonical form if the state comprises several values
Search Algorithms BREADTH FIRST SEARCH

UNIFORM COST SEARCH


UNINFORMED SEARCH DEPTH FIRST SEARCH
ALGORITHMS
BLIND SEARCH DEPTH LIMITED SEARCH Lesser
USES ONLY THE PROBLEM FORMULATED memory
ITERATIVE DEPTH LIMITED SEARCH
SEARCH
ALGORITHMS BEST FIRST SEARCH / GREEDY SEARCH

A* SEARCH

ITERATIVE DEEPENING A* SEARCH


INFORMED SEARCH
ALGORITHMS RECURSIVE BEST FIRST SEARCH
Lesser
HEURISTIC SEARCH MEMORY BOUNDED A* memory
USES A HEURISTIC FUNCTION
WHICH IS PROBLEM SPECIFIC SIMPLIFIED MEMORY BOUNDED A*
Comparing Algorithms
Completeness: Is the algorithm guaranteed to find a solution when there is one?
Optimality: Does the strategy find the optimal solution, as per the Perfomance measure
of the ?
Time complexity: How long does it take to find a solution?
Space complexity: How much memory is needed to perform the search?
Parameters for Complexity
◦ Maximum number of successors in any state space - Branching factor (b)
◦ Minimum number of steps to reach the goal node from the initial node - Depth (d)
◦ Maximum length of any path in the state space (m)

Time and Space complexity for


Search cost – cost to find a path
Total cost – cost to find a path + cost to execute the path found

You might also like