Professional Documents
Culture Documents
Preethi.P
Assistant Professor
Department of Computer Science & Engineering
Machine Intelligence
SEARCH
A Search Problem
Agen
t
Machine Intelligence
SEARCH Problem - Example
Google Maps
Machine Intelligence
Terminologies
Agent :
Agent is an entity that perceives its environment and acts
upon that environment.
The agent program is a concrete implementation, running within some physical system.
Machine Intelligence
Terminologies
State :
State is a configuration of the agent and its environment
Initial State :
Initial state is the state in which the agent begins.
State x
Machine Intelligence
Terminologies
Actions :
Actions choices that can be made in a state.
Transition Model :
Transition Model is a description of what state results from performing any
applicable action in any state.
State Space
State Space is the set of all states reachable from the initial state by any
sequence of actions.
Machine Intelligence
Terminologies
State Space
The state space can be visualized as a directed graph with states,
represented as nodes, and actions, represented as arrows between nodes.
Machine Intelligence
Terminologies
Goal Test
Some problems may have one goal whereas, in some complex problems there
could be multiple goals.
Machine Intelligence
Terminologies
Path Cost
Path Cost
Solution
Solution is a sequence of actions that leads from the initial state to a goal
state.
Optimal Solution
Optimal solution is a solution that has the lowest path cost among all
solutions.
Machine Intelligence
Examples
8 Puzzle Problem
Machine Intelligence
Let’s Analyze
Rubik's Cube
Machine Intelligence
Let’s Analyze
8 Queens Problem
Machine Intelligence
Problem Solving Agents - Steps in Problem Solving
Goal Formulation Goal formulation is based on the current situation and the
agent’s performance measure.
Assumptions about the Under these assumptions, the solution to any problem is a
environment fixed sequence of actions.
Search Strategy The process of looking for a sequence of actions that reaches
the goal is called search.
● The frontier is going to represent all of the things that we could explore
next, that we haven't yet explored or visited.
● The frontier is going to contain the initial state because at the beginning,
that's the only state we know about.
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
TREE-SEARCH(problem):
• Start with a frontier that contains the initial state.
• Repeat:
If the frontier is empty:
return no solution;
else
- Remove a node from the frontier.
- If node contains goal state(perform goal test):
return the solution;
else
Expand node, add resulting nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
A
C D
E F
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform
goal test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
B
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform goa
test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform
goal test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Queue)
A
C D
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform goa
test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Queue)
A
D
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform
goal test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier(Queue)
A
D E
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform goa
test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier(Queue)
A
E
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform
goal test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier(Queue)
A
E F
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform goa
test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
Example :
Find a path from A to E.
Frontier(Queue)
A
F
B Repeat:
If the frontier is empty:
return no solution;
else
C D - Remove a node from the frontier.
- If node contains goal state(perform
goal test):
return the solution;
else
E F Expand node, add resulting
nodes to the frontier
Machine Intelligence
Approach - The general TREE-SEARCH algorithm
C D
E F
Machine Intelligence
The new algorithm : GRAPH -SEARCH
Algorithms that forget their history are doomed to repeat it. 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. The new algorithm is called GRAPH -SEARCH.
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
A
C D Explored Set
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
C D Explored Set
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
B
C D Explored Set
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier
A
C D Explored Set
A B
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
D C
C D Explored Set
A B
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
C
C D Explored Set
A B D
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
F C
C D Explored Set
A B D
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
C
C D Explored Set
A B D F
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
C D Explored Set
A B D F C
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
E
C D Explored Set
A B D F C
E F
Machine Intelligence
Approach - The general GRAPH -SEARCH algorithm
Example :
Find a path from A to E.
Frontier (Stack)
A
C D Explored Set
A B D F C E
E F
Machine Intelligence
Graph Search Example
Machine Intelligence
Parameters to define a good strategy
does it always
maximum number does it always
find a number of nodes
of find least cost
solution if generated
nodes in memory solution
one exists?
● https://cse.iitrpr.ac.in/ckn/courses/s2016/csl452/w2.pdf
● https://online-learning.harvard.edu/course/cs50s-introduction-artificial-
intelligence-python?delta=0
● https://sites.fas.harvard.edu/~cscie119/lectures/search.pdf
● https://courses.cs.washington.edu/courses/cse473/14sp/slides/2-
statespace-search.pdf