Professional Documents
Culture Documents
The path in the 2nd depth level is selected, (i.e) SBG{or) SCG.
Algorithm
Note: if all step costs are equal , Uniform cost search is similar to
breadth first search
Difference between BFS and Uniform Cost Search
BFS Uniform cost search
Follows FIFO Follows Priority Queue
Goal test is applied to the node when it Goal test is applied to the node when it
is first generated is selected for expansion
No such test Test is added to find better path to a
node
Uniform-cost search does not care about depth of a path but only about their
total cost.
Performance Measure
1. Complete : Yes( when the cost is positive number)
2. Optimal: yes
3. Time complexity := O(b [1+C*/e])
4. Space Complexity : O(b [1+C*/e])
Solution:
Algorithm
Performance measure
1. Completeness: No
2. Optimal : No
3. Time complexity: O(bl).
4. Space complexity: O(bl).
5. Iterative deepening search
Definition: Iterative deepening search is a strategy that sidesteps the issue
of choosing the best depth limit by trying all possible depth limits.
Combines the benefits of DFS and BFS
Like DFS=> Memory requirements are modest
Like BFS=> explores a complete layer of new nodes at each iteration before
going to the next layer
In each step, it gradually increase the depth limit until the goal is found
Example: Route finding problem
Algorithm
Performance measure
1. Completeness: Yes
2. Optimal : Yes
3. Time complexity: O(bd).
4. Space complexity: O(bd).
If more than one goal state 'exists then explicit, multiple state search is
required
Comparing uninformed search strategies
- Example
Problem: Route finding from A to B
Solution:
For each node the evaluation function is f(n)=h(n)
Apply the evaluation function h(n) to find a path from A to B
From F, goal state B is reached. Therefore the path from A to Busing greedy
search is A - S - F - B = 450 (i.e) (140 + 99 + 211)
Performance measure
1. Completeness: No
2. Optimal : No
m
3. Time complexity: O(b )
m
4. Space complexity: O(b ).
A* Algorithm
Solution:
From the given graph and estimated cost, the goal state is identified as B
from A
Apply the evaluation function f(n) = g(n) +h(n) to find a path from A to B
g(n)=g(p)+c(p,n)
From P, goal state B is reached. Therefore the path from A to B using A* search is
A – S - R - P -B : 418 (ie) {140 + 80 + 97 + 101), that the path cost is less
than Greedy search path cost.
Performance Measure of A* Algorithm
Complete: yes
Optimal: Yes
Optimality of A*
- conditions for optimality: Admissiblity and Consistency
1. Admissiblity [Admissible heurisitc/optimistic heuristic]
is the one that never overestimates the actual cost to reach the goal
h(n) ≤ c(n) where ,h(n) => estimated cost to reach the goal from n
c(n) /h*(n) => actual cost to reach the goal from b
2. Consistency/Monotonicity
A heuristic h(n) is consistent if, for evey node n and every successor n’ of
n, the estimated cost of reaching the goal from n [h(n)] is ≤ step cost of
getting to n’ [c(n,n’)] plus the estimated cost to reach the goal from n’
[h(n’)]
i.e., h(n) ≤ c(n,n') + h(n')
Time complexity: Time complexity depends on the heuristic function and the
admissible heuristic value
Space complexity: remains in the exponential order, because A* keeps all
generated nodes in memory. Therefore A* usually runs our of space before it
runs out of time
Memory bounded heuristic search
- Reduces memory requirements of A*
- Different types of Memory bounded heuristic search are
Because they forget most of what they have done, both algorithms may
end up re-expanding the same states many times over.
The values at the nodes are given as per the A* function i.e. g+h=f
From the Figure the goal states are D,F,J,I because the h value of these nodes
are zero (marked as a square)
Available memory - 3 nodes of storage space.
A complete local search algorithm always finds a goal if one exists, an optimal
algorithm always finds a global minimum/maximum.
Application of Local Search
1. Job Scheduling
2. Vehicle Routing
3. Telecommunication Network Optimization
Local search algorithms are
does not maintain a search tree, so the current node data structure need only
to record the state and its objective function value(i.e., f(n)
At each step the current node is replaced by the best neighbor
Algorithm
MAX Version
function HILL-CLIMBING(problem) returns a state that is a local maximum
current <- MAKE-NODE(INITIAL-STATE[problem])
loop do
neighbor <- a highest-valued successor of current
if VALUE[neighbor] ≤ VALUE[current] then return STATE[current]
current <- neighbor
MIN Version
function HILL-CLIMBING(problem) returns a state that is a local maximum
current <- MAKE-NODE(INITIAL-STATE[problem])
loop do
neighbor <- a lowest-valued successor of current
if VALUE[neighbor] ≥ VALUE[current] then return STATE[current]
current <- neighbor
Example
A state that is better(higher) than each of its neighboring states, but not
better(lower) than some other states far away
Example: consider the following tree. ‘a’ is an initial state and ‘h’ and ‘k’
are final states. The number near the states is the heuristic value
Example
3. Ridges
A special kind of local maxima
Defn-1: An area of the search space which is higher than the surrounding
area and that itself has a slope
Defn-2: is a sequence of local maxima
To overcome ridges explore in several directions to find out the correct
path
Variants of hill-climbing
the probability of selection can vary with the steepness of the uphill move.
Better than steepest ascent
2. First-choice hill climbing/Simple hill climbing => choose first
successor that is better than current state
implements stochastic hill climbing by generating successors randomly
until one is generated that is better than the current state
3. Random-restart hill climbing => try with different initial states if
chosen initial state fails
based on try and try strategy
It conducts a series of hill-climbing searches from randomly generated
initial state, stopping when a goal is found. (Or) generates different
initial state until it finds a goal state.
2. Simulated annealing
Annealing: is the process of controlling cooling
Note: the chance of accepting worst solution is done only when the
temperature is high
Physical annealing is simulated=> simulated annealing
Simulated Annealing
Variants of hill climbing in which at the beginning of the process Some downhill
moves can be made=> helps to avoid local maxima
Used when the number of moves from a given state is large
Algorithm
function beam-search(problem, k) returns a solution state
start with k randomly generated states
loop
generate all successors of all k states
if any of them is a solution then return it
else select the k best successors
local beam search suffer from a lack of diversity among K states=> they
quickly become concentrated in a small region of the state space, making the
search little more than an expensive version of hill climbing
variant called stochastic beam search
Instead of choosing the best k successors, stochastic beam search
chooses k successors at random, with the probability of choosing a given
Algorithm
f(n) for 24748552 : Q1:6 Q2:5 Q3:4 Q4:4 Q5:3 Q6:1 Q7:0 Q8:0 24
The values of the four states are 24, 23, 20, and 11.
The probability of being chosen for reproduction is directly proportional to the
fitness score, which is denoted as percentage.
24 / (24+23+20+11) = 31%
23 / (24+23+20+11) = 29%
20 / (24+23+20+11) = 26%
11 / (24+23+20+11) = 14%
4. Selecting parents for mating in accordance to their fitness
There are various methods for selection
E.g., Roulette Wheel, Tournament, Rank etc.,
5. Crossover of parents to produce new generation
Types of crossover are One Point Crossover, Multi Point Crossover Uniform
Crossover, etc. In this example one point crossover is
used
a crossover point is randomly chosen. For the first pair
the crossover point is chosen after 3 digits and after 5
digits for the second pair.
In the picture the crossover is specified by lines
6. Mutation of new generation to bring diversity
One digit was mutated in the first, third, and fourth
offspring
The initial population in (a) is ranked by the fitness function in (b), resulting in
pairs for mating in (c). They produce offspring in (d), which are subject to
mutation in (e).
1.1.4 SEARCHING WITH PARTIAL OBSERVATIONS
- In the previous topics we have seen Deterministic, fully observable=>single-
state problem
agent knows exactly which state it will be in
solution is a sequence
- The problem of partial observability => agent percept is not sufficient to pin
down the exact state
- Different types of incompleteness lead to three distinct problem types:
Sensorless problems(conformant): If the agent has no sensors at all
Deterministic, non-observable=>multi-state problem
agent may have no idea where it is
solution is a sequence
Contingency problem: if the environment if partially observable or if
action are uncertain (adversarial)
Nondeterministic and/or partially observable
percepts provide new information about current state
A
c
tion
i) move Right => Result = {2, 4, 6, 8}
ii) Suck => Result = {4, 8}
iii) Move Left => Result={3,7}
iv) Suck => Result = {7} guaranteed! => the agent coerce into
world state
Solve sensorless problems by searching space of belief states, which is
fully observable to agent.
4. Goal test: b satisfies the goal test if all physical states in b satisfies
GOAL-TESTP
5. Path cost : the cost of an action is the same in all states
Example
In the above picture (V1, V2) is arc consistent, because b is the only value
in the domain of V1 and there exists a value g in the domain of V2(i.e.,
V1=b and V2=g are compatible(i.e., satisfies the not-same constraint),
but (V3,V1) is not arc consistent because V3=b and V1=b is not compatible
with it and there is no other value in the domain of V1
AC-3 Algorithm
is the most popular arc-consistent algorithm.
Maintains a queue of arcs. Initially the queue contains all the arcs
in the problem.
This algorithm pops an arc (Xi,Xj) from the queue and makes Xi arc-
consistent with respect to Xj.
If Domain (Di) is unchanged , the algorithm chooses the next arc
Otherwise ,Domain is revised( changed/made smaller), add all the arcs
(Xk,Xi) to the queue where Xk is the neighbor of Xi
If Di is changed to nothing(i.e., there is no value in the domain), the
algorithm returns failure=> means CSP has no consistent solution
c) Path consistency
- Compares 3 variables and 2 constraints
- For each assignment of 2 variables , ensure that the third variable has
legal values
{R, B}
- Example
V1
{R, B} {R, B}
V2 V3
The above CSP is arc-consistent. But there is no solution, because
there are only two colors in three variable domains. In order to
solve it the path consistency takes place
One of the relationship between x1(V1) and x2(v2) is x1="Red"
and x2="Blue". For this pair there is no legal value in V3. Therefore
Red and blue is removed from V1 and V2.
- The path consistency algorithm reduces the variable domain after the arc-
consistency is performed.
- Algorithm
d) K-consistency
- A CSP is k-consistent, for any set of k-1 variables and for any consistent
assignment (i.e., assigned values that satisfy all the constraints among K-
- Given a game tree, the optimal strategy can be determined by examining the
minimax value of each node, which is writtern as MINIMAX- VALUE (n).
MINIMAX- VALUE(n) =
UTILITY(n) if n is a terminal state
Maxs successors(n) MAX-VALUE(s) if n is a MAX node
Mins Successors(n) MIN-VALUE(s) if n is a MIN node
- Algorithm MINMAX
Example : TIC-TAC-TOE
- Performance of Minimax
Complete? Yes (if tree is finite)
Optimal? Yes (against an optimal opponent)
Time complexity? O(bm)
Space complexity? O(bm) (depth-first exploration)
- Alpha-Beta pruning
In MINMAX search, the number of nodes explored increase exponentially,
because MINMAx is DFS
is a modified version of MINMAX
reduces number of nodes exploring=> Pruning
to Prune use branh and bound techniques which involes upperbound and
lowerbound
to maintain upperbound and lowerbound two parameters are represented
called as alpha and beta => called alpha-beta pruning
Alpha(∞)[lower bound]=> the value of the best(highest value) choice so far for
the player MAX
Beta(β)[Upper bound]=> the value of the best(lowest value) choice so far for the
player MIN
Algorithm
Example
Examples:
In solitaire, next card is unknown
Dice are rolled at the beginning of a player’
In stochastic games, there are 4 nodes min, mix, chance and terminal
nodes
Can do expectimax search for games with chance node
Terminal nodes and MAX , MIN nodes work similar to MINMAX
Chance nodes=> the expected value, which is the sum of the value
over all outcomes, weighted by the probability of each chance action
def exp-value(state):
initialize v = 0
for each successor of state:
p = probability(successor)
v += p * value(successor)
return v
Algorithm