Document 7383985

Download Report

Transcript Document 7383985

Artificial Intelligence: Planning
Problems with state space search
Planning Operators
A Simple Planning Algorithm
(Game Playing)
1
AI Planning
• Planning concerns problem of finding sequence
of actions to achieve some goal.
• Action sequence will be system’s plan.
• State-space search techniques, discussed in
lecture 6, may be viewed as simplest form of
planning.
• Based on rules that specify, for possible actions,
how the problem state changes.
• But need to consider further how to represent
these state-change rules.
2
Reminder of Robot Planning
expressed as search..
Me
Rob Beer
Robot opens door
Me
Rob Beer
Robot picks up Me
Me
Rob Beer
Robot moves to next room
Me Rob
Beer
Etc etc
3
Problem State
• How do we capture how the different possible
actions change the state of world (problem state)?
• For “Jugs” problem, problem state was just a pair of
numbers, so could specify explicitly how it changed.
• For more complex problems, representing the
problem state requires specifying all the (relevant)
things that are “true”.
• Can be done using statements in predicate logic:
• in(john, room1)
• open_door(room1, room2)
• Note how we give objects in world unique labels
(e.g., room1).
4
Problem State
• So, for simple robot planning problem we
might have an initial state described by:
•
•
•
•
in(robot, room1)
door_closed(room1, room2)
in(john, room)
in(beer, room2)
• And target state must include:
• in(beer, room1)
• (But many different ways of formulating same
problem.)
5
Representing Actions
• We now specify what the possible actions are
(with capitals to indicate variables)
• move(R1, R2)
• carry(R1, R2, Object)
• open(R1, R2) (open door between R1 and R2)
• For each action, we need to specify precisely:
• When it is allowed.
• E.g., can only pick something up when in the
same room as that object.
• What the change in the problem state will be.
6
Planning Operators
• To do this we specify, for each action:
• A list of facts that must be true before the
action is possible. (Preconditions)
• A list of facts made true by the action. (Add list)
• A list of facts made false by the action (Delete
list).
• E.g., carry(R1, R2, Object)
• pre:door_open(R1, R2), in(robot, R1),
in(Object, R1)
• add:in(robot, R2), in(Object, R2)
• delete: in(robot, R1), in(Object, R1)
7
Planning Operators
• We can now check when an operator may be
applied, and what the new state is.
• Current state:
• in(robot, room1), door_open(room1, room2),
in(beer, room1)
• Action:
• carry(beer, room1, room2)
• New state
• in(robot, room2), door_open(room1, room2),
in(beer, room2)
8
Searching for a Solution
• How do we now search for a sequence of actions
that gets us from initial to target state?
• Can simply use standard search techniques
discussed last week.
• We can define a rule that lets us find possible
“successor” nodes in our search tree.
• To find successor NewState of State:
• Find operator with preconditions satisfied in State.
• Add all the facts in Add list to State
• Delete all the facts in Delete list from State.
• We then use standard depth/breadth first search
9
Towards an implementation
• Express plan operators as prolog facts like:
• op(carry(R1, R2, O),
[door_open(R1, R2), in(r, R1), in(O, R1)],
Action
[in(r, R2), in(O, R2)],
Preconds
[in(r, R1), in(O, R1)]).
Add
Delete
• Define a successor rule.
• successor(State, New) :op(Action, Pre, Add, Delete),
satisfied(Pre, State),
additems(State, Add, Temp),
delitems(Temp, Delete, New).
10
• Now use a simple search algorithm.
• Simplest just exploits Prolog’s depth
first search:
• search(State, State).
search(Initial, Target) :succesor(Initial, Next),
search(Next, Target).
• ?- search([in(r, room1), ..], [in(r,
room), in(beer, room1)…]).
• Problems..
• Order of facts in target state significant.
• Doesn’t yet tell us what the plan IS. Just
says “yes” if a plan exists.
11
Forwards versus Backwards..
• Can search for a solution forwards (from start
state) or backwards (from target).
• Backwards search
search(Initial, Target) :succesor(Previous, Target),
search(Initial, Previous).
• Finds actions that get you to the Target.
• Works out state you’d have to be in for that
action to apply.
• Then searches for actions that get you to that
intermediate state.
12
Problems with Simple Search
• Search is “blind” - We consider every action
that can be done in current state, even if it is
completely irrelevant to the goal.
• E.g., if robot could clap, jump, and roll over,
would consider paths in search tree starting
with these actions, as well as opening door
into the other room.
• Backward search helps a little - but considers
ALL actions that end up in target state, not
focusing on those that start in state more
similar to initial.
13
Means-ends Analysis (MEA)
• Early planning algorithm that attempted to
address these issues.
• Focus the search on actions that reduce the
difference between current state and target.
• Combine forward and backward reasoning.
• Consider actions that can’t immediately apply
in current state.
• Getting to state where useful action can be
applied can be set as new sub-problem to
solve.
14
MEA algorithm
• Find useful action..
preplan
Initial
State
action
Mid
State1
postplan
Mid
State 2
Target
State
• Then set as new sub-problems getting to a
state where that action can apply, and
getting to target from state resulting from
that action.
15
MEA Algorithm in detail
• To find plan from Initial to Target
• If all goals in Target are true in Initial, succeed.
• Otherwise:
• Select an unsolved goal from target state.
• Find an Action that adds goal to target state.
• Enable Action by finding a plan (preplan) that
achieves Actions preconditions. Let midstate1 be
result of applying that plan to initial state.
• Apply Action to midstate1 to give midstate2.
• Find a plan (postplan) from midstate2 to target state.
• Return a plan consisting of preplan, action and
postplan.
16
A little on Game Playing
• Search techniques may also be applied to
game playing problems (e.g., board
games).
• Difference is that we have two players,
each with opposing goals.
• We can still express this as a search tree.
• But the way we search has to be a bit
different.
17
Search Tree
Player 1’s moves
Player 2 ‘s moves
Player 1’s moves
etc
18
Game Playing
• Essence of game playing is how to choose a
move that will maximize your chances of
winning on the assumption that your
opponent will always make the move that is
best for them.
• One algorithm for this “minimax”.
• Form of best-first search, scoring game
states according to how close they are to a
solution, but with assumption that opponent
will try and minimize your “score”.
19
Summary
• Planning: Finding sequence of actions to
achieve goal.
• Actions specified in terms of preconditions,
addlist, delete list.
• Can then use standard search techniques,
or Means-ends-analysis, which focuses
search on actions that achieve goals in
target.
• Game playing - have to consider opponent.
20