0% found this document useful (0 votes)
15 views54 pages

Unit-IV Planning

Uploaded by

farhanask211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views54 pages

Unit-IV Planning

Uploaded by

farhanask211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

7/3/2024

03-07-2024 15CS401-Artificial Intelligence 1

Introduction to Planning
• Planning is an important topic in AI.
• Planning is required for every task , for example reaching a
particular destination requires planning.
• To reach a particular destination , first we should find the best
route and then identify a set of actions to be done at a particular
time , is called planning.
• Planning is deciding a set of actions to be performed , in an agent
environment based on the perception to achieve the decided goal.
• For any planning system , we need the domain description, action
specification and goal description.
2

1
7/3/2024

Introduction to Planning
• Planning is assumed to be sequence of actions.
• Each action has its own set of preconditions, All the preconditions
to be satisfied before performing the action.
• Some effect can be either +ve or –ve
• Two types of planning
• Classical Planning Environment
• Fully Observable, Deterministic, Finite, Static and Discrete.
• Non-Classical Planning is for partially observable or stochastic
environments
• It involves a different set of algorithms and agent designs
3

Planning Problem
• Agent environment states are represented as valuations of
variables.
• An action can be represented as a procedure or program.
• The procedures are used to compute values of state variables.
• After the execution of procedure (i,.e after action ), the
environment state will be changed , towards the goal.

2
7/3/2024

Planning Algorithms
• Representation of Planning problems – states, actions and goals- should
make it possible for planning algorithms.
• Algorithms are nothing but logical structure of the problem.
• To define an efficient algorithm , a language is very important.
• STRIPS Language- The language of classical planner
• Planner decompose the agent world into logical conditions , and represent a
state as conjunction of +ve literals.
• In first order state descriptions , literals must be Ground and function free.
• At(x,) or At (Father(red, Sydney) are not allowed
• The closed world assumption , that is any conditions that are not mentioned
in a state are assumed false.
5

• The STandard Research Institute Problem Solver(STRIPS), is an automated


planning technique used to find a goal , by executing a domain from the
initial state of domain.
• With STRIPS , we can first describe the world ,(Initial and Goal state) by
providing objects, actions , preconditions and effects.
• To describe the world, we used two categories of terms
• States: Initial and Goal state
• Action Schema: objects, actions, preconditions and effects
• Once the world is described , then provide a problem set
• A problem consists of initial state and Goal condition
• STRIPS can then search all possible states , starting from the initial one,
executing
6 various actions , until it reaches the goal.

3
7/3/2024

• A common language for writing STRIPS domain and problem sets ,


is the PDDL.
• In PDDL most of the codes are English words, so that it can be
clearly read and well understood.
• It is relatively easy approach to writing simple AI planning problems

4
7/3/2024

10

5
7/3/2024

11

12

6
7/3/2024

13

Representation of Goals
• A goal is a partially represented state , represented as conjunction
of positive ground literals such as
• Rich ∧ Famous , At( P2,Delhi)
• A propositional state s, satisfies a goal g, if s contains all the atoms
in g
• The propositional state Rich ∧ Famous ∧ Happy
Satisfies the goal state Rich ∧ Famous

14

7
7/3/2024

Representation of Actions
• To perform an action , we need Precondition (how
environment should be to perform this action) and effect
(how the environment will be after performing this action)
• An action for flying a pane from one location to another is
• Action : Fly(p, from, to)
• PRECOND : At(p, from) ∧ Plane(p) ∧ Airport(from) ∧ Airport(to)
• EFFECT : At(p, from) ∧ At(p, to)
• The variables p, from, to are different constants

15

Action Schema
• It represents a number of different actions can be derived
• Action schema consists of three parts
• The action name and parameter list
• Fly(p, from, to) - Fly is action, and p, from, to are parameters
• The precondition is a conjunction of function free positive literals , and it must be true before the action can
be executed
• Variables in the precondition must also appear in the actions parameter list
• The effect is a conjunction of function free literals describing how the state changes , when the action is
executed.
• A positive literal p are declared to be true in the state , and all the negative literals p is declared to be
false
• Variables in the effect must also appear in the actions parameter list
• Planning System divide the effect into two categories
• Add List, and Delete List
• Add List for Positive literals and Delete List negative literals
16

8
7/3/2024

Applicable Action
• An action is applicable in any state , iff that satisfies the precondition ,
otherwise the action has no effect.
• A first-order action schema , first all the variables in precondition will be
substituted.
• At(P1,JFK) ∧ At (P2,SFO) ∧ Plane(P1) ∧Plane(P2) ∧ Airport(JFK) ∧ Airport(SFO)
This state satisfies the precondition
• At(p, from) ∧ Plane(p) ∧ Airport(from) ∧ Airport (to)
• With the substitution {p=P1,from=JFK, to=SFO}
• Thus the concrete action Fly(P!,JFK, SFO) is applicable

17

Solution for Planning Problem


• An action sequence ,that started from the initial state and results in a state
that satisfies the goal.
• Solutions to be partially ordered sets of actions
• Every action sequence , that respects the partial order , is a solution (i.e
every action has its own solution)

18

9
7/3/2024

03-07-2024 15CS401-Artificial Intelligence 19

• The most straight forward approach of planning algorithm, is state


space search
• Forward state space search(Progression)
• Backward state space search(Regression)
• The description of actions in planning problem , and specify both
preconditions and effects.
• It is possible to search in both direction : either forward from the
initial state or backward from the goal.
• We can also use the explicit action and goal representations , to
derive effective heuristics automatically.
20

10
7/3/2024

• Initial State:
• Initial state of the problem
• Actions:
• Applicable to the current state
• First actions preconditions are satisfied ,successor states are generated
• Add positive literals to add list and negative literals to delete list
• Goal Test:
• Whether the state satisfies the goal of the planning
• Step cost:
• Each action is 1(assumed)
21

• From initial state , search forward by selecting operators whose


preconditions can be unified with literals in the state
• New state includes positive literals of effect, the negated literals of
effect are deleted.
• Search forward until goal unifies with resulting state
• This is forward state space search using STRIPS operators

22

11
7/3/2024

23

• Starting from the initial state and using the problems action to search
forward for the goal state

24

12
7/3/2024

1. Compute whether or not a state is a goal state


2. Find the set of all actions that are applicable to a state , and
3. Compute a successor state , that is the result of applying an
action to a state.
• Algorithm takes as input the statement P=(O,s0,g) of planning
problem P. ( O contains a list of actions)
• If P is solvable , then Forward search (O,s0,g) returns a solution
plan, otherwise returns failure.

25

26

13
7/3/2024

• Initial State:
• Initial state of the problem
• Actions:
• Applicable to the current state
• First actions preconditions are satisfied ,successor states are generated
• Add positive literals to add list and negative literals to delete list
• Goal Test:
• Whether the state satisfies the goal of the planning
• Step cost:
• Each action is 1(assumed)
27

• Backward state search starts from the goal states


• Using the inverse of the actions to search backward for the
initial state.

28

14
7/3/2024

1. Start at the goal


2. Test the goal is initial state , otherwise
3. Apply inverse of the planning operators to produce sub goals.
4. The algorithm will stop , if we produce a set of sub goals that
satisfies the initial state

29

30

15
7/3/2024

• How to find an admissible heuristic estimate?


• Distance from a state to the goal
• Look at the effects of the actions and at the goals and guess
how many actions are needed
• NP Hard, Relaxed problem
• Sub goal independence assumption.
• The cost of solving a conjunction of sub goals , is
approximated by the sum of the costs of solving
each sub goal independently.
31

• Idea: Removing all preconditions from the actions


• Which implies , the number of steps required to solve a
conjunction of goals , and the number of unsatisfied goals
• There may be two actions
• Some actions deletes the goal literal achieved by the other
actions
• Some action may achieve multiple goals.
• Combining relaxation with sub goal  exact no.of
unsatisfied goals.
32

16
7/3/2024

• Generate a relaxed problem by removing negative


effects:
• Empty delete list heuristic
• Quite accurate , but computing required , it involves
running a simple planning algorithm

33

03-07-2024 15CS401-Artificial Intelligence 34

17
7/3/2024

• Forward/Backward state space searches are forms


of total ordered plan search
• Explore only strictly linear sequence of actions , directly
connected to start or goal.
• Cannot take advantages of problem decomposition

35

• Works on several sub goals independently


• Solve them with sub plans
• Combines the sub plans
• Flexibility in ordering the sub plans
• Least commitment strategy:
• Delaying a choice during search
• Example, leave actions unordered , unless the must be
sequential
36

18
7/3/2024

37

• A partial order plan for putting on shoes and socks , and


six corresponding linearization's into total order plans.

38

19
7/3/2024

39

40

20
7/3/2024

41

42

21
7/3/2024

43

44

22
7/3/2024

45

46

23
7/3/2024

47

48

24
7/3/2024

49

50

25
7/3/2024

03-07-2024 15CS401-Artificial Intelligence 51

• It is an algorithm for automated planning, developed by Avrim and Merrick


in 1995.
• The Graph plan’s input is planning problem, expressed in STRIPS and
produces sequence of operations for reaching the goal state.
• Convert the planning problem structure into planning graph called as
GRAPHPLAN , in the increment nature.
• It gives the relation between action and states , the precondition must be
satisfy the action.
• The planning graph is a layered graph, with alternate layers of propositions
and actions.
• Layer p0
• Layer a1
• 52 Layer p1

26
7/3/2024

• Propositional problem will look at , what the starting state, what the objects in
the domains are ,and it will produce all the possible actions , and works with
those actions.
• We construct the planning graph from left to right
• We keep inserting actions and propositions
• Then actions and propositions
• Until we get the goal proposition appear on the proposition layer ,and
• They are not mutually exclusive
• There are two states in the planning graph problem
• Construct the Planning Graph
• Search for Solution
• If you cannot get solution , then extend the planning graph and search for
solution , and keep doing that until you get the solution.
53

54

27
7/3/2024

• Planning Graphs are an efficient way to create a


representation of planning problem , that can be
used to
• Achieve better heuristic estimates
• Directly construct plan
• Planning Graphs only work for propositional
problems

55

56

28
7/3/2024

“Have Cake and eat Cake too”

57

58

29
7/3/2024

59

60

30
7/3/2024

61

62

31
7/3/2024

63

64

32
7/3/2024

65

66

33
7/3/2024

67

68

34
7/3/2024

69

70

35
7/3/2024

03-07-2024 15CS401-Artificial Intelligence 71

• Classical planning as Boolean satisfiability


• Planning as first-order logical deduction: Situation calculus
• Planning as constraint satisfaction
• Planning as refinement of partially ordered plans.

72

36
7/3/2024

• Propositionalize the actions: replace each action schema with a set of ground actions formed by
substituting constants for each of the variables.
• Define the initial state: assert F0 for every fluent F in the problem’s initial state, and ¬F for every
fluent not mentioned in the initial state.
• Propositionalize the goal: for every variable in the goal, replace the literals that contain the
variable with a disjunction over constants. For example, the goal of having block A on another
block, On(A, x) ∧ Block(x) in a world with objects A,B and C, would be replaced by the goal
(On(A,A) ∧ Block (A)) ∨ (On(A,B) ∧ Block (B)) ∨ (On(A,C) ∧ Block (C)) .
• Add successor-state axioms: For each fluent F, add an axiom of the form
Ft+1 ⇔ ActionCauses Ft ∨ (Ft ∧ ¬ActionCausesNot Ft) , where ActionCausesF is a disjunction of
all the ground actions that have F in their add list, and ActionCausesNotF is a disjunction of all the
ground actions that have F in their delete list.
• Add precondition axioms: For each ground action A, add the axiom At ⇒ PRE(A)t, that is, if an
action is taken at time t, then the preconditions must have been true.
• Add action exclusion axioms: say that every action is distinct from every other action.
73

Planning in situational
calculus

74

37
7/3/2024

Situation Calculus
• The idea behind situation calculus is that (reachable) states are
definable in terms of the actions required to reach them.
• These reachable states are called situations. What is true in a
situation can be defined in terms of relations with the situation as an
argument.
• Situation calculus is defined in terms of situations. A situation is
either
• init, the initial situation, or
• do(A,S), the situation resulting from doing action A in situation S, if it
is possible to do action A in situation S.

75

Contd..
• Situations are connected by the Result function
• e.g. s1= Result(a,s0) is the function giving the situation that results
from doing action a while in situation s0
• Here, we represent an action sequence (plan) by a list [first | rest ]
where
• first is the initial action and rest is a list of remaining actions.
• PlanResult(p,s) generalizes Result to give the situation resulting from
executing p starting from state s:
• ∀s PlanResult([],s) = s
• ∀s,a,p PlanResult([a | p], s) = PlanResult(p, Result(a,s))
76

38
7/3/2024

Contd..
• Provides a framework for representing change, actions and reasoning
about them.
• Situational calculus:
• - is based on FOPL;
• - a situation variable models new stars of the world;
• - action objects model activities;
• - uses inference methods developed for FOPL to do the reasoning.

77

Planning in Situational Calculus


• Situational calculus is a dialect of first order predicate calculus formalization of
states, actions and the effects of actions on states.
• Actions:- every change requires actions. The constant and function symbols for
actions are completely dependent on the application. Actions typically have
preconditions.
• Situations:- denote possible world histories.
• Constant s0 and function symbol do are used, s0 denotes the initial situation
before any action has been performed.
• do(a, s) denotes the new situation that results from the performing action a in
situation s.

78

39
7/3/2024

SITUATIONAL CALCULUS
Situational calculus is based on FOPL plus:
 Special variables: s,a – objects of type situation and action

 Action functions: return actions.

 E.g., move(A, TABLE, B) represents a move action

 move(x, y, z) represents an action schema

Two special function symbols of type situation

s0 – initial situation

do(a,s) – denotes the situation obtained after performing an action a in

situation s.
Situation-dependent functions and relations
also called fluents

Relation: on(x, y, s) – object x is on object y in situation s;

Function: above(x, s) – object that is above x in situation s.

79

Situational Calculus Example


• Shopping Problem
• “Get a liter of milk, a bunch of bananas and a variable-speed cordless drill.”
• Need to define
• Initial state
• Operations
• A planning problem represented in situational calculus by logical sentences
• initial state : For shopping problem
at(Home,s0)  ¬have(Milk, s0)  ¬have(Banana, s0)  ¬have(Drill,s)

• goal state: a logical query


s: at(Home,s)  have(Milk,s)  have(Bananas,s)  have(Drill,s)

80

40
7/3/2024

Operators in Situational Calculus

• Operators : description of actions


a,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)=s
a,p,s: Result’([a|p],s)=Result’(p,Result(a,s))

81

Solutions in Situational Calculus

• 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

82

41
7/3/2024

Solutions in Situational Calculus: Example

• A solution to the shopping problem is a plan P, applied to so, that 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

83

• Constraint satisfaction has a lot in common with Boolean satisfiability, and


we have seen that CSP techniques are effective for scheduling problems, so it
is not surprising that it is possible to encode a bounded planning problem
(i.e., the problem of finding a plan of length k) as a constraint satisfaction
problem (CSP).
• It is also possible to encode a planning graph into a CSP

84

42
7/3/2024

• All the approaches we have seen so far construct totally ordered plans
consisting of a strictly linear sequences of actions.
• An alternative is to represent plans as partially ordered structures: a plan is a
set of actions and a set of constraints of the form Before(ai, aj) saying that
one action occurs before another.

85

86

43
7/3/2024

• Planning combines the two major areas of AI we have covered so far: search and logic.
• A planner can be seen either as a program that searches for a solution or as one that
(constructively) proves the existence of a solution.
• Each of the major approaches to planning has its adherents, and there is as yet no consensus on
which is best. Competition and cross-fertilization among the approaches have resulted in
significant gains in efficiency for planning systems.
• full decomposability of the problem—we get an exponential speedup.
• Sometimes it is possible to solve a problem efficiently by recognizing that negative interactions
can be ruled out.
• We say that a problem has serializable sub goals if there exists an order of sub goals such that the
planner can achieve them in that order without having to undo any of the previously achieved sub
goals.
• Planners such as GRAPHPLAN, SATPLAN, and FF have moved the field of planning forward, by
raising the level of performance of planning systems, by clarifying the representational and
combinatorial issues involved, and by the development of useful heuristics.
87

03-07-2024 15CS401-Artificial Intelligence 88

44
7/3/2024

• Time , Schedule and Resources


• Hierarchical Task Network Planning
• Planning and acting in Non deterministic domains
• Bounded indeterminacy planning methods
• Unbounded indeterminacy planning methods
• Multi-Agent Planning

89

• The classical planning representation talks about what to


do, and in what order, but the representation cannot talk
about time: how long an action takes and when it occurs.
• For example, the planners air cargo problem could produce
a schedule for an airline that says which planes are assigned
to which flights, but we really need to know departure and
arrival times as well.
• The real world also imposes many resource constraints; for
example, an airline has a limited number of staff—and staff
who are on one flight cannot be on another at the same
time.
90

45
7/3/2024

• Example of Job Scheduling Problem:


• This is a highly simplified automobile assembly problem
• There are two jobs: Assembling two cars C1 and C2
• Each job consists of three actions: adding the engine,
adding the wheels and inspecting the results
• The engine must be put in first and the inspection must be
done last

91

92

46
7/3/2024

• To minimize makespan (plan duration), we must find the earliest start times for all the
actions
• critical path method (CPM) to this graph to determine the possible start and end times
of each action.
• A path through a graph representing a partial-order plan is a linearly ordered sequence
of actions beginning with Start and ending with Finish.
• The critical path is that path whose total duration is longest; the path is “critical”
because it determines the duration of the entire plan.
• The window is specified in terms of an earliest possible start time, ES, and a latest possible
start time, LS.
• The quantity LS – ES is known as the slack of an action.
• ES(Start) = 0
• ES(B) = maxA≺B ES(A) + Duration(A)
• LS(Finish) = ES(Finish)
• LS(A) = minB A LS(B) − Duration(A) .
93

94

47
7/3/2024

95

96

48
7/3/2024

97

• Example Build House Problem:

98

49
7/3/2024

• Example Build House Problem:

99

• Properties of HTN:

100

50
7/3/2024

• Modifying the planner for decompositions:

101

• Modifying the planner for decompositions:

102

51
7/3/2024

103

• Example for HTN with POP Planner(The Gift of the Magi Problem)

104

52
7/3/2024

• Example for HTN with POP Planner(The Gift of the Magi Problem)

105

• Example for HTN with POP Planner(The Gift of the Magi Problem)

106

53
7/3/2024

03-07-2024 15CS401-Artificial Intelligence 107

54

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy