SlideShare a Scribd company logo
AND/OR graphs
 Some problems are best represented asSome problems are best represented as
achieving subgoals, some of whichachieving subgoals, some of which
achieved simultaneously andachieved simultaneously and
independently (AND)independently (AND)
 Up to now, only dealt with OR optionsUp to now, only dealt with OR options
Possess TV set
Steal TV Earn Money Buy TV
Searching AND/OR graphs
 A solution in an AND-OR tree is aA solution in an AND-OR tree is a sub treesub tree
whosewhose leafsleafs are included in the goal setare included in the goal set
 Cost function: sum of costs in AND nodeCost function: sum of costs in AND node
f(n) = f(nf(n) = f(n11) + f(n) + f(n22) + …. + f(n) + …. + f(nkk))
 How can we extend A* to search AND/ORHow can we extend A* to search AND/OR
trees? The AO* algorithm.trees? The AO* algorithm.
AND/OR search
 We must examine several nodesWe must examine several nodes
simultaneously when choosing the nextsimultaneously when choosing the next
movemove
A
B C D
38
E F G H I J
17 9 27
(5) (10) (3) (4) (15) (10)
A
B C
D(3)
(4)
(5)
(9)
AND/OR Best-First-Search
 Traverse the graph (from the initial node)Traverse the graph (from the initial node)
following the best current path.following the best current path.
 Pick one of the unexpanded nodes on thatPick one of the unexpanded nodes on that
path and expand it. Add its successors topath and expand it. Add its successors to
the graph and computethe graph and compute ff for each of themfor each of them
 Change the expanded node’sChange the expanded node’s ff value tovalue to
reflect its successors. Propagate thereflect its successors. Propagate the
change up the graph.change up the graph.
 Reconsider the current best solution andReconsider the current best solution and
repeat until a solution is foundrepeat until a solution is found
AND/OR Best-First-Search
example
A
B C
D(3)
(4)
(5)
(9)
A
(5)
2.1.
A
B C
D
E F(4) (4)
(10)
(3)
(9)
(4)
(10)
3.
AND/OR Best-First-Search
example
B C D
G H E F(5) (7) (4) (4)
(10)
(6)
(12)
(4) (10)
4.
A
A Longer path may be better
B C D
G H E F
A
JI
Unsolvable B C D
G H E F
A
JI
Unsolvable
Interacting Sub goals
C
D
E
A
(2)(5)
AO* algorithm
1.1. LetLet GG be a graph with only starting nodebe a graph with only starting node INIT.INIT.
2.2. Repeat the followings until INIT is labeledRepeat the followings until INIT is labeled
SOLVED or h(INIT) > FUTILITYSOLVED or h(INIT) > FUTILITY
a)a) Select an unexpanded node from the most promisingSelect an unexpanded node from the most promising
path from INIT (call it NODE)path from INIT (call it NODE)
b)b) Generate successors of NODE. If there are none, setGenerate successors of NODE. If there are none, set
h(NODE) = FUTILITY (i.e., NODE is unsolvable);h(NODE) = FUTILITY (i.e., NODE is unsolvable);
otherwise for each SUCCESSOR that is not an ancestorotherwise for each SUCCESSOR that is not an ancestor
of NODE do the following:of NODE do the following:
i.i. Add SUCCESSSOR to G.Add SUCCESSSOR to G.
ii.ii. If SUCCESSOR is a terminal node, label it SOLVED andIf SUCCESSOR is a terminal node, label it SOLVED and
set h(SUCCESSOR) = 0.set h(SUCCESSOR) = 0.
iii.iii. If SUCCESSPR is not a terminal node, compute its hIf SUCCESSPR is not a terminal node, compute its h
AO* algorithm (Cont.)
c)c) Propagate the newly discovered information up thePropagate the newly discovered information up the
graph by doing the following: let S be set of SOLVEDgraph by doing the following: let S be set of SOLVED
nodes or nodes whose h values have been changednodes or nodes whose h values have been changed
and need to have values propagated back to theirand need to have values propagated back to their
parents. Initialize S to Node. Until S is empty repeatparents. Initialize S to Node. Until S is empty repeat
the followings:the followings:
i.i. Remove a node from S and call it CURRENT.Remove a node from S and call it CURRENT.
ii.ii. Compute the cost of each of the arcs emerging fromCompute the cost of each of the arcs emerging from
CURRENT. Assign minimum cost of its successors as its h.CURRENT. Assign minimum cost of its successors as its h.
iii.iii. Mark the best path out of CURRENT by marking the arc thatMark the best path out of CURRENT by marking the arc that
had the minimum cost in step iihad the minimum cost in step ii
iv.iv. Mark CURRENT as SOLVED if all of the nodes connected toMark CURRENT as SOLVED if all of the nodes connected to
it through new labeled arc have been labeled SOLVEDit through new labeled arc have been labeled SOLVED
v.v. If CURRENT has been labeled SOLVED or its cost was justIf CURRENT has been labeled SOLVED or its cost was just
changed, propagate its new cost back up through the graph.changed, propagate its new cost back up through the graph.
So add all of the ancestors of CURRENT to S.So add all of the ancestors of CURRENT to S.
An Example
An Example
A(8)
An Example
C
DB
A
(8)(1)
(2)
[12]
4 5
5
[13]
An Example
C
DB
A
(8)(4)
(2)
[15]
4 5
5
[13]
2
An Example
C
DB
A
(3)(4)
G
E
(2)
(1)
(0)
[15]
4 5
5
2
2
4
[8]
An Example
C
DB
A
(4)(4)
G
E
(2)
(3)
(0)
[15]
4 5
5
2
2
2
4
[9]
3
An Example
C
DB
A
(4)
G
E
(2)
(3)
(0)
[15]
4 5
5
2
2
2
4
Solved
3
Solved
Solved
 Considers the cost (> 0) for switching from one branch toConsiders the cost (> 0) for switching from one branch to
another in the searchanother in the search
 Example: path finding in real lifeExample: path finding in real life
A CBDF E G
11 4 1 2 167
f(B) = 1 + 1 = 2f(B) = 1 + 1 = 2 (A) f(C) = 1 + 2 = 3(A) f(C) = 1 + 2 = 3
f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 3 = 4(B) f(A) = 1 + 3 = 4
f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3
f(A) = 1 + 6 = 7f(A) = 1 + 6 = 7 (C) f(E) = 1 + 7 = 8(C) f(E) = 1 + 7 = 8
f(B) = 1 + 5 = 6f(B) = 1 + 5 = 6 (A) f(C) = 1 + 8 = 9(A) f(C) = 1 + 8 = 9
f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 9 = 10(B) f(A) = 1 + 9 = 10
f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11
Real Time A*
 Considers the cost (> 0) for switching from one branch toConsiders the cost (> 0) for switching from one branch to
another in the searchanother in the search
 Example: path finding in real lifeExample: path finding in real life
A CBDF E G
11 4 1 2 167
f(B) = 1 + 1 = 2f(B) = 1 + 1 = 2 (A) f(C) = 1 + 2 = 3(A) f(C) = 1 + 2 = 3
f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 3 = 4(B) f(A) = 1 + 3 = 4
f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3
f(A) = 1 + 6 = 7f(A) = 1 + 6 = 7 (C) f(E) = 1 + 7 = 8(C) f(E) = 1 + 7 = 8
f(B) = 1 + 5 = 6f(B) = 1 + 5 = 6 (A) f(C) = 1 + 8 = 9(A) f(C) = 1 + 8 = 9
f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 9 = 10(B) f(A) = 1 + 9 = 10
f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11
Another Example
Current State = SCurrent State = S
f(A) = 3 + 5 = 8f(A) = 3 + 5 = 8
f(B) = 2 + 4 = 6f(B) = 2 + 4 = 6
Current State = BCurrent State = B
f(S) = 2 + 8 = 10f(S) = 2 + 8 = 10
f(A) = 4 + 5 = 9f(A) = 4 + 5 = 9
f(C) = 1 + 5 = 6f(C) = 1 + 5 = 6
f(E) = 4 + 2 = 6f(E) = 4 + 2 = 6
Current State = CCurrent State = C
f(H) = 2 + 4 = 6f(H) = 2 + 4 = 6
f(B) = 1 + 6 = 7f(B) = 1 + 6 = 7
A B
C
S
(4)
(4) D
(5)
2
(2)
G
(1)
E
(2)H
(0)
3
4
41
(5)
F
2 13
2
Current State = HCurrent State = H
f(C) = 2 + 7 = 9f(C) = 2 + 7 = 9
Current State = CCurrent State = C
f(B) = 1 + 6 = 7f(B) = 1 + 6 = 7
f(H) =f(H) = ∞∞
Current State = BCurrent State = B
f(S) = 2 + 8 = 10f(S) = 2 + 8 = 10
f(A) = 4 + 5 = 9f(A) = 4 + 5 = 9
f(E) = 4 + 2 = 6f(E) = 4 + 2 = 6
f(C) =f(C) = ∞∞
Current State = ECurrent State = E
f(B) = 4 + 9 = 13f(B) = 4 + 9 = 13
f(D) = 3 + 2 = 5f(D) = 3 + 2 = 5
A B
C
S
(4)
(4) D
(5)
2
(2)
G
(1)
E
(2)H
(0)
3
4
41
(5)
F
2 13
2
Another Example
A B
C
S
(4)
(4) D
(5)
2
(2)
G
(1)
E
(2)H
(0)
3
4
41
(5)
F
2 13
2
Current State = FCurrent State = F
f(E) = 1 + 5 = 6f(E) = 1 + 5 = 6
Current State = ECurrent State = E
f(D) = 3 + 2 = 5f(D) = 3 + 2 = 5
f(B) = 4 + 9 = 13f(B) = 4 + 9 = 13
f(F) =f(F) = ∞∞
Current State = DCurrent State = D
f(G) = 2 + 0 = 2f(G) = 2 + 0 = 2
f(E) = 3 + 13 = 16f(E) = 3 + 13 = 16
Visited Nodes =Visited Nodes =
S, B, C, H, C, B, E, F, E, D, GS, B, C, H, C, B, E, F, E, D, G
Path = S, B, E, D, GPath = S, B, E, D, G
Another Example

More Related Content

What's hot

Compiling fµn language
Compiling fµn languageCompiling fµn language
Compiling fµn language
Didier Plaindoux
 
Best polynomial approximation
Best polynomial approximationBest polynomial approximation
Best polynomial approximationDadang Hamzah
 
Chapter 22 Finite Field
Chapter 22 Finite FieldChapter 22 Finite Field
Chapter 22 Finite Field
Tony Cervera Jr.
 
Volume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensionsVolume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensions
Vissarion Fisikopoulos
 
Use of Green's Fuction in Regularization of PRF
Use of Green's Fuction in Regularization of PRFUse of Green's Fuction in Regularization of PRF
Use of Green's Fuction in Regularization of PRF
Chaand Chopra
 
Efficient Random-Walk Methods forApproximating Polytope Volume
Efficient Random-Walk Methods forApproximating Polytope VolumeEfficient Random-Walk Methods forApproximating Polytope Volume
Efficient Random-Walk Methods forApproximating Polytope Volume
Vissarion Fisikopoulos
 
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkCrystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Jivan Nepali
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
mohanrathod18
 
Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion
Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion
Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion
KNOWeSCAPE2014
 
Ratios
RatiosRatios
Ratios
Shaun Wilson
 
A Short Study of Galois Field
A Short Study of Galois FieldA Short Study of Galois Field
A Short Study of Galois Field
Hazratali Naim
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2chandsek666
 
Quaternionic Modular Symbols in Sage
Quaternionic Modular Symbols in SageQuaternionic Modular Symbols in Sage
Quaternionic Modular Symbols in Sage
mmasdeu
 
5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)
Jan Plaza
 
Search34
Search34Search34
Search34
yosser atassi
 
Monad presentation scala as a category
Monad presentation   scala as a categoryMonad presentation   scala as a category
Monad presentation scala as a categorysamthemonad
 
A Note on TopicRNN
A Note on TopicRNNA Note on TopicRNN
A Note on TopicRNN
Tomonari Masada
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
Soheil Khodayari
 
Chapter 4 review
Chapter 4 reviewChapter 4 review
Chapter 4 reviewgregcross22
 

What's hot (20)

Compiling fµn language
Compiling fµn languageCompiling fµn language
Compiling fµn language
 
Best polynomial approximation
Best polynomial approximationBest polynomial approximation
Best polynomial approximation
 
Chapter 22 Finite Field
Chapter 22 Finite FieldChapter 22 Finite Field
Chapter 22 Finite Field
 
Volume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensionsVolume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensions
 
AI Lesson 05
AI Lesson 05AI Lesson 05
AI Lesson 05
 
Use of Green's Fuction in Regularization of PRF
Use of Green's Fuction in Regularization of PRFUse of Green's Fuction in Regularization of PRF
Use of Green's Fuction in Regularization of PRF
 
Efficient Random-Walk Methods forApproximating Polytope Volume
Efficient Random-Walk Methods forApproximating Polytope VolumeEfficient Random-Walk Methods forApproximating Polytope Volume
Efficient Random-Walk Methods forApproximating Polytope Volume
 
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkCrystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion
Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion
Effects of the Discussion Groups Sizes on the Dynamics of Public Opinion
 
Ratios
RatiosRatios
Ratios
 
A Short Study of Galois Field
A Short Study of Galois FieldA Short Study of Galois Field
A Short Study of Galois Field
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2
 
Quaternionic Modular Symbols in Sage
Quaternionic Modular Symbols in SageQuaternionic Modular Symbols in Sage
Quaternionic Modular Symbols in Sage
 
5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)
 
Search34
Search34Search34
Search34
 
Monad presentation scala as a category
Monad presentation   scala as a categoryMonad presentation   scala as a category
Monad presentation scala as a category
 
A Note on TopicRNN
A Note on TopicRNNA Note on TopicRNN
A Note on TopicRNN
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
Chapter 4 review
Chapter 4 reviewChapter 4 review
Chapter 4 review
 

Similar to Ai4 heuristic2

KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
mihir jain
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star search
Hema Kashyap
 
kmaps
 kmaps kmaps
kmaps
Unsa Shakir
 
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
venkatapranaykumarGa
 
Evaluating definite integrals
Evaluating definite integralsEvaluating definite integrals
Evaluating definite integrals
منتدى الرياضيات المتقدمة
 
All I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School AlgebraAll I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School Algebra
Eric Normand
 
Kmaps.ppt
Kmaps.pptKmaps.ppt
Kmaps.ppt
AshwiniMate10
 
Kmaps.ppt
Kmaps.pptKmaps.ppt
Kmaps.ppt
ShaekAhmed
 
Kmaps.ppt
Kmaps.pptKmaps.ppt
Cerutti -- TAFA2013
Cerutti -- TAFA2013Cerutti -- TAFA2013
Cerutti -- TAFA2013
Federico Cerutti
 
Math 111 Final Exam Review1. Use the graph of y = f(x) in .docx
Math 111 Final Exam Review1. Use the graph of y = f(x) in .docxMath 111 Final Exam Review1. Use the graph of y = f(x) in .docx
Math 111 Final Exam Review1. Use the graph of y = f(x) in .docx
andreecapon
 
CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...
CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...
CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...
CHENNAKESAVA KADAPA
 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monads
kenbot
 
Strongly Connected Components
Strongly Connected Components Strongly Connected Components
Strongly Connected Components
Md. Shafiuzzaman Hira
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
Iffat Anjum
 
Mid-Term ExamName___________________________________MU.docx
Mid-Term ExamName___________________________________MU.docxMid-Term ExamName___________________________________MU.docx
Mid-Term ExamName___________________________________MU.docx
annandleola
 
Iterative methods with special structures
Iterative methods with special structuresIterative methods with special structures
Iterative methods with special structures
David Gleich
 
Digital Notes
Digital NotesDigital Notes
Digital Notes
devansh singh
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on Steroids
François Garillot
 

Similar to Ai4 heuristic2 (20)

KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star search
 
kmaps
 kmaps kmaps
kmaps
 
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
 
Evaluating definite integrals
Evaluating definite integralsEvaluating definite integrals
Evaluating definite integrals
 
All I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School AlgebraAll I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School Algebra
 
Kmaps.ppt
Kmaps.pptKmaps.ppt
Kmaps.ppt
 
Kmaps.ppt
Kmaps.pptKmaps.ppt
Kmaps.ppt
 
Kmaps.ppt
Kmaps.pptKmaps.ppt
Kmaps.ppt
 
Cerutti -- TAFA2013
Cerutti -- TAFA2013Cerutti -- TAFA2013
Cerutti -- TAFA2013
 
Math 111 Final Exam Review1. Use the graph of y = f(x) in .docx
Math 111 Final Exam Review1. Use the graph of y = f(x) in .docxMath 111 Final Exam Review1. Use the graph of y = f(x) in .docx
Math 111 Final Exam Review1. Use the graph of y = f(x) in .docx
 
CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...
CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...
CutFEM on hierarchical B-Spline Cartesian grids with applications to fluid-st...
 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monads
 
Strongly Connected Components
Strongly Connected Components Strongly Connected Components
Strongly Connected Components
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
Mid-Term ExamName___________________________________MU.docx
Mid-Term ExamName___________________________________MU.docxMid-Term ExamName___________________________________MU.docx
Mid-Term ExamName___________________________________MU.docx
 
Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
Iterative methods with special structures
Iterative methods with special structuresIterative methods with special structures
Iterative methods with special structures
 
Digital Notes
Digital NotesDigital Notes
Digital Notes
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on Steroids
 

More from Mohammad Faizan

Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
Mohammad Faizan
 
Jdbc basic features
Jdbc basic featuresJdbc basic features
Jdbc basic features
Mohammad Faizan
 
Tutorial c#
Tutorial c#Tutorial c#
Tutorial c#
Mohammad Faizan
 
Java 8 from perm gen to metaspace
Java 8  from perm gen to metaspaceJava 8  from perm gen to metaspace
Java 8 from perm gen to metaspace
Mohammad Faizan
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
Mohammad Faizan
 
Software maintenance Unit5
Software maintenance  Unit5Software maintenance  Unit5
Software maintenance Unit5
Mohammad Faizan
 
Hibernate using jpa
Hibernate using jpaHibernate using jpa
Hibernate using jpa
Mohammad Faizan
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
Mohammad Faizan
 
Unit3 Software engineering UPTU
Unit3 Software engineering UPTUUnit3 Software engineering UPTU
Unit3 Software engineering UPTU
Mohammad Faizan
 
Unit2 Software engineering UPTU
Unit2 Software engineering UPTUUnit2 Software engineering UPTU
Unit2 Software engineering UPTU
Mohammad Faizan
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
Mohammad Faizan
 
Allama Iqbal shiqwa with meaning
Allama Iqbal shiqwa with meaningAllama Iqbal shiqwa with meaning
Allama Iqbal shiqwa with meaning
Mohammad Faizan
 
Coda file system tahir
Coda file system   tahirCoda file system   tahir
Coda file system tahir
Mohammad Faizan
 

More from Mohammad Faizan (18)

Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Jdbc basic features
Jdbc basic featuresJdbc basic features
Jdbc basic features
 
Tutorial c#
Tutorial c#Tutorial c#
Tutorial c#
 
Java 8 from perm gen to metaspace
Java 8  from perm gen to metaspaceJava 8  from perm gen to metaspace
Java 8 from perm gen to metaspace
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
 
Software maintenance Unit5
Software maintenance  Unit5Software maintenance  Unit5
Software maintenance Unit5
 
Hibernate using jpa
Hibernate using jpaHibernate using jpa
Hibernate using jpa
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
 
Unit3 Software engineering UPTU
Unit3 Software engineering UPTUUnit3 Software engineering UPTU
Unit3 Software engineering UPTU
 
Unit2 Software engineering UPTU
Unit2 Software engineering UPTUUnit2 Software engineering UPTU
Unit2 Software engineering UPTU
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Allama Iqbal shiqwa with meaning
Allama Iqbal shiqwa with meaningAllama Iqbal shiqwa with meaning
Allama Iqbal shiqwa with meaning
 
Web tech chapter 1 (1)
Web tech chapter 1 (1)Web tech chapter 1 (1)
Web tech chapter 1 (1)
 
Mdm intro-chapter1
Mdm intro-chapter1Mdm intro-chapter1
Mdm intro-chapter1
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Coda file system tahir
Coda file system   tahirCoda file system   tahir
Coda file system tahir
 
Chapter30 (1)
Chapter30 (1)Chapter30 (1)
Chapter30 (1)
 
Chapter30
Chapter30Chapter30
Chapter30
 

Ai4 heuristic2

  • 1. AND/OR graphs  Some problems are best represented asSome problems are best represented as achieving subgoals, some of whichachieving subgoals, some of which achieved simultaneously andachieved simultaneously and independently (AND)independently (AND)  Up to now, only dealt with OR optionsUp to now, only dealt with OR options Possess TV set Steal TV Earn Money Buy TV
  • 2. Searching AND/OR graphs  A solution in an AND-OR tree is aA solution in an AND-OR tree is a sub treesub tree whosewhose leafsleafs are included in the goal setare included in the goal set  Cost function: sum of costs in AND nodeCost function: sum of costs in AND node f(n) = f(nf(n) = f(n11) + f(n) + f(n22) + …. + f(n) + …. + f(nkk))  How can we extend A* to search AND/ORHow can we extend A* to search AND/OR trees? The AO* algorithm.trees? The AO* algorithm.
  • 3. AND/OR search  We must examine several nodesWe must examine several nodes simultaneously when choosing the nextsimultaneously when choosing the next movemove A B C D 38 E F G H I J 17 9 27 (5) (10) (3) (4) (15) (10) A B C D(3) (4) (5) (9)
  • 4. AND/OR Best-First-Search  Traverse the graph (from the initial node)Traverse the graph (from the initial node) following the best current path.following the best current path.  Pick one of the unexpanded nodes on thatPick one of the unexpanded nodes on that path and expand it. Add its successors topath and expand it. Add its successors to the graph and computethe graph and compute ff for each of themfor each of them  Change the expanded node’sChange the expanded node’s ff value tovalue to reflect its successors. Propagate thereflect its successors. Propagate the change up the graph.change up the graph.  Reconsider the current best solution andReconsider the current best solution and repeat until a solution is foundrepeat until a solution is found
  • 6. AND/OR Best-First-Search example B C D G H E F(5) (7) (4) (4) (10) (6) (12) (4) (10) 4. A
  • 7. A Longer path may be better B C D G H E F A JI Unsolvable B C D G H E F A JI Unsolvable
  • 9. AO* algorithm 1.1. LetLet GG be a graph with only starting nodebe a graph with only starting node INIT.INIT. 2.2. Repeat the followings until INIT is labeledRepeat the followings until INIT is labeled SOLVED or h(INIT) > FUTILITYSOLVED or h(INIT) > FUTILITY a)a) Select an unexpanded node from the most promisingSelect an unexpanded node from the most promising path from INIT (call it NODE)path from INIT (call it NODE) b)b) Generate successors of NODE. If there are none, setGenerate successors of NODE. If there are none, set h(NODE) = FUTILITY (i.e., NODE is unsolvable);h(NODE) = FUTILITY (i.e., NODE is unsolvable); otherwise for each SUCCESSOR that is not an ancestorotherwise for each SUCCESSOR that is not an ancestor of NODE do the following:of NODE do the following: i.i. Add SUCCESSSOR to G.Add SUCCESSSOR to G. ii.ii. If SUCCESSOR is a terminal node, label it SOLVED andIf SUCCESSOR is a terminal node, label it SOLVED and set h(SUCCESSOR) = 0.set h(SUCCESSOR) = 0. iii.iii. If SUCCESSPR is not a terminal node, compute its hIf SUCCESSPR is not a terminal node, compute its h
  • 10. AO* algorithm (Cont.) c)c) Propagate the newly discovered information up thePropagate the newly discovered information up the graph by doing the following: let S be set of SOLVEDgraph by doing the following: let S be set of SOLVED nodes or nodes whose h values have been changednodes or nodes whose h values have been changed and need to have values propagated back to theirand need to have values propagated back to their parents. Initialize S to Node. Until S is empty repeatparents. Initialize S to Node. Until S is empty repeat the followings:the followings: i.i. Remove a node from S and call it CURRENT.Remove a node from S and call it CURRENT. ii.ii. Compute the cost of each of the arcs emerging fromCompute the cost of each of the arcs emerging from CURRENT. Assign minimum cost of its successors as its h.CURRENT. Assign minimum cost of its successors as its h. iii.iii. Mark the best path out of CURRENT by marking the arc thatMark the best path out of CURRENT by marking the arc that had the minimum cost in step iihad the minimum cost in step ii iv.iv. Mark CURRENT as SOLVED if all of the nodes connected toMark CURRENT as SOLVED if all of the nodes connected to it through new labeled arc have been labeled SOLVEDit through new labeled arc have been labeled SOLVED v.v. If CURRENT has been labeled SOLVED or its cost was justIf CURRENT has been labeled SOLVED or its cost was just changed, propagate its new cost back up through the graph.changed, propagate its new cost back up through the graph. So add all of the ancestors of CURRENT to S.So add all of the ancestors of CURRENT to S.
  • 18.  Considers the cost (> 0) for switching from one branch toConsiders the cost (> 0) for switching from one branch to another in the searchanother in the search  Example: path finding in real lifeExample: path finding in real life A CBDF E G 11 4 1 2 167 f(B) = 1 + 1 = 2f(B) = 1 + 1 = 2 (A) f(C) = 1 + 2 = 3(A) f(C) = 1 + 2 = 3 f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 3 = 4(B) f(A) = 1 + 3 = 4 f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3 f(A) = 1 + 6 = 7f(A) = 1 + 6 = 7 (C) f(E) = 1 + 7 = 8(C) f(E) = 1 + 7 = 8 f(B) = 1 + 5 = 6f(B) = 1 + 5 = 6 (A) f(C) = 1 + 8 = 9(A) f(C) = 1 + 8 = 9 f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 9 = 10(B) f(A) = 1 + 9 = 10 f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11 Real Time A*  Considers the cost (> 0) for switching from one branch toConsiders the cost (> 0) for switching from one branch to another in the searchanother in the search  Example: path finding in real lifeExample: path finding in real life A CBDF E G 11 4 1 2 167 f(B) = 1 + 1 = 2f(B) = 1 + 1 = 2 (A) f(C) = 1 + 2 = 3(A) f(C) = 1 + 2 = 3 f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 3 = 4(B) f(A) = 1 + 3 = 4 f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3f(B) = 1 + 5 = 6 (A) f(C) = 1 + 2 = 3 f(A) = 1 + 6 = 7f(A) = 1 + 6 = 7 (C) f(E) = 1 + 7 = 8(C) f(E) = 1 + 7 = 8 f(B) = 1 + 5 = 6f(B) = 1 + 5 = 6 (A) f(C) = 1 + 8 = 9(A) f(C) = 1 + 8 = 9 f(D) = 1 + 4 = 5f(D) = 1 + 4 = 5 (B) f(A) = 1 + 9 = 10(B) f(A) = 1 + 9 = 10 f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11f(F)=1+11= 12 (D) f(B) = 1 + 10 = 11
  • 19. Another Example Current State = SCurrent State = S f(A) = 3 + 5 = 8f(A) = 3 + 5 = 8 f(B) = 2 + 4 = 6f(B) = 2 + 4 = 6 Current State = BCurrent State = B f(S) = 2 + 8 = 10f(S) = 2 + 8 = 10 f(A) = 4 + 5 = 9f(A) = 4 + 5 = 9 f(C) = 1 + 5 = 6f(C) = 1 + 5 = 6 f(E) = 4 + 2 = 6f(E) = 4 + 2 = 6 Current State = CCurrent State = C f(H) = 2 + 4 = 6f(H) = 2 + 4 = 6 f(B) = 1 + 6 = 7f(B) = 1 + 6 = 7 A B C S (4) (4) D (5) 2 (2) G (1) E (2)H (0) 3 4 41 (5) F 2 13 2
  • 20. Current State = HCurrent State = H f(C) = 2 + 7 = 9f(C) = 2 + 7 = 9 Current State = CCurrent State = C f(B) = 1 + 6 = 7f(B) = 1 + 6 = 7 f(H) =f(H) = ∞∞ Current State = BCurrent State = B f(S) = 2 + 8 = 10f(S) = 2 + 8 = 10 f(A) = 4 + 5 = 9f(A) = 4 + 5 = 9 f(E) = 4 + 2 = 6f(E) = 4 + 2 = 6 f(C) =f(C) = ∞∞ Current State = ECurrent State = E f(B) = 4 + 9 = 13f(B) = 4 + 9 = 13 f(D) = 3 + 2 = 5f(D) = 3 + 2 = 5 A B C S (4) (4) D (5) 2 (2) G (1) E (2)H (0) 3 4 41 (5) F 2 13 2 Another Example
  • 21. A B C S (4) (4) D (5) 2 (2) G (1) E (2)H (0) 3 4 41 (5) F 2 13 2 Current State = FCurrent State = F f(E) = 1 + 5 = 6f(E) = 1 + 5 = 6 Current State = ECurrent State = E f(D) = 3 + 2 = 5f(D) = 3 + 2 = 5 f(B) = 4 + 9 = 13f(B) = 4 + 9 = 13 f(F) =f(F) = ∞∞ Current State = DCurrent State = D f(G) = 2 + 0 = 2f(G) = 2 + 0 = 2 f(E) = 3 + 13 = 16f(E) = 3 + 13 = 16 Visited Nodes =Visited Nodes = S, B, C, H, C, B, E, F, E, D, GS, B, C, H, C, B, E, F, E, D, G Path = S, B, E, D, GPath = S, B, E, D, G Another Example