artificial intelligence – lecture 4aass.oru.se/~mbl/ai/lectures.2010/ai-4.pdf · 2 planning pad...
TRANSCRIPT
2
Planning
PAD representation
Planspace
search
Minmax for Reversi
• Use given representation of states
• Function generating legal moves
• about 410 choices each turn
• Search 34 ply's
• Heuristic at leaf nodes
• eg. AI score – Human score
• eg. Extra points for corners
3
Planning
PAD representation
Planspace
search
Alphabeta pruning
• Reduces the size of the search tree
• Can we compute the finalscore without expandingnode D ?
4
Planning
PAD representation
Planspace
search
Alphabeta pruning continued
• Alpha: Best choise for a MAX node so far.
• Beta: Best choise for a MIN node so far.
• Unbound MAX nodes have alpha = infinity
• Unbound MIN nodes have beta = +infinity
• Alpha pruning: Cut of under MIN nodes having beta value < alpha value of any of it's MAXnode ancestors.
• Beta pruning: Cut of under MAX nodes having alpha value > beta value of any of it's MIN node ancestors.
5
Planning
PAD representation
Planspace
search
Alphabeta pruning in reversi
• AI vs. AI: 4 ply search• 11m46s for example game
• Alphabeta prunning• 6m 36s for same game
6
Planning
PAD representation
Planspace
search
Planning techniques
• Planning is the problem of finding a sequence of primitive actions to achieve some goal
• Often in context of robotics
• State search (df, bf, IDA, A* etc.) may be viewed as simple planning techniques.
• Plannings is usually more!
• PAD representation of actions
• Plan space search
• ...
7
Planning
PAD representation
Planspace
search
Representing the world
• How do we represent
• State of the world
• Actions that we can perform, their prerequisites, and consequences.
• Description of the goal state
• The generated plan
• Use primitive predicate logic formulas for the state
[at (robot, livingroom), at(beer, kitchen), at(fred, livingroom), door_closed(kitchen,livingroom)].
8
Planning
PAD representation
Planspace
search
Representing actions (“Operators”)
• PAD notation• Formulas containing variables (eg. R1, R2, O)
• Precondition: must be true to perform action
• Additions: will be true after doing action
• Deletions: will be false after doing action
9
Planning
PAD representation
Planspace
search
Representing actions (“Operators”)
• State progression
• We can apply an operator (P,A,D) to state S if all facts in P are true in S.
• Result of applying an operator in S is A + (S – D)
• Goal regression• We can apply an operator (P,A,D) from goal G if any facts in
A are not true in G.
• Resulting goal is P + (GA)
• Variables
• Instantiate all variables in (P,A,D) to any concrete symbols as neccessary for state progression or goal regression
10
Planning
PAD representation
Planspace
search
Forward search
• Naive idea
• Begin with starting state
• Generate all actions that can be performed in this state
• Perfom search (depth first, breadth first, ... ) until a goal state is reached
• This is a complete and sound planning algorithm, but inefficient!• Typically the branching factor can be very high for
planning problems
• Attempts many branches that “makes no sense”• Ie. does not progress towards the goal or contribute with a condition
needed for another action
11
Planning
PAD representation
Planspace
search
Meansend analysis
• MEA focuses on actions that reduce the distance between the current state and the goal
• Even actions that cannot be applied in the current state are considered, if they reduce this distance• These actions give new goals to achieve, using goal
regression
12
Planning
PAD representation
Planspace
search
Finding a goal
• Suppose current state is:[at (robot, livingroom), at(beer, kitchen), at(fred, livingroom), door_closed(kitchen,livingroom)].
• Goal state is:[at(beer,livingroom), at(fred, livingroom), at(robot,livingroom), doorclosed(kitchen, livingroom) ]
• Only action that helps is the “carry” action, but this action does not satisfy the preconditions
• Recursively apply MEA with a new goal state that satisfy the requirements for the carry action
13
Planning
PAD representation
Planspace
search
Planning algorithm
• If all goals are true in current state, then succeed
• Otherwise:• Select an unsolved goal
• Find action that satisfy goal
• Enable action by finding a plan (Preplan) that achieves it's preconditions
• Apply action to generate new state (midstate)
• Find plan to target state (postplan)
• Return plan containing preplan, action, postplan
14
Planning
PAD representation
Planspace
search
Blocksworld domain
• Classical AI problem, used to compare different planners
15
Planning
PAD representation
Planspace
search
Blocksworld operators
Drop(X,Y): block X from Y to the table:
P: on(X,Y), clear(X)
A: on(X, table), clear(Y)
D: on(X,Y)
Move(X,Y,Z): block X from block Y to block Z
P: on(X,Y), clear(X), clear(Z)
A: on(X,Z), clear(Y)
D: on(X,Y), clear(Z)
Lift(X,Y): block X from table to block Y
P: on(X,table), clear(Y)
A: on(X,Y)
D: clear(Y)
16
Planning
PAD representation
Planspace
search
Planspace search
• Instead of searching over possible states, search over possible plans until we have found a suitable plan• Plan: suitable set of operators
• Partially ordered plans: order between operators not completely fixed
• Search in space of possible plans
• Refinements and modifications of plans
• Least commitment: since we do not commit the order between operators until absolutely necessary
17
Planning
PAD representation
Planspace
search
Example of partially ordered plan
P DA
18
Planning
PAD representation
Planspace
search
Plan space search
• A plan consists of
• steps (corresponding to the operators)
• constraints (on the order the steps are performed)
• dependency information (requirements, links and conflicts)
• Requirements:
• Step and condition that must be true immediatly prior to the step
• Links:
• Condition + producer step (having condition in A) + consumer step (having condition in P)
• Conflicts:
• Condition + clobberer step (having condition in D)
19
Planning
PAD representation
Planspace
search
Plan refinement
• Add constraints to eliminate conflict:• Constrain the clobberer to come before the producer or
after the consumer of the threatened link.
• Linking steps to eliminate requirements:• Eliminate requirement with condition r for step q by
adding link L with producer P, consumer q and condition r where p is a new or existing step that adds r.
• Note: A link implies an ordering.
20
Planning
PAD representation
Planspace
search
Desired properties of new plan
A new plan must have all the steps, constraints, and links of the plan it was generated from.
If, in a given plan, there is a link L with producer P, consumer q, and condition r, then there must be corresponding steps P and q such that P adds r and q has r as a precondition.
If, in a given plan, there is a link L with producer P, consumer q, and condition r and a step c that (given the current set of constraints) could come between P and q and deletes r: then there is a conflict with link L and clobberer c.
21
Planning
PAD representation
Planspace
search
Example
22
Planning
PAD representation
Planspace
search
Example
23
Planning
PAD representation
Planspace
search
Example
24
Planning
PAD representation
Planspace
search
Example
25
Planning
PAD representation
Planspace
search
Example
26
Planning
PAD representation
Planspace
search
Example
27
Planning
PAD representation
Planspace
search
Planning
• Many different algorithms exists
• Forward search
• Means end analysis (goal regression)
• Planspace search
• Graphplan
• Exploits graph structure algorithms to optimise the search
• …
• Many different problems exists (!)
• Deterministic world in which we know everything
• Nondeterministic outcomes of actions
• Unknown properties of world
• Dynamically changing world (adversaries!)