380 likes | 529 Views
Chap.11 Planning. CS570 Artificial Intelligence Kwang-hyung Lee. Planning Agent Similar to a problem-solving agent construct plans that achieve its goal execute them Difference from a problem-solving agent representation of goals, states, actions ways to search for solutions.
E N D
Chap.11 Planning CS570 Artificial Intelligence Kwang-hyung Lee
Planning AgentSimilar to a problem-solving agent construct plans that achieve its goal execute them • Difference from a problem-solving agent • representation of goals, states, actions • ways to search for solutions
11.1 Simple planning agent 11.1 A simple planning agent • An agent uses percepts to build a complete and correct model • It calls a planning algorithm to generate a plan of action • The agent executes the steps of the plan • planning agent in Figure 11.1problem-solving agent in Figure 3.1
11.2 Form problem solving to planning 11.2 From problem Solving to planning • Difference • representations of goals states, actions • representation and construction of action sequences • Basic element of problem-solving • representation of actions • representation of states • representation of goals • representation of plans
11.2 Form problem solving to planning • Example:Shopping problem“Get a quart of milk, a bunch of banana and a variable-speed cordless drill” • need to define • initial state • operations
11.2 Form problem solving to planning • Problem solver in Figure 11.2 • too many branches • too many actions, states • heuristic evaluation function • Problem-Solving agent • consider sequence of actions from the initial state • decide what to do in the initial state when relevant choices are • It cannot decide where to go until the agent figures out how to obtain items
11.2 Form problem solving to planning • Planning • “Open up” the representation of states, goals and actions states and goals : sets of sentences actions : logical description of precondition and effects direct connections between states and actionsex) goal : conjunctionHave(Milk) Buy(x) • “free” to add actions • most goals of the world are independent of most other partsdivide-and-conquer strategy
11.3 Planning in Situation Calculus 11.3 Planning in Situation Calculus • A planning problem represented in situation calculus by logical sentences • initial state : For shopping problemAt(Home,s0) ¬Have(Milk, s0) ¬Have(Banana, s0) ¬Have(Drill,s) • goal state: a logical querys At(Home,s) Have(Milk,s) Have(Bananas,s) Have(Drill,s)
11.3 Planning in Situation Calculus • Operators : description of actionsa,s Have(Milk,Result(a,s)) [(a=Buy(Milk) At(Supermarket,s) (Have(Milk,s) a Drop(Milk))]Result’(l,s) means result from sequence of actions l starting in s.s Result’([],s)=sa,p,s Result’([a|p],s)=Result’(p,Result(a,s))
11.3 Planning in Situation Calculus • A solution to the shopping problem is a plan P, applied to So, yields a situation satisfying the goal query :At(Home, Result’(p,s0)) Have(Milk,Result’(p, s0)) Have(Bananas, Result’(p, s0) Have(Drill,Result’ (p, s0))P=[Go(Supermarket),Buy(Bananas), Go(HardwareStore),Buy(Drill),Go(Home)] • To make planning practical(1) Restrict the language(2) use a special-purpose algorithm
11.4 Basic Representations for planning 11.4 Basic Representations for planning • STRIPS: Representation for state and goals • initial state for the shopping problemAt(Home) ¬Have(Milk) ¬Have(Banana) ¬Have(Drill) ……incomplete state description • goalAt(Home) Have(Milk) Have(Banana) Have(Drill) It can contain variablesAt(x) Sells(x,Milk) • The initial and goal state are input to planning systems
11.4 Basic Representations for planning • Representation for actions • STRIP operations consist of • action description • precondition • effect • ex)Op(ACTIOIN:Go(there), PRECOND:At(here) Path(here,there), EFFECT:At(there) ¬At(here)) • operator schema: an operator with variables • an operator o is applicable in a state s if way to instantiate the variables in o, so that every one of the precondition of o is true in s.That is, if Precond(o) s
11.4 Basic Representations for planning • Situation space and plan space • Situation space • progression planner : forward search • regression planner : backward search • partial plan : expand it with a complete plan that solves the problem plan space • Refinement operators take a partial plan and add constraints to it • Search through the space of situations Search through the space of plans
11.4 Basic Representations for planning • Representation for plans • To search through a space of plans • ex) “putting on a pair of shoes” • goal : RightShoeOn LeftShoeOn • initial state : no literal • operators:Op(ACTION:RightShoe,PRECOND:RightSockOn,EFFECT:RrightShoeOn)Op(ACTION:RightSock,EFFECT:RrightSockOn)Op(ACTION:LeftShoe,PRECOND:LeftSockOn,EFFECT:LeftShoeOn)Op(ACTION:LeftSock,EFFECT:LeftSockOn) • partial plan : RightShoe, LeftShoe • least commitment - partial ordertotal order - linearization
11.4 Basic Representations for planning • A plan is defined as a data structure • A set of plan steps • A set of step ordering • A set of variable binding constraints • A set of causal links : sic sj”si achieves c for sj” • initial plan before any refinementsStart < FinishRefine and manipulate until a plan that is a solution
11.4 Basic Representations for planning - Initial plan
11.4 Basic Representations for planning • Solutions • solution : a plan that an agent guarantees achievement of the goal • a solution is a complete and consistent plan • a complete plan : every precondition of every step is achieved by some other step • a consistent plan : no contradictions in the ordering or binding constraints. When we meet a inconsistent plan we backtrack and try another branch
11.5 A partial-order planning example 11.5 A partial-order planning example • Shopping problem: “get milk, banana, drill and bring them back home” • assumption1)Go action can travel the two locations2)no need money • initial state : operator startOp(ACTION:Start,EFFECT:At(Home) Sells(HWS,Drill) Sells(SM,Milk), Sells(SM,Banana)) • goal state : Finish Op(ACTION:Finish, PRECOND:Have(Drill) Have(Milk) Have(Banana) At(Home)) • actions:Op(ACTION:Go(there),PRECOND:At(here),EFFECT:At(there) ¬At(here))Op(ACTION:Buy(x),PRECOND:At(store) Sells(store,x),EFFECT:Have(x))
11.5 A partial-order planning example • There are many possible ways in which the initial plan elaborated • one choice : three Buy actions for three preconditions of Finish action • second choice:sells precondition of Buy• Bold arrows:causal links, protection of precondition• Light arrows:ordering constraints
11.5 A partial-order planning example • causal links : protected linksa causal link is protected by ensuring that threats are ordered to come before or after the protected link • demotion : placed beforepromotion : placed after
11.6 Partial-order planning algorithm 11.6 Partial-order planning algorithm
11.7 planning with partially instantiated operators 11.7 planning with partially instantiated operators • Variable binding constraints • resolve now with an equality constraint • resolve now with an inequality constraint • resolve later (see fig 11.14)
11.8 knowledge engineering for planning 11.8 knowledge engineering for planning • Methodology for solving problems with the planning approach(1) Decide what to talk about(2) Decide on a vocabulary of conditions, operators, and objects(3) Encode operators for the domain(4) Encode a description of the specific problem instance(5) pose problems to the planner and get back plans
11.8 knowledge engineering for planning • (ex) The blocks world (1) what to talk about • cubic blocks sitting on a table • one block on top of another • A robot arm pick up a block and moves it to another position (2) Vocabulary • objects:blocks and table • On(b,x) : b is on x • Move(b,x,y) : move b form x to y • ¬exist x On(x,b) or x ¬On(x,b) : precondition • clear(x)
11.8 knowledge engineering for planning (3)OperatorsOp(ACTION:Move(b,x,y), PRECOND:On(b,x) Clear(b) Clear(y), EFFECT:On(b,y) Clear(x) ¬On(b,x) ¬Clear(y))Op(ACTION:MoveToTable(b,x), PRECOND:On(b,x) Clear(b), EFFECT:On(b,Table) Clear(x) ¬On(b,x))