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
Search
Solution
Execution
GOAL FORMULATION
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.
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 must be quite certain of what is going on.
Control theorists call this an open-loop system, because ignoring the percepts breaks
the loop between agent and environment.
ROMANIAN MAP
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.
5. A path cost function that assigns a numeric cost to each path.
Vacuum World Problem
VACUUM WORLD:
PROBLEM FORMULATION
8-PUZZLE:
PROBLEM FORMULATION
8-PUZZLE:
PROBLEM FORMULATION
SEARCHING FOR SOLUTIONS
A solution is an action sequence, so search algorithms work by considering various
possible action sequences
The possible action sequences starting at the initial state form a search tree with the
initial state at the root; the branches are actions, and the nodes correspond to states
in the state space of the problem.
Expanding the current state is, applying each legal action to the current state,
thereby generating a new set of states
SEARCH TREE
SEARCH TREE
SEARCH STRATEGY
the essence of search—following up one option now and putting the others aside
for later, in case the first choice does not lead to a solution.
The set of all leaf nodes available for expansion at any given point is called the
frontier.
The process of expanding nodes on the frontier continues until either a solution is
found or there are no more states to expand.
Search algorithms all share this basic structure; they vary primarily according to how
they choose which state to expand next —the so-called search strategy.
TREE SEARCH / GRAPH
SEARCH
INFRASTRUCTURE
FOR SEARCH ALGORITHMS
FRONTIER [FRINGE]
The frontier needs to be stored in such a way that the search algorithm can easily choose
the next node to expand according to its preferred strategy. The appropriate data structure
for this is a queue.
• 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 non-decreasing function of the depth of
the node.
• The time complexity would be O(bd+1), The space complexity is O(bd)
• For uniform tree, the total number of nodes generated is
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
140 75 118
374
418
450 455 Drobeta
Bucharest
Bucharest
Bucharest Craiova
486
Drobeta
UNIFORM-COST SEARCH:
ILLUSTRATION
UNIFORM-COST SEARCH:
OPTIMALITY
• Observe that whenever uniform-cost search selects a node n for expansion, the
optimal path to that node has been found.
• Were this not the case, there would have to be another frontier node n’ on
the optimal path from the start node to n, n’ would have lower g-cost than
n and would have been selected first
• 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.
Both versions are nonoptimal. For example, in Figure 3.16, depth first search will explore the
entire left subtree even if node C is a goal node. If node J were also a goal node, then depth-
first search would return it as a solution instead of C, which would be a better solution; hence,
depth-first search is not optimal.
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
• 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.