SlideShare una empresa de Scribd logo
1 de 37
Searching large spaces

Finding Paths
Efficiently with A*
presented by
Nicolas Bettenburg




                         1
2
3
What is the fastest way to
       get to TD?




                             4
B
A




        5
A student’s mental model of Kingston...

       Domino's Pizza

                         350
                                                 Grizzly Grill             500              TD
                                          50
                          Pizza Pizza
                                                      60

                                 140                   A&P                            700

                                               100
                                                                                 Hospital
                                        Starbucks

                   900



                                          400                    750




                                                                          1000

                                                     Goodwin Hall
                                    100
                                                           400
                         Gordon Hall


                                                            Biosciences

                                                                                                 6
Describe the Problem as a State Space


                                                   Gordon Hall




                      Goodwin                                                               Domino's
                        Hall                                                                 Pizza




Gordon Hall   Biociences    Hospital                 Starbucks                    Gordon Hall      Grizzly Grill




Goodwin                     Goodwin                                                 Goodwin
               Hospital                TD Canada        A&P         Pizza PIzza                    TD Canada
  Hall                        Hall                                                    Hall




                                       Starbucks    Grizzly Grill   Starbucks      Grizzly Grill




                                                                                                                   7
Uninformed Search
Breadth-First Search will find the path through
 the search tree to the shallowest solution.

                             Gordon Hall




            Domino's Pizza                         Goodwin Hall




             Grizzly Grill   Biociences              Starbucks        Hospital




                 TD                        Pizza                         TD
                              Hospital                      A&P
               Canada                      PIzza                       Canada


            1,75 km                                                  1,55 km
                                 TD        Grizzly         Grizzly
                               Canada       Grill           Grill




                                                                                 8
Breadth-First Search will need to keep
O(bd+1 ) nodes in memory!

b is the branching factor
d is the depth of the solution

                                         b=10
                        Depth    Nodes           Time     Memory
                          2       1100          1/10 s     1 MB
                          4      111,100         11 s     106 MB
                          6       10^7           19 m     10 GB
                          8       10^9           31 h      1 TB
                         10      10^11          129 d     101 TB
                         12      10^13           35 y     10 PB
                         14      10^15          3,523 y    1 EB


                                                                   9
Uninformed Search
Depth-First Search will always expand
  the deepest unexplored node.
                         Gordon Hall




        Domino's Pizza                         Goodwin Hall




         Grizzly Grill   Biociences              Starbucks       Hospital




             TD                        Pizza                       TD
                          Hospital                      A&P
           Canada                      PIzza                     Canada




                             TD        Grizzly         Grizzly
                           Canada       Grill           Grill



                                         TD              TD
                                       Canada          Canada



                                                                            10
Uninformed Search

                   Depth-First   Breadth-First
                   Search        Search

Space complexity     O(b · m)        O(bd+1 )

Time complexity       O(bm )         O(bd+1 )

Complete?              No              Yes


                                                 11
Can you compute
   a solution?
       Yes.
                     Can you compute
                       a best solution?
                     Yes. With enough
                     time and memory
Can you compute
 a best solution
more efficiently?
 This rest of this
  presentation.

                                          12
Idea: Add problem
specific information
using some heuristic.




                        13
For each node, measure the distance from that node
to the goal “as the bird flies”.
       Domino's Pizza

                         350
                                                 Grizzly Grill             500              TD
                                          50
                          Pizza Pizza
                                                      60

                                 140                   A&P                            700

                                               100
                                        Starbucks                                Hospital


                   900



                                          400                    750




                                                                          1000

                                                     Goodwin Hall
                                    100
                                                           400

                         Gordon Hall


                                                            Biosciences


                                                                                                 14
Greedy Best-First
               Search


                               Domino's Pizza
                                                 350
                                                                         Grizzly Grill             500              TD
                                                                  50


Always to expand the node                         Pizza Pizza

                                                         140
                                                                              60

                                                                               A&P                            700



that is closest to the goal.                                           100
                                                                Starbucks                                Hospital


                                           900



                                                                  400                    750




                                                                                                  1000

                                                                             Goodwin Hall
                                                            100
                                                                                   400

                                                 Gordon Hall


                                                                                    Biosciences


                                                                                                                    15
Greedy Best-First
                   Search
                                                      Gordon Hall
                                                         900


                      Goodwin                                                                  Domino's
                        Hall                                                                    Pizza
                             780                                                                     1000



Gordon Hall   Biociences     Hospital                   Starbucks                    Gordon Hall      Grizzly Grill
   900           820           300




Goodwin                      Goodwin                                                   Goodwin
               Hospital                   TD Canada        A&P         Pizza PIzza                    TD Canada
  Hall                         Hall                                                      Hall
                                    780       0




                                          Starbucks    Grizzly Grill   Starbucks      Grizzly Grill




                                                                                                                      16
Domino's Pizza

                  350
                                          Grizzly Grill             500               TD
                                   50
                   Pizza Pizza
                                               60

                          140                   A&P                             700

                                        100
                                 Starbucks                                 Hospital


            900



                                   400                    750




                                                                   1000


                             100
                                              Goodwin Hall                            1,55km!
                                                                             Not the best solution
                                                    400
                  Gordon Hall


                                                     Biosciences
                                                                              but much faster with
                                                                          less memory consumption!


                                                                                                 17
Problems

• follows single path all the way to goal
• will back up when hitting dead end
• not better than Depth-First Search




                                            18
A* Search
Define an evaluation function as:
f(n) = g(n) + h(n)
          g(n) = cost(start, n)
          h(n) = distance(n, end)



Thus f(n) describes the estimated cost
of the cheapest solution through n.

Expand the node with the smallest f(n)

                                         19
Input:
1    OPEN = {n0}
2    CLOSED = {}                                        G, n0, t
3    while (OPEN is not empty)
4      n = pop(OPEN)
5
6
       if (n = t)
         terminate
                                                  Output:
7      else                                 Best path from n0 to t
8        M = Expand(n)
9        for each m in M do
10          if (exists m’ in OPEN with m’ = m)
11            if (f(m’) smaller or equal f(n) + f(m))
12             continue
13          else if (exists m’ in CLOSED with m’ = m)
14            if (f(m’) smaller or equal f(n) + f(m))
15            continue
16          else
17            OPEN = OPEN  {m}
18            CLOSED = CLOSED  {m}
19            parent (m) = n and OPEN = OPEN + {m}
20       end for
21       CLOSED = CLOSED + {n}
22     end if
23   end while


                                                                   20
Gordon Hall

                                                                                                   900 = 0 + 900




                                                                           Domino's Pizza                                     Goodwin Hall

                                                                          1680 = 900 + 780                                880 = 100 + 780




                                                                                                    Biociences                 Starbucks                  Hospital


Domino's Pizza                                                                                    1320 = 500 + 820        1100 = 500+600              1150 = 850 + 300

                  350
                                          Grizzly Grill             500                      TD
                                   50
                   Pizza Pizza
                                               60                                                                     Pizza
                                                                                                                                       A&P
                                                                                                                      PIzza
                          140                   A&P                                   700
                                                                                                              1170 = 640+530      1110 = 600+510
                                        100
                                 Starbucks                                       Hospital

                                                                                                                                      Grizzly
            900                                                                                                                                    1110 = 660+450
                                                                                                                                       Grill



                                   400                    750                                                                          TD
                                                                                                                                                   1160 = 1160 + 0
                                                                                                                                     Canada



                                                                   1000

                                              Goodwin Hall
                             100
                                                    400

                  Gordon Hall


                                                     Biosciences


                                                                                                                                                                         21
Properties of A*
           A* is optimal if h(n) is consistent


h(n)is consistent, if it never over-estimates the true cost
and it fullfils the triangle inequality.

f(n) = g(n) + h(n)
with g(n) is the true cost from start to n.

Hence f(n) never over-estimates
the true cost of a solution through n.
                                                              22
Properties of A*
Suppose an sub-optimal goal node n’ appears on the fringe.
Let the cost of the optimal solution be C*.
Since n’ is sub-optimal and h(n’) = 0
f(n’) = g(n’) + h(n’) = g(n’) + 0 = g(n’) > C*    (a)

For a fringe node n on the optimal path
f(n) = g(n) + h(n) ≤C*                             (b)

Combining (a) and (b) shows f(n) ≤ C* < f(g’)

So n’ will not be expanded and A* will return an optimal
solution.
                                                             23
Properties of A*
                     A* is complete


The f-costs along any path are non-decreasing.

Since A* always expands the the fringe node with lowest f-cost,
we will eventually find a path where the f-cost equals the
cost of an optimal solution C*, if such a path exists.




                                                                  24
Properties of A*
              A* is optimally efficient



For any heuristic function h(n),
no other algorithm can expand fewer nodes with f(n) < C*
without running the risk of missing the optimal solution.




                                                            25
A* can be used for many other problems:


    8-Puzzle              Rubik’s Cube




                                          26
Start State                   Goal State


average solution cost:      22 steps
average branching factor:   3
complete state space:       322 ≈ 3.1 x 1010
distinct state space:       181,440

                                               27
Good heuristics to use with
A* and the 8-Puzzle:

h1 : number of misplaced tiles

h2: sum of manhattan distances from
current positions to goal positions


         Depth     Cost h1       Cost h2
           4         13            12

           22       18,094        1,219

                                           28
There are much harder
            Problems

15-Puzzle:
1013 distinct states

Rubik’s Cube:
8! x 37 x 12! x 210 ≈ 4.3 x 1019 states
branching factor: 13
8! ways to arrange corner cubes
seven indenpendent, eighth dependent on previous choices

12! ways to arrange edges
eleven can be flipped independently,
twelfth depending on previous choices
                                                           29
Image from http://todaysinsidescoop.blogspot.com/2008/04/snowball-effect.html
                                                                                30
Divide into Subproblems!


 * 2 4                      1 2
 *   *                    3 4 *
 * 3 1                    * * *
     Start                   Goal

Cost of C* for this subproblem forms lower
 bound on the cost of complete problem
                                             31
Calculate costs for every possible
       subproblem instance

     Store these in a database

 Use the recorded values as h(n)


Can solve 15-puzzles in a few
        milliseconds!




                                      32
Pattern databases allowed to find the first
optimal solutions to Rubik’s cube in 1997!
                 (18 moves)




                                             33
Computing a pattern
database is expensive!
Usually BFS backwards
from goal to start.




                         34
Compute needed pattern
  database entries on
       demand!

  5 2 4                              * 2 4
                transformation
  8   7                              *   *
  9 3 1                              * 3 1
 real state s                    abstract state Φ(s)

    Search on abstraction levels
                                                       35
Hierarchical A*

              *   *   4

state Øi(s)   *       *   h(Øi(s))
              *   *   *


     .            .          .
     .            .          .
     .            .          .
              *   2   4

state Ø(s)    *       *   h(Ø(s))
              *   3   1


              5   2   4

  state s     8       7      h(s)
              9   3   1


                                     36
Conclusions




              37

Más contenido relacionado

Más de Nicolas Bettenburg

Mining Development Repositories to Study the Impact of Collaboration on Softw...
Mining Development Repositories to Study the Impact of Collaboration on Softw...Mining Development Repositories to Study the Impact of Collaboration on Softw...
Mining Development Repositories to Study the Impact of Collaboration on Softw...Nicolas Bettenburg
 
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source CodeUsing Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source CodeNicolas Bettenburg
 
A Lightweight Approach to Uncover Technical Information in Unstructured Data
A Lightweight Approach to Uncover Technical Information in Unstructured DataA Lightweight Approach to Uncover Technical Information in Unstructured Data
A Lightweight Approach to Uncover Technical Information in Unstructured DataNicolas Bettenburg
 
Managing Community Contributions: Lessons Learned from a Case Study on Andro...
Managing Community Contributions:  Lessons Learned from a Case Study on Andro...Managing Community Contributions:  Lessons Learned from a Case Study on Andro...
Managing Community Contributions: Lessons Learned from a Case Study on Andro...Nicolas Bettenburg
 
Studying the impact of Social Structures on Software Quality
Studying the impact of Social Structures on Software QualityStudying the impact of Social Structures on Software Quality
Studying the impact of Social Structures on Software QualityNicolas Bettenburg
 
An Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release LevelAn Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release LevelNicolas Bettenburg
 
An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...
An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...
An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...Nicolas Bettenburg
 
Automatic Identification of Bug Introducing Changes
Automatic Identification of Bug Introducing ChangesAutomatic Identification of Bug Introducing Changes
Automatic Identification of Bug Introducing ChangesNicolas Bettenburg
 
Cloning Considered Harmful Considered Harmful
Cloning Considered Harmful Considered HarmfulCloning Considered Harmful Considered Harmful
Cloning Considered Harmful Considered HarmfulNicolas Bettenburg
 
Predictors of Customer Perceived Quality
Predictors of Customer Perceived QualityPredictors of Customer Perceived Quality
Predictors of Customer Perceived QualityNicolas Bettenburg
 
Extracting Structural Information from Bug Reports.
Extracting Structural Information from Bug Reports.Extracting Structural Information from Bug Reports.
Extracting Structural Information from Bug Reports.Nicolas Bettenburg
 
Computing Accuracy Precision And Recall
Computing Accuracy Precision And RecallComputing Accuracy Precision And Recall
Computing Accuracy Precision And RecallNicolas Bettenburg
 
Duplicate Bug Reports Considered Harmful ... Really?
Duplicate Bug Reports Considered Harmful ... Really?Duplicate Bug Reports Considered Harmful ... Really?
Duplicate Bug Reports Considered Harmful ... Really?Nicolas Bettenburg
 
The Quality of Bug Reports in Eclipse ETX'07
The Quality of Bug Reports in Eclipse ETX'07The Quality of Bug Reports in Eclipse ETX'07
The Quality of Bug Reports in Eclipse ETX'07Nicolas Bettenburg
 

Más de Nicolas Bettenburg (18)

Mining Development Repositories to Study the Impact of Collaboration on Softw...
Mining Development Repositories to Study the Impact of Collaboration on Softw...Mining Development Repositories to Study the Impact of Collaboration on Softw...
Mining Development Repositories to Study the Impact of Collaboration on Softw...
 
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source CodeUsing Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
 
A Lightweight Approach to Uncover Technical Information in Unstructured Data
A Lightweight Approach to Uncover Technical Information in Unstructured DataA Lightweight Approach to Uncover Technical Information in Unstructured Data
A Lightweight Approach to Uncover Technical Information in Unstructured Data
 
Managing Community Contributions: Lessons Learned from a Case Study on Andro...
Managing Community Contributions:  Lessons Learned from a Case Study on Andro...Managing Community Contributions:  Lessons Learned from a Case Study on Andro...
Managing Community Contributions: Lessons Learned from a Case Study on Andro...
 
Mud flash
Mud flashMud flash
Mud flash
 
Studying the impact of Social Structures on Software Quality
Studying the impact of Social Structures on Software QualityStudying the impact of Social Structures on Software Quality
Studying the impact of Social Structures on Software Quality
 
An Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release LevelAn Empirical Study on Inconsistent Changes to Code Clones at Release Level
An Empirical Study on Inconsistent Changes to Code Clones at Release Level
 
An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...
An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...
An Empirical Study on the Risks of Using Off-the-Shelf Techniques for Process...
 
Fuzzy Logic in Smart Homes
Fuzzy Logic in Smart HomesFuzzy Logic in Smart Homes
Fuzzy Logic in Smart Homes
 
Automatic Identification of Bug Introducing Changes
Automatic Identification of Bug Introducing ChangesAutomatic Identification of Bug Introducing Changes
Automatic Identification of Bug Introducing Changes
 
Cloning Considered Harmful Considered Harmful
Cloning Considered Harmful Considered HarmfulCloning Considered Harmful Considered Harmful
Cloning Considered Harmful Considered Harmful
 
Approximation Algorithms
Approximation AlgorithmsApproximation Algorithms
Approximation Algorithms
 
Predictors of Customer Perceived Quality
Predictors of Customer Perceived QualityPredictors of Customer Perceived Quality
Predictors of Customer Perceived Quality
 
Extracting Structural Information from Bug Reports.
Extracting Structural Information from Bug Reports.Extracting Structural Information from Bug Reports.
Extracting Structural Information from Bug Reports.
 
Computing Accuracy Precision And Recall
Computing Accuracy Precision And RecallComputing Accuracy Precision And Recall
Computing Accuracy Precision And Recall
 
Duplicate Bug Reports Considered Harmful ... Really?
Duplicate Bug Reports Considered Harmful ... Really?Duplicate Bug Reports Considered Harmful ... Really?
Duplicate Bug Reports Considered Harmful ... Really?
 
The Quality of Bug Reports in Eclipse ETX'07
The Quality of Bug Reports in Eclipse ETX'07The Quality of Bug Reports in Eclipse ETX'07
The Quality of Bug Reports in Eclipse ETX'07
 
Metropolis Instant Radiosity
Metropolis Instant RadiosityMetropolis Instant Radiosity
Metropolis Instant Radiosity
 

Último

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Último (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Finding Paths in Large Spaces - A* and Hierarchical A*

  • 1. Searching large spaces Finding Paths Efficiently with A* presented by Nicolas Bettenburg 1
  • 2. 2
  • 3. 3
  • 4. What is the fastest way to get to TD? 4
  • 5. B A 5
  • 6. A student’s mental model of Kingston... Domino's Pizza 350 Grizzly Grill 500 TD 50 Pizza Pizza 60 140 A&P 700 100 Hospital Starbucks 900 400 750 1000 Goodwin Hall 100 400 Gordon Hall Biosciences 6
  • 7. Describe the Problem as a State Space Gordon Hall Goodwin Domino's Hall Pizza Gordon Hall Biociences Hospital Starbucks Gordon Hall Grizzly Grill Goodwin Goodwin Goodwin Hospital TD Canada A&P Pizza PIzza TD Canada Hall Hall Hall Starbucks Grizzly Grill Starbucks Grizzly Grill 7
  • 8. Uninformed Search Breadth-First Search will find the path through the search tree to the shallowest solution. Gordon Hall Domino's Pizza Goodwin Hall Grizzly Grill Biociences Starbucks Hospital TD Pizza TD Hospital A&P Canada PIzza Canada 1,75 km 1,55 km TD Grizzly Grizzly Canada Grill Grill 8
  • 9. Breadth-First Search will need to keep O(bd+1 ) nodes in memory! b is the branching factor d is the depth of the solution b=10 Depth Nodes Time Memory 2 1100 1/10 s 1 MB 4 111,100 11 s 106 MB 6 10^7 19 m 10 GB 8 10^9 31 h 1 TB 10 10^11 129 d 101 TB 12 10^13 35 y 10 PB 14 10^15 3,523 y 1 EB 9
  • 10. Uninformed Search Depth-First Search will always expand the deepest unexplored node. Gordon Hall Domino's Pizza Goodwin Hall Grizzly Grill Biociences Starbucks Hospital TD Pizza TD Hospital A&P Canada PIzza Canada TD Grizzly Grizzly Canada Grill Grill TD TD Canada Canada 10
  • 11. Uninformed Search Depth-First Breadth-First Search Search Space complexity O(b · m) O(bd+1 ) Time complexity O(bm ) O(bd+1 ) Complete? No Yes 11
  • 12. Can you compute a solution? Yes. Can you compute a best solution? Yes. With enough time and memory Can you compute a best solution more efficiently? This rest of this presentation. 12
  • 13. Idea: Add problem specific information using some heuristic. 13
  • 14. For each node, measure the distance from that node to the goal “as the bird flies”. Domino's Pizza 350 Grizzly Grill 500 TD 50 Pizza Pizza 60 140 A&P 700 100 Starbucks Hospital 900 400 750 1000 Goodwin Hall 100 400 Gordon Hall Biosciences 14
  • 15. Greedy Best-First Search Domino's Pizza 350 Grizzly Grill 500 TD 50 Always to expand the node Pizza Pizza 140 60 A&P 700 that is closest to the goal. 100 Starbucks Hospital 900 400 750 1000 Goodwin Hall 100 400 Gordon Hall Biosciences 15
  • 16. Greedy Best-First Search Gordon Hall 900 Goodwin Domino's Hall Pizza 780 1000 Gordon Hall Biociences Hospital Starbucks Gordon Hall Grizzly Grill 900 820 300 Goodwin Goodwin Goodwin Hospital TD Canada A&P Pizza PIzza TD Canada Hall Hall Hall 780 0 Starbucks Grizzly Grill Starbucks Grizzly Grill 16
  • 17. Domino's Pizza 350 Grizzly Grill 500 TD 50 Pizza Pizza 60 140 A&P 700 100 Starbucks Hospital 900 400 750 1000 100 Goodwin Hall 1,55km! Not the best solution 400 Gordon Hall Biosciences but much faster with less memory consumption! 17
  • 18. Problems • follows single path all the way to goal • will back up when hitting dead end • not better than Depth-First Search 18
  • 19. A* Search Define an evaluation function as: f(n) = g(n) + h(n) g(n) = cost(start, n) h(n) = distance(n, end) Thus f(n) describes the estimated cost of the cheapest solution through n. Expand the node with the smallest f(n) 19
  • 20. Input: 1 OPEN = {n0} 2 CLOSED = {} G, n0, t 3 while (OPEN is not empty) 4 n = pop(OPEN) 5 6 if (n = t) terminate Output: 7 else Best path from n0 to t 8 M = Expand(n) 9 for each m in M do 10 if (exists m’ in OPEN with m’ = m) 11 if (f(m’) smaller or equal f(n) + f(m)) 12 continue 13 else if (exists m’ in CLOSED with m’ = m) 14 if (f(m’) smaller or equal f(n) + f(m)) 15 continue 16 else 17 OPEN = OPEN {m} 18 CLOSED = CLOSED {m} 19 parent (m) = n and OPEN = OPEN + {m} 20 end for 21 CLOSED = CLOSED + {n} 22 end if 23 end while 20
  • 21. Gordon Hall 900 = 0 + 900 Domino's Pizza Goodwin Hall 1680 = 900 + 780 880 = 100 + 780 Biociences Starbucks Hospital Domino's Pizza 1320 = 500 + 820 1100 = 500+600 1150 = 850 + 300 350 Grizzly Grill 500 TD 50 Pizza Pizza 60 Pizza A&P PIzza 140 A&P 700 1170 = 640+530 1110 = 600+510 100 Starbucks Hospital Grizzly 900 1110 = 660+450 Grill 400 750 TD 1160 = 1160 + 0 Canada 1000 Goodwin Hall 100 400 Gordon Hall Biosciences 21
  • 22. Properties of A* A* is optimal if h(n) is consistent h(n)is consistent, if it never over-estimates the true cost and it fullfils the triangle inequality. f(n) = g(n) + h(n) with g(n) is the true cost from start to n. Hence f(n) never over-estimates the true cost of a solution through n. 22
  • 23. Properties of A* Suppose an sub-optimal goal node n’ appears on the fringe. Let the cost of the optimal solution be C*. Since n’ is sub-optimal and h(n’) = 0 f(n’) = g(n’) + h(n’) = g(n’) + 0 = g(n’) > C* (a) For a fringe node n on the optimal path f(n) = g(n) + h(n) ≤C* (b) Combining (a) and (b) shows f(n) ≤ C* < f(g’) So n’ will not be expanded and A* will return an optimal solution. 23
  • 24. Properties of A* A* is complete The f-costs along any path are non-decreasing. Since A* always expands the the fringe node with lowest f-cost, we will eventually find a path where the f-cost equals the cost of an optimal solution C*, if such a path exists. 24
  • 25. Properties of A* A* is optimally efficient For any heuristic function h(n), no other algorithm can expand fewer nodes with f(n) < C* without running the risk of missing the optimal solution. 25
  • 26. A* can be used for many other problems: 8-Puzzle Rubik’s Cube 26
  • 27. Start State Goal State average solution cost: 22 steps average branching factor: 3 complete state space: 322 ≈ 3.1 x 1010 distinct state space: 181,440 27
  • 28. Good heuristics to use with A* and the 8-Puzzle: h1 : number of misplaced tiles h2: sum of manhattan distances from current positions to goal positions Depth Cost h1 Cost h2 4 13 12 22 18,094 1,219 28
  • 29. There are much harder Problems 15-Puzzle: 1013 distinct states Rubik’s Cube: 8! x 37 x 12! x 210 ≈ 4.3 x 1019 states branching factor: 13 8! ways to arrange corner cubes seven indenpendent, eighth dependent on previous choices 12! ways to arrange edges eleven can be flipped independently, twelfth depending on previous choices 29
  • 31. Divide into Subproblems! * 2 4 1 2 * * 3 4 * * 3 1 * * * Start Goal Cost of C* for this subproblem forms lower bound on the cost of complete problem 31
  • 32. Calculate costs for every possible subproblem instance Store these in a database Use the recorded values as h(n) Can solve 15-puzzles in a few milliseconds! 32
  • 33. Pattern databases allowed to find the first optimal solutions to Rubik’s cube in 1997! (18 moves) 33
  • 34. Computing a pattern database is expensive! Usually BFS backwards from goal to start. 34
  • 35. Compute needed pattern database entries on demand! 5 2 4 * 2 4 transformation 8 7 * * 9 3 1 * 3 1 real state s abstract state Φ(s) Search on abstraction levels 35
  • 36. Hierarchical A* * * 4 state Øi(s) * * h(Øi(s)) * * * . . . . . . . . . * 2 4 state Ø(s) * * h(Ø(s)) * 3 1 5 2 4 state s 8 7 h(s) 9 3 1 36