SlideShare a Scribd company logo
1 of 24
UNIT – 2
Heuristic Techniques
Heuristic Search Techniques
1. Generate & Test
2. Hill Climbing
 Simple Hill Climbing
 Steepest Ascent Hill Climbing
3. Best First Search & A*
4. Problem Reduction & AO*
5. Constraint Satisfaction
6. Means – Ends Analysis
 A best-first search depends on the use of a heuristic
to select the most promising path to a goal node.
 Best first search selects the next node based on the
best estimate out of all the estimates of the heuristic
function calculated so far – this is where Best-First
Search differs from Hill Climbing.
 Greedy best-first search tries to expand the node that
is closest to the goal, that this is likely to lead to a
solution quickly.
 Use Priority queue for implementation
 Thus, it evaluates nodes by using just the heuristic
function; that is, f (n) = h(n)
Step 1: Place the starting node into the OPEN list.
Step 2: If the OPEN list is empty, Stop and return failure.
Step 3: Remove the node n, from the OPEN list which has the lowest
value of h(n), and places it in the CLOSED list.
Step 4: Expand the node n, and generate the successors of node n.
Step 5: Check each successor of node n, and find whether any node is
a goal node or not. If any successor node is goal node, then return
success and terminate the search, else proceed to Step 6.
Step 6: For each successor node, algorithm checks for evaluation
function f(n), and then check if the node has been in either OPEN or
CLOSED list. If the node has not been in both list, then add it to the
OPEN list.
Step 7: Return to Step 2.
S is initial state
G is goal state
H(N) heuristic function is the estimated
straight line distance from node n to goal
Expand the nodes of S
 Initialization: Open= [S], Closed= [ ]
 Open= [B,A], Closed= [S]
 Open=[A], Closed=[S, B]
 Open=[F,E,A],Closed= [S, B]
 Open=[E,A], Closed=[S, B, F]
 Open=[G,E,I,A], Closed=[S, B, F]
 Open=[E,I,A], Closed=[S, B, F, G]
 Hence the final solution path will be:
 S----> B----->F----> G
 A specialization of Best-First Search
 The procedure followed by A* Search is:
Along a path to the goal, at each node, the A*
algorithm generates all the child nodes,
For each child node, A* computes the estimate of
the distance (cost) from the start node to a goal
node through each of the children,
A* selects the child node which has the minimum
cost and expands it. The process than repeats for
this selected node until the goal is found or the
search ends in failure.
 The total cost function f(n) used by A*, for the
current node n during the search process is given
by
 OPEN LIST stores the nodes which have been
visited but not expanded and are available (are
“open”) for expansion, that is, their child nodes are
yet to be identified.
 CLOSED LIST stores the nodes that have been
visited and are not available (are “closed”) for
further expansion.
1. Initialize: Set OPEN={s}, CLOSED={ },
g(s)=0 and f(s)=h(s).
2. Fail: if OPEN={ }; terminate and fail.
3. Select: Select the minimum cost state, n
from OPEN. Save n in CLOSED.
4. Terminate: If n  G, where G is the set of
goal states, terminate with success and
return f(n).
5. Expand: For each child, m, of n
6. IF m  G, where G is the set of goal states, terminate
with success and return f(n).
if m  [OPEN  CLOSED], CALCULATE F(M)
Set f(m) = g(m) + h(m)
Insert m in OPEN.
7. Return: Return to Step 2.
Expand the nodes of A
Step1 :Initialization: Open= [A], Closed= [ ]
Step 2:Remove A and move adjacent of A i.e B & F in open and
calculates f(B) and f(F).
f(B) = 6 + 8 = 14
f(F) = 3 + 6 = 9
So,
 Open= [F,B], Closed= [A]
Step3: Since f(F) < f(B), so it decides to remove node F and move
its adjacent in Open G,H
f(G) = (3+1) + 5 = 9
f(H) = (3+7) + 3 = 13
So,
Open= [G,H,B], Closed= [A,F]
Path- A → F
 Step4: Since f(G) < f(H), so it decides to remove
node G and move its adjacent in Open I and
calculate f(I)
f(I) = (7) + 1 = 8
So,
Open= [I,H,B], Closed= [A,F,G]
Path- A  F G
 Step5: Since node I was only adjacent to node G ,so it
decides to remove node I and move its adjacent in Open E
and J and calculate f(E) and f(J)
f(E) = (12) + 3 = 15
f(J)= (10) +0=10
So,Open= [J,E,H,B], Closed= [A,F,G,I] Path- A → F → G → I
 Step4: Since f(J) < f(E), so it decides to remove
node J as J is goal node also and exit
So,
So,Open= [E,H,B], Closed= [A,F,G,I,J]
 Path- A → F → G → I → J
A-5
B-4 C-23
D-2
E-3
F-0
2
3
4 3
1
20
C(n,m)
h(n)
OPEN
A(5)
CLOSED
A(5)
Initial state of OPEN and CLOSED. g(A)=0, f(A)=h(A)=5.
OPEN
A(5)
B(7) C(25)
CLOSED
A(5)
A(5) B(7)
Expand A to obtain B and C. B does not belong to [OPEN union CLOSED].
Therefore, set g(B)=g(A) + C(A, B) = 0 + 3 = 3.
And, set f(B) = g(B) + h(B) = 3 + 4 = 7. Place B on OPEN.
Similarly, g(C)=0 + 2 = 2 and f(C)=0+23=25. Place C in OPEN. Return to step 2.
Minimum cost state in OPEN is B. Put B in CLOSED. B does not belong to G.
OPEN
A(5)
B(7) C(25)
C(25) D(9)
CLOSED
A(5)
A(5) B(7) D(9)
A(5) B(7)
Expand B to obtain D. D does not belong to [OPEN union CLOSED].
Therefore, set g(D)=g(B) + C(B, D) = 3 + 4 = 7.
And, set f(D) = g(D) + h(D) = 7 + 2 = 9. Place D in OPEN. Return to step 2.
Minimum cost state in OPEN is D. Put D in CLOSED. D does not belong to G.
OPEN
A(5)
B(7) C(25)
C(25) D(9)
C(25) E(11)
CLOSED
A(5)
A(5) B(7) D(9)
A(5) B(7)
A(5) B(7) D(9) E(11)
Expand D to obtain E. E does not belong to [OPEN union CLOSED].
Therefore, set g(E)=g(D) + C(D, E) = 7 + 1 = 8.
And, set f(E) = g(E) + h(E) = 8 + 3 = 11. Place E in OPEN. Return to step 2.
Minimum cost state in OPEN is E. Put E in CLOSED. E does not belong to G.
OPEN
A(5)
B(7) C(25)
C(25) D(9)
C(25) E(11)
C(25) F(28)
CLOSED
A(5)
A(5) B(7) D(9)
A(5) B(7)
A(5) B(7) D(9) E(11)
A(5) B(7) D(9) E(11) C(25)
Expand E to obtain F. F does not belong to [OPEN union CLOSED].
Therefore, set g(F)=g(E) + C(E, F) = 8 + 20 = 28.
And, set f(F) = g(F) + h(F) = 28 + 0 = 28. Place F in OPEN. Return to step 2.
Minimum cost state in OPEN is C. Put C in CLOSED. C does not belong to G.
OPEN
A(5)
B(7) C(25)
C(25) D(9)
C(25) E(11)
C(25) F(28)
F(28) D(7)
CLOSED
A(5)
A(5) B(7) D(9)
A(5) B(7)
A(5) B(7) D(9) E(11)
A(5) B(7) E(11 C(25)
A(5) B(7) D(9) E(11) C(25)
Expand C to obtain D. D belongs to [OPEN union CLOSED] as it is in CLOSED.
Therefore, set g(D)=min{g(D), g(C) + C(C, D)} = min{7, 2 + 3} = 5.
And, set f(D) = g(D) + h(D) = 5 + 2 = 7. As f(D) has decreased from 9 to 7, and D
belongs to CLOSED, therefore move D from CLOSED to OPEN. Return to step 2.
OPEN
A(5)
B(7) C(25)
C(25) D(9)
C(25) E(11)
C(25) F(28)
F(28) D(7)
F(28) E(9)
CLOSED
A(5)
A(5) B(7) D(9)
A(5) B(7)
A(5) B(7) D(9) E(11)
A(5) B(7) E(11 C(25)
A(5) B(7) E(11 C(25) D(7)
A(5) B(7) C(25 D(7)
Minimum cost state in OPEN is D. Put D in CLOSED. D does not belong to G.
Expand D to obtain E. E belongs to [OPEN union CLOSED] as it is in CLOSED.
Therefore, set g(E)=min{g(E), g(D) + C(D, E)} = min{8, 5 + 1} = 6.
And, set f(E) = g(E) + h(E) = 6 + 3 = 9. As f(E) has decreased from 11 to 9, and E
belongs to CLOSED, therefore move E from CLOSED to OPEN. Return to step 2.
F(28)
OPEN
A(5)
B(7) C(25)
C(25) D(9)
C(25) E(11)
C(25) F(28)
F(28) D(7)
F(28) E(9)
F(28)
CLOSED
A(5)
A(5) B(7) D(9)
A(5) B(7)
A(5) B(7) D(9) E(11)
A(5) B(7) E(11 C(25)
A(5) B(7) C(25) D(7)
A(5) B(7) C(25) D(7) E(9)
Minimum cost state in OPEN is E. Put E in CLOSED. E does not belong to G.
F(26)
Expand E to obtain F. F belongs to [OPEN union CLOSED] as it is in OPEN.
Therefore, set g(F)=min{g(F), g(E) + C(E, F)} = min{28, 6 + 20} = 26.
And, set f(F) = g(F) + h(F) = 26 + 0 = 26. As f(F) has decreased from 28 to 26, but
F does not belong to CLOSED, it is already in OPEN. Replace it. Return to step 2.
Minimum cost state in OPEN is F with the cost 26. F belongs to G. Therefore,
return f(F)=26. This is the minimum cost of reaching the goal node F.
 When will a node have to be moved from
CLOSED to OPEN?
This is required only in the case when the data
structure being used for the search is a graph
rather than a tree.
In the case of a graph, the moving of a node from
CLOSED to OPEN indicates a backtracking and
that the path followed till the node being moved
is not the best path and there are other
alternative paths which may be better.

More Related Content

Similar to heuristic - best search and a*

Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptxDrYogeshDeshmukh1
 
HEURISTIC SEARCH and other technique.pptx
HEURISTIC SEARCH and other technique.pptxHEURISTIC SEARCH and other technique.pptx
HEURISTIC SEARCH and other technique.pptxrakeshkumar12020604
 
1.3 Distance and Midpoint Formulas
1.3 Distance and Midpoint Formulas1.3 Distance and Midpoint Formulas
1.3 Distance and Midpoint Formulassmiller5
 
Obj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance FormulasObj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance Formulassmiller5
 
College Algebra MATH 107Record your answers and work on th.docx
College Algebra MATH 107Record your answers and work on th.docxCollege Algebra MATH 107Record your answers and work on th.docx
College Algebra MATH 107Record your answers and work on th.docxclarebernice
 
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchJarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchPalGov
 
Module For Mathematics
Module For Mathematics Module For Mathematics
Module For Mathematics jrbt2014
 

Similar to heuristic - best search and a* (10)

Chap4
Chap4Chap4
Chap4
 
Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptx
 
HEURISTIC SEARCH and other technique.pptx
HEURISTIC SEARCH and other technique.pptxHEURISTIC SEARCH and other technique.pptx
HEURISTIC SEARCH and other technique.pptx
 
Finite fields
Finite fieldsFinite fields
Finite fields
 
Mathematics 10.pptx
Mathematics 10.pptxMathematics 10.pptx
Mathematics 10.pptx
 
1.3 Distance and Midpoint Formulas
1.3 Distance and Midpoint Formulas1.3 Distance and Midpoint Formulas
1.3 Distance and Midpoint Formulas
 
Obj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance FormulasObj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance Formulas
 
College Algebra MATH 107Record your answers and work on th.docx
College Algebra MATH 107Record your answers and work on th.docxCollege Algebra MATH 107Record your answers and work on th.docx
College Algebra MATH 107Record your answers and work on th.docx
 
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchJarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
 
Module For Mathematics
Module For Mathematics Module For Mathematics
Module For Mathematics
 

More from SwatiHans10

Transmission control protocol ...............................
Transmission control protocol ...............................Transmission control protocol ...............................
Transmission control protocol ...............................SwatiHans10
 
analytics platform
analytics platformanalytics platform
analytics platformSwatiHans10
 
data collection.ppt
data collection.pptdata collection.ppt
data collection.pptSwatiHans10
 
filler structures.pptx
filler structures.pptxfiller structures.pptx
filler structures.pptxSwatiHans10
 
filler structures
filler structuresfiller structures
filler structuresSwatiHans10
 
knowledge representation.pptx
knowledge representation.pptxknowledge representation.pptx
knowledge representation.pptxSwatiHans10
 
Multiplexing.ppt
Multiplexing.pptMultiplexing.ppt
Multiplexing.pptSwatiHans10
 
3D Transformation
3D Transformation3D Transformation
3D TransformationSwatiHans10
 

More from SwatiHans10 (14)

routing algo n
routing algo                                nrouting algo                                n
routing algo n
 
ethernet nn
ethernet                                         nnethernet                                         nn
ethernet nn
 
Transmission control protocol ...............................
Transmission control protocol ...............................Transmission control protocol ...............................
Transmission control protocol ...............................
 
search_sort.ppt
search_sort.pptsearch_sort.ppt
search_sort.ppt
 
analytics platform
analytics platformanalytics platform
analytics platform
 
kpi
kpikpi
kpi
 
data collection.ppt
data collection.pptdata collection.ppt
data collection.ppt
 
filler structures.pptx
filler structures.pptxfiller structures.pptx
filler structures.pptx
 
filler structures
filler structuresfiller structures
filler structures
 
knowledge representation.pptx
knowledge representation.pptxknowledge representation.pptx
knowledge representation.pptx
 
Multiplexing.ppt
Multiplexing.pptMultiplexing.ppt
Multiplexing.ppt
 
ER.ppt
ER.pptER.ppt
ER.ppt
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

heuristic - best search and a*

  • 1. UNIT – 2 Heuristic Techniques
  • 2. Heuristic Search Techniques 1. Generate & Test 2. Hill Climbing  Simple Hill Climbing  Steepest Ascent Hill Climbing 3. Best First Search & A* 4. Problem Reduction & AO* 5. Constraint Satisfaction 6. Means – Ends Analysis
  • 3.  A best-first search depends on the use of a heuristic to select the most promising path to a goal node.  Best first search selects the next node based on the best estimate out of all the estimates of the heuristic function calculated so far – this is where Best-First Search differs from Hill Climbing.  Greedy best-first search tries to expand the node that is closest to the goal, that this is likely to lead to a solution quickly.  Use Priority queue for implementation  Thus, it evaluates nodes by using just the heuristic function; that is, f (n) = h(n)
  • 4. Step 1: Place the starting node into the OPEN list. Step 2: If the OPEN list is empty, Stop and return failure. Step 3: Remove the node n, from the OPEN list which has the lowest value of h(n), and places it in the CLOSED list. Step 4: Expand the node n, and generate the successors of node n. Step 5: Check each successor of node n, and find whether any node is a goal node or not. If any successor node is goal node, then return success and terminate the search, else proceed to Step 6. Step 6: For each successor node, algorithm checks for evaluation function f(n), and then check if the node has been in either OPEN or CLOSED list. If the node has not been in both list, then add it to the OPEN list. Step 7: Return to Step 2.
  • 5. S is initial state G is goal state H(N) heuristic function is the estimated straight line distance from node n to goal
  • 6. Expand the nodes of S  Initialization: Open= [S], Closed= [ ]  Open= [B,A], Closed= [S]  Open=[A], Closed=[S, B]  Open=[F,E,A],Closed= [S, B]  Open=[E,A], Closed=[S, B, F]  Open=[G,E,I,A], Closed=[S, B, F]  Open=[E,I,A], Closed=[S, B, F, G]  Hence the final solution path will be:  S----> B----->F----> G
  • 7.  A specialization of Best-First Search  The procedure followed by A* Search is: Along a path to the goal, at each node, the A* algorithm generates all the child nodes, For each child node, A* computes the estimate of the distance (cost) from the start node to a goal node through each of the children, A* selects the child node which has the minimum cost and expands it. The process than repeats for this selected node until the goal is found or the search ends in failure.
  • 8.  The total cost function f(n) used by A*, for the current node n during the search process is given by  OPEN LIST stores the nodes which have been visited but not expanded and are available (are “open”) for expansion, that is, their child nodes are yet to be identified.  CLOSED LIST stores the nodes that have been visited and are not available (are “closed”) for further expansion.
  • 9. 1. Initialize: Set OPEN={s}, CLOSED={ }, g(s)=0 and f(s)=h(s). 2. Fail: if OPEN={ }; terminate and fail. 3. Select: Select the minimum cost state, n from OPEN. Save n in CLOSED. 4. Terminate: If n  G, where G is the set of goal states, terminate with success and return f(n).
  • 10. 5. Expand: For each child, m, of n 6. IF m  G, where G is the set of goal states, terminate with success and return f(n). if m  [OPEN  CLOSED], CALCULATE F(M) Set f(m) = g(m) + h(m) Insert m in OPEN. 7. Return: Return to Step 2.
  • 11.
  • 12. Expand the nodes of A Step1 :Initialization: Open= [A], Closed= [ ] Step 2:Remove A and move adjacent of A i.e B & F in open and calculates f(B) and f(F). f(B) = 6 + 8 = 14 f(F) = 3 + 6 = 9 So,  Open= [F,B], Closed= [A] Step3: Since f(F) < f(B), so it decides to remove node F and move its adjacent in Open G,H f(G) = (3+1) + 5 = 9 f(H) = (3+7) + 3 = 13 So, Open= [G,H,B], Closed= [A,F] Path- A → F
  • 13.  Step4: Since f(G) < f(H), so it decides to remove node G and move its adjacent in Open I and calculate f(I) f(I) = (7) + 1 = 8 So, Open= [I,H,B], Closed= [A,F,G] Path- A  F G  Step5: Since node I was only adjacent to node G ,so it decides to remove node I and move its adjacent in Open E and J and calculate f(E) and f(J) f(E) = (12) + 3 = 15 f(J)= (10) +0=10 So,Open= [J,E,H,B], Closed= [A,F,G,I] Path- A → F → G → I
  • 14.  Step4: Since f(J) < f(E), so it decides to remove node J as J is goal node also and exit So, So,Open= [E,H,B], Closed= [A,F,G,I,J]  Path- A → F → G → I → J
  • 16. OPEN A(5) CLOSED A(5) Initial state of OPEN and CLOSED. g(A)=0, f(A)=h(A)=5.
  • 17. OPEN A(5) B(7) C(25) CLOSED A(5) A(5) B(7) Expand A to obtain B and C. B does not belong to [OPEN union CLOSED]. Therefore, set g(B)=g(A) + C(A, B) = 0 + 3 = 3. And, set f(B) = g(B) + h(B) = 3 + 4 = 7. Place B on OPEN. Similarly, g(C)=0 + 2 = 2 and f(C)=0+23=25. Place C in OPEN. Return to step 2. Minimum cost state in OPEN is B. Put B in CLOSED. B does not belong to G.
  • 18. OPEN A(5) B(7) C(25) C(25) D(9) CLOSED A(5) A(5) B(7) D(9) A(5) B(7) Expand B to obtain D. D does not belong to [OPEN union CLOSED]. Therefore, set g(D)=g(B) + C(B, D) = 3 + 4 = 7. And, set f(D) = g(D) + h(D) = 7 + 2 = 9. Place D in OPEN. Return to step 2. Minimum cost state in OPEN is D. Put D in CLOSED. D does not belong to G.
  • 19. OPEN A(5) B(7) C(25) C(25) D(9) C(25) E(11) CLOSED A(5) A(5) B(7) D(9) A(5) B(7) A(5) B(7) D(9) E(11) Expand D to obtain E. E does not belong to [OPEN union CLOSED]. Therefore, set g(E)=g(D) + C(D, E) = 7 + 1 = 8. And, set f(E) = g(E) + h(E) = 8 + 3 = 11. Place E in OPEN. Return to step 2. Minimum cost state in OPEN is E. Put E in CLOSED. E does not belong to G.
  • 20. OPEN A(5) B(7) C(25) C(25) D(9) C(25) E(11) C(25) F(28) CLOSED A(5) A(5) B(7) D(9) A(5) B(7) A(5) B(7) D(9) E(11) A(5) B(7) D(9) E(11) C(25) Expand E to obtain F. F does not belong to [OPEN union CLOSED]. Therefore, set g(F)=g(E) + C(E, F) = 8 + 20 = 28. And, set f(F) = g(F) + h(F) = 28 + 0 = 28. Place F in OPEN. Return to step 2. Minimum cost state in OPEN is C. Put C in CLOSED. C does not belong to G.
  • 21. OPEN A(5) B(7) C(25) C(25) D(9) C(25) E(11) C(25) F(28) F(28) D(7) CLOSED A(5) A(5) B(7) D(9) A(5) B(7) A(5) B(7) D(9) E(11) A(5) B(7) E(11 C(25) A(5) B(7) D(9) E(11) C(25) Expand C to obtain D. D belongs to [OPEN union CLOSED] as it is in CLOSED. Therefore, set g(D)=min{g(D), g(C) + C(C, D)} = min{7, 2 + 3} = 5. And, set f(D) = g(D) + h(D) = 5 + 2 = 7. As f(D) has decreased from 9 to 7, and D belongs to CLOSED, therefore move D from CLOSED to OPEN. Return to step 2.
  • 22. OPEN A(5) B(7) C(25) C(25) D(9) C(25) E(11) C(25) F(28) F(28) D(7) F(28) E(9) CLOSED A(5) A(5) B(7) D(9) A(5) B(7) A(5) B(7) D(9) E(11) A(5) B(7) E(11 C(25) A(5) B(7) E(11 C(25) D(7) A(5) B(7) C(25 D(7) Minimum cost state in OPEN is D. Put D in CLOSED. D does not belong to G. Expand D to obtain E. E belongs to [OPEN union CLOSED] as it is in CLOSED. Therefore, set g(E)=min{g(E), g(D) + C(D, E)} = min{8, 5 + 1} = 6. And, set f(E) = g(E) + h(E) = 6 + 3 = 9. As f(E) has decreased from 11 to 9, and E belongs to CLOSED, therefore move E from CLOSED to OPEN. Return to step 2. F(28)
  • 23. OPEN A(5) B(7) C(25) C(25) D(9) C(25) E(11) C(25) F(28) F(28) D(7) F(28) E(9) F(28) CLOSED A(5) A(5) B(7) D(9) A(5) B(7) A(5) B(7) D(9) E(11) A(5) B(7) E(11 C(25) A(5) B(7) C(25) D(7) A(5) B(7) C(25) D(7) E(9) Minimum cost state in OPEN is E. Put E in CLOSED. E does not belong to G. F(26) Expand E to obtain F. F belongs to [OPEN union CLOSED] as it is in OPEN. Therefore, set g(F)=min{g(F), g(E) + C(E, F)} = min{28, 6 + 20} = 26. And, set f(F) = g(F) + h(F) = 26 + 0 = 26. As f(F) has decreased from 28 to 26, but F does not belong to CLOSED, it is already in OPEN. Replace it. Return to step 2. Minimum cost state in OPEN is F with the cost 26. F belongs to G. Therefore, return f(F)=26. This is the minimum cost of reaching the goal node F.
  • 24.  When will a node have to be moved from CLOSED to OPEN? This is required only in the case when the data structure being used for the search is a graph rather than a tree. In the case of a graph, the moving of a node from CLOSED to OPEN indicates a backtracking and that the path followed till the node being moved is not the best path and there are other alternative paths which may be better.