**4. The** *Graphplan* **algorithm**

The cognitive level uses the *Graphplan* algorithm to generate the plans that the other levels should execute. Originally, the algorithm used a propositional knowledge representation, so this will be adopted here for the algorithm description. The rest of this section uses [12, 13] as references.

Mathematically, a planning problem may be stated as P ¼ <sup>Σ</sup>, *sj*, *<sup>g</sup>* , where <sup>Σ</sup> <sup>¼</sup> ð Þ *S*, *A*, *γ* is the problem domain (that comprises the set of states *S*, the set of actions *A* and a state transformation function *γ* ¼ *S* � *A* ! *S*), *s <sup>j</sup>* is the initial state and *g* is the goal state.

Each action *a*∈ *A* has a set *prencond a*ð Þ of precondition propositions and a set *effects a*ð Þ¼ *effects*þð Þ *a* ∪ *effects*�ð Þ *a* of effects. The effects, in turn, may be broken down into two subsets: *effects*þð Þ *a* , the set of positive propositions (propositions to be added), and *effects*�ð Þ *a* , the set of negative propositions (propositions to be deleted). The applicability condition for an action *a*, in a given state *s*, may be written as *precond a*ð Þ⊆*s*. The new state produced by the application of *a* would be *γ*ð Þ¼ *s*, *a s* � *effects*� ð Þ ð Þ *a* ∪ *effects*þð Þ *a* .

Consider an action layer *Aj* and the propositional layer *Pj*�<sup>1</sup> preceding it. *Aj* contains all actions *a* such that *precond a*ð Þ⊆ *Pj*�1, and *Pj*�<sup>1</sup> all propositions *p* such that *p*∈*Pj*�1. The so called planning graph is the built by connecting elements in *Pj*�<sup>1</sup> to elements in *Aj* by edges:


If two actions *a*1, *a*<sup>2</sup> ∈ *A <sup>j</sup>* obey *effects*�ð Þ *a*<sup>1</sup> ∩ *precond a*ð Þ<sup>2</sup> ∪ *effects*þð Þ *a*<sup>2</sup> <sup>¼</sup> <sup>∅</sup> and *effects*�ð Þ *a*<sup>2</sup> ∩ *precond a*ð Þ<sup>1</sup> ∪ *effects*þð Þ *a*<sup>1</sup> <sup>¼</sup> <sup>∅</sup>, they a said to be *independent*; if not, they are *dependent*, or *mutually exclusive* (*mutex*).

Propositions can also be *mutex*: *p* and *q* are *mutex* if every action in *A <sup>j</sup>* that adds *p* is *mutex* with every action in *Aj* that produces *q*, and there are no actions in *Aj* that adds both *p* and *q*. Also, if a precondition of an action is *mutex* with a precondition of another action, the actions are *mutex*.

*System Level Design and Conception of a System-on-a-Chip (SoC) for Cognitive Robotics DOI: http://dx.doi.org/10.5772/intechopen.98643*

The algorithm begins by expanding the graph. The pseudo-code for the expansion step is given in Algorithm 1.
