Académique Documents
Professionnel Documents
Culture Documents
Artificial Intelligence
Lecture 3
Solving Problems by Searching
(Part I)
1
Contents
3.1 Problem-Solving Agents (goal-based agent)
3.2 Example Problems
3.3 Searching for Solutions
3.4 Search Tree Terminology
3.5 Measuring Problem-Solving Performance
Introduction
If a person/program doesn't know better, one way to solve a
problem is exhaustive search
Introduction
Intelligent agents are supposed to maximize their performance measure
This can be simplified if the agent can adopt a goal and aim at
satisfying it
Goal formulation (based on the current situation and the agents
performance measure)
is the first step in problem solving
Problem formulation is the process of deciding what actions and
states to consider, given a goal (desirable state)
41 mins
36 mins
43 mins
Goal
MMU, Cyberjaya
5
Introduction
Search is the process of looking for a sequence of actions that
reaches the goal state
Once a solution is found, the recommended actions can be carried
out
This phase is called the execution phase
Problem-Solving Agents
Problem-solving agent (goal-based agent)
Decides what to do by finding a sequence of actions that lead
to desirable states (goal)
Steps in problem-solving:
Problem-Solving Agents
A problem can be defined into FOUR components:
1. an initial state
2. a set of actions
3. a goal test
4. a path cost function
Problem-Solving Agents
1.
Initial state
the state that the agent starts, e.g., In(Puchong)
2.
Actions
a description of possible actions available to the agent
uses a successor function
SUCCESSOR-FN(X) returns a set of
action, successor
one of the legal
actions in state x
Problem-Solving Agents
The initial state and successor function define the state space of the
problem
State space
the set of all possible states reachable from the initial state
forms a graph
nodes states
10
Problem-Solving Agents
State space graph
KL
PJ
Initial state
Puchong
Goal
Cyberjaya
Subang
Shah Alam
Problem-Solving Agents
3.
Goal test
determines whether a given state is a goal state,
e.g., In(Cyberjaya)
4.
Problem-Solving Agents
An optimal solution has the lowest path cost among all solutions
13
Problem-Solving Agents
Example: Romanian Holiday (Romania driving problem)
Goal
Start
On holiday in Romania;
currently in Arad.
14
Problem-Solving Agents
Formulate goal:
in Bucharest
Formulate problem:
states: various cities
sequence of cities
e.g., Arad, Sibiu, Fagaras, Bucharest
15
Problem-Solving Agents
[Recap]: A problem is defined by FOUR components:
e.g., at Arad
e.g., x = at Bucharest
16
Example Problems
The toy problems to illustrate example problems:
The Vacuum World
8-queens problem
Example Problems
The Vacuum world example:
Assume, the agent knows the locations and the dirt places
19
Example Problems
The state space for the vacuum world example
Example Problems
The state space for the vacuum world example
states? discrete: dirt and robot location
initial state? any
actions? Left, Right, Suck
goal test? no dirt at all locations
path cost? 1 per action
21
Example Problems
1
Goal state:: 7, 8
Initial state:: 5
Solution:: [Right, Suck]
7
22
Example Problems
The 8-queens Problem
The goal of the 8-queens problem is to place eight queens on a
chessboard so that no two queens are in the same row, column, or
diagonal.
A solution
23
Not a solution
Example Problems
The 8-queens Problem
A queen threatens (attacks) another queen in the same row,
column or in diagonal
In this example, the two queens
on the corners are the only queens
threatening each other.
Goal test: 8 queens on board, none attacked.
Example Problems
The 8-queens Problem
There are two main kinds of formulation.
In either case, the path cost is of no interest because only the final
state counts.
25
Example Problems
The 8-queens Problem
states? - any arrangement of n 8 queens
- or arrangements of n 8 queens in leftmost n columns,
1 per column, such that no queen attacks any other.
initial state? no queens on the board
actions? - add queen to any empty square
- or add queen to leftmost empty square such that it is
not attacked by other queens.
goal test? 8 queens on the board, none attacked.
26
Example Problems
Other Real-World Problems
Route-finding problem
Routing in computer networks,
Military operations planning,
Airline travel planning systems
Touring problems
Visit every city exactly once, starting and ending in the same
city
State: must include not just the current location but also the
set of cities the agent has visited
27
28
29
31
32
36
37
38
39
40
Expansion of nodes
41
3. The action
the action that was applied to the parent node that generated this
node
5. The depth
the number of steps in the path from the initial state
42
43
44
45
MAKE-QUEUE(Elements)
creates a queue with the
given elements
Returns solution
48
Time Complexity:
How long does it take to find a solution? (no. of nodes generated)
Space Complexity
How much memory is needed to perform the search? (max. no. of
nodes generated)
Optimality
Does the strategy find the optimal (least-cost) solution?
49
50
d = Depth
S
b=2
51
The End
53