# Learning and Planning Based on Merged Experience from Multiple Situations for a Service Robot
## 2 Learning and Planning Methods
### Representation  
In this section, we propose or modify some definitions in experience-based planning domains (EFPDs). The representations of actions can be hierarchical as in HTNs [22]. The main definitions of main concepts in this paper are listed below:  
**Definition 1**. : A **method**: \(m=(h,\,L_{I}\ T_{1},\,L_{2}\ T_{2},\,\ldots\,\,L_{n}\ T_{n})\), in which \(h\) is the abstract method's head including the name of an argument list for \(m\), \(L_{i}\) is a predicate list for the preconditions of the \(i\)th branch, and \(T_{i}\) is a subtask list. Based on methods, the planner knows how nonprimitive tasks can be decomposed into other tasks. There is a complete definition of methods and operators in the complete task knowledge domain, and the methods are used to guide the decomposition of a task under multiple conditions as \"middle layers\". Inspired by this notion, to merge the plan-based activity experiences from multiple situations in the same task, we define the abstract methods that served as middle layers in the merged activity schema. **Definition 2**. : An **abstract method**: \(am=[h,\,(presub_{1})(sub_{1}),\,(presub_{2})(sub_{2}),\,\ldots,\,(presub_{n})(sub_{n})]\), where \(h\) is the head of the abstract method, \((presub_{i})(sub_{i})\) is the \(i\)th branch of \(am\), \(presub_{i}\) is a predicate list for the preconditions of the \(i\)th branch, and \(sub_{i}\) is a list of ordered subtasks, which is composed of abstract operators or other abstract methods. **Definition 3**. : An **activity schema** is a triple, \(ma=(t,\,AM,\,\Omega)\), where \(t\) is a task head, \(AM\) is the set of abstract methods to decompose the \(t\) and \(\Omega\) is an enriched abstract plan to achieve the \(t\). Here, \(ma\) is a task model learned from an experience. The research goal is how to merge activity experiences from multiple situations and generate an intelligent and efficient plan that could adapt to the dynamically changing environment. There are four research problems in this paper and the respective solutions are given as follows. **Problem 1**: How to abstract the sequence of abstract methods \(AM\) from taught subtasks sequence \(M\), and conceptualize the activity experiences as activity schema \(ma\). Problem 1 is formalized as: \(AM=\text{abs}(M)\), \(ma=(t,\,AM,\,\Omega)\). **Solution 1**: The preconditions and structures of the abstract methods \(AM\) that compose the activity schema \(ma\) can be extracted according to the function abstract (\(M\)) in Algorithm 1 in Section 2.3. **Problem 2**: How to merge activity experiences for multiple situations through abstract methods. Let \(ma\) be an activity schema for the target task \(t\), and \(ma^{\prime}\) is a merged activity schema in the activity schema memory for the identical target task \(t\). Problem 2 is formalized as: \(ma^{\prime}=\text{mer}(ma,\,ma^{\prime})\). Figure 1: An overview of the learning and planning system. **Solution 2:** The preconditions or structures of the abstract methods _MA'_ that compose the activity schema _ma'_ can be detected and adjusted according to the function Merge (_ma_, _ma'_) in Algorithm 1 in Section 2.3.2. **Problem 3:** How to find an optimal plan for a learned task with different objects. Problem 3 is formalized as: (_\(\pi\)_, tasktree, planttree_) = \(P\)(_D_, \(P\), _ma_), where \(\pi\) is an optimal plan solution, _tasktree_ is a task tree [19], _plantree_ is a plan tree [19], \(P\) is a task planning problem, and \(D\) is an experience-based planning domain [2]. **Solution 3:** Planning based on activity schema with merging optimization as the function SBOP(_D_, \(P\), _ma_) in Algorithm 2 in Section 2.4.1. **Problem 4:** How to replan automatically to recover from the failure that is due to an exception that has been merged in the activity schema.