Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views77 pages

Lecture 3 - State Based Search Revised

Chapter 3 discusses the definition of intelligence and various approaches to defining artificial intelligence (AI), including the capabilities required for machines to pass the Turing Test. It outlines the characteristics of agents, including intelligent and autonomous agents, and introduces problem-solving through state-based search and search strategies. The chapter also covers specific examples like the MARS rover and the N Queens problem, emphasizing the evaluation of search strategies in terms of completeness, optimality, and complexity.

Uploaded by

Rounakul Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views77 pages

Lecture 3 - State Based Search Revised

Chapter 3 discusses the definition of intelligence and various approaches to defining artificial intelligence (AI), including the capabilities required for machines to pass the Turing Test. It outlines the characteristics of agents, including intelligent and autonomous agents, and introduces problem-solving through state-based search and search strategies. The chapter also covers specific examples like the MARS rover and the N Queens problem, emphasizing the evaluation of search strategies in terms of completeness, optimality, and complexity.

Uploaded by

Rounakul Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 77

1

Chapter 3

PREVIEW OF
PREVIOUS LESSONS
Credits: Dr. Shamim Akhter, Abdus Salam, Mukta
08/07/25
Saddam Hossain
2

DEFINE INTELLIGENCE
Intelligence is a rather hard to define term;
Intelligence is often defined in terms of what we
understand as intelligence in humans.

Allen Newell defines intelligence as the ability to


bring all the knowledge a system has at its
disposal to bear in the solution of a problem.

A more practical definition that has been used in


the context of building artificial systems with the
intelligence is to perform better on tasks that
humans currently do better.

08/07/25
3
WHAT THE DIFFERENT APPROACHES
DEFINING AI

Thinking humanly
Thinking rationally

Acting humanly

Acting rationally

08/07/25
SUPPOSE YOU ARE DESIGNING A MACHINE TO PASS 4
THE TURING TEST. WHAT ARE THE CAPABILITIES SUCH
A MACHINE MUST HAVE?

 Natural Language processing


 Knowledge Representation
 Automated reasoning
 Machine Learning
 Computer Vision
 Robotics

08/07/25
5

QUESTION FORM LECTURE 1

 Design ten questions to pose to a


man/machine that is taking the Turing
test.

 List 5 tasks that you will like a computer


to be able to do within the next 5 years.

List 5 tasks that computer are unlikely to


be able to do in the next 10 years.

08/07/25
6

QUESTION FORM LECTURE 2


Define Agent:
An agent is anything that can be viewed as
perceiving its environment through sensors
and acting upon that environment through
actuators

Intelligent Agent:
a)must sense
b)must act
c)must be autonomous
d)must be rational

08/07/25
7

QUESTION FORM LECTURE 2


Rational Agent:

For each possible percept sequence, an ideal


rational agent should do whatever action is
expected to maximize its performance measure,
on the basis of the evidence provided by the
percept sequence and whatever built-in
knowledge the agent has.

08/07/25
8

QUESTION FORM LECTURE 2

Autonomous Agent:

Autonomous agents are software entities that are


capable of taking independent action in dynamic,
unpredictable environment. An autonomous
agent can learn and adapt to a new environment.

08/07/25
9

QUESTION FORM LECTURE 2


Describe the salient features of an agent.
An agent perceives its environment using

sensors.
An agent takes actions in the environment

using actuators.
A rational agent acts so as to reach its goal

or to maximize its utility.


Reactive agents decide their action on the

basis of their current state and then percepts.


Deliberative agents reasons about their
goals to decide their action.

08/07/25
10

QUESTION FORM LECTURE 2

Find out PEAS model for the MARS rover.

What are the percepts for this agent?


Characterize the operating environment.

What are the actions the agent can take?

How can one evaluate the performance

of the agent?

08/07/25
11

QUESTION FORM LECTURE 2

What are the percept devices for this


agent?
Panoramic and Microscopic cameras

A radio receiver

Spectrometers for studying rock sample

including an alpha particle X-ray


spectrometer, Miniature thermal
spectrometer.

08/07/25
12

QUESTION FORM LECTURE 2


 Characterize the operating environment

The Environment (The Martian surface)


Partially observable
Non-deterministic

Sequential

Dynamic

Continuous

May be single-agent

08/07/25
13

QUESTION FORM LECTURE 2


 What are the actions the agent can take?

The rover spirit has


oMotor driven wheels for locomotion.
oAlong with a robotic arm to bring sensors close

to interesting rocks and


oRock abrasion tool (RAT) capable of efficiently

drilling 45mm holes in hard volcanic rock.


oSpirit also has a radio transmitter for
communication.

08/07/25
14

QUESTION FORM LECTURE 2


 Performance:

oMaximizing the distance or variety of terrain it


traverses
oCollecting as many samples as possible

o Finding life (for which it receives 1 point if it

succeeds and 0 points if it fails)


oMaximizing lifetime or minimizing power
consumptions.

08/07/25
15

QUESTION FORM LECTURE 2

What sort of agent architecture do you think


most suitable for this agent?

Model-based reflex agent for low level


navigation;
For route planning, experimentation etc
some combination of goal-based and
utility-based would be needed.

08/07/25
16

GOAL DIRECTED AGENT

A goal directed agent needs to achieve certain


goals.

Many problems can be represented as a set of


states and a set of rules how one states
transformed to another.

The agent must choose a sequence of actions to


achieve the desired goal.

08/07/25
17

SOLVING PROBLEMS
BY SEARCHING
08/07/25 Chapter 3
18

STATE BASED SEARCH


Each state is an abstract representation of the agent’s
environment. It is an abstraction that denotes a
configuration of the agent.

Initial state: The description of the starting


configuration of the agent.

Action/Operator: An action/operator takes the agent


from one state to another state. A state can have a
number of successor states.

A plan is a sequence of actions.

08/07/25
19

STATE BASED SEARCH

A goal is a description of a set of the desirable


states of the world. Goal states are often
specified by a goal test which any goal state
must satisfy.

Path Cost: path positive number


Usually path cost=sum of steps costs.

08/07/25
20

STATE BASED SEARCH

Problem formulation means choosing a relevant


set of states to consider and feasible set of
operators to move from one state to another.

Search is the process of imagining sequences of


operators applied to initial state and checking
which sequence reaches a goal state.

08/07/25
Example: Romania
21

 On holiday in Romania; currently in Arad.


 Flight leaves tomorrow from Bucharest
 Formulate goal:
 be in Bucharest
 Formulate problem:
 states: various cities
 actions: drive between cities
 Find solution:
 sequence of cities, e.g., Arad, Sibiu, Fagaras,
Bucharest

08/07/25
Example: Romania
22

08/07/25
Single-state problem
23
formulation
A problem is defined by four items:

1. initial state, S0 where S0 ɛ S. e.g., "at Arad"


2. Actions, operator or successor function S(x) = set of action–
state pairs
– e.g., S(Arad) = {<Arad  Zerind, Zerind>, … }
A: SS set of operators.
3. goal test, can be
– explicit, e.g., x = "at Bucharest"
– implicit, e.g., Checkmate)
4. path cost (additive)
– e.g., sum of distances, number of actions executed, etc.
– c(x,a,y) is the step cost, assumed to be ≥ 0

• A solution is a sequence of actions leading from the initial


state to a goal state
08/07/25
Search Problem
24

Finds a sequence of actions which transfers the agent from


the initial state to a goal state.

 Representing the search problems:


 A search problem is represented using a directed graph.
 The states are represented as nodes,
 The allowed actions are represented as arcs.

08/07/25
Pegs and Disks
25

 Consider the following


problem we have
3 pegs and 3 disks.

 Operators: One may move


the topmost Disk on any needle
to the topmost position to any
other needle.

08/07/25
8 Queens
26

 Place 8 queens on a chessboard so that no two queens are


in the same row, column or diagonal.

08/07/25
N Queens problem formulation
27
1

 States: Any arrangement of 0 to 8 queens on the board.

 Initial State: 0 Queen on the board.

 Successor function: Add a queen in any square.

 Goal test: 8 Queens on the board and none are attacked.

08/07/25
N Queens problem formulation
28
2

 States: Any arrangement of 8 queens on the board.

 Initial State: All queens are at column 1.

 Successor function: Change the position of any one queen.

 Goal test: 8 Queens on the board and none are attacked.

08/07/25
N Queens problem formulation
29
3

 States: Any arrangement of k queens in the first k rows


such that none are attacked.

 Initial State: 0 Queens on the board.

 Successor function: Add a queen to the (k+1)th row so


that none are attacked.

 Goal test: 8 Queens on the board and none are attacked.

08/07/25
Example: The 8-puzzle
30

 states?
 actions?
 goal test?
 path cost?

08/07/25
Example: The 8-puzzle
31

• states? locations of tiles


• actions? move blank left, right, up, down
• goal test? = goal state (given)
• path cost? 1 per move
[Note: optimal solution of n-Puzzle family is NP-hard]

• 08/07/25
8-puzzle partial state space
32

08/07/25
Basic search algorithms
33

Let L be a list containing the initial state (L=the


fringe)
Loop
if L is empty return failure.
Node  select (L)
if Node is a goal
then return Node
(the path from initial state to Node)
else apply all the applicable operators to Node
And
merge the newly generated states into fringe.
08/07/25
Basic search algorithm: Key
34
issues
 Search tree may be unbounded
Because of loops
Because state space is infinite.

 Return a path or a node?

 How selecting a node is done?

 How much is the known about the quality of the


intermediate states?

 Is the aim to find out minimal cost path or any path


as soon as possible. 08/07/25
Find a Path
35

 Shortest Path
E
 Any Path
B

 Blind Search A D F H
 BFS
 DFS
C
G

08/07/25
Search Tree
36

 List all possible paths


A
 Eliminate Cycles from Path
 Result: A search tree
B C

D E D G
E
B
C F B F
A D F H

C G H
G G E
G H
08/07/25
Search Tree- Terminology
37

 Root Node A
 Leaf Node
 Ancestor/ B C

Descendant E G
D D
Branching Factor
 Complete Path/
Partial Path C F B F
 Expanding Open
G H
Nodes results in G E
G H
closed nodes.
08/07/25
Basic search algorithms
38

Let L be a list containing the initial state (L=the fringe)


Loop
if L is empty return failure.
Node  remove-first(fringe)
if Node is a goal
then return the path from initial state to Node
else generate all successors of Node and
merge the newly generated states into fringe.
End Loop

08/07/25
Evaluating Search Strategies
39

• Completeness: Is the strategy guaranteed


to find a solution if one exists?
• Optimallity: If a solution is found, is the
solution guaranteed to have the minimum
cost?
• Time complexity: Time taken (number of
nodes expanded) (Worst case or average
case) to find a solution.
• Space? Space used by the algorithm
measured in terms of the maximum size
of the fringe.
08/07/25
Search Strategies
40

• Blind Search
 Depth First search
 Breadth First Search
 Iterative deepening search
 Bidirectional Search
• Informed Search
• Constraint satisfaction Search
• Adversary Search

08/07/25
Breadth First search
41

Let L be a list containing the initial state (L=the


fringe)
Loop
if L is empty return failure.
Node  remove-first(fringe)
if Node is a goal
then return the path from initial state to
Node
merge the newly generated states into fringe.
else generate all successors of Node and

End Loop
08/07/25
A
42

B C
E
B D E D G
A D F H

C C F B F
G

G H
G G E
H

FRINGE: A B C D E D G
08/07/25
Implementation: states vs. nodes
43

• A state is a (representation of) a physical


configuration
• A node is a data structure constituting part of a
search tree includes state, parent node, action,
path cost g(x), depth

• The Expand function creates new nodes, filling in


the various fields and using the SuccessorFn of
the problem to create the corresponding states.
08/07/25
Search strategies
44

• A search strategy is defined by picking the order of


node expansion
• Strategies are evaluated along the following
dimensions:
– completeness: does it always find a solution if one exists?
– time complexity: how long does it take to find soln
– space complexity: maximum number of nodes in memory
– optimality: does it always find a least-cost solution?
• Time and space complexity are measured in terms
of
– b: maximum branching factor of the search tree
– d: depth of the least-cost solution
– m: maximum depth of the state space (may be ∞)


08/07/25
Uninformed search
45
strategies
 Uninformed search strategies use only the
information available in the problem
definition
 Breadth-first search
 Uniform-cost search
 Depth-first search
 Depth-limited search
 Iterative deepening search

08/07/25
Breadth-first search
46

 Expand shallowest unexpanded node


 Implementation:
 fringe is a FIFO queue, i.e., new successors
go at end

08/07/25
Breadth-first search
47

 Expand shallowest unexpanded node


 Implementation:
 fringe is a FIFO queue, i.e., new
successors go at end

08/07/25
Breadth-first search
48

 Expand shallowest unexpanded node


 Implementation:
 fringe is a FIFO queue, i.e., new successors
go at end

08/07/25
Breadth-first search
49

 Expand shallowest unexpanded node


 Implementation:
 fringe is a FIFO queue, i.e., new successors
go at end

08/07/25
Properties of breadth-first
50
search
 Complete? Yes (if b is finite)

 Time? 1+b+b2+b3+… +bd + (bd+1-b) = O(bd+1)

 Space? O(bd+1) (keeps every node in memory)

 Optimal? Yes (if cost = 1 per step)

 Space is the bigger problem (more than time)

08/07/25
Uniform-cost search
51

• Expand least-cost unexpanded node


• Implementation:
– fringe = queue ordered by path cost
• Equivalent to breadth-first if step costs all equal
• Complete? Yes, if step cost ≥ ε
• Time? Guided by path cost rather than depth of nodes
with g ≤ cost of optimal solution, O(bceiling(C*/ ε)) where C* is
the cost of the optimal solution
• Space? # of nodes with g ≤ cost of optimal solution,
O(bceiling(C*/ ε)
• Optimal? Yes – nodes expanded in increasing order of g(n)

08/07/25
Depth-first search
52

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
53

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
54

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
55

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
56

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
57

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
58

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
59

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
60

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
61

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
62

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Depth-first search
63

 Expand deepest unexpanded node


 Implementation:
 fringe = LIFO queue, i.e., put successors at
front

08/07/25
Properties of depth-first search
64

• Complete? No: fails in infinite-depth spaces,


spaces with loops
– Modify to avoid repeated states along path
 complete in finite spaces
• Time? O(bm): terrible if m is much larger than d
– but if solutions are dense, may be much faster than
breadth-first
• Space? O(bm), i.e., linear space!
• Optimal? No


 08/07/25
Depth-limited search
65 = depth-first search with depth limit l, cutoff
i.e., nodes at depth l have no successors
 Recursive implementation:

 Optimal =No, l>d


 Time complexity= O(bl) Important to know the exact limit before
 Space Complexity = O (b*l) Known as diameter
08/07/25
Iterative deepening search
66

08/07/25
Iterative deepening search l
67
=0

08/07/25
Iterative deepening search l
68
=1

08/07/25
Iterative deepening search l
69
=2

08/07/25
Iterative deepening search l
70
=3

08/07/25
Properties of iterative deepening
search
71
 Complete? Yes
 Time?
(d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)
 Space? O(bd)
 Optimal? Yes, if step cost = 1

08/07/25
Summary of algorithms
72

08/07/25
Bidirectional Search
73

08/07/25
Bidirectional Search
74

 Two simultaneous search


 Forward from the initial state
 Backward from the goal
 Stop when two search meet at middle
 O(bd/2)

08/07/25
Bidirectional Search
75

 Works well only when there are unique start and


goal states, but performs ambiguously when
there are multiple goals.
 Should able to search backwards from goal.
Requires the ability to generate predecessor
states.
 Can (sometimes) lead to finding a solution more
quickly.

 Time and Space Complexity is O(bd/2)

08/07/25
Bidirectional Search
76

08/07/25
Summary
77

 Problem formulation usually requires abstracting


away real-world details to define a state space
that can feasibly be explored

 Variety of uninformed search strategies

 Iterative deepening search uses only linear space


and not much more time than other uninformed
algorithms

08/07/25

You might also like