• Aucun résultat trouvé

2.2 Classical Planning & HTN Planning

2.2.2 HTN Planning

Different from classical planning, hierarchical task network (HTN) planning [Erol et al.,1994a] is a planning formalism which is based on domain-specific heuristics about the hierarchical decomposition of compound tasks, until primitive tasks are obtained. [Erol et al., 1994a] proposes a model-theoretic semantics for HTN planning which is operational. In this thesis, we adapt the presentation way of operators in HTN planning to conform with that of operators in classical planning, which is used in [Ghallab et al., 2004].

HTN planning is also defined on a function-free first-order language L whose vocabulary includes a finite set of predicates and constants and an infinite set of variables. In addition, the vocabulary of L includes a finite set of primitive task symbols, a finite set of compound task symbols and an infinite set of task

3If it is clear from the context, we abbreviate “plan-existence problem for classical planning”

as “classical planning problem” simply.

Chapter 2. Shoham’s Database Perspective and Automated Planning 22 labeling symbols which are used to identify tasks, so that multiple instances of task symbols are allowed. All these sets are mutually disjoint.

In HTN planning, task symbols are syntactically atoms and fall into two categories:

primitive task symbols that can be executed directly and compound task symbols that cannot. Every task syntactically is a pair of (t:α) where t is a task labeling symbol that cannot occur more than once in the planning problem and α is a task symbol.4 A primitive task is associated with an operator. Just as classical planning, every operator has the form of o = (name(o),pre(o),eff+(o),eff(o)) where its name name(o) is syntactically an atom n(t); its precondition pre(o) is a formula in L; its positive effect eff+(o) and its negative effect eff(o) are two sets of atoms, respectively. We suppose that after grounding the atoms, these two sets are disjoint. Similarly, we usually take the task symbol as name(o) and use it to denote the entire operator o.

A task network is a couple d= [T, ϕ] consisting of a set of tasks T and a boolean formula ϕ. The boolean formula ϕ is constructed5 from variable binding con-straints such as (v = v0) and (v = c), ordering constrains such as (t ≺ t0), and state constraints such as (t, l),(l, t),(t, l, t0) wherev, v0 are propositional variables, l is a literal, c is a constant, and n, n0 are tasks in T. Intuitively, ordering con-straint (t ≺ t0) means task t has to be performed before taskt0; state constraints (t, l),(l, t) and (t, l, t0) mean that l must be true in the state immediately after t, immediately before t, and in all states between t and t0. The task network [T, ϕ]

is achieved if the set of tasks T is achieved and the boolean formula ϕholds.

A task network is called primitive if it only contains primitive tasks. A task network is ground if all variables in all tasks and constraint formula are ground.

A decomposition method (α, d) specifies that the compound taskα can be decom-posed into the task network d: α is going to be achieved once d is achieved. For example, the action of submitting a paper can be decomposed into a task network d= [T, ϕ] where T consists of the two actions of writing a paper and uploading it

4We usually use the task labeling symbol to denote the entire task.

5Logical connectives¬,∧,are allowed.

Chapter 2. Shoham’s Database Perspective and Automated Planning 23 and constraint ϕexpresses that the writing action has to be performed before the uploading action.

An HTN planning domain is a tuple D = (O,M) where O is a set of operators and M is a set of decomposition methods. An HTN planning problem is a tuple P = (D, sI, d) where D is an HTN planning domain, sI is the initial state which is also a set of ground atoms and d is the initial task network to plan for. If all actions and atoms are ground in the HTN planning problem, we call it ground (or propositional) HTN planning problem, Let us introduce the operational semantics of HTN planning.

Just as in classical planning, the change of the world is defined by the state-transition function, which is determined by a set of ground primitive tasks O:

γ : 2Atm(L0)×O −→2Atm(L0), where:

ˆ γ(s, o) is defined iff s|=pre(o);

ˆ γ(s, o) = (s\eff(o))∪eff+(o) ifγ(s, o) is defined.

A plan is a sequence of ground primitive tasks. As before, a plan ho1, . . . , oni is executable in a states0 iff there exists a sequence of statess1, . . . , sn such that for all 1≤i≤n, γ(si−1, oi) = si.

A plan σ is a completion of a primitive task network d in state sI, denoted by σ ∈comp(D, sI, d), if σ is a total ordering of a ground instance of d that satisfies the constraint formula and is executable in sI.

Definition 2.1. For a ground primitive task network d = [{t1, . . . , tn}, ϕ], let σ = hf1, . . . , fni ∈ comp(D, sI, d) and π be a permutation such that whenever π(i) = j, αi =fj. Then the constraint formula in task network d is evaluated as follows:

ˆ (ci =cj), if ci, cj are the same constants

ˆ f irst[ti, tj, . . .] ismin{π(i), π(j), . . .}

Chapter 2. Shoham’s Database Perspective and Automated Planning 24

ˆ last[ti, tj, . . .] ismax{π(i), π(j), . . .}

ˆ (ti ≺tj) is true ifπ(i)< π(j)

ˆ (l, ti) is true ifsπ(i)−1 |=l

ˆ (ti, l) is true ifsπ(i) |=l

ˆ (ti, l, tj) is true if sk |=l for π(i)≤k < π(j)

ˆ logical connectives¬,∧,∨ are evaluated as in propositional logic

wheremin{.}andmax{.}are the minimum and maximum number of the natural number set, respectively.

Tasks in a task network are called totally ordered if there is only a total ordering of tasks to satisfy the constraints in the task network.

If d is a primitive task network containing variables, then

comp(D, sI, d) ={σ |σ∈comp(D, sI, d0), d0 is a ground instance of d}.

If a task networkd contains non-primitive tasks, then the set of completions ford is the empty set.

Next we introduce how to decompose tasks.

Definition 2.2. For a task network d = [{t, t1, . . . , tn}, ϕ] where t : α is a non-primitive task, let m = (α,[{t01, . . . , t0k}, ϕm]) be a decomposition method.6 Then we define reduce(d, t, m) as follows:

reduce(d, t, m) = [{t01, . . . , t0k, t1, . . . , tn}, ϕm∧ψ]

where ψ is obtained from ϕwith the following modifications:

6We suppose the task symbols in the decomposition methodmhave been renamed with task symbols which do not occur anywhere else.

Chapter 2. Shoham’s Database Perspective and Automated Planning 25

ˆ replace (t ≺ti) with (last[t01, . . . , t0k]≺ti), as ti must be after every subtask of t

ˆ replace (ti ≺ t) with (ti ≺ f irst[t01, . . . , t0k]), as ti must be before every subtask of t

ˆ replace (l, t) with (l, f irst[t01, . . . , t0k]), as l must be true immediately before the first subtask oft

ˆ replace (t, l) with (last[t01, . . . , t0k], l), asl must be true immediately after the last subtask oft

ˆ replace (ni, l, t) with (ni, l, f irst[t01, . . . , t0k]), asl must be true betweenti and the first subtask oft

ˆ replace (t, l, ti) with (last[t01, . . . , t0k], l, ti), as l must be true between the last subtask of t and ti

ˆ replace every occurrence of t in the expressionsf irst[.] andlast[.] in ϕwith t01, . . . , t0k

Intuitively, reduce(d, t, m) is the task network obtained from task network d by replacing t with the subtasks in the decomposition method m and incorporating the constraint formula of the decomposition method into the constraint formula of d.

Then we define the set of reductions of d = [T, ϕ] in state sI and domain D, denoted by red(D, sI, d), as follows:

red(D, sI, d) = {reduce(d, t, m)|t ∈T, m∈D}.

The solution for an HTN planning problem P = (D, sI, d) is a plan such that the task network d will be achieved by decomposing compound tasks iteratively via the decomposition methods in D, starting from the initial state sI.

Chapter 2. Shoham’s Database Perspective and Automated Planning 26 More precisely, A plan σ solves a primitive task networkd in the initial state sI, iffσ ∈comp(D, sI, d); a plan σ solves a non-primitive task networkdin the initial state sI iff σ solves some reduction d0 ∈red(D, sI, d) in the initial state sI.

Definition 2.3. We define the set of planssol(D, sI, d) which solve an HTN plan-ning problem P = (D, sI, d):

sol1(D, sI, d) = comp(D, sI, d)

solk+1(D, sI, d) = solk(D, sI, d)∪ [

d0∈red(D,sI,d)

solk(D, sI, d0) sol(D, sI, d) = [

k

solk(D, sI, d)

Intuitively, solk(D, sI, d) is the set of plans that can be derived in k steps of re-finements, while sol(D, sI, d) is the set of plans that can be derived in any finite number of steps.

The decision problem for HTN planning is called the plan-existence problem for HTN planning which is to decide whether there is a solution of the HTN planning problem. The plan-existence problem for HTN planning, whether variables are allowed or not, is undecidable [Erol et al., 1996]. Alfordet al. [2015a] summarize the complexity results of the plan-existence problem for HTN planning with var-ious restrictions, which range from PSPACE up to undecidable. In particular, if all tasks in task networks are totally ordered by the constraints, the complex-ity for propositional HTN planning is EXPTIME-complete and the complexity for non-ground HTN planning is 2-EXPTIME-complete because of the exponen-tial size expansion caused by the grounding procedure. If we additionally restrict the decomposition of tasks not to be recursive, the complexity for propositional HTN planning reduces toPSPACE-complete andEXPSPACE-complete for the non-ground case.

Chapter 2. Shoham’s Database Perspective and Automated Planning 27