AI 4 Solving Problem Search Space (1)
AI 4 Solving Problem Search Space (1)
Searching
Outline
Problem-solving
agents
Problem types
Problem formulation
Example problems
Basic search
algorithms
Overview
Recall our previous discussion of reflex agents. Such agents cannot operate
well in environments for which the state to action mapping is too large to store
or would take too long to learn.
The process of looking for a sequence of actions that reaches the goal is
called search. A search algorithm takes a problem as input and returns a
solution in the form of an action sequence.
Well-defined problems and
solutions
A problem can be defined formally by (5) components:
(1) The initial state from which the agent starts.
(2) A description of possible actions available to the agent: ACTIONS(s)
(3) A description of what each action does, i.e. the transition model, specified
by a function RESULT (s,a)=a’.
Together, the initial state, actions and transition model implicitly defined the
state space of the problem – the set of all states reachable from the initial state
by any sequence of actions.
The state space forms a directed network or graph in which the nodes are
states and the edges between nodes are actions. A path in the state space is a
sequence of states connected by a sequence of actions.
Well-defined problems and
solutions
(4) The goal test, which determines whether a given state is a goal state.
Frequently the goal test is intuitive (e.g. check if we arrived at the destination)
– but note that it is also sometimes specified by an abstract property (e.g.
“check mate”).
(5) A path cost function that assigns a numeric cost to each path. The
problem- solving agent chooses a cost function that reflects its own
performance measure.
Commonly (but not always), the cost of a path is additive in terms of the
individual actions along a path. Denote the step cost to take action ‘a’ in state
s, arriving in s’ as: c(s,a,s’).
A key element of successful problem formulation relates to abstraction –
the process of removing (inessential) details from a problem representation.
Example: The 8-
puzzle
the board.
Actions: Add a queen to any empty square.
Transition Model: Returns the board with a queen added to
redundant
In general, apaths.
TREE-SEARCH considers all possible paths 2
1
Tree search algorithms
Basic idea:
Offline, simulated exploration of state space by generating
successors of already-explored states (a.k.a.~expanding
states)
Tree search example
Tree search example
Tree search example
Infrastructure for search algorithms
Recall that queues are characterized by the order in which the store the
inserted nodes:
FIFO (first-in, first-out): pops the oldest element of the queue.
LIFO (last-in, first-out, i.e. a stack) pops the newest element.
PRIORITY QUEUE: pops element with highest “priority.”
Search strategies
A search strategy is defined by picking the order of node
expansion
Strategies are evaluated along the following dimensions:
completeness: does it always find a solution when one exists?
time complexity: number of nodes generated
space complexity: maximum number of nodes in memory
optimality: does it always find a least-cost solution?
Breadth-first search
Uniform-cost search
Depth-first search
Depth-limited search
Iterative deepening search
Breadth-first
search
BFS is a simple strategy in which the root node is expanded
first, then all the successors of the root node are expanded
next, then their successors, etc.
As those nodes are expended, they are dropped from the frontier,
so then the search “backs up” to the next deepest node that still has
unexplored successors.