Artificial Intelligence & Machine Learning, Zusammenfassungen von Künstliche Intelligenz

Toggle sidebar
bg1
3/27/2026
1
Search Algorithms for Small-Size Problems
Dr. Berke Gür
Artificial Intelligence & Machine Learning
Dr. Berke Gür
3/27/2026
1
Chapter Overview
•Small-sized (discrete) search algorithms
–Uninformed (blind) search algorithms
•Breadth-first algorithm
•Uniform-cost algorithm (Dijkstra's algorithm)
–Informed (Heuristic) search algorithms
•First-best algorithm
•A* algorithm
Artificial Intelligence & Machine Learning
Dr. Berke Gür
3/27/2026
2
1
2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Unvollständige Textvorschau

Nur auf Docsity: Lade Artificial Intelligence & Machine Learning und mehr Zusammenfassungen als PDF für Künstliche Intelligenz herunter!

1

Search Algorithms for Small-Size Problems

Dr. Berke Gür Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 1

Chapter Overview

  • Small-sized (discrete) search algorithms
    • Uninformed (blind) search algorithms
      • Breadth-first algorithm
      • Uniform-cost algorithm (Dijkstra's algorithm)
    • Informed (Heuristic) search algorithms
      • First-best algorithm
      • A* algorithm Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 2 1

2

Defining Discrete Problems

  • A discrete problem has a finite number of states (s)
    • The starting state
    • Several intermediate states
    • The goal state
  • An action (a) is what causes the agent to move from one state to another
  • A solution to a problem is defined as a sequence of actions that gets the agent from the starting state to the goal state Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 3

Performance of Search Algorithms

  • Completeness: Is the algorithm guaranteed to find a solution when there is one?
  • Optimality: Does the strategy find the optimal solution
    • An optimal solution is the solution with the lowest path cost
  • Time complexity: How long does it take to find a solution?
  • Space complexity: How much memory is needed to perform the search? Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 4 3

4

Tree-Search Methods

  • A typical tree search
    • Given an
      • Initial state (In{Arad})
      • Goal state (In{Bucharest})
    • Test whether the current (or initial) state is a goal state - This is done to solve trick problems like «starting in Arad, get to Arad» - If «yes», end search
    • Consider taking various actions
      • Apply each legal action to (i.e. expand) current state
      • Actions will generate a new set of states Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 7

Tree-Search Methods

  • Expand (In{Arad}) & add 3 branches from the parent node (In{Arad})
  • This leads to 3 new child nodes
    • In{Sibiu}
    • In{Timisoara}
    • In{Zerind}
  • Now these 3 possibilities must be considered
  • Choose a node & put others aside for later (in case the first choice does not lead to a solution) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 8 7

5

Tree-Search Methods

  • Choose (In{Sibiu}) & check to see it is not the goal state
  • Expand it to get
    • In{Arad}
    • In{Fagaras}
    • In{Oradea}
    • In{Rimnicu Vilcea}
  • Choose any of these 4 or go back & choose - In{Timisoara} - In{Zerind} Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 9

Tree-Search Methods

  • Search algorithms vary according to how they choose which state to expand next called the search strategy
  • The path from Arad to Sibiu and back to Arad is a repeated state in the search tree
  • In this case the repeated state is generated by a loopy path
  • Path costs are additive & step costs are nonnegative
  • Thus, a loopy path to any given state is never better than the same path with the loop removed Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 10 9

7

Tree vs. Graph Search

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 13 Graph Representation Tree Representation

Uninformed (Blind) Search Algorithms

  • Uninformed search algorithms use no additional information about states beyond that provided in the problem definition
  • All they can do is generate successors (nodes) & distinguish a goal state from a non-goal state
  • In this chapter, we discuss 2 uninformed search methods
    • Breadth-first search
    • Uniform-cost search Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 14 13

8

  • Breadth-first search is a simple strategy
  • The root node is expanded first, then all the successors of the root node are expanded next, then their successors, & so on
  • In general, all the nodes are expanded at a given depth in the search tree before any nodes at the next level are expanded

Breadth-First Search

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 15

  • The shallowest unexpanded node is chosen for expansion using a very simply FIFO queue for the frontier - New nodes (which are always deeper than their parents) go to the back of the queue - Old nodes (which are shallower than the new nodes) get expanded first

Breadth-First Search

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 16 15

10

Uniform-Cost Search

  • Breadth-first search is optimal when all step costs are equal (always expands the shallowest unexpanded node)
  • By a simple extension, an algorithm that is optimal with any step-cost function can be devised
  • Instead of expanding the shallowest node, uniform-cost search expands the node (n) with the lowest path cost g(n)
  • This is done by storing the frontier as a priority queue ordered by g(n)
  • This algorithm is also known as Dijkstra's algorithm Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 19
  • There are some other differences compared to breadth-first
    • The goal test is applied to a node when it is selected for expansion (the first goal node generated may be on a suboptimal path)
    • A test is added in case a better path is found to a node currently on the frontier

Uniform-Cost Search

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 20

  • The problem is to get from Sibiu to Bucharest
  • The successors of Sibiu are Rimnicu Vilcea [g(n) = 80] and Fagaras [g(n) = 99]
  • Expand Rimnicu Vilcea (least cost)
  • Add Pitesti [g(n) = 80 + 97 = 177]
  • Least-cost node is now Fagaras
  • Expand Faragas, add Bucharest [goal; g(n) = 99 + 211 = 310]
  • Goal node is been generated (but algorithm keeps going)
  • Expand Pitesti & add a second path to goal [g(n) = 80 + 97 + 101 = 278]
  • Algorithm checks to see if this new path is better than the old one
  • Since it is, the old path is discarded
  • Final solution has a g-cost 278 19

11

Optimality of Uniform-Cost Search

  • Uniform-cost search is optimal in general
  • Uniform-cost search only cares about the total cost of a path (& not about the number of steps a path has) - Therefore, it will get stuck in an infinite loop if there is a path with an infinite sequence of zero-cost actions (e.g., a sequence of «No-Operation» actions)
  • Completeness is guaranteed provided the cost of every step exceeds some small positive constant (ε)
  • Uniform-cost search is guided by path costs rather than depths (its complexity is not easily characterized) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 21

Optimality of Uniform-Cost Search

  • Assume (C*) is the cost of the optimal solution
  • Assume that every action costs at least (ε)
  • The algorithm’s worst-case time & space complexity is [b(1 + floor(C*/ε))]
  • This can be much greater than (bd^ )
  • This is because uniform-cost search can explore large trees of small steps before exploring paths involving large & perhaps useful steps
  • When all step costs are equal, b(1 + floor(C*/ε))^ becomes b(d^ + 1)
    • Uniform-cost search is like breadth-first search
    • Breadth-first stops as soon as it generates a goal
    • Uniform-cost search examines all the nodes at the goal’s depth to see if one has a lower cost
    • Thus uniform-cost search does strictly more work by expanding nodes at depth (d) unnecessarily Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 22 21

13

Greedy Best-First Algorithm

  • The node closest to the goal is most likely on the shortest path
  • Greedy best-first search tries to expand the node that is closest to the goal
  • It evaluates nodes by using just the heuristic function (e.g., f (n) = h(n))
  • The worst-case time & space complexity for the tree version is (bm)
    • (b) is the branching factor (no of branches per node)
    • (m) is the max depth of the search space Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 25
  • Romania road map
    • The first node to be expanded from Arad will be Sibiu
    • This is because hSLD{Sibiu} = 253 km is closer to Bucharest than hSLD{Zerind} = 374 km or hSLD{Timisoara} = 329 km
    • The next node to be expanded will be hSLD{Fagaras} = 176 km because it is closest
    • Fagaras in turn generates the goal Bucharest

Ex: Romania Road Map with Greedy Best-First

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 26 25

14

  • A solution is found without expanding any node not on the solution path
  • The solution is not optimal: The path via Sibiu and Fagaras to Bucharest is 32 km longer than the path through Rimnicu Vilcea & Pitesti
  • Consider the problem of getting from Iasi to Fagaras
  • The heuristic suggests Neamt be expanded first because it is closest to Fagaras (dead end)

Ex: Romania Road Map with Greedy Best-First

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 27

  • The solution is to go first to Vaslui (a step that is farther from the goal) & then to Urziceni, Bucharest & Fagaras
  • The algorithm will never find this solution
  • Expanding Neamt puts Iasi back into the frontier & Iasi is closer to Fagaras than Vaslui is, and so Iasi will be expanded again, leading to an infinite loop

Ex: Romania Road Map with Greedy Best-First

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 28 27

16

Optimality of A*

  • Every consistent heuristic is also admissible (consistency is stricter)
  • It is quite hard (but not impossible) to devise admissible but not consistent heuristics - The tree-search version of A* is optimal if h(n) is admissible - The graph-search version A* is optimal if h(n) is consistent
  • Among optimal algorithms of this type (algorithms that extend search paths from the root & use the same heuristic information) A* is optimally efficient for any given consistent heuristic
  • This means that no other optimal algorithm is guaranteed to expand fewer nodes than A* (except possibly through tie-breaking among nodes with f (n) = C*) Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 31

Ex: Romania Road Map with A*

Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 32 31

17

A* Contours

  • A* expands the frontier node of lowest f-cost
  • It is possible to draw concentric increasing f-cost bands emerging from the start node - Ex: All nodes have f (n) = 400 inside the 400 contour
  • For uniform-cost search (A* search using h(n) = 0), the bands will be «circular» around the start state
  • With more accurate heuristics, the bands will stretch toward the goal state & become more narrowly focused around the optimal path Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 33

Pruning

  • If (C*) is the cost of the optimal solution path
    • A* expands all nodes with f (n) < C*
    • A* might then expand some of the nodes right on the «goal contour» (where f (n) = C*) before selecting a goal node
  • A* does not expand nodes with f (n) > C*
    • For example, Timisoara ( f = 447) is not expanded even though it is a child of the root because C* = 418
  • The subtree below Timisoara is pruned (~budamak)
    • The algorithm safely ignores this subtree while still guaranteeing optimality
  • Pruning is eliminating possibilities from consideration without having to examine them
  • Pruning is very important for many areas of AI Artificial Intelligence & Machine Learning Dr. Berke Gür 3/27/ 34 33