0% found this document useful (0 votes)
13 views42 pages

Ch-3 - AI Problem Solving by Searching

Chapter Three discusses problem-solving agents in AI, focusing on search strategies and terminologies essential for solving search problems. It outlines the components of a search problem, including search space, start state, and goal test, and differentiates between uninformed and informed search strategies. The chapter emphasizes the importance of evaluating search algorithms based on completeness, optimality, and time and space complexity.

Uploaded by

sultangemeda258
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)
13 views42 pages

Ch-3 - AI Problem Solving by Searching

Chapter Three discusses problem-solving agents in AI, focusing on search strategies and terminologies essential for solving search problems. It outlines the components of a search problem, including search space, start state, and goal test, and differentiates between uninformed and informed search strategies. The chapter emphasizes the importance of evaluating search algorithms based on completeness, optimality, and time and space complexity.

Uploaded by

sultangemeda258
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/ 42

Chapter Three:

Problem Solving Agents (Goal Based)


Outlines:
• Problem Solving by Searching
•What is search and terminologies?
•Search Strategies
•Unformed Search Strategies
•Informed Search Strategies
• Local Search Strategies

AI ch3-4 compiled by MT 1
What is search and terminologies?

Searching is a step by step procedure to solve a search-


problem in a given search space.
A search problem can have three main factors:
• Search Space: Search space represents a set of possible
solutions, which a system may have.
• Start State: It is a state from where agent begins the
search.
• Goal test: It is a function which observe the current
state and returns whether the goal state is
• achieved or not.

AI ch3-4 compiled by MT 2
Searching Terminologies
• Search tree: A tree representation of search problem is called
Search tree. The root of the search tree is the root node which is
corresponding to the initial state.
• Actions: It gives the description of all the available actions to the
agent.
• Transition model: A description of what each action do, can be
represented as a transition model.
• Path Cost: It is a function which assigns a numeric cost to each path.
• Solution: It is an action sequence which leads from the start node to
the goal node.
• Optimal Solution: If a solution has the lowest cost among all
solutions

AI ch3-4 compiled by MT 3
Search / Problem Solving

• A problem consists of: the initial state, a set of operators, a


goal test function, and a path cost function.
• The environment of the problem is represented by a state
space.
• A single general search algorithm can be used to solve any
problem.
• Search algorithms are judged on completeness, optimality, time
complexity and space complexity.
• Complexity depends on b, the branching factor; and d, the
depth of the shallowest solution

AI ch3-4 compiled by MT 4
Cont…

• The simplest agents discussed in previous chapter were


the reflex agents, which base their actions on a direct
mapping from states to actions.
• Such agents cannot operate well in environments for
which this mapping would be too large to store and
would take too long to learn.
• Goal-based agents, on the other hand, consider future
actions and the desirability of their outcomes.
• This chapter describes one kind of goal-based agent
called a problem-solving agent.
• Intelligent agents are supposed to maximize their
performance measure.
• As we mentioned earlier, achieving this is sometimes
simplified if the agent can adopt a goal and aim at
satisfying it. AI ch3-4 compiled by MT 5
Cont…
• The basic algorithm for problem – solving have 3
phases.
• Formulate the problem
• Search for a solution, and
• Execute the solution.
• State space is important in solving problems.
• It is the set of all possible states that the agent can be
in.
• A limited set (possible one) can be the goal.

AI ch3-4 compiled by MT 6
Cont…
Problem Types
• Based on the environment types the problem type can
be different type.

Environment Type Problem Type


Deterministic, fully-observable Single-state problem
Non-observable, known state space Sensorless/conformant problem
Nondeterministic and/or partially-observable Contingency problem
Partially observable, unknown state space Exploration problem
AI ch3-4 compiled by MT 7
Problem Solving Agent
Goal Formulation
• based on the current situation and the agent’s
performance measure, goal formulation is the first step in
problem solving.
• Goals help organize behavior by limiting the objectives
that the agent is trying to achieve and hence the actions it
needs to consider.
• a goal is 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.
• Before it can do this, it needs to decide what sorts of
actions and states it should consider.
AI ch3-4 compiled by MT 8
Cont…
Problem Formulation:
• Problem formulation is the process of deciding what actions and states to
consider, given a goal.
Search:
• Is the process of looking for a sequence of actions that reaches the goal i
Solution:
• A search algorithm takes a problem as input and returns a solution in the
form of an action sequence.
Execution Phase:
• Once a solution is found, the actions it recommends can be carried out.
• Thus, we have a simple “formulate, search, execute” design for the
agent.
• After formulating a goal and a problem to solve, the agent calls a search
procedure to solve it.
• Once the solution has been executed, the agent will formulate a new goal.
AI ch3-4 compiled by MT 9
Well-defined Problems solving in AI:
A problem can be defined formally the components:
1. Initial State:
• is states that the agent starting point of the problem.
2. Goal state :
• The desired ourcome or solution to the problem.
3. State space:
-The set of all possible state that can be reached
-4. Action:
-The set of all possible operations that cen be performed in each
states
-5. Solution:
-- A sequence of actions that leads from intial state to goal state.

. AI ch3-4 compiled by MT 10
Transition Model
• 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
• State Space
• Together, the initial state, actions, and transition model implicitly
define the state space of the problem—the set of all states
reachable from the initial state by any sequence of actions.
– Graph
• The state space forms a directed network or graph in which the
nodes are states and the links between nodes are actions.
– Path
• A path in the state space is a sequence of states connected by a
sequence of actions.
AI ch3-4 compiled by MT 11
Goal Test
• The goal test, which determines whether a given
state is a goal state.
– Sometimes there is an explicit set of possible goal states,
and the test simply checks whether the given state is one
of them.
Path Cost
• 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.
• The cost of a path can be described as the sum of the
costs of the individual actions along the path.
AI ch3-4 compiled by MT 12
Example Problems
• A toy problem
– is intended to illustrate or exercise various problem-solving
methods.
– It can be given a concise, exact description and hence is
usable by different researchers to compare the performance
of algorithms.
– vacuum world, 8-puzzle, 8-queens problem etc.
• A real-world problem
– is one whose solutions people actually care about. Such
problems tend not to have a single agreed-upon description,
but we can give the general flavor of their formulations.
– route-finding problem, Touring problems, traveling
salesperson problem, VLSI layout, Robot navigation,
Automatic assembly sequencing, protein design etc.
AI ch3-4 compiled by MT 13
Cont...

There are different types of search strategy.

One thing common to all this strategies, they can assess
against a certain criteria:

Completeness : find a solution if there is one

Optimality: find the least-cost solution

Time complexity: big-O complexity of the algorithm
regarding the number of nodes generated.

Space complexity: big-O complexity of the algorithm
regarding memory used.

AI ch3-4 compiled by MT 14
Measuring Problem-solving Performance
• We can evaluate an algorithm’s performance in four
ways:
– Completeness: Is the algorithm guaranteed to find a
solution when there is one?
– Optimality: Does the strategy find the optimal solution?
– Time complexity: How long does it take to find a
solution?
– Space complexity: How much memory is needed to
perform the search?
• Complexity is expressed in terms of three quantities:
– b, the branching factor or maximum number of
successors of any node;
– d, the depth of the shallowest goal node (i.e., the number
of steps along the path from the root); and
AI ch3-4 compiled by MT 15
Types of Search Strategies(Algorithms)
There are two types of search strategies:
1. Uninformed Search (Blind Search).
• Algorithms and strategies have no additional information about states beyond that
provided in the problem definition.
• All they can do is generate successors and distinguish a goal state from a non-goal
state.
• All search strategies are distinguished by the order in which nodes are
expanded. The uninformed search does not contain any domain
knowledge such as closeness, the location of the goal. It is also called level
order traversal.
• It operates in a brute-force way as it only includes information about how
to traverse the tree and how to identify leaf and goal nodes.
• Uninformed search applies a way in which search tree is searched without
any information about the search space like initial state operators and test
for the goal, so it is also called blind search.
• Eg. Breadth-first search, Uniform-cost search, Depth-first search,
Depth-limited search, Iterative deepening depth-first search, Bidirectional
search AI ch3-4 compiled by MT 16

2. Informed Search (Heuristic Search)
– Strategies that know whether one non-goal state is
“more promising” than another are called informed
search or heuristic search strategies.
– can do quite well given some guidance on where to
look for solutions.
– E.g. Greedy best-first search, A* search, Memory-
bounded heuristic search.

AI ch3-4 compiled by MT 17
1. Breadth-First Search(BFS)
• BFS algorithm starts searching from the root node of
the tree and expands all successor node at the current
level before moving on to nodes of next depth level.
• It searches breadth wise in a tree or graph, so it is
called breadth-first search.
• Breadth-first search implemented using FIFO queue
data structure.
• 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 in which the shallowest unexpanded
node is chosen for expansion.
AI ch3-4 compiled by MT 18
Breadth-First Search:

• Breadth-first search expands the shallowest nodes in the search tree first. It
is complete, optimal for unit-cost operators, and has time and space
complexity of O(bd).
• It has two factors of time-complexity and space- complexity have to be
considered here also. Breadth-first search, being a brute search generates all
the nodes for identifying the goal. The amount of time taken for generating
these node is prepositional to the depth “d “ and branching factor “b “ .
Unlike depth-first search wherein the search procedure has to remember only
the paths it has generated, breath-first search procedure has to remember
every node it has generated.
Here searching progresses level by level, unlike depth-first search, this goes
deep into the tree.

AI ch3-4 compiled by MT 19
BFS
• bfs

AI ch3-4 compiled by MT 20
• How does breadth-first search rate according
to the four criteria from the previous section?
– it is complete
– is optimal
– space complexity is O(bd)
– time complexity is O(bd)

AI ch3-4 compiled by MT 21
2, Depth-first Search(DFS)
• Depth-first search is a recursive algorithm for traversing a tree or
graph data structure. It is called the depth-first search because it
starts from the root node and follows each path to its greatest
depth node before moving to the next path.
• DFS uses a stack data structure for its implementation.
• The process of the DFS algorithm is similar to the BFS algorithm.
Depth-first search always expands the deepest node in the current
frontier of the search tree where the nodes have no successors.
• Whereas breadth-first-search uses a FIFO queue, depth-first search
uses a LIFO queue.
• A variant of depth-first search called backtracking search uses still
less memory.
• The depth-first search algorithm is an instance of the graph-search
algorithm.
• Is explore as far down a branch as possible before backtracking and
explore other branches. AI ch3-4 compiled by MT 22
Depth-First Search:

• This is a very simple type of brute-force search technique.


• The search begins by expanding the initial node, i.e., by using an
operator, generate all successors of the initial node and test them.
• It expands the deepest node in the search tree first. It is neither
complete nor optimal, and has time complexity of O(bm) and
space complexity of O(bm), where m is the maximum depth.

• This algorithm finds whether the goal can be reached or not.


• The important factors to be considered in any searching
procedure are the time- complexity and space-complexity.

AI ch3-4 compiled by MT 23
DFS

AI ch3-4 compiled by MT 24
Cont…
• Completeness: depth-first search is not complete.
• Optimal: depth-first search is not optimal.
• Space complexity: For a state space with
branching factor b and maximum depth m, depth-
first search requires storage of only O(bm) nodes.
(advantage over breadth-first search).
• Time complexity: 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 and
b is branching factor.

AI ch3-4 compiled by MT 25
3, Depth limited search

• A depth-limited search algorithm is similar to


depth-first search with a predetermined limit.
Depth limited search can solve the drawback
of the infinite path in the Depth-first search.
• In this algorithm, the node at the depth limit
will treat as it has no successor nodes further.

AI ch3-4 compiled by MT 26
Cont…
Depth-limited search can be terminated with two Conditions of
failure:
a. Standard failure value: It indicates that problem does not have
any solution.
b. Cutoff failure value: It defines no solution for the problem
within a given depth limit.
• Advantages:
– Depth-limited search is Memory efficient.
• Disadvantages:
– Depth-limited search also has a disadvantage of incompleteness.
– It may not be optimal if the problem has more than one solution

AI ch3-4 compiled by MT 27
Find the path to get the goal ‘J‘ if in depth limit is 2

AI ch3-4 compiled by MT 28
4, Uniform 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 path 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.

AI ch3-4 compiled by MT 29
Find the goal node ‗’G‘ for the following search tree

AI ch3-4 compiled by MT 30
5, Iterative Deeping DFS

• It is a combining the benefit of DFS and BFS algorithms by iteratively


increasing the depth limit. This search algorithm finds out the best depth
limit and does it by gradually increasing the limit until a goal is found.
• This algorithm performs depth-first search up to a certain "depth limit", and it
keeps increasing the depth limit after each iteration until the goal node is
found.
• This Search algorithm combines the benefits of Breadth-first search's fast
search and depth-first search's memory efficiency.
• The iterative search algorithm is useful uninformed search when search space
is large, and depth of goal node is unknown.
• It is complete; optimal for unit-cost operators, and has time complexity of
O(bd) and space complexity of O(bd).
• Preferred method in large search spaces when depth of solution is not
known.

AI ch3-4 compiled by MT 31
• Solution
.
1'st Iteration---- > A
2'nd Iteration--- > A, B, C
3'rd Iteration ----- >A, B, D, E, C, F, G
In the third iteration, the algorithm will find the goal node.

AI ch3-4 compiled by MT 32
6. Bidirectional search

• Bidirectional search algorithm runs two simultaneous


searches, one form initial state called as forward-search
and other from goal node called as backward-search, to
find the goal node.
• Bidirectional search replaces one single search graph with
two small sub-graphs in which one starts the search from
an initial vertex and other starts from goal vertex.
• The search stops when these two graphs intersect each
other. It can use search techniques such as BFS, DFS, DLS,
etc.

AI ch3-4 compiled by MT 33
Find the path to get the goal node ‗16‘

AI ch3-4 compiled by MT 34
Comparing Uninformed Search Strategies

AI ch3-4 compiled by MT 35
Fig. 3.6. Comparison of uninformed search strategies
B, Informed Search Strategies

• It uses domain knowledge and additional information.


• In an informed search, problem information is available which can
guide the search.
• It guide the search process toward the goal moreefficiently and find a
solution than an uninformed search strategy.
• Informed search is also called a Heuristic search. A heuristic is a way
which might not always be guaranteed for best solutions but
guaranteed to find a good solution in reasonable time.
• Informed search can solve much complex problem which could not
be solved in another way.
• Eg: gready best-first search, A* search, Hill-climbing search and Beam
search

AI ch3-4 compiled by MT 36
1, Gready Best-first search

• Greedy best-first search algorithm always selects the


path /node which appears closest to the goal based
on heuristic function.
• It is the combination of depth-first search and
breadth-first search algorithms. It uses the heuristic
function and search.
• Best-first search allows us to take the advantages of
both algorithms. With the help of best-first search, at
each step, we can choose the most promising node.

AI ch3-4 compiled by MT 37
2, A* Search
• The most widely known form of best-first search is called
A* search (pronounced “A-star search”).
• It evaluates nodes by combining g(n), the cost to reach
the node, and h(n), the cost to get from the node to the
goal: f(n)=g(n)+h(n) .
• Since g(n) gives the path cost from the start node to node
n, and h(n) is the estimated cost of the cheapest path
from n to the goal, we have f(n)= estimated cost of the
cheapest solution through n.
• Thus, if we are trying to find the cheapest solution, a
reasonable thing to try first is the node with the lowest
value of g(n)+h(n).
• It turns out that this strategy is more than just
reasonable: provided that the heuristic function h(n)
AI ch3-4 compiled by MT 38
satisfies certain conditions.
.

• Best-first search expands the minimum cost


node first. The following search strategies are
variants of best-first search.
• Greedy search minimizes the estimated cost to
reach the goal. Search time is usually reduced,
but optimality and completeness are lost.

AI ch3-4 compiled by MT 39
A* search
• It minimizes the current cost plus the estimated
cost to the goal. If the latter is never
overestimated (admissible heuristic) and we
handle repeated states, A* is complete,
• optimal, and optimally efficient among all optimal
search algorithms for a given admissible heuristic.
Its space complexity is still exponential in problem
size.

AI ch3-4 compiled by MT 40
Application of Problem solving and search Algorithms
• Problem solving and search Algorithms have a
wide range of Application in AI includes:
 Game playing; chess, Go
 Path-finding: in navigation systems
 Puzzle solving
 Robotics
 Scheduling and planning

AI ch3-4 compiled by MT 41
.

END OF CHAPTER 3

AI ch3-4 compiled by MT 42

You might also like