summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-01-14 00:09:21 +0000
committerjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-01-14 00:09:21 +0000
commit2e3e405960262affe3f7d91ff5250aaa56f3e849 (patch)
tree921804dbbf2e8ed81def25d113f6a89b50dd8e5f
parent10a3df789a00e1f4f1a8dfe4e7f54db8bb1f6782 (diff)
downloadATCD-2e3e405960262affe3f7d91ff5250aaa56f3e849.tar.gz
Thu Jan 14 00:06:06 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
-rw-r--r--SA_POP/ChangeLog19
-rw-r--r--SA_POP/Planner.cpp60
-rw-r--r--SA_POP/SA_POP_Types.h157
-rw-r--r--SA_POP/SA_WorkingPlan.cpp199
4 files changed, 245 insertions, 190 deletions
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog
index 27a2a695492..1f889ff40f1 100644
--- a/SA_POP/ChangeLog
+++ b/SA_POP/ChangeLog
@@ -1,8 +1,23 @@
+Thu Jan 14 00:06:06 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+
+ * Planner.cpp:
+
+ Update Planner::calc_plan_eu().
+
+ * SA_POP_Types.h:
+
+ Update to plan struct (include the goal) and Null ID values.
+
+ * SA_WorkingPlan.cpp:
+
+ Update to SA_WorkingPlan initialization (using reset_plan()).
+
+
Wed Jan 13 16:16:38 UTC 2010 Daniel L.C. Mack <daniel.l.mack@vanderbilt.edu>
* utils/SANetGenerator/EUNets.py:
-
- Wrapper for creating multiple networks with the same parameters.
+
+ Wrapper for creating multiple networks with the same parameters.
Wed Jan 13 04:14:15 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp
index 036ab0e36e3..4646640e34f 100644
--- a/SA_POP/Planner.cpp
+++ b/SA_POP/Planner.cpp
@@ -142,24 +142,18 @@ bool Planner::replan (size_t sa_max_steps, SA_POP::Goal goal)
//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****
// Clear plan.
- this->plan_.causal_links.clear ();
- this->plan_.connections.clear ();
- this->plan_.sched_links.clear ();
- this->plan_.task_insts.clear ();
- this->plan_.threat_links.clear ();
+ this->plan_.clear ();
+
+ // Reset the working plan
+ this->working_plan_->reset_plan ();
// Add goal to working plan and task network.
- //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****
- // Need to reset working plan.
- //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****
- this->working_plan_->reset_plan();
this->working_plan_->set_goal (goal);
this->sanet_->update_goals (goal.goal_conds);
// Run spreading activation.
this->sanet_->update (sa_max_steps);
-
// Set planning strategy goals and satisfy open conditions.
this->plan_strat_->set_goals (goal.goal_conds);
if (this->plan_strat_->satisfy_open_conds ()) {
@@ -178,13 +172,10 @@ bool Planner::replan (size_t sa_max_steps)
// Full replanning not implemented, so just restart planning.
//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****
// Clear plan.
- //TODO: Refactor this plan clearing into own function.
- this->plan_.causal_links.clear ();
- this->plan_.connections.clear ();
- this->plan_.sched_links.clear ();
- this->plan_.task_insts.clear ();
- this->plan_.threat_links.clear ();
+ this->plan_.clear ();
+
// Reset the working plan
+ this->working_plan_->reset_plan ();
// Run spreading activation.
this->sanet_->update (sa_max_steps);
@@ -203,6 +194,7 @@ bool Planner::replan (size_t sa_max_steps)
// Get current plan.
const Plan& Planner::get_plan (void)
{
+ this->plan_ = this->working_plan_->get_plan ();
return this->plan_;
};
@@ -505,6 +497,42 @@ void Planner::notify_plan_changed (void)
double Planner::calc_plan_eu(Plan plan)
{
+ // Probability of goal conditions should be completely updated
+ // by spreading activation for <= 2 times the number of tasks
+ // in the plan (because even a serial plan will be of no longer
+ // than the number of tasks and times 2 to account for
+ // update of condition nodes between tasks).
+ size_t sa_max_steps = 2 * plan.task_insts.size ();
+
+ // Clone current SANet.
+ SANet::Network sanet (*(this->sanet_));
+
+ // Deactivate all nodes, before activating relevant ones.
+ sanet.set_nodes_state (false);
+
+ SA_POP::Goal goal = plan.goal;
+
+ // Activate goal conditions.
+ for (SA_POP::GoalMap::iterator goal_iter = goal.goal_conds.begin (); goal_iter != goal.goal_conds.end (); goal_iter++) {
+ sanet.set_cond_state (goal_iter->first, true);
+ }
+
+ // Activate only nodes relevant to the plan (tasks in plan and their preconditions).
+ for (PlanInstSet::iterator inst_iter = plan.task_insts.begin (); inst_iter != plan.task_insts.end (); inst_iter++) {
+ if ((*inst_iter).inst_id == INIT_TASK_INST_ID) {
+ std::cerr << "SA_POP::Planner::calc_plan_eu(Plan plan): Initial state task instance found in plan." << std::endl;
+ throw "SA_POP::Planner::calc_plan_eu(Plan plan): Initial state task instance found in plan.";
+ }
+
+ // Activate task.
+ sanet.set_task_state ((*inst_iter).task_id, true);
+
+ // Activate preconditions.
+ SA_POP::CondSet preconds = this->get_preconds ((*inst_iter).task_id);
+ for (SA_POP::CondSet::iterator cond_iter = preconds.begin (); cond_iter != preconds.end (); cond_iter++) {
+ sanet.set_cond_state ((*cond_iter).id, true);
+ }
+ }
//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
// Replace with correct code to activate all tasks and their preconditions on a clone of the network.
/*
diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h
index 4f4980810f6..098a80f6c20 100644
--- a/SA_POP/SA_POP_Types.h
+++ b/SA_POP/SA_POP_Types.h
@@ -36,9 +36,10 @@
#define SA_POP_DEBUG_VERBOSE 30
// SET current SA-POP Debug output level.
-#define SA_POP_DEBUG_LEVEL SA_POP_DEBUG_VERBOSE
+#define SA_POP_DEBUG_LEVEL SA_POP_DEBUG_TEMP
#define _CRTDBG_MAP_ALLOC
+
#if defined (SA_POP_HAS_ACE)
#define SA_POP_DEBUG(x,y) \
if (x <= SA_POP_DEBUG_LEVEL) \
@@ -90,12 +91,6 @@ namespace SA_POP {
/// Type of a task type ID.
typedef std::string TaskTypeID;
- /// NULL task ID (for unknown/uninitialized tasks).
- const TaskID NULL_TASK_ID = 0;
-
- /// NULL condition ID (for unknown/uninitialized conditions).
- const CondID NULL_COND_ID = 0;
-
/// Type of a port id.
typedef std::string PortID;
@@ -159,49 +154,63 @@ namespace SA_POP {
/// Type of a set of task ids.
typedef std::set<TaskID> TaskSet;
-
/// Type of a task instance id.
/// (must be unique across all task instances).
typedef long TaskInstID;
+ /// Type of a task implementation id.
+ /// (must be unique across all task implementations).
+ typedef std::string TaskImplID;
+
+ /// Type of a task implementation parameter id/name.
+ typedef std::string ImplParamID;
+
+ /// Type of a task implementation parameter kind/type.
+ typedef std::string ImplParamKind;
+
+ /// Type of a task implementation parameter value.
+ typedef std::string ImplParamValue;
+
+
+
+
+ // PLACEHOLDER IDs (for conditions, tasks, instances, & implementations).
+ // NOTE: MUST BE LESS THAN OR EQUAL TO 0.
+
+ /// NULL condition ID (for unknown/uninitialized conditions).
+ const CondID NULL_COND_ID = 0;
+
+ /// NULL task ID (for unknown/uninitialized tasks).
+ const TaskID NULL_TASK_ID = 0;
+
+ /// Initial state (as task) ID (for placeholder in planning).
+ const TaskID INIT_TASK_ID = -5;
+
/// Goal task instance ID (for task instance placeholders in open goals).
const TaskInstID GOAL_TASK_INST_ID = -1;
/// Null task instance ID (for unknown/uninitialized task instances).
const TaskInstID NULL_TASK_INST_ID = -2;
- /// Initial state (as task) ID (for placeholder in planning).
- const TaskID INIT_TASK_ID = -5;
-
/// Initial state (as task) instance ID (for placeholder in planning).
const TaskInstID INIT_TASK_INST_ID = -6;
- /// Type of a task implementation id.
- /// (must be unique across all task implementations).
- typedef std::string TaskImplID;
-
/// Null task implementation ID (for unknown/uninitialized task implementations).
const TaskImplID NULL_TASK_IMPL_ID = "NULL_TASK_IMPL_ID";
- /// Type of a task implementation parameter id/name.
- typedef std::string ImplParamID;
+ /// Initial state (as task) implementation ID (for placeholder in planning/scheduling).
+ const TaskImplID INIT_TASK_IMPL_ID = "init_impl";
+
- /// Type of a task implementation parameter kind/type.
- typedef std::string ImplParamKind;
- /// Type of a task implementation parameter value.
- typedef std::string ImplParamValue;
enum TaskChoiceType{REUSE_INST, NEW_INST};
- struct TaskChoice {
+ struct TaskChoice {
TaskChoiceType choice;
TaskInstID task_inst_id;
TaskID task_id;
};
- /// Initial state (as task) implementation ID (for placeholder in planning/scheduling).
- const TaskImplID INIT_TASK_IMPL_ID = "init_impl";
-
/// List of TaskChoices
typedef std::list<TaskChoice> TaskChoiceList;
@@ -461,6 +470,53 @@ namespace SA_POP {
/// Type of a goal ID.
typedef std::string GoalID;
+ /// Null goal ID (for unknown/uninitialized goals).
+ const GoalID NULL_GOAL_ID = "NULL_GOAL_ID";
+
+ /// Type of a set of conditions with associated time constraints.
+ typedef std::map<CondID, TimeValue> TimeConstraintMap;
+
+ /// Type of a goal for SA-POP.
+ struct Goal
+ {
+ // Unique ID of goal.
+ GoalID goal_id;
+
+ // Human-readable name of goal (used for debugging, not identification).
+ std::string name;
+
+ // Goal conditions with utility values.
+ GoalMap goal_conds;
+
+ // Start-by and end-by constraints on conditions, in relative time
+ // (relative to start of opstring to achieve this goal).
+ TimeConstraintMap rel_times;
+
+ // Start-by and end-by constraints on conditions, in clock time.
+ TimeConstraintMap abs_times;
+
+ // Expected time range for start of opstring (for achieving this goal)
+ // execution.
+ TimeWindow start_window;
+
+ /// Clear goal to an empty/uninitialized state.
+ void clear (void) {
+ this->abs_times.clear ();
+ this->goal_conds.clear ();
+ this->rel_times.clear ();
+
+ this->goal_id = SA_POP::NULL_GOAL_ID;
+ this->name = "NULL_GOAL";
+ this->start_window.first = SA_POP::NULL_TIME;
+ this->start_window.second = SA_POP::NULL_TIME;
+ };
+
+ bool operator== (const Goal &s) const { return (this->goal_id == s.goal_id); };
+ bool operator!= (const Goal &s) const { return !(*this == s); };
+ bool operator< (const Goal &s) const { return this->goal_id < s.goal_id; };
+ };
+
+
/// Type of a plan ID.
typedef GoalID PlanID;
@@ -472,6 +528,9 @@ namespace SA_POP {
// Human-readable name of plan (used for debugging, not identification).
std::string name;
+ // Goal this plan is intended to achieve.
+ Goal goal;
+
// Task instances in plan.
PlanInstSet task_insts;
@@ -493,6 +552,23 @@ namespace SA_POP {
// Expected end window.
TimeWindow end_window;
+ /// Clear plan to an empty/uninitialized state.
+ void clear (void) {
+ this->causal_links.clear ();
+ this->connections.clear ();
+ this->sched_links.clear ();
+ this->task_insts.clear ();
+ this->threat_links.clear ();
+ this->goal.clear ();
+
+ this->end_window.first = SA_POP::NULL_TIME;
+ this->end_window.second = SA_POP::NULL_TIME;
+ this->name = "NULL_PLAN";
+ this->plan_id = SA_POP::NULL_GOAL_ID;
+ this->start_window.first = SA_POP::NULL_TIME;
+ this->start_window.second = SA_POP::NULL_TIME;
+ };
+
bool operator== (const Plan &s) const { return (this->task_insts == s.task_insts && this->connections == s.connections); };
bool operator!= (const Plan &s) const { return !(*this == s); };
bool operator< (const Plan &s) const
@@ -503,37 +579,6 @@ namespace SA_POP {
};
};
- /// Type of a set of conditions with associated time constraints.
- typedef std::map<CondID, TimeValue> TimeConstraintMap;
-
- /// Type of a goal for SA-POP.
- struct Goal
- {
- // Unique ID of goal.
- GoalID goal_id;
-
- // Human-readable name of goal (used for debugging, not identification).
- std::string name;
-
- // Goal conditions with utility values.
- GoalMap goal_conds;
-
- // Start-by and end-by constraints on conditions, in relative time
- // (relative to start of opstring to achieve this goal).
- TimeConstraintMap rel_times;
-
- // Start-by and end-by constraints on conditions, in clock time.
- TimeConstraintMap abs_times;
-
- // Expected time range for start of opstring (for achieving this goal)
- // execution.
- TimeWindow start_window;
-
- bool operator== (const Goal &s) const { return (this->goal_id == s.goal_id); };
- bool operator!= (const Goal &s) const { return !(*this == s); };
- bool operator< (const Goal &s) const { return this->goal_id < s.goal_id; };
- };
-
//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
// IS THIS REALLY SUPPOSED TO BE CALLED A SET? WHAT IS THIS STRUCT FOR? COMMENT IT.
diff --git a/SA_POP/SA_WorkingPlan.cpp b/SA_POP/SA_WorkingPlan.cpp
index c860f69dc5e..ebed6a9143c 100644
--- a/SA_POP/SA_WorkingPlan.cpp
+++ b/SA_POP/SA_WorkingPlan.cpp
@@ -36,56 +36,16 @@ adj_min_times_cmd_ (0),
adj_max_times_cmd_ (0),
add_threats_cmd_ (0)
{
- this->task_insts_.clear ();
- this->task_impls_.clear ();
- this->causal_links_.clear ();
- this->reused_insts_.clear();
- this->sched_links_.clear();
-
- // Clear goal.
- this->goal_.goal_id = "NULL";
- this->goal_.name = "NULL";
- this->goal_.abs_times.clear ();
- this->goal_.rel_times.clear ();
- this->goal_.goal_conds.clear ();
- this->goal_.start_window = std::make_pair (0, 0);
-
- // Clear plan.
- this->plan_.causal_links.clear ();
- this->plan_.connections.clear ();
- this->plan_.sched_links.clear ();
- this->plan_.task_insts.clear ();
- this->plan_.threat_links.clear ();
+ // Initialize variables.
+ this->reset_plan ();
+ // Create template commands.
this->add_task_cmd_ = new SA_AddTaskCmd (this);
this->assoc_impl_cmd_ = new SA_AssocTaskImplCmd (this);
this->resolve_threat_cmd_ = new SA_ResolveCLThreatCmd (this);
this->resolve_sched_cmd_ = new SA_ResolveSchedOrderCmd (this);
this->adj_min_times_cmd_ = new SA_AdjustMinTimesCmd (this);
this->adj_max_times_cmd_ = new SA_AdjustMaxTimesCmd (this);
-
- PrecedenceSet temp;
- this->precedence_graph_.insert(std::make_pair(BEFORE,temp));
- this->precedence_graph_.insert(std::make_pair(AFTER,temp));
- this->precedence_graph_.insert(std::make_pair(SIMUL,temp));
- this->precedence_graph_.insert(std::make_pair(UNRANKED,temp));
-
- this->init_start.insert(std::make_pair(-6, (TimeWindow)std::make_pair(NULL_TIME, NULL_TIME)));
- this->init_end.insert(std::make_pair(-6, (TimeWindow)std::make_pair(NULL_TIME, NULL_TIME)));
-
- for(int i = 0; i < 2; i++){
- this->init_start.insert(std::make_pair(i,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
- this->init_end.insert(std::make_pair(i,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
- }
-
- this->no_condition.id = -4;
- this->no_link.cond.id = -4;
- this->no_link.first = -4;
- this->no_link.second = -4;
-
- this->task_impls_.insert(std::pair<TaskInstID, TaskImplID>(INIT_TASK_INST_ID, INIT_TASK_IMPL_ID));
- this->task_insts_.insert(std::pair<TaskInstID, TaskID>(INIT_TASK_INST_ID, INIT_TASK_ID));
-
};
// Destructor.
@@ -98,39 +58,43 @@ SA_WorkingPlan::~SA_WorkingPlan (void)
void SA_WorkingPlan::reset_plan ()
{
+ // Init simple variables.
+ this->next_inst_id_ = 1;
- next_inst_id_ =1;
+ // Clear sets, maps, & structs.
this->task_insts_.clear ();
this->task_impls_.clear ();
this->causal_links_.clear ();
this->reused_insts_.clear();
this->sched_links_.clear();
-
- // Clear goal.
- this->goal_.goal_id = "NULL";
- this->goal_.name = "NULL";
- this->goal_.abs_times.clear ();
- this->goal_.rel_times.clear ();
- this->goal_.goal_conds.clear ();
- this->goal_.start_window = std::make_pair (0, 0);
-
- // Clear plan.
- this->plan_.causal_links.clear ();
- this->plan_.connections.clear ();
- this->plan_.sched_links.clear ();
- this->plan_.task_insts.clear ();
- this->plan_.threat_links.clear ();
-
this->precedence_graph_.clear();
-
this->init_start.clear();
this->init_end.clear();
+ this->goal_.clear ();
+ this->plan_.clear ();
+ // Initialize precedence graph.
PrecedenceSet temp;
this->precedence_graph_.insert(std::make_pair(BEFORE,temp));
this->precedence_graph_.insert(std::make_pair(AFTER,temp));
this->precedence_graph_.insert(std::make_pair(SIMUL,temp));
this->precedence_graph_.insert(std::make_pair(UNRANKED,temp));
+
+ this->init_start.insert(std::make_pair(-6, (TimeWindow)std::make_pair(NULL_TIME, NULL_TIME)));
+ this->init_end.insert(std::make_pair(-6, (TimeWindow)std::make_pair(NULL_TIME, NULL_TIME)));
+
+ for(int i = 0; i < 2; i++){
+ this->init_start.insert(std::make_pair(i,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+ this->init_end.insert(std::make_pair(i,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+ }
+
+ this->no_condition.id = -4;
+ this->no_link.cond.id = -4;
+ this->no_link.first = -4;
+ this->no_link.second = -4;
+
+ this->task_impls_.insert(std::pair<TaskInstID, TaskImplID>(INIT_TASK_INST_ID, INIT_TASK_IMPL_ID));
+ this->task_insts_.insert(std::pair<TaskInstID, TaskID>(INIT_TASK_INST_ID, INIT_TASK_ID));
}
// Set goal.
@@ -162,72 +126,75 @@ const Plan& SA_WorkingPlan::get_plan (void)
{
//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
// Should track whether plan has changed rather than regenerating every time.
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
// Clear plan.
- this->plan_.causal_links.clear ();
- this->plan_.connections.clear ();
- this->plan_.sched_links.clear ();
- this->plan_.task_insts.clear ();
- this->plan_.threat_links.clear ();
+ this->plan_.clear ();
+
+ // Set goal.
+ this->plan_.goal = this->goal_;
- //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
- // (Need absolute windows from goal)
// Set time windows.
- this->plan_.start_window = std::make_pair (0, 0);
- this->plan_.end_window = std::make_pair (0, 0);
- //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ this->plan_.start_window = this->goal_.start_window;
//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
- // (Need goal structure to set plan ID & name)
- // Set plan ID and name from goal.
- this->plan_.plan_id = "1";
- this->plan_.name = this->plan_.plan_id;
+ // (Set absolute end window from start window + end windows of goal conditions)
+ this->plan_.end_window.first = NULL_TIME;
+ this->plan_.end_window.second = NULL_TIME;
//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // Set plan ID and name from goal.
+ this->plan_.plan_id = this->goal_.goal_id;
+ this->plan_.name = this->goal_.name;
+
// Add task instances to plan.
for (InstToTaskMap::iterator iter =
this->task_insts_.begin ();
iter != this->task_insts_.end (); iter++)
{
- // Creat task instance and set instance and task IDs from task instance map.
- PlanTaskInst inst;
- inst.inst_id = iter->first;
- inst.task_id = iter->second;
-
- //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
- // (Need to add separate Type to task nodes instead of using name.)
- // Set instance type.
- inst.type_id = this->planner_->get_task_name (inst.task_id);
- // Give instance a name.
- inst.name = "TaskInst";
- inst.name += to_string (inst.inst_id);
- inst.name += "_";
- inst.name += inst.type_id;
- //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
-
- // Set start and end windows for this instance.
- SA_WorkingPlan::InstToWinMap::iterator win_iter;
- win_iter = this->start_window_map_.find (inst.inst_id);
- if (win_iter != this->start_window_map_.end ())
- inst.start_window = win_iter->second;
- else
- throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find start window for task instance.";
- win_iter = this->end_window_map_.find (inst.inst_id);
- if (win_iter != this->end_window_map_.end ())
- inst.end_window = win_iter->second;
- else
- throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find end window for task instance.";
-
- // Set suggested implementation for this instance.
- InstToImplMap::iterator impl_iter;
- impl_iter = this->task_impls_.find (inst.inst_id);
- if (impl_iter != this->task_impls_.end ())
- inst.suggested_impl = impl_iter->second;
- else
- throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find implementation from task instance.";
-
- // Add instance to plan.
- this->plan_.task_insts.insert (inst);
+ // If the task instance is a placeholder, don't add it.
+ if (iter->first < 0 || iter->first == GOAL_TASK_INST_ID || iter->first == INIT_TASK_INST_ID || iter->first == NULL_TASK_INST_ID)
+ continue;
+
+ // Creat task instance and set instance and task IDs from task instance map.
+ PlanTaskInst inst;
+ inst.inst_id = iter->first;
+ inst.task_id = iter->second;
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Need to add separate Type to task nodes instead of using name.)
+ // Set instance type.
+ inst.type_id = this->planner_->get_task_name (inst.task_id);
+ // Give instance a name.
+ inst.name = "TaskInst";
+ inst.name += to_string (inst.inst_id);
+ inst.name += "_";
+ inst.name += inst.type_id;
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set start and end windows for this instance.
+ SA_WorkingPlan::InstToWinMap::iterator win_iter;
+ win_iter = this->start_window_map_.find (inst.inst_id);
+ if (win_iter != this->start_window_map_.end ())
+ inst.start_window = win_iter->second;
+ else
+ throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find start window for task instance.";
+ win_iter = this->end_window_map_.find (inst.inst_id);
+ if (win_iter != this->end_window_map_.end ())
+ inst.end_window = win_iter->second;
+ else
+ throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find end window for task instance.";
+
+ // Set suggested implementation for this instance.
+ InstToImplMap::iterator impl_iter;
+ impl_iter = this->task_impls_.find (inst.inst_id);
+ if (impl_iter != this->task_impls_.end ())
+ inst.suggested_impl = impl_iter->second;
+ else
+ throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find implementation from task instance.";
+
+ // Add instance to plan.
+ this->plan_.task_insts.insert (inst);
}
// Add scheduling links.
@@ -244,8 +211,8 @@ const Plan& SA_WorkingPlan::get_plan (void)
this->causal_links_.begin ();
cl_iter != this->causal_links_.end (); cl_iter++)
{
- // If this is the placeholder goal task instance, don't add connection.
- if (cl_iter->second.second == SA_POP::GOAL_TASK_INST_ID)
+ // If either task instance in this causal link is a placeholder, don't add connection.
+ if (cl_iter->second.first < 0 || cl_iter->second.second < 0 || cl_iter->second.first == SA_POP::INIT_TASK_INST_ID || cl_iter->second.second == SA_POP::GOAL_TASK_INST_ID)
continue;
// If this condition is a data condition, add data connection to plan.