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

7. Problem solving agents, Search Algorithms

The document outlines the problem-solving process for an agent on a vacation in Romania, focusing on reaching Bucharest from Arad. It details the steps of goal formulation, problem formulation, search, and execution, emphasizing the importance of state space, actions, and search algorithms. Additionally, it discusses strategies for managing redundant paths and measuring problem-solving performance in terms of completeness, cost optimality, and complexity.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

7. Problem solving agents, Search Algorithms

The document outlines the problem-solving process for an agent on a vacation in Romania, focusing on reaching Bucharest from Arad. It details the steps of goal formulation, problem formulation, search, and execution, emphasizing the importance of state space, actions, and search algorithms. Additionally, it discusses strategies for managing redundant paths and measuring problem-solving performance in terms of completeness, cost optimality, and complexity.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Problem-Solving Agents

Touring Vacation Problem: Agent in Romania

● An agent is on a touring vacation in Romania, aiming to:


• Take in the sights
• Improve Romanian language skills
• Enjoy nightlife without hangovers

● The agent starts in Arad and has a nonrefundable ticket to fly


out of Bucharest the following day. The challenge is determining
the optimal path to Bucharest. The environment is fully
observable, deterministic, and known.
Problem-Solving Process
1. Goal Formulation
● The agent adopts the goal of reaching Bucharest. Goals serve to:
• Organize behavior
• Limit objectives
• Narrow down actions to be considered

2. Problem Formulation
● The agent creates an abstract model of the relevant world. Key
considerations include:
• States: Cities in Romania (e.g., Arad, Sibiu, Bucharest)
• Actions: Traveling from one city to an adjacent city
• State Changes: Current city changes based on the travel action
Problem-Solving Process (cont…)
3. Search
● The agent simulates possible sequences of actions to find a
solution (path to Bucharest).
• Solution example: Arad → Sibiu → Fagaras → Bucharest
• If no solution exists, it concludes Bucharest is unreachable.

4. Execution
● The agent executes the actions in the solution. In a fully
deterministic environment, percepts during execution can be
ignored (open-loop system).
Search problems and solutions
● A search problem includes:
• State Space: All possible states of the environment
• Initial State: Starting point (e.g., Arad)
• Goal States: Desired endpoint (e.g., Bucharest)
• Actions: Possible transitions between states
• Example: ACTIONS(Arad) = {ToSibiu, ToTimisoara, ToZerind}
• Transition Model: Defines the result of actions
• Example: RESULT(Arad, ToZerind) = Zerind
• Action Cost Function: Numeric cost for applying an action

● A solution is a path from the initial state to a goal state, with an


optimal solution minimizing total path cost.
Formulating problems

● Our formulation of the problem of getting to Bucharest is a model—an


abstract mathematical description—and not the real thing.

● Abstraction simplifies the problem by:


• Removing irrelevant details (e.g., weather, road conditions)
• Ensuring abstract solutions can be mapped to real-world solutions
• Focusing on high-level actions (e.g., driving between cities)
instead of granular details (e.g., moving the steering wheel)
Formulating problems
Valid Abstraction:
● The abstraction is valid if we can elaborate any abstract solution into
a solution in the more detailed world; a sufficient condition is that for
every detailed state that is “in Arad,” there is a detailed path to some
state that is “in Sibiu,” and so on

Useful Abstraction:
● The abstraction is useful if carrying out each of the actions in the
solution is easier than the original problem; in our case, the action
“drive from Arad to Sibiu” can be carried out without further search or
planning by a driver with average skill.
Search Algorithms
Introduction
● A search algorithm takes a search problem as input and returns a
solution, or an indication of failure.

● We consider algorithms that superimpose a search tree over the


state-space graph, forming various paths from the initial state, trying
to find a path that reaches a goal state.

● Each node in the search tree corresponds to a state in the state space
and the edges in the search tree correspond to actions. The root of
the tree corresponds to the initial state of the problem.
Introduction (cont…)

● The state space describes the (possibly infinite) set of states in


the world, and the actions that allow transitions from one state
to another.

● The search tree describes paths between these states, reaching


towards the goal.

● The search tree may have multiple paths to (and thus multiple
nodes for) any given state, but each node in the tree has a
unique path back to the root (as in all trees).
Partial search trees for finding a route
from Arad to Bucharest
Nodes that have been expanded are lavender with
bold letters. Nodes on the frontier that have been
generated but not yet expanded are in green
The set of states corresponding to these two
types of nodes are said to have been reached
Partial search trees for finding a route
from Arad to Bucharest
• The set of unexpanded nodes are called the frontier of the search tree.

• We say that any state that has had a node generated for it has been reached
(whether or not that node has been expanded).

• Note that the frontier separates two regions of the state-space graph: an
interior region where every state has been expanded, and an exterior region
of states that have not yet been reached.

• Nodes that could be generated next are shown in faint dashed lines. Notice in
the bottom tree there is a cycle from Arad to Sibiu to Arad; that can’t be an
optimal path, so search should not continue from there.
Best-First search
● How do we decide which node from the frontier to expand next? A
very general approach is called best-first search, in which we choose a
node, n, with minimum value of some evaluation function, f (n).
● On each iteration we choose a node on the frontier with minimum f
(n) value, return it if its state is a goal state, and otherwise apply
EXPAND to generate child nodes.
● The algorithm returns either an indication of failure, or a node that
represents a path to a goal.
● By employing different f (n) functions, we get different specific
algorithms,
Search data structures

• Search algorithms require a data structure to keep track of the search


tree.
• A node in the tree has four components:
• node.STATE: State corresponding to the node.
• node.PARENT: Parent node that generated this node.
• node.ACTION: Action applied to parent’s state.
• node.PATH-COST: Total cost from the initial state to this node.
• Following PARENT pointers recovers the states and actions along the
path to the node.
Managing the Frontier
● We need a data structure to store the frontier. The appropriate choice
is a queue of some kind
• Operations on a frontier:
• IS-EMPTY(frontier): Checks if the frontier is empty.
• POP(frontier): Removes and returns the top node.
• TOP(frontier): Returns the top node without removing it.
• ADD(node, frontier): Adds a node to the queue.
• Types of queues:
• Priority Queue: Pops the node with the minimum cost.
• FIFO Queue: First-In-First-Out, used in breadth-first search.
• LIFO Queue: Last-In-First-Out, used in depth-first search.
Redundant Paths in Search

• Repeated states arise from cycles or redundant paths.


• Example: Path Arad → Sibiu → Arad.

• Issues with redundant paths:


• Infinite search trees.
• Inefficient exploration.

• Eliminating redundant paths speeds up search by orders of


magnitude.
Strategies for Reducing Redundant Paths

1. Track Reached States:


1. Best for state spaces with many redundant paths.
2. Uses a lookup table (e.g., hash table).

2. Ignore Redundant Paths:


1. Suitable for problems with unique paths to states.
2. Reduces memory usage.

3. Cycle Detection Only:


1. Eliminates short cycles by checking parent pointers.
2. Reduces memory while handling short-term redundancies.
Measuring Problem-Solving Performance

• Criteria for Evaluation:


• Completeness: Finds a solution if one exists.
• Cost Optimality: Finds the solution with the lowest path cost.
• Time Complexity: Measured by states/actions considered.
• Space Complexity: Memory needed for the search.

• Completeness:
• Ensures all reachable states are explored in finite spaces.
• Requires systematic exploration in infinite spaces.
Understanding Complexity

● Time and space complexity are considered with respect to


some measure of the problem difficulty. In theoretical
computer science, the typical measure is the size of the state-
space graph, |V|+|E|, where
• |V|: Number of vertices (state nodes).
• |E|: Number of edges (state/action pairs).

● This is appropriate when the graph is an explicit data structure,


such as the map of Romania.
Understanding Complexity

● But in many AI problems, the graph is represented only


implicitly by the initial state, actions, and transition model.

● For an implicit state space, complexity can be measured in


terms of
○ d, the depth or number of actions in an optimal solution;
○ m, the maximum number of actions in any path; and
○ b, the branching factor or number of successors of a node that
need to be considered.

You might also like