4 #include <ext/hash_map>
14 * This class creates, holds and executes a plan.
19 * Creates a plan given the input actions, initial state and goal.
21 * @param actions A list of actions which will be used to reach the goal.
22 * @param init The initial state which the plan will start from.
23 * @param goal The goal state which the plan will try to reach.
25 Planner(std::vector<Action> actions, Literals init, Literals goal);
28 * Deletes all the remaining nodes and actions.
34 * Creates new threads for execution of each action.
36 * If any action fail in some way, this method will try to replan and
37 * recursively call itself.
45 * This method does the actual planning. Given the input node it will
46 * try to find all preconditions and create links from parent nodes
47 * to this node and, if the precondition did not have a node associated
48 * with it, create a new and recursively call this method for the newly
51 * @param node The node which this method will find parent nodes for.
53 void makePlan(Node* node);
56 * Adds this node to the internal map and vector.
58 void addNode(Node* node);
61 * This method goes through the executed nodes and then calls
62 * executeChildren for these nodes.
67 * Iterates through the children of the input node and satisfies all
68 * preconditions possible with this node. The children will be executed
69 * if all preconditions have been satisfied.
71 int executeChildren(Node* node);
74 * Addes the remaining actions to the actions map, creates new start and
75 * finish nodes and runs makePlan.
80 * Deletes all nodes, updates _init and _goal, and clears the internal maps and vector.
82 int cleanupExecution();
84 //! Semaphore which is used to signal if a new node has been executed and added to _executedNodes.
86 //! Mutex for access to _executedNodes.
88 //! Holds the nodes which have been executed, but the children haven't been taken care of yet.
89 std::queue<Node*> _executedNodes;
91 //! The start node in the plan graph.
93 //! The end node in the plan graph.
95 //! Map from all the effects which can be achieved with the already added nodes.
96 __gnu_cxx::hash_map<std::string,Node*> _addedEffects;
97 //! Map with all effects available and their corresponding actions.
98 __gnu_cxx::hash_map<std::string,Action*> _actionEffects;
99 //! The initial state.
103 //! All the nodes added to the current plan.
104 std::vector<Node*> _addedNodes;
105 //! All the non-executed actions available in the current plan.
106 std::vector<Action*> _actions;