Search Algorithms with Examples by Hsinchun Chen & Reza Ebrahimi

Search Algorithms with Examples by Hsinchun Chen & Reza Ebrahimi
Slide Note
Embed
Share

This comprehensive guide delves into various search algorithms such as Depth First Search, Breadth First Search, Hill Climbing, A*, Genetic Algorithms, and Reinforcement Learning. The content includes examples, explanations, and visuals to help understand the principles and applications of these algorithms in different scenarios. Whether you are a beginner or an experienced practitioner in the field, this resource offers valuable insights into deterministic and stochastic search strategies for pathfinding and optimization problems.

  • Search Algorithms
  • Hsinchun Chen
  • Reza Ebrahimi
  • Examples
  • Pathfinding

Uploaded on Mar 10, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Search Algorithms with Examples Hsinchun Chen & Reza Ebrahimi February, 2020 Acknowledgement: Chapter 4, Exploring Alternatives, AI, Winston 1

  2. Search Algorithms: Deterministic I. Find a path: heuristic (e.g., estimated remaining distance, e.r.d.) 1. Depth First Search (DFS): Stack (LIFO) 2. Hill Climbing: DFS + heuristic (e.r.d.) 3. Breadth First Search (BFS): Queue (FIFO) 4. Beam Search: BFS + search only the best (e.r.d.) w nodes at each level (pruning) 5. Best First Search: follows the best path based on heuristic (e.r.d.) only II. Find an optimal path: actual distance 6. British Museum Search: exhaustive DFS or BFS, add all distances 7. Brand and Bound (BNB): follows the optimal path based on actual accumulated distance 8. Dynamic Programming: BNB + removing longer paths reaching the same node (pruning) 9. A*: follows the optimal path based on actual distance + heuristic (e.g., e.r.d.) 2

  3. Search Algorithms: Stochastic (Global Optimum) III. Genetic Algorithms: modeled as evolution/natural selection with genes Random initialization (G0, stochastic) with bit strings (genes, e.g., m bits) & initial population (pop- size, Vi) & evaluate fitness (fitness function, F(Vi)) Reproduction based on fitness & roulette wheel selection (of Vi; random) based on individual fitness (F(Vi)) Recombination with crossover (Pc, e.g., 0.3-0.9; exploitation ) and mutation (Pm, e.g., 0.01-0.03; exploration ) Evolve over many generations until convergence IV. Reinforcement Learning: modeled as Markov Decision Process (MDP) with agents S: a set of environment and agent states A: a set of actions of the agent (e.g., agent s action selection as policy map ) P(S |S, A): the probability of transition from state S to S under action A R(S |S, A): the immediate reward after transition from state S to S under action A Stochastic (random) rules that describe what the agent observes (O). An RL agent (A) interacts with its environment in discrete time steps to receive an observation (O) with a specific reward (R). RF aims to collect as much reward as possible through the process of exploration (e.g., e-greedy method; e at random) and exploitation (1 e). 3

  4. A Simple Example: Traveling from S to G (Chapter 4, AI, Exploring Alternatives) 4 4 A B C 3 6.7 10.4 Actual Distance S G 5 5 8.9 6.9 Estimated Remaining Distance (e.r.d.) 4 D F E 3 2 4 Rules: 1) Search direct neighbors 2) No cycle/repeat 3) Stop when goal reached 4

  5. I. Find a Path: (1) Depth First Search (DFS) & (2) Hill Climbing DFS: Stack (LIFO); search depth first Hill Climbing: DFS + e.r.d. (check only unfinished paths at the same level) S S A D 8.9 10.4 A D B D 10.4 6.9 A E C E X B F 3 6.7 F D X G Stop! Stop! G 5

  6. I. Find a Path: (3) Breadth First Search (BFS) & (4) Beam Search BFS: Queue (FIFO); search level by level (by breadth) S Beam Search: BFS + best (e.r.d.) w (e.g., 2) nodes S 10.4 8.9 A D A D 6.9 A E A E B 10.4 D B D 8.9 6.7 X X E B C E 6.9 C E 6.7 B F B F 3 X X X G G A C C E B F D F Stop! Stop! 6

  7. I. Find a Path: (5) Best First Search Search the best path based on heuristic only (e.g., e.r.d.) Check all unfinished paths at all levels S 10.4 8.9 A D 10.4 6.9 A E F 6.7 3 B Stop! G 7

  8. II. Find an Optimal Path: (6) British Museum Search (BMS) BMS Steps: 1. Perform exhaustive BFS or DFS to find all paths 2. Add all actual distances for all paths 3. Pick the shortest path S 4 3 A D 4 5 2 5 A E B D 4 5 4 2 4 5 E B C E B F 3 4 4 5 4 5 2 4 4 G A C C E B F D F . . . 8

  9. II. Find an Optimal Path: (7) Branch and Bound (BNB) & (8) Dynamic Programming Dynamic Programming: BNB + removing longer paths reaching the same node BNB: actual accumulated distances S 3 4 S 4 3 (4) (3) A D (4) (3) 4 A D 2 5 5 4 2 5 5 (6) (8) (9) (7) A E B D (6) (8) (9) (7) A E B D 4 5 4 4 2 4 5 5 5 X X 4 (10) (13) (10) E (11) B (12) C E (10) (11) B F (11) (12) C E (11) B F 3 4 4 5 2 4 4 X 3 X X X (13) G (15) (15) (14) A C (16) (15) F B (14) (13) D F G Stop! Stop! Stop: All unfinished paths >= Finished path 9

  10. II. Find an Optimal Path: (9) A* (A Star) A*: Actual Distance + e.r.d. (needs to be under-estimate) S 4 3 (12.9) A D (13.4) 5 2 (19.4) (12.9) 4 A E 5 (17.7) B F (13) G Stop: when a finished path is found Stop! 10

Related


More Related Content