Professional Documents
Culture Documents
sequence of cities
4 Prepared by Chala S. (MSc in CSE) 03/21/2023
Road map of Romania Touring
Problem Formulation
States: 2 agent location *2 possible dirt locations
*2 different dirt states= 8 states
Initial state: any state
Actions: Left, Right, and Suck
Transition model: complete state space, see next
slide.
Goal test: check if both squares are clean
Path cost: each step costs 1
10 Prepared by Chala S. (MSc in CSE) 03/21/2023
Complete state space
Arrangements of n queens, one per column in the leftmost n columns, with no queen
attacking another.
Actions:
Add a queen to any square in the leftmost empty column such that it is not attacked by any
other queen
2057 sequences to investigate and solutions are easy to find.
15 Prepared by Chala S. (MSc in CSE) 03/21/2023
Example Problems – Towers of Hanoi
States: combinations of poles and disks
Actions: move disk x from pole y to pole z
subject to constraints
• cannot move disk on top of smaller disk
• cannot move disk if other disks on top
Goal test: disks from largest (at bottom) to
smallest on goal pole
Path cost: 1 per move
Problem Formulation
States: list of colors for each cell on each face
Initial state: one specific cube configuration
Actions: rotate row x or column y on face z
direction
Goal: configuration has only one color on
each face
Path cost: 1 per move
GRAPH-SEARCH
Uses “explored” set to avoid visiting already
explored states.
Uses “frontier” set to store states that remain
to be explored and expanded.
20 Prepared by Chala S. (MSc in CSE) 03/21/2023
Graph-Search
Redundant paths can cause a tractable problem to become intractable.
The way to avoid exploring redundant paths is to remember where one has been.
To do this, we augment the TREE-SEARCH algorithm with a data structure called the
explored set (also known as the closed list), which remembers every expanded node.
Newly generated nodes that match previously generated nodes—ones in the explored set or
the frontier—can be discarded instead of being added to the frontier.
does the strategy find the highest-quality solution when there are several different solutions?
Time complexity:
how long does it take to find a solution?
Space complexity:
how much memory is needed to perform the search?
Uninformed search
no information about the number of steps or the path cost from the current state to the goal.
search the state space blindly
Informed search, or heuristic search uses some kind of:
evaluation function to tell us how far each expanded state is from a goal state,
heuristic function to help us decide which state is likely to be the best one to expand next.
27 Prepared by Chala S. (MSc in CSE) 03/21/2023
Uninformed Search Strategies
Given a state, we only know whether it is a goal state or not
Cannot say one non-goal state looks better than another non-goal state
Traverse state space blindly in hope of somehow hitting a goal state at some point
General uninformed search strategies:
Breadth-first search g e o f t he
f o r t h e frin
q u e ue used e r a t ed but
Uniform-cost search u e : t y p e of f no d es gen
Key iss n o f t ree lea
( co lle c ti o
re e
search t
Depth-first search
p a n d e d)
ex
Depth-limited search not yet
A D
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17 G 25
30 Prepared by Chala S. (MSc in CSE) 03/21/2023
BFS on a Graph
The disadvantage:
if the branching factor of a node is large,
for even small instances (e.g., chess)
the space complexity and the time complexity are enormous
Implementation:
A D
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17 G 25
40 Prepared by Chala S. (MSc in CSE) 03/21/2023
DFS Analysis
It overcomes
the time and space complexities
Complete? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
complete in finite spaces
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
44
19 19 17 G 25 Prepared by Chala S. (MSc in CSE) 03/21/2023
Iterative deepening search
No choosing of the best depth limit
It tries all possible depth limits: first 0, then 1, 2, and so on
combines the benefits of depth-first and breadth-first search
Space? O(bd)
Start Goal
The general approach we consider is called best-first search: a general TREE-SEARCH or GRAPH-
SEARCH algorithm in which a node is selected for expansion based on an evaluation function, f(n).
f(n): construed as a cost estimate, so the node with the lowest evaluation is expanded first.
Identical to that for uniform-cost search, except for the use of f instead of g to order the priority
queue.
The choice of f determines the search strategy
Example: We use the straight line distance heuristic, which we will call hSLD
hSLD(In(Arad))= 366
Let’s examine:
Arad Sibiu Fagaras Bucharest
An assignment that does not violate any constraints is called a consistent or legal
assignment.
A complete assignment is one in which every variable is mentioned, and a solution to
a CSP is a complete assignment that satisfies all the constraints.
The task is coloring each region either red, green, or blue in such a way that the neighboring: regions
have no the same color.
Any Question?