Docsity

POP Algorithm with Example in Artificial Intelligence Programming | CS 662, Study notes of Computer Science

Partial preview of the text

Download POP Algorithm with Example in Artificial Intelligence Programming | CS 662 and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence

Programming^ More Planning

Chris Brooks Department of Computer ScienceUniversity of San Francisco

Previously on CS662 ... Planning

combines search and knowledge representation. Construct a partially-ordered sequence of actions toachieve a goal. Insights:^ Only select actions that help achieve our plan^ Don’t have to solve the problem in order^ Don’t have to produce a linear ordering on events.^ Search through space of plans, rather than states.

Department of Computer Science — University of San Francisco – p.1/

POP example Start:^

at(Town)

has(Coins),

has(Dagger)

:not

(grown

(Beanstalk))

Finish:

has(Gold)

Department of Computer Science — University of San Francisco – p.3/

POP example actions:wield.^

Pre:

has(w)

Effect:

holding(w)

go. Pre:

at(x),

!at(y)

Effect:

!at(x),

at(y)

plantBeans.

Pre:

at(Field),

has(Beans)

Effect:

!has(Beans),

grown(Beanstalk)

defeatDragon.

Pre:

at(Cave),

wearing(Armor),

holding(Sword) Effect:

has(Gold) wear.

Pre:

has(x)

Effect:

wearing(x)

climbBeanstalk:

Pre:

at(Field),

grown(Beanstalk)

Effect:

has(Armor) buyBeans.

Pre:

at(Town),

has(Coins)

Effect:

!has(Coins),

has(Beans)

getSwordFromLake

Pre:

at(Lake),

wearing(Armor)

Effect:

has(Sword)

Department of Computer Science — University of San Francisco – p.4/

Hierarchical Task Networks A Hierarchical Task Network (HTN) specifies a plan atvarious levels of detail, or granularity.^ Insight: if we can decompose a plan into severalindependent subplans, we can solve these problems(mostly) independently.^ We can also reuse components of a plan in a newsetting. The actions in our high-level plan will correspond toentire plans in a lower-level representation.

Department of Computer Science — University of San Francisco – p.6/

HTN Example

GoOnTrip has(Brooks, ticket)

at(Brooks, Hawaii)

PackSuitcase

GetToAirport

GetOnPlane

at(Brooks, Hawaii) at(Brooks, SFO)has(Brooks, suitcase)at(Brooks, SFO) has(Brooks, suitcase)at(Brooks, home) FindSuitcase

FindSwimsuit

walkToCar^

DriveToSFO

WalkToGate ParkCar

FindSeat^ Department of Computer Science — University of San Francisco – p.7/

HTN Algorithm Begin with our initial plan

Start,^

F inish

,^ Start^

≺^ F inish

While (no solution)^ Select an open precondition

p^ on an action

B^ or an abstract action

′ a.

if we have selected a precondition:^ Find each action

A^ that satisfies that precondition; generate a new plan for each action. for each of these plans:^ •^ Add ordering constraints

A^ ≺^ B

, plus causal links

p^ A → B

-^ Resolve any conflicts between causal links. If no consistent plan exists,discard. else if we have selected an abstract plan Find each decomposition

d^ of action

′ a

For each decomposition: Add this new subplan Check for task sharing. Resolve conflicts.

Department of Computer Science — University of San Francisco – p.9/

Subtask sharing Primitive plans can interact in two ways The positive interaction is called

subtask sharing

Two subplans both contain the same action or achievethe same effect.^ PackSuitcase and GoToAirport might both containcheckWeather as actions. We can eliminate one of them. This is sometimes called synergy

Department of Computer Science — University of San Francisco – p.10/

HTNs in practice HTNs have been extremely successful in real-worldplanning systems. Most problems really are decomposable. Subtask sharing is very xommon in practice. Having the ability to reuse plan fragments is extremelybeneficial. Plan fragments can also be learned (chunked) fromexperience.^ The first time I solve buyTicket, I can determine whatis specific to my problem and what is generic andcreate a generalized version that keeps only genericinformation.

Department of Computer Science — University of San Francisco – p.12/

Nondeterminism So far, we have only thought about planning (andsearch, for that matter) in deterministic environments.^ Actions always succeed. What about worlds in which actions might fail? What about problems in which our agent has incompleteinformation?

Department of Computer Science — University of San Francisco – p.13/

Sensorless planning In sensorless planning, we construct a standard planand execute without any perception. Our plan must work no matter what actions fail. Assumes that the world can always be coerced into aparticular state.^ We can just use our standard algorithms.^ Many worlds cannot be coerced like this.

Department of Computer Science — University of San Francisco – p.15/

Conditional Planning Conditional planning accounts for the fact that actionsmight fail by integrating sensing actions into the plan.^ After we put the tire onto the axle, look at the axle toensure that the tire is actually there. We need to modify our actions to have

disjunctive

effects

. P utOnT ire

(tire) P reconditions

:^ On (tire, Ground

)^ ∧^ Clear

(Axle

)

Ef f ect

: (On

(tire, Axle

)^ ∧ ¬On

(tire, Ground

)^ ∧

¬Clear

(Axle

))^ ∨^ On

(tire, Ground

)^ Department of Computer Science — University of San Francisco – p.16/

Execution Monitoring Conditional planning assumes that all planning happens offline

. We plan, and then execute. This is fine when all possible failures are known inadvance. But what about worlds where there are problems wecan’t anticipate? In this case, our agent must be able to monitor itsexecution and replan if necessary.

Department of Computer Science — University of San Francisco – p.18/

Replanning Our replanning agent starts with a normal plan. Before taking an action, it examines the world to see ifany of the preconditions for that action have becomeunsatisfied. If so, the agent constructs a new plan that satisfiesthese preconditions. The agent can also look ahead at future actions to see ifthere are unsatisfied preconditions that will not befulfilled by an effect.^ This helps avoid proceeding with plans that cannotsucceed.

Department of Computer Science — University of San Francisco – p.19/