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

CS302 Unit1-III

The document discusses different types of problem solving and search algorithms used in artificial intelligence. It defines the components of a problem including the initial state, actions, transition model, goal test, and path costs. It then describes uninformed and informed search approaches. Specific algorithms covered include breadth-first search, depth-first search, and uniform-cost search. Breadth-first search expands nodes by level, depth-first search explores nodes as deep as possible first before backtracking, and uniform-cost search prioritizes nodes with the lowest cumulative path cost. The advantages and disadvantages of each search type are also summarized.

Uploaded by

Prakhar Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
340 views

CS302 Unit1-III

The document discusses different types of problem solving and search algorithms used in artificial intelligence. It defines the components of a problem including the initial state, actions, transition model, goal test, and path costs. It then describes uninformed and informed search approaches. Specific algorithms covered include breadth-first search, depth-first search, and uniform-cost search. Breadth-first search expands nodes by level, depth-first search explores nodes as deep as possible first before backtracking, and uniform-cost search prioritizes nodes with the lowest cumulative path cost. The advantages and disadvantages of each search type are also summarized.

Uploaded by

Prakhar Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

ARTIFICIAL

INTELLIGENCE

UNIT-1
Problem Solving and Search
Problem Solving Agent
• An agent that tries to come up with a sequence of actions that will
bring the environment into a desired state.
Search
• The process of looking for such a sequence, which leads to the
desired known state and found to be best sequence is called search.

A well-defined problem can be described by:


• Initial state
• Operator or successor function - for any state x returns s(x), the set
of states reachable from x with one action
• State space - all states reachable from initial by any sequence of
actions
• Path - sequence through state space
• Path cost - function that assigns a cost to a path. Cost of a path is the
sum of costs of individual actions along the path
• Goal test - test to determine if at goal state
Problem Solving and Search
A problem can be defined formally by five components:
• INITIAL STATE : The initial state that the agent starts in
• ACTIONS: 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.
• TRANSITION MODEL: That represents a description of what each
action does.
• Successor : Any state reachable from a given state by a single action.
• State Space : Initial State + Actions + Transition Model.
• Graph : A directed Graph in which the nodes are states and the links
between nodes are actions.
• GOAL TEST : Determines whether a given state is a goal state or not.
• PATH COST AND STEP COST
• Path Cost : Its a function that assigns a numeric cost to each path.
The problem solving agent chooses a cost function that reflects its
own performance measure.
• Step Cost : Taking step ‘a’ in state ‘s’ to reach state ‘s1’. The function
can be denoted by C(s, a, s1).
Searching for Solution
• A search tree is formed for solution. The root is search node
which is the initial state. We test for goal state. The process
involve testing and expanding the nodes in the tree.
A node in tree has five components:
State – The state in the state space to which the node
corresponds.
Parent Node – The node in the search tree that generated this
node.
Action- The action that was applied to the parent to generate
the node.
Path Cost- The cost denoted by g(n), from initial to current state.
Depth – The number of steps along the path from initial node.
Search Types:-
BASIS FOR UNINFORMED
INFORMED SEARCH
COMPARISON SEARCH
Basic  Uses knowledge to No use of knowledge
find the steps to the
solution.

Efficiency Highly efficient as it Efficiency is


consumes less time mediatory
and cost.

Cost Low Comparatively high

Performance Finds solution more Speed is slower than


quickly informed search

Algorithms Heuristic depth first Depth-first search,


and breadth-first breadth-first search
search, and A* search and lowest cost first
search
Breadth-First Search
• Breadth First Search (BFS) searches breadth-wise in the problem
space. Breadth-First search is like traversing a tree where each node
is a state which may a be a potential candidate for solution. It
expands nodes from the root of the tree and then generates one
level of the tree at a time until a solution is found. It is very easily
implemented by maintaining a queue of nodes.
Breadth-First Search
ALGORITHM: BREADTH-FIRST SEARCH
1. Create a variable called NODE-LIST and set it to initial state
2. Until a goal state is found or NODE-LIST is empty do
a. Remove the first element from NODE-LIST and call it E.
If NODE-LIST was empty, quit
b. For each way that each rule can match the state described
in E do:
i. Apply the rule to generate a new state
ii. If the new state is a goal state, quit and return this state
iii. Otherwise, add the new state to the end of NODE-LIST
 
ADVANTAGES OF BREADTH-FIRST SEARCH
• Breadth first search will never get trapped exploring the
useless path forever.
• If there is a solution, BFS will definitely find it out.
• If there is more than one solution then BFS can find the
minimal one that requires less number of steps.

DISADVANTAGES OF BREADTH-FIRST SEARCH


• The main drawback of Breadth first search is its memory
requirement. It requires lots of memory since each level of the
tree must be saved into memory to expand the next level.
• BFS needs lots of time if the solution is far away from the
root node.
Depth-First Search
• Depth-first search (DFS) is an algorithm for traversing or
searching tree or graph data structures. The algorithm starts at
the root node (selecting some arbitrary node as the root node
in the case of a graph) and explores as far as possible along
each branch before backtracking. DFS uses a stack data
structure for its implementation.

ALGORITHM: DEPTH FIRST SEARCH


1. If the initial state is a goal state, quit and return success
2. Otherwise, do the following until success or failure is signaled:
a) Generate a successor, E, of initial state. If there are no more
successors, signal failure.
b) Call Depth-First Search, with E as the initial state
c) If success is returned, signal success. Otherwise continue in
this loop.
Depth-First Search

• It will start searching from root node S, and traverse A, then B,


then D and E, after traversing E, it will backtrack the tree as E
has no other successor and still goal node is not found. After
backtracking it will traverse node C and then G, and here it will
terminate as it found goal node.
Depth-First Search
 
ADVANTAGES
• DFS requires less memory since only the nodes on the current
path are stored.
• It takes less time to reach to the goal node than BFS algorithm
(if it traverses in the right path).

DISADVANTAGES
• There is the possibility that many states keep re-occurring,
and there is no guarantee of finding the solution.
• And there is no guarantee to find a minimal solution, if more
than one solution exists.
• DFS algorithm goes for deep down searching and sometime it
may go to the infinite loop.
Uniformed Cost Search
• Uniform-cost search is a searching algorithm used for
traversing a weighted tree or graph. This algorithm comes into
play when a different cost is available for each edge. The
primary goal of the uniform-cost search is to find a path to the
goal node which has the lowest cumulative cost. Uniform-cost
search expands nodes according to their path costs form the
root node. It can be used to solve any graph/tree where the
optimal cost is in demand. A uniform-cost search algorithm is
implemented by the priority queue. It gives maximum priority
to the lowest cumulative cost. Uniform cost search is
equivalent to BFS algorithm if the path cost of all edges is the
same.
EXAMPLE
 
Uniformed Cost Search
Advantages:
Uniform cost search is optimal because at every state
the path with the least cost is chosen.

Disadvantages:
It does not care about the number of steps involve in
searching and only concerned about path cost. Due to
which this algorithm may be stuck in an infinite loop.
Thank you

You might also like