Document 7362308
Download
Report
Transcript Document 7362308
DCP 1172
Introduction to Artificial Intelligence
Chang-Sheng Chen
Topics Covered:
•Introduction to Planning (generalized state-space
search)
•Means-Ends Analysis (back-chaining)
1
Outline
• What is planning?
• Formal definitions of planning problems
• Basic planning algorithms
• Recent development
• Appendix
• Tower of Hanoi
• Missionaries & Cannibals
DCP 1172, Ch. 6
2
Planning as a Real-World Problem
• What is Planning?
• Planning is a search problem that requires to find an
efficient sequence of actions that transform a system from
a given starting state to the goal state
• Planning problem has a wide range of applications in the
real world
• planning in daily life
• game world
• workflow management
DCP 1172, Ch. 6
3
Planning a Trip
Begin
Preparation
Rental Car Reservation
Confirm Reservations
DCP 1172, Ch. 6
Airline Reservation
Hotel Reservation
End
4
Towers of Hanoi
DCP 1172, Ch. 6
5
Sliding-Tile Puzzle
DCP 1172, Ch. 6
6
Planning in Workflow Management
Start Assembly
Examine Order
Gather
Components
Assembly Box
and Motherboard
Install
Video Card
Install
Network Card
Insert Modem
Plug in CD
Plug in Battery
Install
Internal Disk
Install
Motherboard
DCP 1172, Ch. 6
Test
End Assembly
7
Partial-Order Plan versus Total-Order Plan
• Partial-order plan
• consists partially ordered set of actions
• sequence constraints exist on these actions
• plan generation algorithm can be applied to
transform partial-order plan to total-order plan
• Total-order plan
• consists totally ordered set of actions
DCP 1172, Ch. 6
8
Partial-Order Plan
Get brush
Paint ceiling
Start
Finish
Get ladder
DCP 1172, Ch. 6
9
Total-Order Plan
Start
Get ladder
Get brush
Paint ceiling
Finish
Start
Get brush
Get ladder
Paint ceiling
Finish
DCP 1172, Ch. 6
10
Features of Planning Problems
• Large search space
• Action is associated with system states
• Restrictions on the action sequence
• Valid solution may not exist
• Optimization requirement
DCP 1172, Ch. 6
11
The Problem Space
• Formal way to specify the details of a specific problem;
captures critical features that influence problem
solving
• Problem Space: Includes the initial, intermediate
and goal states of the problem.
• Also includes the problem solver’s knowledge at each
of these steps.
DCP 1172, Ch. 6
12
Planning - Information Processing Approach
• Elements in the Representation of a Problem:
• The givens (or start state)
• The goal (or end state)
• The operators
• The constraints
• Example: Tower of Hanoi Problem
• Concept of the problem solving process
• Heuristics for moving through the problem space
• Means-ends analysis
DCP 1172, Ch. 6
2
13
Problem Space: Operators and Goals
• Operators: The set of legal moves that can be
performed during problem solving.
• Goal: Ultimate solution to the problem.
Well-defined problems explicitly specify the
final goal.
• Tower of Hanoi -- all disks moved to target peg
• Algebra equation -- x = ??
Ill-defined problems only vaguely specify the
goal state, the operators or both.
• Write a coherent essay about……….
• Become a millionaire!
DCP 1172, Ch. 6
14
What’s Given?
• Initial state of the problem
• Goal state of the problem
• A finite set of actions:
• pre-conditions: a finite set of conditions for the
action to be performed
• post-conditions: a finite set of conditions that will
be changed after the action is performed
• cost
DCP 1172, Ch. 6
15
What’s Output?
• A sequence of actions that meet the following
criteria
• every action matches the current system state
• can transform system from initial state to goal state
• the total cost of the actions is below a specified value
DCP 1172, Ch. 6
16
The Problem Space, Illustrated
DCP 1172, Ch. 6
17
Tower of Hanoi
Start State
Goal State
Operators: Moving disks from peg to peg
Constraints: Can only move one disk at a time
A larger disk can’t be stacked on a smaller disk
A disk can’t be moved if there is another disk on top
of it
DCP 1172, Ch. 6
3
18
Idea of a Problem Space..
At each state: Number of possible “next moves”
Can be thought of as a “space of all possible moves”
DCP 1172, Ch. 6
4
19
Problem Space
• Legal moves between two states
• Problem solving = search in problem space
DCP 1172, Ch. 6
20
5
Towers of Hanoi
• Optimal solution: 7 moves (shortest route from start state
to goal state)
DCP 1172, Ch. 6
621
Towers of Hanoi
• Less than optimal solution: 19 moves
DCP 1172, Ch. 6
7
22
Algorithms vs. Heuristics
• Algorithms
• guarantee a solution to a problem
• e.g., algebra: 3x + 4 = 2x
• Usually problem specific
• Heuristics
• don't guarantee a solution to a problem,
• cut down search
• can be used on a lot of problems
DCP 1172, Ch. 6
923
Heuristics: Subgoaling
• Break the problem down into subgoals and solve
these one at a time
• E.g. Tower of Hanoi
• First concentrate on getting the large disk to
the third peg
DCP 1172, Ch. 6
24
12
Heuristics: Means-Ends Analysis
I want to go to the mall.
• What’s the difference between what I have and what I want?
One of distance.
• What changes distance? My car.
My car won’t work.
• What is needed to make it work? A new battery.
What has new batteries?
• An auto repair shop.
I want the auto repair shop to put in a new battery; but the
shop doesn’t know I need one.
• What is the difficulty? One of communication.
What allows communication? A telephone...and so on.
DCP 1172, Ch. 6
1425
Means-End Analysis
• Simon (1972)
• Solving problems by repeatedly determining the
difference between the current state and the goal or
subgoal state, then finding an operator that reduces
this difference.
• Used the Tower of Hanoi Problem to study means-end
analysis.
DCP 1172, Ch. 6
26
Heuristics: Means-Ends Analysis
• Identify a difference between current state and
goal state
• Set a subgoal to reduce the difference.
• Apply an operator to reduce the difference
• (If operator can’t be applied, new
subgoal = remove obstacle that prevents
applying the operator)
DCP 1172, Ch. 6
13
27
The Recursive Structure of Means-Ends Analysis
Transform
Reduce
Apply
DCP 1172, Ch. 6
28
Algorithms vs Heuristics
Algorithmic Search
Heuristic Search
Start
Start
Choose Operator
Choose
Operators
Randomly
no
Feasible?
yes
no
Apply
Operator
Favored by
Means Ends?
yes
Apply Operator
DCP 1172, Ch. 6
29
Heuristics: Means-Ends Analysis
I want to solve the Tower of Hanoi
S1: Set a subgoal to move the largest disk to the right
S1: I can’t move it because the middle disk is on top
S2: Set a subgoal to move the middle disk
S2: I can;t move it because the small disk is on top
S3: Set a subgoal to move the small disk
S3 Move the small disk
S2: Move the middle disk
S1:Move the large disk.
S1: I can’t move it because there is no free disk
DCP 1172, Ch. 6
1430
STRIPS Planning System
• A tuple T = (P, O, I, G), where
• P is a finite set of ground literals, the conditions
• O is a finite set of operators
• I is the initial state, a subset of P
• G is the goal state, a subset of P
DCP 1172, Ch. 6
31
STRIPS Operators
• Each operator O has the following attributes
• PC, a set of ground literals, defines the precondition of
the operator
• D, a set of ground literals, defines the conditions that will
be removed after the operation is executed
• A, a set of ground literals, defines the conditions that will
be added after the operation is executed
• C, the cost of the operation
DCP 1172, Ch. 6
32
A Simple Example - Blocks World
A
C
A
B
B
Initial State
On(C, A)
Clear(Fl)
On(A, Fl)
Clear(B)
On(B, Fl)
Clear(C)
C
Goal State
On(A, B)
On(B, C)
On(C, Fl)
Clear(A)
Clear(Fl)
DCP 1172, Ch. 6
33
Graphical Representation of Initial State
On(C, A)
Clear(Fl)
On(A, Fl) Clear(B)
On(B, Fl)
Clear(C)
Start
T
DCP 1172, Ch. 6
34
Graphical Representation of Goal State
Nil
finish
On(A, B)
On(B, C)
On(C, Fl)
DCP 1172, Ch. 6
Clear(A)
Clear(Fl)
35
Block World - Operator
• Move(x, y, z)
• Move block x that is above y to above z
• PC: On(x,y), Clear(x), Clear(z)
• D: Clear(z), On(x, y)
• A: On(x,z), Clear(y), Clear(Fl)
DCP 1172, Ch. 6
36
Graphical Representation of Operator
A
Clear(y)
Operator
PC
On(x, y)
On(x, z)
Clear(Fl)
Move(x, y, z)
Clear(x)
DCP 1172, Ch. 6
Clear(z)
37
Forward Chaining
• Search from the initial state
• Expand the search tree by finding the set of all applicable
operators from the current state
• applicable means the precondition of the operator is
a subset of current state
• Update current state
• For every state that is reached, record the shortest path (or
path with lowest cost) from the initial state to this state
• If the goal state is reached, stop the algorithm
DCP 1172, Ch. 6
38
Forward Chaining
On(C, Fl)
Clear(Fl)
On(A, Fl)
Clear(B)
On(B, Fl)
Clear(C)
Clear(A)
Move(C, A, Fl)
On(C, A)
Clear(Fl)
On(A, Fl)
Clear(B)
On(B, Fl)
On(B, C)
Clear(C)
Clear(Fl)
Move(B, Fl, C)
On(C, A)
Clear(B)
On(A, Fl)
DCP 1172, Ch. 6
39
Backward Chaining
• Search backward from the goal state
• Expand the search tree by finding the set of all
applicable operators that can reach the current state
• applicable means set A of the operator is a subset of
current state
• Update the state
• If the initial state is reached, stop the algorithm
• The solution is a partial-ordered plan
• Constraints in action ordering may be violated
DCP 1172, Ch. 6
40
Backward Chaining
On(A, B)
On(B, C)
On(C, Fl)
Clear(A)
Clear(Fl)
On(B, C)
On(C, Fl)
Clear(A)
Clear(Fl)
On(A, Fl)
Clear(B)
DCP 1172, Ch. 6
Move(A, Fl, B)
41
Missionaries & Cannibals
• Three missionaries and three cannibals on one bank of a
river -- need to get to other bank
• Boat holds 2
• Move them across
• Constraint: the number of cannibals can never be larger
than the number of missionaries on any bank of the river
• Reminder: someone must row boat back
• Let’s play:
http://www.learn4good.com/games/puzzle/boat.htm
DCP 1172, Ch. 6
42
Heuristics - Missionaries & Cannibals
• Missionaries & Cannibals
Problem
• 3 Missionaries and 3
Cannibals
• goal: get all 6 across river
• boat can carry 2 at a time
• Cannibals can never
outnumber Missionaries
MMM CCC
MMM CCC
DCP 1172, Ch. 6
43
15
Missionaries & Cannibals Solution
1
2
MMM CCC (b)
12 MMM CCC (b)
MM CC
M C (b)
CC (b)
11 MMM C
3 MMM CC (b)
C
10 MMM CC (b)
C
4
MMM
CCC (b)
5
MMM C (b)
CC
6
MC
MM CC (b)
increasing difference
between initial and goal
state
DCP 1172, Ch. 6
9
CCC (b)
MMM
CC
8 MMM C (b)
7
MM CC (b)
MC
44
Recent Developments
• Plan Reuse
• Graphplan
• Problem-specific planning
• Evolutionary computation approach
DCP 1172, Ch. 6
45
Plan Reuse
• Reuse old plans for new planning problems
• Consists of two steps
• plan matching
• plan modification
• Research findings
• generally, plan reuse is even harder than plan from
scratch
• do better only when two problems are close
enough
• plan matching could be the bottleneck
DCP 1172, Ch. 6
46
Graphplan
• Partial-order general planner
• Constructing a planning graph before search
• plan graph contains all possible actions that can be
taken in each time step
• actions that interfere with one another can coexist in
the graph
• More efficient than other general planners in some
problems
DCP 1172, Ch. 6
47
Problem-specific Planning
• Heuristics combined during search
• heuristics is problem dependent
• cannot apply to other problems
• Usually outperforms general planners in specific
problems
• Example
• in sliding-tile puzzle, accurate estimation of
the distance between current state and
goal state can speed up the search for a
plan
DCP 1172, Ch. 6
48
Evolutionary Computation Approach
•
•
•
•
Non-deterministic algorithm
Starts from a set of randomized plan
Plans are evolved during generations
In each generation
• evaluate the performance of the plan
• select the plans to next generation, based on
performance
• crossover, mutation to create new plans
DCP 1172, Ch. 6
49
Experimental Results
• Towers of Hanoi
• can solve the 5 and 6-disk case with high probability
• state-aware crossover does not perform well
• Sliding-tile puzzle
• can solve 3*3 problem case with high probability
• state-aware crossover perform much better since a
looser definition of matching state is used
• Performance scalability is not good
• Heuristics may be helpful to improve the performance
DCP 1172, Ch. 6
50