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

AIT307 AI Unit2 3

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

AIT307 AI Unit2 3

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

Module 2 - PROBLEM-SOLVING AGENTS

AIT 307 - Introduction to Artificial Intelligence


Dr Prem Sankar C
Outline of MODULE 2:

CO1: Explain the fundamental concepts of intelligent systems


and their architecture. (Cognitive Knowledge Level:
Understanding)
● Searching for solutions, CO2: Illustrate uninformed and informed search techniques
● Uninformed search strategies, for problem solving in intelligent systems. (Cognitive
Knowledge Level: Understanding)
● Informed search strategies,
● Heuristic functions
PO1-Engineering Knowledge
PO2 Problem Analysis
PO12 Life long learning

PROBLEM-SOLVING AGENTS
INFORMED (HEURISTIC)
SEARCH -
Informed (Heuristic) Search Strategies

Informed search strategy is one that uses problem-specific knowledge beyond


the definition of the problem itself.

It can find solutions more efficiently than an uninformed strategy.

Informed search strategies, also known as heuristic search, utilize additional


information or heuristics to guide the search process more efficiently than
uninformed search algorithms.

Heuristics estimate the cost of reaching the goal state from a given node, helping
to prioritize the search towards promising paths.
Key Components

Heuristic function (h(n)): Estimates the cost from the


current node (n) to the goal. Heuristic functions are the most
common form in which additional knowledge of the problem is
imparted to the search algorithm.

Evaluation function (f(n)): Combines the cost to reach the


node (g(n)) and the estimated cost to the goal (h(n)).
Priority queue: Stores nodes based on their evaluation
function values.
Types of Informed Search Strategies
Best-First Search
● Selects the node with the lowest estimated cost to the goal (h(n)) for
expansion.
● Doesn't guarantee finding the optimal solution.
A* Search
● Combines the cost to reach a node (g(n)) with the estimated cost to the goal
(h(n)) to form an evaluation function f(n) = g(n) + h(n).
● Selects the node with the lowest f(n) for expansion.
● Guarantees finding the optimal solution if the heuristic is admissible (never
overestimates the true cost).
Informed search strategies significantly improve the efficiency of search
algorithms by leveraging domain-specific knowledge.
BEST-FIRST SEARCH
Best-First Search

Best-First Search is an informed search algorithm that explores the search space
by selecting the node that appears to be closest to the goal state based on an
evaluation function, f(n).
The evaluation function is construed as a cost estimate, so the node with the
lowest evaluation is expanded first.

Key Components
● Heuristic function: Estimates the distance from the current node to the goal.
● Priority queue: Stores nodes based on their estimated distances.

Heuristic functions are the most common form in which additional


knowledge of the problem is imparted to the search algorithm.
How Best-First Search Works
Initialization:
● A priority queue is used to store nodes and their estimated distances to the
goal.
● The starting node is added to the priority queue with its estimated distance.
Exploration:
● The node with the lowest estimated distance is removed from the priority
queue.
● If this node is the goal node, the algorithm terminates and returns the path.
● For each neighbor of the extracted node:
○ Calculate the estimated distance to the goal for the neighbor.
○ Add the neighbor to the priority queue with its estimated distance.
Advantages

● Often more efficient than uninformed search algorithms.


● Can find good solutions relatively quickly.
Disadvantages
● Doesn't guarantee finding the optimal solution.
● The quality of the search depends heavily on the accuracy of the
heuristic function.
The choice of f determines the search strategy.

Most best-first algorithms include as a component of f a heuristic


function, denoted h(n):
h(n) = estimated cost of the cheapest path from the state at node n to
a goal state.

if n is a goal node, then h(n)=0.


For example, in Romania, one might estimate the cost of the
cheapest path from Arad to Bucharest via the straight-line distance
from Arad to Bucharest.

Heuristic functions are the most common form in which additional


knowledge of the problem is imparted to the search algorithm.
Greedy best-first search
Greedy Best-First Search
Greedy Best-First Search is a variant of Best-First Search where the evaluation
function is solely based on the heuristic function (h(n)).

This means it prioritizes the node that appears to be closest to the goal based on the
heuristic estimate, without considering the actual cost to reach that node.

Greedy best-first search tries to expand the node that is closest to


the goal, on the grounds that this is likely to lead to a solution quickly.
It evaluates nodes by using just the heuristic function; that is, f(n) =
h(n).
Eg: finding the shortest path between two cities on a map. A greedy
best-first search would always choose the city that appears closest to
the destination, regardless of the actual distance to get there.
How it Works

Initialization:

● A priority queue is used to store nodes and their estimated distances to the
goal.
● The starting node is added to the priority queue with its estimated distance.
Exploration:
● The node with the lowest estimated distance (based on the heuristic) is
removed from the priority queue.
● If this node is the goal node, the algorithm terminates and returns the path.
● For each neighbor of the extracted node:
○ Calculate the estimated distance to the goal for the neighbor.
○ Add the neighbor to the priority queue with its estimated distance.
Key Characteristics

Efficiency: Often faster than uninformed search algorithms due


to its focus on promising nodes.
Simplicity: Easy to implement.
Non-optimal: Doesn't guarantee finding the optimal solution. Can
get stuck in local optima.
Greedy: Chooses the most promising option at each step without
considering the overall path cost.
Greedy best-first search- Route finding problems in Romania

We use straight line distance heuristic, Hsld


If the goal is Bucharest, we need to know the straight-line distances to Bucharest
hSLD is correlated with actual road distances and is, therefore, a useful heuristic
The first node to be expanded from Arad will be Sibiu because it is
closer to Bucharest than either Zerind or Timisoara. The next node
to be expanded will be Fagaras because it is closest. Fagaras in
turn generates Bucharest, which is the goal.

For this particular problem, greedy best-first search using hSLD


finds a solution without ever expanding a node that is not on the
solution path; hence, its search cost is minimal.

It is not optimal, however: the path via Sibiu and Fagaras to


Bucharest is 32 kilometers longer than the path through Rimnicu
Vilcea and Pitesti. This shows why the algorithm is called
“greedy”—at each step it tries to get as close to the goal as it can.
Greedy best-first tree search is also incomplete even in a finite state space,
much like depth-first search.

Consider the problem of getting from Iasi to Fagaras. The heuristic suggests
that Neamt be expanded first because it is closest to Fagaras, but
it is a dead end.

The worst-case time and space complexity for the tree version is O(b^m)
where m is the maximum depth of the search space.
A* Search
A* Search
A Search* is an informed search algorithm that combines the efficiency of Best-First
Search with the optimality guarantees of Uniform Cost Search (UCS).
It is widely used in pathfinding and other search problems.

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)

Key Components
● Heuristic function (h(n)): Estimates the cost from the current node to the goal.
● Path cost (g(n)): The actual cost to reach the current node from the start.
● Evaluation function (f(n)): The sum of g(n) and h(n) (f(n) = g(n) + h(n)).
How A* Search Works
Initialization:
● A priority queue is used to store nodes and their evaluation function values.
● The starting node is added to the priority queue with an evaluation function value of
0.
Exploration:
● The node with the lowest evaluation function value is removed from the priority
queue.
● If this node is the goal node, the algorithm terminates and returns the path.
● For each neighbor of the extracted node:
○ Calculate the tentative path cost to the neighbor.
○ Calculate the evaluation function value for the neighbor.
○ If the neighbor is not in the priority queue or the tentative path cost is less than
the previous known path cost, update the neighbor's path cost and evaluation
function value, and add it to the priority queue.
Other details

A∗ search is both complete and optimal.

The algorithm is identical to UNIFORM-COST-SEARCH


except that A∗ uses g + h instead of g.
Progress of an A∗ tree search
●Bucharest first appears on the frontier here but it is not selected for expansion
because its f-cost (450) is higher than that of Pitesti (417).
●Another way to say this is that there might be a solution through Pitesti whose
cost is as low as 417, so the algorithm will not settle for a solution that costs
450.
Disadvantages of A* Algorithm
1.Completeness Depends on Heuristic Accuracy: -The completeness of A*
(guaranteeing to find a solution if one exists) depends on the accuracy of the heuristic
function. If the heuristic is not admissible or overly optimistic, it might lead the
algorithm down the wrong path, preventing it from finding the optimal solution.
2.Heuristic Knowledge Requirement: A* requires a good heuristic function to guide the
search effectively. Designing an appropriate heuristic can be challenging and requires
domain-specific knowledge.
3.Memory Usage and Performance: A* can consume a significant amount of memory,
especially in large graphs or grids. The algorithm needs to store and manage the open
set, which can grow substantially, affecting both memory usage and performance.
4.Worst-Case Time Complexity: This can happen when the heuristic is not admissible
or the graph structure causes many unnecessary node expansions.
5.Sensitivity to Graph Structure and Heuristics: A* performance can vary based on the
structure of the graph and the choice of heuristic.
6.Inability to Handle Dynamic Changes in the Graph: A* is designed for static graphs.
If the graph changes dynamically during the search (e.g., due to obstacles moving or
changing weights), A* may need to restart the search or be recalculated, leading to
inefficiency in certain scenarios.
7.Difficulty in Handling High-Dimensional Spaces:
Conditions for Optimality: Admissibility
Understanding Admissibility
For A* search to guarantee finding the optimal solution, the heuristic function used must be
admissible.
An admissible heuristic is one that never overestimates the true cost to reach the goal.

Mathematically, if:
h(n) is the estimated cost from node n to the goal.
h*(n) is the actual cost from node n to the goal.
Then, for an admissible heuristic:
h(n) <= h*(n)
Examples
Admissible heuristics are by nature optimistic because they think the cost of
solving the problem is less than it actually is

Eg, straight-line distance hSLD that we used in getting to Bucharest is n


admissible heuristic
because the shortest path between any two points is a straight line

Straight line cannot be an overestimate


Conditions for optimality: Consistency

A heuristic function is consistent if for every node n and its successor n',
the estimated cost of reaching the goal from n is less than or equal to the
step cost from n to n' plus the estimated cost of reaching the goal from n'.
Mathematically:
● h(n) <= c(n, n') + h(n')
Where:
● h(n) is the estimated cost from node n to the goal.
● c(n, n') is the cost of moving from node n to its successor n'.
● h(n') is the estimated cost from node n' to the goal.
Optimality of A*
the tree-search version of A∗ is optimal if h(n) is admissible, while the
graph-search version is optimal if h(n) is consistent.
A∗ expands no nodes with f(n) > C∗—for example, Timisoara is not expanded in
even though it is a child of the root
the subtree below Timisoara is pruned; because hSLD is admissible, the
algorithm can safely ignore this subtree while still guaranteeing optimality
Pruning eliminates possibilities from consideration without having to examine
them
A∗ is optimally efficient for any given consistent heuristic.
That is, no other optimal algorithm is guaranteed to expand fewer nodes
than A∗
This is because any algorithm that does not expand all nodes with f(n) <
C∗ runs the risk of missing the optimal solution.
Overestimation and
Underestimation in A* Algorithm
Under estimation in A* Algorithm
In the context of A* search, underestimation refers to a heuristic function
that estimates a lower cost to reach the goal than the actual cost. While this
might seem counterintuitive, it's crucial to understand its implication

Overestimation in A* Algorithm
Overestimation in A* search occurs when the heuristic function provides an
estimate of the cost to reach the goal that is greater than the actual cost. In
other words, the heuristic function is inadmissible.
Underestimation in A* Algorithm
Here cost of each arch is 1
Each node has f=g+h
Here initially B has lowest f cost(4) so it will be expanded
next
It has only one successor E its fcost=3+2=5 which is
same as path cost of C
If we resolve this in favour of current path we follow and
choose E.
E’s successor F has cost 6 and now this path is less
attractive and we will go back to C whose cost is 5
Here by underestimating h cost we wasted some effort
Overestimation in A* Algorithm
Again we expand B first then E then F then reach Goal
G with a solution path of length 4
Suppose there is a direct path from D to solution giving
path length of 2
We will never find it
By overestimating h’(D) we make D look so bad
If h’ overestimate h then we cannot guarantee to find
the cheapest path solution unless we expand entire
graph
h’ never over-estimates h then A* is admissible
HEURISTIC FUNCTIONS
Heuristics

● Heuristics are problem-solving techniques or strategies that


use practical and intuitive to find solutions.
● They provide additional knowledge beyond the problem
definition.
● They are often used when finding the exact solution would
be computationally infeasible or excessively
time-consuming
Heuristic Functions

A heuristic function is a function that estimates the cost of reaching the goal
from a particular state in a search algorithm. In other words, it's an educated
guess about the cost of reaching the goal from a given state.
It's essentially a rule of thumb or an educated guess that helps guide the
search process towards promising paths.
Heuristic functions are primarily used in informed search algorithms like:
1. Best-First Search
2. *A Search
The heuristic function is denoted as h(n), where n is a particular state.

It's important to note that a heuristic is an estimate, not an exact value


Key Characteristics

Approximation: Heuristic functions provide an


approximation of the actual cost to reach the goal.
Efficiency: They help to reduce the search space by
prioritizing nodes that are likely to be closer to the goal.
Problem-specific: The design of a heuristic function depends
on the specific problem being solved.
Greedy Best-First Search

In this algorithm, nodes are expanded based solely on their heuristic value. It always
expands the node that appears to be closest to the goal.

Here f(n) = h(n)


A* Search

It combines the cost of getting from the start state to the current state
with the heuristic estimate of the cost to reach the goal from the
current state.
The evaluation function f(n) = g(n) + h(n)
g(n) = the actual cost from the initial state to the current state.
h(n) = the heuristic function estimate
Example: The 8-Puzzle

In the 8-puzzle problem, a common heuristic is the number of misplaced tiles.

This function estimates the minimum number of moves required to reach the goal
state by counting the tiles that are not in their correct positions.
Admissible Heuristics
h1 = the number of misplaced tiles.
For Figure 3.28, all of the eight tiles are out of position, so the start
state would have h1 = 8. h1 is an admissible heuristic because it is
clear that any tile that is out of place must be moved at least once.
• h2 = the sum of the distances of the tiles from their goal positions.
Because tiles cannot move along diagonals, the distance we will
count is the sum of the horizontal and vertical distances. This is
sometimes called the city block distance or Manhattan distance.
h2 is also admissible because all any move can do is move one tile
one step closer to the goal. Tiles 1 to 8 in the start state give a
Manhattan distance of
h2 = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 = 18 .
neither of these overestimates the true solution cost, which is 26.
Heuristic Performance

Experiments on sample problems can determine the number of


nodes searched and CPU time for different strategies.
One other useful measure is effective branching factor: If a
method expands N nodes to find solution of depth d, and a
uniform tree of depth d would require a branching factor of b*
to contain N nodes, the effective branching factor is b*
N = 1 + b* + (b*)2 + ...+ (b*)d
HEURISTIC FUNCTIONS

•8-puzzle search space


Typical solution length: 22 steps
Average branching factor: 3
Exhaustive search: 322=3.1 x 1010
Bound on unique states: 9!/2 = 181,440 distinct reachable states
•15-puzzle is roughly 1013
Experimental Results on 8-puzzle problems
Quality of Heuristics

Since A* expands all nodes whose f value is less than that of an


optimal solution, it is always better to use a heuristic with a higher
value as long as it does not over-estimate.
Therefore h2 is uniformly better than h1 , or h2 dominates h1 .
A heuristic should also be easy to compute, otherwise the
overhead of computing the heuristic could outweigh the time
saved by reducing search (e.g. using full breadth-first search to
estimate distance wouldn’t help).
Properties of Admissibility
Heuristic Functions
Consistency
Admissibility

● heuristic is admissible if it never overestimates the


cost to reach the goal from any given state.
● Formula: h(n) ≤ h*(n)
● where h*(n) is the true cost to reach the goal from
state n.
Consistency

The estimated cost from a current state to the goal is never more than
the cost of getting from the current state to a neighbouring state, plus
the estimated cost from that neighbouring state to the goal.
If h(n) is the estimated cost from state n to the goal, c(n,a,n′) is the actual
cost of getting from n to its neighbour n′ using some action a, and h(n′)
is the estimated cost from n′ to the goal, then the consistency condition
can be written as:
h(n)≤c(n,a,n′)+h(n′)
Applications

● Navigation Systems: Real-time route planning by estimating travel distances and


times.
● Game Playing: Chess and Go, by evaluating board positions to make informed
moves.
● Machine Learning Feature Selection: select the most relevant features to improve
performance.
● Network Routing: Determine the optimal paths for data packets, optimizing
performance and resource usage.
● Scheduling and Timetabling: Allocate resources and time slots to optimize task
sequences and resource utilization.
Any Questions ?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy