AI Lecture 03 (Uninformed Search)
AI Lecture 03 (Uninformed Search)
Uninformed Search
Course Code: CSC4226 Course Title: Artificial Intelligence and Expert System
1. Problem-Solving Agents
2. Example Problems
Goal Formulation
Problem
Formulation
Environment
examining future
actions
Formulate, Search,
Execution
Open Loop System
Goals help organize behavior by limiting the objectives
that the agent is trying to achieve and hence the actions it
needs to consider.
Goal formulation, based on the current situation and the
agent’s performance measure, is the first step in problem
solving
Goal: A set of world states—exactly those states in which
the goal is satisfied.
The agent’s task is to find out
how to act, now and in the future, so that it reaches a goal state.
PROBLEM FORMULATION:
BASED ON ENVIRONMENT
Problem formulation is the process of deciding what actions and states to consider,
given a goal.
In an Unknown environment the agent will not know which of its possible actions is
best, because it does not yet know enough about the state that results from taking
each action.
Solution is the sequence of actions that takes any agent to the goal state, exactly
those state the agent is satisfied.
A search algorithm takes a problem as input and returns a solution in the form of an
action sequence.
While the agent is executing the solution sequence it ignores its percepts when
choosing an action because it knows in advance what they will be. An agent that
carries out its plans with its eyes closed.
Control theorists call this an open-loop system, because ignoring the percepts breaks
the loop between agent and environment.
WELL-DEFINED PROBLEMS
A problem can be defined formally by five components:
1. The initial state that the agent starts in. For example, the initial state for our
agent in Romania might be described as In(Arad).
2. A description of the possible actions available to the agent. Given a particular
state s, ACTIONS(s) returns the set of actions that can be executed in s. We say that
each of these actions is applicable in s. For example, from the state In(Arad), the
applicable actions are {Go(Sibiu), Go(Timisoara), Go(Zerind)}.
3. A description of what each action does; the formal name for this is the
transition model, specified by a function RESULT(s, a) that returns the state that
results from doing action a in state s. We also use the term successor to refer to
any state reachable from a given state by a single action.2 For example, we have
RESULT(In(Arad),Go(Zerind)) = In(Zerind) .
4. The goal test, which determines whether a given state is a goal state.
Queues are characterized by the order in which they store the inserted nodes.
Three common variants are -
1. the first-in, first-out For FIFO queue, which pops the oldest element of the
queue;
2. the last-in, first-out or LIFO queue (also known as a stack), which pops the
newest element of the queue; and
3. the priority queue,
MEASURING PROBLEM-SOLVING
PERFORMANCE
SEARCH ALGORITHMS
UNINFORMED
SEARCH STRATEGIES
BREADTH-FIRST SEARCH
• Breadth-first search 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, and so on.
• In general, all the nodes are expanded at a given depth in the search tree before any
nodes at the next level are expanded.
• Breadth-first search is an instance of the general graph-search algorithm (Figure 3.7) in
which the shallowest unexpanded node is chosen for expansion.
• This is achieved very simply by using a FIFO queue for the frontier.
• Thus, new nodes (which are always deeper than their parents) go to the back of the
queue, and old nodes, which are shallower than the new nodes, get expanded first.
• The goal test is applied to each node when it is generated rather than when it is
selected for expansion.
• Following the general template for graph search, discards any new path to a state
already in the frontier or explored set
BREADTH-FIRST SEARCH:
PSEUDOCODE
BREADTH-FIRST SEARCH:
FOUR CRITERIA
• complete—if the shallowest goal node is at some finite depth d, breadth-first search will
eventually find it after generating all shallower nodes.
• Breadth-first search is optimal if the path cost is a nondecreasing function of the depth of
the node.
or uniform tree, the total number of nodes generated is
The time complexity would be O(bd+1)
The space complexity is O(bd)
BREADTH-FIRST SEARCH:
MEMORY REQUIREMENTS
UNIFORM-COST SEARCH
• Instead of expanding the shallowest node, uniform-cost search
expands the node n with the lowest path cost g(n).
• This is done by storing the frontier as a priority queue ordered by g
• Then, because step costs are nonnegative, paths never get shorter as nodes
are added
• Instead, let C* be the cost of the optimal solution, and assume that every
action costs at least ε .
The search proceeds immediately to the deepest level of the search tree, where
the nodes have no successors
As those nodes are expanded, they are dropped from the frontier, so then the
search “backs up” to the next deepest node that still has unexplored successors.
A depth-first tree search, may generate all of the O(bm) nodes in the search tree, where m is
the maximum depth of any node; this can be much greater than the size of the state space.
For a state space with branching factor b and maximum depth m, depth-first search requires
storage of only O(bm) nodes.
DFS v/s BFS
DFS v/s BFS
DEPTH-LIMITED SEARCH
1. Like depth-first search, its memory requirements are modest: O(bd) to be precise.
2. Like breadth-first search, it is complete when the branching factor is finite and optimal
when the path cost is a nondecreasing function of the depth of the node
ITERATIVE DEEPENING
DEPTH-FIRST SEARCH TREE
IDP: COMPLEXITY
• Iterative deepening search may seem wasteful because states are generated
multiple times. It turns out this is not too costly.
• The reason is that in a search tree with the same (or nearly the same) branching
factor at each level, most of the nodes are in the bottom level, so it does not
matter much that the upper levels are generated multiple times.
• In an iterative deepening search, the nodes on the bottom level (depth d) are
generated once, those on the next-to-bottom level are generated twice, and so
on, up to the children of the root, which are generated d times.