Professional Documents
Culture Documents
Chapter 3
Chapter 3
Artificial Intelligence
Chapter 3 - Searching and Planning
by Mintesinot Getachew
❑ Solving Problems by Searching and
planning
❑ Constraint Satisfaction Problem
❑ Problem Solving Agents
❑ Problem spaces and search
Outline
❑ Knowledge and rationality
❑ Heuristic search strategies
❑ Search and optimization (gradient
descent)
❑ Adversarial search
❑ Planning and scheduling
❑ Avoiding Repeated States
❑ Dynamic game theory
2
Solving Problems
By Searching and
Planning
3
Solving Problems by Searching and planning
Solving Problems by Searching
❑ Searching is a fundamental problem-solving technique in AI.
❑ It involves systematically exploring a space of possible solutions until a
goal state is reached.
❑ The space of possible solutions can be represented as a search tree or
graph.
❑ There are different search algorithms, such as depth-first search,
breadth-first search, and A* search, each with its own advantages and
limitations.
4
Solving Problems by Searching and planning
Planning in AI
❑ Planning is the process of finding a sequence of actions that transform an
initial state into a goal state.
❑ It involves reasoning about the effects of actions and their interactions.
❑ There are different types of planning, such as forward planning and
backward planning.
❑ Planning can be done using search algorithms or rule-based systems.
❑ Planning is used in many applications, such as robotics, scheduling, and
game playing.
5
Constraint satisfaction problem (CSP)
❑ CSP is a type of problem in AI that involves finding a solution that satisfies
a set of constraints or limitations.
❑ Representation: CSP can be represented as a set of variables, a set of
domains for each variable, and a set of constraints that specify the
allowable combinations of values for the variables.
❑ Examples: CSP can be applied to various real-world problems, such as
scheduling, planning, routing, configuration, and design.
❑ Algorithms: There are various algorithms that can be used to solve CSP,
such as backtracking search, forward checking, arc consistency, and
constraint propagation.
6
Constraint satisfaction problem (CSP) …Cont’d
❑ Heuristics: To improve the efficiency of CSP algorithms, various heuristics
can be used, such as variable and value ordering, constraint propagation,
and domain splitting.
❑ Complexity: The complexity of CSP depends on the number of variables, the
size of the domain, and the number and nature of the constraints.
❑ Applications: CSP has many practical applications in different fields, such as
manufacturing, logistics, finance, and healthcare.
❑ Challenges: Some of the challenges of CSP include dealing with incomplete
or uncertain information, handling large and complex problem domains, and
developing efficient algorithms and heuristics.
7
AI Agent Problem Formulation
▪ Problem formulation involves defining the problem, its objectives, and the constraints
that the agent must operate under.
10
Types of search algorithms
11
Uninformed search Strategies
❑ The uninformed search does not contain any domain specific knowledge such
as closeness, the location of the goal.
❑ Blind search algorithms are often used in situations where the state space is
small or the problem is relatively simple.
❑ Class of general-purpose search algorithms which operates in brute force-way.
12
Common Uninformed search Algorithms
❑ Breadth-first search (BFS): explores all neighbor nodes before proceeding to the next level.
❑ Depth-first search (DFS): explores as far as possible along each branch before backtracking.
❑ Iterative deepening search (IDS): performs a series of depth-limited searches with increasing
depth limits.
❑ Uniform-cost search (UCS): expands the node with the lowest path cost.
❑ Bidirectional search: performs two simultaneous searches, one from the initial state and one
from the goal state, and stops when the two meet in the middle.
❑ Depth-limited search (DLS): limits the depth of the search to a specified level.
13
Depth First Search
14
Example: Search using Depth first algorithm
9 2 5 7 2
2
D G
G G H J
8
7 E
G
G H
Path S→C→D→E→G 15
◉ Completeness: DFS search algorithm is complete within finite state space
as it will expand every node within a limited search tree.
◉ Space Complexity: DFS algorithm needs to store only single path from the
root node, hence space complexity of DFS is equivalent to the size of the
fringe set, which is O(bm).
◉ DFS search algorithm is non-optimal, as it may generate a large number of
steps or high cost to reach to the goal node.
16
Breadth First Search
17
Example: Search using Breadth first algorithm
S 1
5 S Visited list: S, C, D, F
9 6
6
3 1 2
C D E F
C D F
9 2 5 7 2
2
G G H J
D G E E J
8
7
G
Path S→C→G
18
◉ Time Complexity: Time Complexity of BFS algorithm can be obtained by
the number of nodes traversed in BFS until the shallowest Node.
○ Where the d= depth of shallowest solution and n = number of nodes
at every state.
19
Iterative deepening search (IDS)
20
Completeness: This algorithm is complete is if the branching factor is finite.
Time Complexity: Let's suppose b is the branching factor and depth is d then the worst-case
time complexity is O(bd).
Optimal: IDS algorithm is optimal if path cost is a non- decreasing function of the depth of the
node.
21
Uniform-cost Search Algorithm
22
Example: Search using Uniform-Cost algorithm
S 1
5 S Visited list: S, C, F, D, E, J
9 6 5
6 9 6
3 1 2
C D E F
C D F 6
2 5 9
9 2 5 7 2 2
2 3 9
G G H J
D G E J
8 8 14 8 8
7 1 5 7 7
G D G H G
9 13 15 15
Path S→F→E→G 23
Depth-Limited Search Algorithm
24
Completeness: DLS search algorithm is complete if the solution is above the depth-limit.
Optimal: Depth-limited search can be viewed as a special case of DFS, and it is also not
optimal even if ℓ > d.
25
Bidirectional Search Algorithm
26
Bidirectional Search Algorithm
…Cont’d
❑ Advantages:
❑ Bidirectional search is fast.
❑ Bidirectional search requires less memory
❑ Disadvantages:
❑ Implementation of the bidirectional search tree is difficult.
❑ In bidirectional search, one should know the goal state in advance.
27
Informed (Heuristic) Search strategies
28
Traveling salesman problem
Mizan Agaro
50 KM
105 KM
Bonga Jimma
Hawassa
What are algorithms that can be used to solve TSP, prepare at least 4 page report. (Assignment) 29
Best-first Search Algorithm (Greedy Search)
❑ This algorithm always selects the path which appears best at that moment.
❑ We expand the node closest to the goal node.
❑ The “closeness” is estimated by a heuristic h(x).
h(x) = Estimate of distance of node x from the goal node.
Lower the value of h(x), closer is the node from the goal.
❑ It is the combination of depth-first search and breadth-first search
algorithms.
❑ Best-first search allows us to take the advantages of both algorithms.
30
Best first search algorithm
31
Example
Question. Consider the below search problem, and we will traverse it using greedy best-first
search. At each iteration, each node is expanded using evaluation function f(n)=h(n) , which
is given in the below table.
32
Solution
In this search example, we are using two lists which are OPEN and VISITED Lists. Following are the iteration for
traversing the above example.
34
Algorithm of A* search
35
Example
Question. In this example, we will traverse the given graph using the A* algorithm. The
heuristic value of all states is given in the below table so we will calculate the f(n) of each
state using the formula f(n)= g(n) + h(n), where g(n) is the cost to reach any node from start
state. Here we will use OPEN and VISITED list.
36
Solution
In this search example, we are using two lists which are OPEN and VISITED Lists. Following are the iteration for
traversing the above example.
★ A* algorithm returns the path which occurred first, and it does not
search for all remaining paths.
★ The efficiency of A* algorithm depends on the quality of heuristic.
★ A* algorithm expands all nodes which satisfy the condition f(n)
38
Introduction to AI
"Artificial intelligence is the future and the future
is here.” Dave Waters
39