summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-01-08 21:02:16 +0000
committerjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-01-08 21:02:16 +0000
commitb8b5b41be67582e74a6f0babcac1211e46435712 (patch)
tree332f58d3a4cd5ac9a25338ad1a524dc82e35ecfb
parentf1a5bf2de857ceb2f5b3375068cd82e85316e156 (diff)
downloadATCD-b8b5b41be67582e74a6f0babcac1211e46435712.tar.gz
Fri Jan 8 20:59:42 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
-rw-r--r--SA_POP/C2W/C2W_Demo.cpp7
-rw-r--r--SA_POP/ChangeLog17
-rw-r--r--SA_POP/LogGraphOut.cpp4
-rw-r--r--SA_POP/Planner.cpp51
-rw-r--r--SA_POP/Planner.h250
-rw-r--r--SA_POP/SANet/SANet.cpp19
-rw-r--r--SA_POP/SANet/SANet.h28
-rw-r--r--SA_POP/SA_POP_Types.h14
-rw-r--r--SA_POP/SA_POP_Utils.cpp2
-rw-r--r--SA_POP/SA_POP_Utils.h2
-rw-r--r--SA_POP/SA_PlanHeuristics.cpp9
-rw-r--r--SA_POP/SA_WorkingPlan.cpp4
12 files changed, 210 insertions, 197 deletions
diff --git a/SA_POP/C2W/C2W_Demo.cpp b/SA_POP/C2W/C2W_Demo.cpp
index 3e2f3c96ebe..d4beaab5d9d 100644
--- a/SA_POP/C2W/C2W_Demo.cpp
+++ b/SA_POP/C2W/C2W_Demo.cpp
@@ -262,8 +262,11 @@ int main (int argc, char* argv[])
//planner->add_out_adapter (&s_out);
//planner->add_out_adapter (&screen_out);
- planner->plan (15, goal);
- planner->calculate_plan_utility(15);
+ planner->plan (SA_POP::Default::SA_MAX_STEPS, goal);
+ SA_POP::Plan plan = planner->get_plan ();
+ SA_POP::Utility plan_eu = planner->calc_plan_eu (plan);
+
+ std::cout << "Expected utility of generated plan: " << plan_eu << std::endl;
//}
/*
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog
index d733422d30e..d37921220b4 100644
--- a/SA_POP/ChangeLog
+++ b/SA_POP/ChangeLog
@@ -1,3 +1,20 @@
+Fri Jan 8 20:59:42 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+
+ * Planner.h:
+ * Planner.cpp:
+ * SA_POP_Types.h:
+ * SA_POP_Utils.h:
+ * SA_POP_Utils.cpp:
+ * SA_PlanHeuristics.cpp:
+ * SA_WorkingPlan.cpp:
+ * LogGraphOut.cpp:
+ * C2W/C2W_Demo.cpp:
+ * SANet/SANet.h:
+ * SANet/SANet.cpp:
+
+ Preliminary clean up of unclear/missing comments and non-robust code in SA-POP related to Planner functionality.
+
+
Wed Dec 30 22:01:23 UTC 2009 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
* Planner.cpp:
diff --git a/SA_POP/LogGraphOut.cpp b/SA_POP/LogGraphOut.cpp
index 4fe2eb4980b..67f117f7945 100644
--- a/SA_POP/LogGraphOut.cpp
+++ b/SA_POP/LogGraphOut.cpp
@@ -153,7 +153,7 @@ void LogGraphOut::notify_plan (SA_POP::Planner *planner)
if(!byStep)
{
//Print out the entire graph first.
- planner->print_graph(gfile, graphmap);
+ planner->print_sanet_graphviz(gfile, graphmap);
//Now print out the graph of the causal links in the plan.
for (CLSet::iterator cl_iter = plan.causal_links.begin ();
cl_iter != plan.causal_links.end ();
@@ -172,7 +172,7 @@ void LogGraphOut::notify_plan (SA_POP::Planner *planner)
else if(byStep)
{
//Format a dot file with the entire graph to get the entire structure ready to print.
- planner->print_graph(gfile, graphmap);
+ planner->print_sanet_graphviz(gfile, graphmap);
//Propogate the image of taking a step in the plan by modifying the colors of the nodes.
color_step(planner);
//Use the timing to find the current step and color as necessary
diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp
index 9100a880143..bdfab9209d2 100644
--- a/SA_POP/Planner.cpp
+++ b/SA_POP/Planner.cpp
@@ -212,12 +212,18 @@ const TaskEUMap& Planner::get_eu_changes (void)
return this->eu_changes_;
};
-// Print network.
+// Print a text representation of the task network.
void Planner::print_sanet (std::basic_ostream<char, std::char_traits<char> >& strm,
bool verbose)
{
this->sanet_->print (strm, verbose);
-}
+};
+
+// Print the graphviz representation of the task network.
+void Planner::print_sanet_graphviz (std::basic_ostream<char, std::char_traits<char> >& strm, std::map<std::string, std::string>& graphmap)
+{
+ this->sanet_->print_graphviz(strm, graphmap);
+};
// Recursively plan (satisfy all open conditions & schedule constraints).
bool Planner::recurse_plan (void)
@@ -336,18 +342,6 @@ void Planner::update_cond_val (CondID cond_id, double true_prob)
this->sanet_->update_cond_val (cond_id, true_prob);
};
-// Update a condition's (goal) utility.
-void Planner::update_cond_util (CondID cond_id, double utility)
-{
- this->sanet_->update_cond_util (cond_id, utility);
-};
-
-// Update all condition utilities based on new goal set.
-void Planner::update_goals (GoalMap goals)
-{
- this->sanet_->update_goals (goals);
-};
-
// Get a condition's current value (probability of being true).
double Planner::get_cond_val (CondID cond_id)
{
@@ -382,16 +376,12 @@ CondKind Planner::get_cond_type (CondID cond_id)
return this->sanet_->get_cond_type (cond_id);
};
-// Get a task's current expected utility.
-double Planner::get_task_current_eu (TaskID task_id)
-{
- return this->sanet_->get_task_current_eu (task_id);
-};
-
-// Get a task's future expected utility.
-double Planner::get_task_future_eu (TaskID task_id)
+// Get a task's future expected utility (EU) from spreading activation.
+// (NOTE: Future EU is based on whatever spreading
+// activation has already been executed).
+Utility Planner::get_task_sa_eu (TaskID task_id)
{
- return this->sanet_->get_task_future_eu (task_id);
+ return this->sanet_->get_task_sa_eu (task_id);
};
// Get all preconditions of a task.
@@ -438,9 +428,10 @@ CondSet Planner::get_effects (TaskID task_id)
return this->sanet_->get_effects (task_id);
};
-SANet::LinkWeight Planner::get_link(SANet::TaskID id, SANet::CondID cond_ID)
+// Get the probability of a task's effect.
+SANet::LinkWeight Planner::get_effect_prob(SANet::TaskID id, SANet::CondID cond_ID)
{
- return this->sanet_->get_link(id, cond_ID);
+ return this->sanet_->get_effect_prob(id, cond_ID);
}
// Get all tasks that satisfy a condition.
@@ -512,9 +503,9 @@ void Planner::notify_plan_changed (void)
}
};
-double Planner::calculate_plan_utility(size_t sa_max_steps)
+double Planner::calc_plan_eu(Plan plan)
{
-// sanet_->reset_step();
+ size_t sa_max_steps = 100;
sanet_->set_nodes_state(false);
for(CLSet::iterator it = this->plan_.causal_links.begin(); it !=
@@ -626,12 +617,6 @@ TaskImplID Planner::get_impl_id (TaskInstID task_inst)
}
-void Planner::print_graph (std::basic_ostream<char, std::char_traits<char> >& strm, std::map<std::string, std::string>& graphmap)
-{
- this->sanet_->print_graphviz(strm, graphmap);
-
-}
-
//Allows the planner to update an effect link
void Planner::update_effect (SANet::TaskID tsk, SANet::CondID cnd, SANet::LinkWeight weight)
{
diff --git a/SA_POP/Planner.h b/SA_POP/Planner.h
index 7a2661bd6c4..73221389dbe 100644
--- a/SA_POP/Planner.h
+++ b/SA_POP/Planner.h
@@ -40,7 +40,6 @@ namespace SA_POP {
class Planner {
public:
-
/// Constructor.
Planner (void);
@@ -48,7 +47,6 @@ namespace SA_POP {
virtual ~Planner (void);
-
// ************************************************************************
// Initialization methods.
// ************************************************************************
@@ -80,8 +78,9 @@ namespace SA_POP {
virtual void generate_all_threats(void);
+
// ************************************************************************
- // Planning and changed planning info accessor methods.
+ // Planning/re-planning methods.
// ************************************************************************
/// Run planning.
@@ -112,19 +111,39 @@ namespace SA_POP {
*/
virtual bool replan (size_t sa_max_steps);
+
+
+ // ************************************************************************
+ // Plan accessor methods.
+ // ************************************************************************
+
/// Get current plan.
/**
* @return Reference to current plan.
*/
virtual const Plan& get_plan (void);
+ /// Calculate expected utility (EU) of a plan for current conditions.
+ /**
+ * @param plan Plan for which to calculate EU.
+ *
+ * @return Expected utility of provided plan given current conditions.
+ */
+ virtual EUCalc calc_plan_eu (Plan plan);
+
/// Get last set of expected utility changes.
/**
* @return Reference to last set of expected utility changes.
*/
virtual const TaskEUMap& get_eu_changes (void);
- /// Print network.
+
+
+ // ************************************************************************
+ // Task network display/output methods.
+ // ************************************************************************
+
+ /// Print a text representation of the task network.
/**
* @param strm Output stream on which to print network representation.
*
@@ -133,6 +152,15 @@ namespace SA_POP {
virtual void print_sanet (std::basic_ostream<char, std::char_traits<char> >& strm
= std::cout, bool verbose = false);
+ /// Print the graphviz representation of the task network.
+ /**
+ * @param strm Output stream on which to print the graphviz representation.
+ *
+ * @param graphmap Mapping from ??? to ???.
+ */
+ virtual void print_sanet_graphviz (std::basic_ostream<char, std::char_traits<char> >& strm,
+ std::map<std::string, std::string>& graphmap);
+
// ************************************************************************
@@ -157,8 +185,6 @@ namespace SA_POP {
/// Satisfy scheduling constraints in fully instantiated plan (no
/// recursive call backs).
/**
- *
- *
* @return True if fully satisfied plan found, false otherwise.
*/
virtual bool full_sched ();
@@ -177,9 +203,9 @@ namespace SA_POP {
/// Undo and remove command.
/**
- * @param id The id of the command to undo and remove.
+ * @param id The ID of the command to undo and remove.
*
- * @exception InvalidCommand The id provided does not correspond to top
+ * @exception InvalidCommand The ID provided does not correspond to top
* command.
*/
virtual void undo_command (CommandID id);
@@ -192,9 +218,9 @@ namespace SA_POP {
/// On current command, undo last execution (if any) & execute next option.
/**
- * @param id The id of the command to undo and remove.
+ * @param id The ID of the command to undo and remove.
*
- * @exception InvalidCommand The id provided does not correspond to top
+ * @exception InvalidCommand The ID provided does not correspond to top
* command.
*
* @return True if command had an option to execute, false otherwise.
@@ -203,13 +229,13 @@ namespace SA_POP {
/// Undo and remove all commands back to specified point.
/**
- * @param id The id of the command to undo and remove through.
+ * @param id The ID of the command to undo and remove through.
*/
virtual void undo_through (CommandID id);
- /// Get the current command id.
+ /// Get the current command ID.
/**
- * @return The id of the current command
+ * @return The ID of the current command
*/
virtual CommandID cur_command_id();
@@ -220,26 +246,12 @@ namespace SA_POP {
/// Update a condition's current value (probability of being true).
/**
- * @param cond_id The condition id.
+ * @param cond_id ID of the condition.
*
* @param true_prob New probability that condition is true.
*/
virtual void update_cond_val (CondID cond_id, double true_prob);
- /// Update a condition's (goal) utility.
- /**
- * @param cond_id The condition id.
- *
- * @param utility New goal utility of condition.
- */
- virtual void update_cond_util (CondID cond_id, double utility);
-
- /// Update all condition utilities based on new goal set.
- /**
- * @param goals Set of goal condition ids and associated utilities.
- */
- virtual void update_goals (GoalMap goals);
-
// ************************************************************************
@@ -248,7 +260,7 @@ namespace SA_POP {
/// Get a condition's current value (probability of being true).
/**
- * @param cond_id The condition id.
+ * @param cond_id ID of the condition.
*
* @return Probability that condition is true.
*/
@@ -262,7 +274,7 @@ namespace SA_POP {
/// Get a task's name.
/**
- * @param task_id The task id.
+ * @param task_id ID of the task.
*
* @return Task name.
*/
@@ -270,7 +282,7 @@ namespace SA_POP {
/// Get a condition's name.
/**
- * @param cond_id The condition id.
+ * @param cond_id ID of the condition.
*
* @return Condition name.
*/
@@ -278,31 +290,25 @@ namespace SA_POP {
/// Get a condition's type/kind.
/**
- * @param cond_id The condition id.
+ * @param cond_id ID of the condition.
*
* @return Condition type.
*/
virtual CondKind get_cond_type (CondID cond_id);
- /// Get a task's current expected utility.
- /**
- * @param task_id The task id.
- *
- * @return Current task expected utility.
- */
- virtual double get_task_current_eu (TaskID task_id);
-
- /// Get a task's future expected utility.
+ /// Get a task's future expected utility (EU) from spreading activation.
+ /// (NOTE: Future EU is based on whatever spreading
+ /// activation has already been executed).
/**
- * @param task_id The task id.
+ * @param task_id ID of the task.
*
* @return Future task expected utility.
*/
- virtual double get_task_future_eu (TaskID task_id);
+ virtual Utility get_task_sa_eu (TaskID task_id);
/// Get all preconditions of a task.
/**
- * @param task_id The task id.
+ * @param task_id ID of the task.
*
* @return Set of all preconditions with associated values.
*/
@@ -310,7 +316,7 @@ namespace SA_POP {
/// Get currently unsatisfied preconditions of a task.
/**
- * @param task_id The task id.
+ * @param task_id ID of the task.
*
* @return Set of all unsatisfied preconditions with associated values.
*/
@@ -318,17 +324,25 @@ namespace SA_POP {
/// Get all effects of a task.
/**
- * @param task_id The task id.
+ * @param task_id ID of the task.
*
* @return Set of all effects with associated values.
*/
virtual CondSet get_effects (TaskID task_id);
- SANet::LinkWeight get_link(SANet::TaskID id, SANet::CondID cond_ID);
+ /// Get the probability of a task's effect.
+ /**
+ * @param task_ID ID of task.
+ *
+ * @param cond_ID ID of effect condition.
+ *
+ * @returns Probability of effect given successful task execution.
+ */
+ virtual Probability get_effect_prob (SANet::TaskID id, SANet::CondID cond_ID);
/// Get all tasks that satisfy a condition.
/**
- * @param cond_id The condition id.
+ * @param cond_id ID of the condition.
*
* @return Set of all tasks that satisfy the given condition.
*/
@@ -336,12 +350,11 @@ namespace SA_POP {
/// Get ports for a causal link.
/**
- * @param task1_id ID of start task node in causal link.
+ * @param task1_id ID of start task in causal link.
*
- * @param cond_id ID of condition node in both precondition and effect
- * links.
+ * @param cond_id ID of the condition node in causal link.
*
- * @param task2_id ID of end task node in causal link.
+ * @param task2_id ID of end task in causal link.
*/
virtual LinkPorts get_clink_ports (TaskID task1_id, CondID cond_id,
TaskID task2_id);
@@ -352,11 +365,11 @@ namespace SA_POP {
// Planning task/condition info accessor methods.
// ************************************************************************
- /// Get task id of a task instance.
+ /// Get task ID of a task instance.
/**
- * @param inst_id The task instance id.
+ * @param inst_id The task instance ID.
*
- * @return The task id of this task instance.
+ * @return ID of the task of this task instance.
*/
virtual TaskID get_task_from_inst (TaskInstID inst_id);
@@ -375,7 +388,7 @@ namespace SA_POP {
/// Get all implementations of a task.
/**
- * @param task_id The task id.
+ * @param task_id ID of the task.
*
* @return The set of all implementations (ids) for the given task.
*/
@@ -383,7 +396,7 @@ namespace SA_POP {
/// Get task implementation.
/**
- * @param impl_id The task implementation id.
+ * @param impl_id The task implementation ID.
*
* @return Reference to the task implementation.
*/
@@ -391,9 +404,9 @@ namespace SA_POP {
/// Get utilization info of a task implementation for a resource.
/**
- * @param impl_id The task implementation id.
+ * @param impl_id The task implementation ID.
*
- * @param resource_id The resource id.
+ * @param resource_id The resource ID.
*
* @return The quantity of resource used.
*/
@@ -402,44 +415,46 @@ namespace SA_POP {
/// Get all resources used by a task implementation.
/**
- * @param impl_id The task implementation id.
+ * @param impl_id The task implementation ID.
*
* @return The set of all resources used (with associated usage values).
*/
virtual ResourceMap get_all_resources (TaskImplID impl_id);
+
+
+
// ************************************************************************
// Scheduling Precedence Graph/Time Windows/Resources accessor methods.
// ************************************************************************
+ /// Get the Task instances in a particular set of the specified task instance
+ /**
+ * @param task_inst The Task Instance whose Precedence Set has been queried
+ *
+ * @param prec_rel The Precedence relation to the task_inst
+ *
+ * @return A pointer to the Task Instance Set that has the relation prec_rel to task_inst
+ */
+ virtual const TaskInstSet* get_prec_insts (TaskInstID task_inst, PrecedenceRelation prec_rel);
+
+ /// Get the Start Window of the Task instance
+ /**
+ * @param task_inst The Task Instance whose Start Window is required
+ *
+ * @return The Start Window of task_inst
+ */
+ virtual TimeWindow get_start_window (TaskInstID task_inst);
+
+ /// Get the End Window of the Task instance
+ /**
+ * @param task_inst The Task Instance whose End Window is required
+ *
+ * @return The End Window of task_inst
+ */
+ virtual TimeWindow get_end_window (TaskInstID task_inst);
- /// Get the Task instances in a particular set of the specified task instance
- /**
- * @param task_inst The Task Instance whose Precedence Set has been queried
- *
- * @param prec_rel The Precedence relation to the task_inst
- *
- * @return A pointer to the Task Instance Set that has the relation prec_rel to task_inst
- */
- virtual const TaskInstSet* get_prec_insts (TaskInstID task_inst, PrecedenceRelation prec_rel);
-
- /// Get the Start Window of the Task instance
- /**
- * @param task_inst The Task Instance whose Start Window is required
- *
- * @return The Start Window of task_inst
- */
- virtual TimeWindow get_start_window (TaskInstID task_inst);
-
- /// Get the End Window of the Task instance
- /**
- * @param task_inst The Task Instance whose End Window is required
- *
- * @return The End Window of task_inst
- */
- virtual TimeWindow get_end_window (TaskInstID task_inst);
-
- //Get the duration of a task instance
+ ///Get the duration of a task instance
/**
* @param task_inst The task instance of which the duration is returned
*
@@ -447,39 +462,38 @@ namespace SA_POP {
*/
virtual TimeValue get_duration(TaskInstID task_inst);
- /// Get task implementation id of a task instance.
+ /// Get task implementation ID of a task instance.
/**
- * @param inst_id The task instance id.
+ * @param inst_id The task instance ID.
*
- * @return The task implementation id of this task instance.
+ * @return The task implementation ID of this task instance.
*/
- /// Get task implementation id of a task instance.
- virtual TaskImplID get_task_impl_from_inst (TaskInstID inst_id);
+ virtual TaskImplID get_task_impl_from_inst (TaskInstID inst_id);
/// Get the capacity of a resource.
/**
- * @param res_id The resource id whose capacity that we want to get.
+ * @param res_id The resource ID whose capacity that we want to get.
*
* @return The capacity of the resource
*/
- virtual ResourceValue get_capacity (ResourceID res_id);
+ virtual ResourceValue get_capacity (ResourceID res_id);
/// Get the Causal and Scheduling orderings to this task instance
/**
* @param inst_id The task instance to which all orderings are required
*/
- virtual TaskInstSet before_orderings (TaskInstID inst_id);
+ virtual TaskInstSet before_orderings (TaskInstID inst_id);
/// Get the Causal and Scheduling orderings from this task instance
/**
* @param inst_id The task instance from which all orderings are required
*/
- virtual TaskInstSet after_orderings (TaskInstID inst_id);
+ virtual TaskInstSet after_orderings (TaskInstID inst_id);
+
+ /// Get all the task instances
+ virtual TaskInstSet get_all_insts();
- /// Get all the task instances
- virtual TaskInstSet get_all_insts();
-
- /// Check if the instance id already exists and is being reused.
+ /// Check if the instance ID already exists and is being reused.
/**
* @param task_inst The task instance being checked
*
@@ -491,35 +505,25 @@ namespace SA_POP {
/**
* @param task_inst The task instance.
*
- * @return The task implementation id.
+ * @return The task implementation ID.
*/
virtual TaskImplID get_impl_id (TaskInstID task_inst);
- /// (re) Set Effect Link
- /**
- * @param task_inst The task id
- * @param task_inst The Cond ID
- * @param task_inst The LinkWeight
- *
- *
- * @return nothing
- */
- virtual void update_effect (SANet::TaskID tsk, SANet::CondID cnd, SANet::LinkWeight weight);
-
- /// print the graphviz network of the SANet
- /**
- * @param strm Output stream on which to print network representation.
- *
- * @return nothing
- */
- virtual void print_graph (std::basic_ostream<char, std::char_traits<char> >& strm, std::map<std::string, std::string>& graphmap);
-
- virtual WorkingPlan* get_working_plan(void){return this->working_plan_;};
+ /// (re) Set Effect Link
+ /**
+ * @param task_inst ID of the task.
+ * @param task_inst ID of the condition.
+ * @param task_inst The LinkWeight
+ *
+ *
+ * @return nothing
+ */
+ virtual void update_effect (SANet::TaskID tsk, SANet::CondID cnd, SANet::LinkWeight weight);
- virtual void set_backtrack_cmd_id(CommandID cmd){backtrack_cmd = cmd;};
+ virtual WorkingPlan* get_working_plan(void){return this->working_plan_;};
- virtual double calculate_plan_utility(size_t sa_max_steps);
+ virtual void set_backtrack_cmd_id(CommandID cmd){backtrack_cmd = cmd;};
protected:
/// Threshold for current probability of a condition to be satisfied.
diff --git a/SA_POP/SANet/SANet.cpp b/SA_POP/SANet/SANet.cpp
index 93883aaad50..b978a2947e1 100644
--- a/SA_POP/SANet/SANet.cpp
+++ b/SA_POP/SANet/SANet.cpp
@@ -188,6 +188,7 @@ void SANet::Network::reset_step(){
}
+// Get the prior probability for a task node in the network.
Probability SANet::Network::get_prior(TaskID ID)
{
TaskNodeMap::iterator task_iter = task_nodes_.find (ID);
@@ -200,7 +201,8 @@ Probability SANet::Network::get_prior(TaskID ID)
}
-LinkWeight SANet::Network::get_link(TaskID task_ID, CondID cond_ID)
+// Get the probability of a task's effect in the network.
+Probability SANet::Network::get_effect_prob(TaskID task_ID, CondID cond_ID)
{
TaskNodeMap::iterator task_iter = task_nodes_.find (task_ID);
if (task_iter == task_nodes_.end ()) {
@@ -553,7 +555,7 @@ void SANet::Network::update_cond_util (CondID cond_id, Utility utility)
cond_iter->second->set_goal_util (utility);
};
-// Update all condition utilities based on new goal set.
+// Update all goal condition utilities based on new goal set.
void SANet::Network::update_goals (GoalMap goals)
{
SANet::GoalMap goal;
@@ -646,15 +648,10 @@ CondKind SANet::Network::get_cond_type (CondID cond_id)
return cond_iter->second->get_cond_kind ();
};
-// Get a task's current expected utility.
-Utility SANet::Network::get_task_current_eu (TaskID task_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
- throw "Plan monitoring/updating/replanning not yet implemented: SANet::SANet::Network::get_task_current_eu ().";
-};
-
-// Get a task's future expected utility.
-Utility SANet::Network::get_task_future_eu (TaskID task_id)
+// Get a task's future expected utility (EU) from spreading activation.
+// (NOTE: Future EU is based on whatever spreading
+// activation has already been executed).
+Utility SANet::Network::get_task_sa_eu (TaskID task_id)
{
TaskNodeMap::iterator task_iter = task_nodes_.find (task_id);
if (task_iter == task_nodes_.end ()) {
diff --git a/SA_POP/SANet/SANet.h b/SA_POP/SANet/SANet.h
index b50318b17d5..276fcc6b723 100644
--- a/SA_POP/SANet/SANet.h
+++ b/SA_POP/SANet/SANet.h
@@ -206,7 +206,7 @@ namespace SANet {
*/
virtual void update_cond_util (CondID cond_id, Utility utility);
- /// Update all condition utilities based on new goal set.
+ /// Update all goal condition utilities based on new goal set.
/**
* @param goals Set of goal condition ids and associated utilities.
*/
@@ -317,23 +317,15 @@ namespace SANet {
*/
virtual const GoalMap& get_goals (void);
- /// Get a task's current expected utility.
- /**
- * @param task_id The task id.
- *
- * @return Current task expected utility.
- */
- virtual Utility get_task_current_eu (TaskID task_id);
-
- /// Get a task's future expected utility.
- /// (NOTE: Future probability is based on whatever spreading
- /// activiation has already been executed).
+ /// Get a task's future expected utility (EU) from spreading activation.
+ /// (NOTE: Future EU is based on whatever spreading
+ /// activation has already been executed).
/**
* @param task_id The task id.
*
* @return Future task expected utility.
*/
- virtual Utility get_task_future_eu (TaskID task_id);
+ virtual Utility get_task_sa_eu (TaskID task_id);
/// Get all preconditions of a task.
/**
@@ -399,15 +391,15 @@ namespace SANet {
*/
virtual Probability get_prior (TaskID ID);
- /// Get a link weight for an effect in the network.
+ /// Get the probability of a task's effect in the network.
/**
- * @param task_ID Task ID.
+ * @param task_ID ID of task node.
*
- * @param cond_ID Condition ID.
+ * @param cond_ID ID of effect condition.
*
- * @returns Weight of the effect link.
+ * @returns Probability of effect given successful task execution.
*/
- virtual LinkWeight get_link(TaskID task_ID, CondID cond_ID);
+ virtual Probability get_effect_prob(TaskID task_ID, CondID cond_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
diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h
index 16bd73f1cdf..4f4980810f6 100644
--- a/SA_POP/SA_POP_Types.h
+++ b/SA_POP/SA_POP_Types.h
@@ -212,6 +212,7 @@ namespace SA_POP {
//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
// WHAT DOES THIS STRUCT DO / HOW IS IT USED?
+ // NOT A GENERIC SIMPLE TYPE IN SA-POP SO SHOULD BE MOVED TO FILES OF WHATEVER SPECIFIC CLASSES USE IT.
struct SortTaskByTime{
TaskID task_id;
@@ -534,6 +535,9 @@ namespace SA_POP {
};
+//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****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.
+ // LOOKS LIKE A STD::PAIR WOULD SUFFICE UNLESS THIS IS A MORE GENERAL TYPE THAN IT APPEARS.
struct TaskInstEndTimeSet{
TaskInstID inst;
double end_time;
@@ -542,6 +546,7 @@ namespace SA_POP {
return end_time < compare.end_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*****
/// Type of particular Task Implementation mapped to a Task Implementation Set.
@@ -558,6 +563,11 @@ namespace SA_POP {
typedef SA_POP::ListMultiMap<Condition, TaskInstID> OpenCondMap;
+//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
+ // WHAT ARE THESE STRUCTS FOR? COMMENT THEM.
+ // NOT GENERIC SIMPLE TYPEs IN SA-POP, SO SHOULD BE MOVED TO SA_POP_UTILS.H OR FILES OF WHATEVER SPECIFIC CLASSES USE IT.
+ // SOME/ALL OF FOLLOWING STRUCTS SHOULD BE RECREATED AS CLASSES, GIVEN THEIR COMPLEXITY.
+//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
//Following structures form the condition-checking heuristic we use; if a task satisfies a condition for a
//instance task once, it cannot satisfy another instance of that task unless some of the open conditions open
//when it was first used
@@ -811,7 +821,9 @@ namespace SA_POP {
/// Relative path (from root path) to SA-POP XML schemas.
const std::string XSD_REL_PATH_STR = "/docs/schema/";
- /// Maximum number of steps to run spreading activation.
+ /// Default for maximum number of steps to run spreading activation.
+ /// (WARNING: Should be left at a "high" value so any reasonable plan
+ /// length for SA-POP planning can be accommodated.)
/// (NOTE: Corresponds to consideration of the probabilistic effects
/// of action sequences up to a length of half this value.)
const size_t SA_MAX_STEPS = 1000;
diff --git a/SA_POP/SA_POP_Utils.cpp b/SA_POP/SA_POP_Utils.cpp
index b5123c4a5f5..437948d6e6b 100644
--- a/SA_POP/SA_POP_Utils.cpp
+++ b/SA_POP/SA_POP_Utils.cpp
@@ -6,7 +6,7 @@
/**
* @file SA_POP_Types.cpp
*
- * This file contains the implementation of class types used throughout SA-POP.
+ * This file contains the implementation of helper classes used by SA-POP.
*
* @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
*/
diff --git a/SA_POP/SA_POP_Utils.h b/SA_POP/SA_POP_Utils.h
index 95973e0b548..e52fe0e2a76 100644
--- a/SA_POP/SA_POP_Utils.h
+++ b/SA_POP/SA_POP_Utils.h
@@ -6,7 +6,7 @@
/**
* @file SA_POP_Utils.h
*
- * This file contains the definitions of classes that are utilized in SA_POP.
+ * This file contains the definitions of helper classes used by SA-POP.
*
* @author Daniel L.C. Mack <daniel.l.mack@vanderbilt.edu>
*/
diff --git a/SA_POP/SA_PlanHeuristics.cpp b/SA_POP/SA_PlanHeuristics.cpp
index dfc0fc568de..d34b2ac32af 100644
--- a/SA_POP/SA_PlanHeuristics.cpp
+++ b/SA_POP/SA_PlanHeuristics.cpp
@@ -168,7 +168,7 @@ TaskChoiceList SA_TaskStrategy::choose_task_fair (Condition open_cond)
for (TaskSet::iterator iter = tasks.begin (); iter != tasks.end (); iter++)
{
task_map.insert (std::make_pair (
- this->planner_->get_task_future_eu (*iter), *iter));
+ this->planner_->get_task_sa_eu (*iter), *iter));
}
std::multimap<TaskID, TaskInstID> tasks_to_insts;
@@ -268,7 +268,7 @@ TaskChoiceList SA_TaskStrategy::choose_task_once(Condition open_cond){
for (TaskSet::iterator iter = tasks.begin (); iter != tasks.end (); iter++)
{
task_map.insert (std::make_pair (
- this->planner_->get_task_future_eu (*iter), *iter));
+ this->planner_->get_task_sa_eu (*iter), *iter));
}
std::multimap<TaskID, TaskInstID> tasks_to_insts;
@@ -286,8 +286,11 @@ TaskChoiceList SA_TaskStrategy::choose_task_once(Condition open_cond){
TaskChoiceList task_list;
task_list.clear ();
+//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
+ // WE NEED TO PUT A THRESHOLD ON PROBABILITY OF TRUE/FALSE INSTEAD OF COMPARING A DOUBLE TO A BOOL.
//If init can handle it, put it on here first
if(this->planner_->get_cond_val(open_cond.id) == open_cond.value){
+//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****
TaskChoice init_choice;
init_choice.choice = REUSE_INST;
init_choice.task_id = INIT_TASK_ID;
@@ -339,7 +342,7 @@ TaskChoiceList SA_TaskStrategy::choose_task (Condition open_cond)
for (TaskSet::iterator iter = tasks.begin (); iter != tasks.end (); iter++)
{
task_map.insert (std::make_pair (
- this->planner_->get_task_future_eu (*iter), *iter));
+ this->planner_->get_task_sa_eu (*iter), *iter));
}
std::multimap<TaskID, TaskInstID> tasks_to_insts;
diff --git a/SA_POP/SA_WorkingPlan.cpp b/SA_POP/SA_WorkingPlan.cpp
index 27a99e46735..c860f69dc5e 100644
--- a/SA_POP/SA_WorkingPlan.cpp
+++ b/SA_POP/SA_WorkingPlan.cpp
@@ -389,13 +389,13 @@ void SA_WorkingPlan::generate_all_threats(void)
CausalLink causal_threatened = (*nit).second;
TaskID threatened_task = this->task_insts_.find(causal_threatened.first)->second;
- SANet::LinkWeight threat_effect = this->planner_->get_link(threat_possibility_taskid, condition.id);
+ SANet::LinkWeight threat_effect = this->planner_->get_effect_prob(threat_possibility_taskid, condition.id);
SANet::LinkWeight causal_effect;
if(threatened_task == INIT_TASK_ID){
causal_effect = 2*(this->planner_->get_cond_val(causal_threatened.cond.id)-.5);
}else{
- causal_effect = this->planner_->get_link(threatened_task, causal_threatened.cond.id);
+ causal_effect = this->planner_->get_effect_prob(threatened_task, causal_threatened.cond.id);
}
if((threat_effect > 0 && causal_effect < 0 )|| (threat_effect < 0 && causal_effect > 0)){