diff options
author | jkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-18 20:32:15 +0000 |
---|---|---|
committer | jkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-18 20:32:15 +0000 |
commit | cd9ba4b205b47f9dfb5dfb08f6ab61f284545043 (patch) | |
tree | 791c626da68531fe612e8a90c215880bda87e610 | |
parent | f73891659a9df43681a1fcff9fac22e2e9eb1347 (diff) | |
download | ATCD-cd9ba4b205b47f9dfb5dfb08f6ab61f284545043.tar.gz |
Fri Dec 18 20:28:36 UTC 2009 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
-rw-r--r-- | SA_POP/ChangeLog | 19 | ||||
-rw-r--r-- | SA_POP/Planner.cpp | 12 | ||||
-rw-r--r-- | SA_POP/SANet/SANet.cpp | 85 | ||||
-rw-r--r-- | SA_POP/SANet/SANet.h | 184 | ||||
-rw-r--r-- | SA_POP/SANet/SANode.cpp | 5 | ||||
-rw-r--r-- | SA_POP/SANet/SANode.h | 2 | ||||
-rw-r--r-- | SA_POP/SA_POP_Types.h | 10 | ||||
-rw-r--r-- | SA_POP/SA_WorkingPlan.cpp | 2 | ||||
-rw-r--r-- | SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_SchedStrategy.cpp | 2 |
9 files changed, 181 insertions, 140 deletions
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog index 32e7713993b..8803fed21b2 100644 --- a/SA_POP/ChangeLog +++ b/SA_POP/ChangeLog @@ -1,3 +1,22 @@ +Fri Dec 18 20:28:36 UTC 2009 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu> + + * SA_POP_Types.h: + * Planner.cpp: + * SA_WorkingPlan.cpp: + * experiments/EU_Performance/Exp_Core/Exp_EU_SchedStrategy.cpp: + + Cleaned up SA-POP Debug statements & debug levels. + + + * Planner.cpp: + * SANet/SANet.h: + * SANet/SANet.cpp: + * SANet/SANode.h: + * SANet/SANode.cpp: + + Removed SANet cruft (including non-functional methods called from the planner in SA-POP). + Also cleaned up some of the SANet & SANode commenting and constructors. + Fri Dec 18 01:00:33 UTC 2009 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu> * SA_Builder.h: diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp index b96bbe14453..1862d015a70 100644 --- a/SA_POP/Planner.cpp +++ b/SA_POP/Planner.cpp @@ -514,7 +514,7 @@ void Planner::notify_plan_changed (void) double Planner::calculate_plan_utility(size_t sa_max_steps) { - sanet_->reset_step(); +// sanet_->reset_step(); sanet_->set_nodes_state(false); for(CLSet::iterator it = this->plan_.causal_links.begin(); it != @@ -525,7 +525,7 @@ double Planner::calculate_plan_utility(size_t sa_max_steps) this->sanet_->set_task_state(this->working_plan_->get_task_from_inst((*it).second), true); this->sanet_->set_cond_state((*it).cond.id, true); - this->sanet_->note_causal_link(*it); +// this->sanet_->note_causal_link(*it); @@ -540,15 +540,15 @@ double Planner::calculate_plan_utility(size_t sa_max_steps) this->sanet_->set_cond_state(it->first, true); } - sanet_->restrict_prop_to_clinks(true); +// sanet_->restrict_prop_to_clinks(true); sanet_->update(sa_max_steps); - sanet_->restrict_prop_to_clinks(false); +// sanet_->restrict_prop_to_clinks(false); double conj_utils = 0; for(GoalMap::iterator it = goals.begin(); it != goals.end(); it++){ std::cout<<it->second<<std::endl; - std::cout<<this->sanet_->get_current_cond_val(it->first, this->sanet_->get_step())<<std::endl; - conj_utils+=(it->second * this->sanet_->get_current_cond_val(it->first, this->sanet_->get_step())); + std::cout<<this->sanet_->get_cond_future_val(it->first, this->sanet_->get_step())<<std::endl; + conj_utils+=(it->second * this->sanet_->get_cond_future_val(it->first, this->sanet_->get_step())); } std::cout<<"Plan utility: "<<conj_utils<<std::endl; diff --git a/SA_POP/SANet/SANet.cpp b/SA_POP/SANet/SANet.cpp index 7ca2e00c957..07cabb4066f 100644 --- a/SA_POP/SANet/SANet.cpp +++ b/SA_POP/SANet/SANet.cpp @@ -23,14 +23,22 @@ using namespace SANet; SANet::Network::Network (void) -: step_ (0), restrict_prop_to_clinks_(false) +: step_ (0) +//, restrict_prop_to_clinks_(false) { - // Clear maps. + // Clear maps & sets. this->task_nodes_.clear (); this->cond_nodes_.clear (); this->precond_links_.clear (); this->effect_links_.clear (); this->goals_.clear (); + this->active_tasks_.clear (); + this->disabled_tasks_.clear (); + this->active_conds_.clear (); + this->disabled_conds_.clear (); +// this->causal_links_by_first_.clear (); +// this->causal_links_by_cond_.clear (); +// this->causal_links_by_second_.clear (); }; int SANet::Network::get_step(){ @@ -54,9 +62,9 @@ SANet::Network::~Network () } }; -void SANet::Network::restrict_prop_to_clinks(bool val){ - restrict_prop_to_clinks_ = val; -} +//void SANet::Network::restrict_prop_to_clinks(bool val){ +// restrict_prop_to_clinks_ = val; +//}; void SANet::Network::add_task (TaskID ID, std::string name, MultFactor atten_factor, TaskCost cost, Probability prior_prob) @@ -73,7 +81,7 @@ void SANet::Network::add_task (TaskID ID, std::string name, MultFactor atten_fac TaskNode *node; // Set initially to active - active_tasks.insert(ID); + this->active_tasks_.insert(ID); // Add task node, throwing exception if insertion fails. node = new TaskNode (ID, name, atten_factor, cost, prior_prob); @@ -96,13 +104,13 @@ void SANet::Network::reset_step(){ } +/* void SANet::Network::note_causal_link(SA_POP::CausalLink clink){ causal_links_by_first_.insert(std::pair<TaskID, SA_POP::CausalLink> (clink.first, clink)); causal_links_by_cond_.insert(std::pair<CondID, SA_POP::CausalLink> (clink.cond.id, clink)); causal_links_by_second_.insert(std::pair<TaskID, SA_POP::CausalLink> (clink.second, clink)); } -/* bool SANet::Network::is_clink_first_to_cond_by_first(TaskID task, CondID cond){ for(std::multimap<SANet::TaskID, SA_POP::CausalLink>::iterator it = causal_links_by_first_.lower_bound(task); @@ -142,9 +150,9 @@ Probability SANet::Network::get_prior(TaskID ID) } -LinkWeight SANet::Network::get_link(TaskID ID, CondID cond_ID) +LinkWeight SANet::Network::get_link(TaskID task_ID, CondID cond_ID) { - TaskNodeMap::iterator task_iter = task_nodes_.find (ID); + TaskNodeMap::iterator task_iter = task_nodes_.find (task_ID); if (task_iter == task_nodes_.end ()) { throw UnknownNode (); } @@ -189,7 +197,7 @@ void SANet::Network::add_cond (CondID ID, std::string name, MultFactor atten_fac CondNode *node; // Set initially to active - active_conds.insert(ID); + this->active_conds_.insert(ID); // Add condition node, throwing exception if insertion fails. node = new CondNode (ID, name, atten_factor, @@ -433,6 +441,9 @@ void SANet::Network::print_link_ports (std::basic_ostream<char, void SANet::Network::update (int max_steps) { + // Reset network and nodes to initial step. + this->reset_step (); + // Flag for whether network changed on last step, initially true. bool net_changed = true; @@ -450,8 +461,8 @@ void SANet::Network::update (int max_steps) // Update all active task nodes. //for (TaskNodeMap::iterator node_iter = task_nodes_.begin (); // node_iter != task_nodes_.end (); node_iter++) - for(std::set<TaskID>::iterator node_iter = active_tasks.begin(); - node_iter != active_tasks.end(); node_iter++) + for(std::set<TaskID>::iterator node_iter = this->active_tasks_.begin(); + node_iter != this->active_tasks_.end(); node_iter++) { // Update node, setting net_changed flag if node changed. if (task_nodes_.find(*node_iter)->second->update ()) { @@ -462,8 +473,8 @@ void SANet::Network::update (int max_steps) // Update all active condition nodes. //for (CondNodeMap::iterator node_iter = cond_nodes_.begin (); // node_iter != cond_nodes_.end (); node_iter++) - for(std::set<CondID>::iterator node_iter = active_conds.begin(); - node_iter != active_conds.end(); node_iter++) + for(std::set<CondID>::iterator node_iter = this->active_conds_.begin(); + node_iter != this->active_conds_.end(); node_iter++) { // Update node, setting net_changed flag if node changed. if (cond_nodes_.find(*node_iter)->second->update ()) { @@ -525,7 +536,7 @@ Probability SANet::Network::get_cond_val (CondID cond_id) return iter->second->get_init_prob (); }; -Probability SANet::Network::get_current_cond_val(CondID cond_id, int step){ +Probability SANet::Network::get_cond_future_val(CondID cond_id, int step){ CondNodeMap::iterator iter = this->cond_nodes_.find(cond_id); if(iter == this->cond_nodes_.end()) throw "SANet::Network::get_cond_val (): Unknown condition node."; @@ -725,7 +736,7 @@ LinkPorts SANet::Network::get_clink_ports (TaskID task1_id, CondID cond_id, this->get_precond_port (cond_id, task2_id)); }; -/// Set Task State. +// Set Task State. void SANet::Network::set_task_state(TaskID task_ID, bool state) { @@ -734,22 +745,22 @@ void SANet::Network::set_task_state(TaskID task_ID, bool state) if(state) { //insetr into active, remove from disabled - active_tasks.insert(task_ID); + this->active_tasks_.insert(task_ID); - disabled_tasks.erase(task_ID); + this->disabled_tasks_.erase(task_ID); } else { //remove from active, insert into disabled - active_tasks.erase(task_ID); + this->active_tasks_.erase(task_ID); - disabled_tasks.insert(task_ID); + this->disabled_tasks_.insert(task_ID); } -} +}; -/// Set Cond State. +// Set Cond State. void SANet::Network::set_cond_state(CondID cond_ID, bool state) { @@ -757,24 +768,24 @@ void SANet::Network::set_cond_state(CondID cond_ID, bool state) if(state) { //insetr into active, remove from disabled - active_conds.insert(cond_ID); + this->active_conds_.insert(cond_ID); - disabled_conds.erase(cond_ID); + this->disabled_conds_.erase(cond_ID); } else { //remove from active, insert into disabled - active_conds.erase(cond_ID); + this->active_conds_.erase(cond_ID); - disabled_conds.insert(cond_ID); + this->disabled_conds_.insert(cond_ID); } -} +}; -/// Set All nodes to State. +// Set All nodes to State. void SANet::Network::set_nodes_state(bool state) { if(state) @@ -785,18 +796,18 @@ void SANet::Network::set_nodes_state(bool state) node_iter != task_nodes_.end (); node_iter++) { node_iter->second->set_activity(state); - active_tasks.insert(node_iter->first); + this->active_tasks_.insert(node_iter->first); - disabled_tasks.erase(node_iter->first); + this->disabled_tasks_.erase(node_iter->first); } for (CondNodeMap::iterator node_iter = cond_nodes_.begin (); node_iter != cond_nodes_.end (); node_iter++) { node_iter->second->set_activity(state); - active_conds.insert(node_iter->first); + this->active_conds_.insert(node_iter->first); - disabled_conds.erase(node_iter->first); + this->disabled_conds_.erase(node_iter->first); } } else @@ -807,19 +818,19 @@ void SANet::Network::set_nodes_state(bool state) node_iter != task_nodes_.end (); node_iter++) { node_iter->second->set_activity(state); - active_tasks.erase(node_iter->first); + this->active_tasks_.erase(node_iter->first); - disabled_tasks.insert(node_iter->first); + this->disabled_tasks_.insert(node_iter->first); } for (CondNodeMap::iterator node_iter = cond_nodes_.begin (); node_iter != cond_nodes_.end (); node_iter++) { node_iter->second->set_activity(state); - active_conds.erase(node_iter->first); + this->active_conds_.erase(node_iter->first); - disabled_conds.insert(node_iter->first); + this->disabled_conds_.insert(node_iter->first); } } -}
\ No newline at end of file +};
\ No newline at end of file diff --git a/SA_POP/SANet/SANet.h b/SA_POP/SANet/SANet.h index 26fe0f56865..ef49ed94473 100644 --- a/SA_POP/SANet/SANet.h +++ b/SA_POP/SANet/SANet.h @@ -69,24 +69,6 @@ namespace SANet { virtual void add_task (TaskID ID, std::string name, MultFactor atten_factor, TaskCost cost, Probability prior_prob); - /// Get a prior for the task node in the network. - /** - * @param ID Node ID. - * - * - * @returns Probability of the prior. - */ - virtual Probability get_prior (TaskID ID); - - /// Get a link weight for an effect in the network. - /** - * @param ID Task ID. - * @param ID Cond ID. - * - * @returns LinkWeight of the link. - */ - virtual LinkWeight get_link(TaskID ID, CondID cond_ID); - /// Add a new condition node to the network. /** * @param ID Node ID. @@ -140,58 +122,29 @@ namespace SANet { virtual void add_effect_link (TaskID task_ID, CondID cond_ID, LinkWeight weight, PortID port_ID = ""); - /// Update the task to condition link. + /// Set the state of a task node. /** - * @param cond_ID Condition node ID. - * * @param task_ID Task node ID. * - * @param weight Link weight (probability task sets condition to - * true, or negative of the probability task sets condition to false). - * - * @param port_ID ID of port (on task) associated with this condition - * (used for data nodes). - */ - virtual void update_effect_link(TaskID task_ID, CondID cond_ID, - LinkWeight weight, PortID port_ID= ""); - - /// Set Task State. - /** - * - * @param task_ID Task node ID. - * - * - * @param state State for the task to be set to; + * @param state New state (false for inactive, and true for active); */ virtual void set_task_state(TaskID task_ID, bool state); - /// Set Cond State. + /// Set the state of a condition node. /** - * * @param cond_ID Condition node ID. * - * - * @param state State for the condition to be set to; + * @param state New state (false for inactive, and true for active); */ virtual void set_cond_state(CondID cond_ID, bool state); - /// Set All nodes to State. + /// Set state of all nodes. /** - * - * - * @param state State to set all nodes to; + * @param state New state (false for inactive, and true for active); */ virtual void set_nodes_state(bool state); - /// Update the task prior. - /** - * - * @param task_ID Task node ID. - * - * - * @param prior new prior to be used for the task; - */ - virtual void update_prior(TaskID task_ID, Probability prior); + // ************************************************************************ @@ -267,6 +220,31 @@ namespace SANet { */ virtual void update_goals (GoalMap goals); + /// Update the prior probability of a task. + /** + * @param task_ID Task node ID. + * + * @param prior New prior probability; + */ + virtual void update_prior(TaskID task_ID, Probability prior); + + /// Update a task to condition link. + /** + * @param cond_ID Condition node ID. + * + * @param task_ID Task node ID. + * + * @param weight Link weight (probability task sets condition to + * true, or negative of the probability task sets condition to false). + * + * @param port_ID ID of port (on task) associated with this condition + * (used for data nodes). + */ + virtual void update_effect_link(TaskID task_ID, CondID cond_ID, + LinkWeight weight, PortID port_ID= ""); + + + // ************************************************************************ @@ -383,48 +361,76 @@ namespace SANet { virtual LinkPorts get_clink_ports (TaskID task1_id, CondID cond_id, TaskID task2_id); - /// Get the duration of a task - /** - * @param task_id ID of the Task - * - * @return duration of the task - */ - virtual TimeValue get_duration (TaskID task_id); + /// Get the prior probability for a task node in the network. + /** + * @param ID Node ID. + * + * @returns Prior probability of the task. + */ + virtual Probability get_prior (TaskID ID); - void reset_step(); + /// Get a link weight for an effect in the network. + /** + * @param task_ID Task ID. + * + * @param cond_ID Cond ID. + * + * @returns Weight of the effect link. + */ + virtual LinkWeight get_link(TaskID task_ID, CondID cond_ID); - Probability get_current_cond_val(int step, CondID cond_id); + /// Get the duration of a task + /** + * @param task_id ID of the Task + * + * @return duration of the task + */ + virtual TimeValue get_duration (TaskID task_id); + + + Probability get_cond_future_val(int step, CondID cond_id); - int get_step(); + int get_step(); - void note_causal_link(SA_POP::CausalLink clink); +// void note_causal_link(SA_POP::CausalLink clink); + +// void restrict_prop_to_clinks(bool val); - void restrict_prop_to_clinks(bool val); protected: + // ************************************************************************ + // Structure variables. + // ************************************************************************ + /// Map from ID to node pointer for all task nodes in network. TaskNodeMap task_nodes_; /// Map from ID to node pointer for all condition nodes in network. CondNodeMap cond_nodes_; + /// Map from precondition links to associated ports. + PrecondLinkPortMap precond_links_; + + /// Map from effect links to associated ports. + EffectLinkPortMap effect_links_; + + + + // ************************************************************************ + // State variables. + // ************************************************************************ + //Set of Active Task Nodes - std::set<SANet::TaskID> active_tasks; + std::set<SANet::TaskID> active_tasks_; //Set of Disabled Task Nodes - std::set<SANet::TaskID> disabled_tasks; + std::set<SANet::TaskID> disabled_tasks_; //Set of Active Condition Nodes - std::set<SANet::CondID> active_conds; + std::set<SANet::CondID> active_conds_; //Set of Active Task Nodes - std::set<SANet::CondID> disabled_conds; - - /// Map from precondition links to associated ports. - PrecondLinkPortMap precond_links_; - - /// Map from effect links to associated ports. - EffectLinkPortMap effect_links_; + std::set<SANet::CondID> disabled_conds_; /// Goals. GoalMap goals_; @@ -433,16 +439,26 @@ namespace SANet { int step_; - //bool is_clink_first_to_cond_by_first(TaskID task, CondID cond); - //bool is_clink_first_to_cond_by_cond (CondID cond, TaskID task); - //bool is_clink_cond_to_second_by_second(TaskID task, CondID cond); - //bool is_clink_cond_to_second_by_cond(CondID cond, TaskiD second); - std::multimap<TaskID, SA_POP::CausalLink> causal_links_by_first_; - std::multimap<CondID, SA_POP::CausalLink> causal_links_by_cond_; - std::multimap<TaskID, SA_POP::CausalLink> causal_links_by_second_; +// bool restrict_prop_to_clinks_; + + +// std::multimap<TaskID, SA_POP::CausalLink> causal_links_by_first_; +// std::multimap<CondID, SA_POP::CausalLink> causal_links_by_cond_; +// std::multimap<TaskID, SA_POP::CausalLink> causal_links_by_second_; + + + + // ************************************************************************ + // State helper methods. + // ************************************************************************ + + void reset_step(); - bool restrict_prop_to_clinks_; + //bool is_clink_first_to_cond_by_first(TaskID task, CondID cond); + //bool is_clink_first_to_cond_by_cond (CondID cond, TaskID task); + //bool is_clink_cond_to_second_by_second(TaskID task, CondID cond); + //bool is_clink_cond_to_second_by_cond(CondID cond, TaskiD second); }; }; diff --git a/SA_POP/SANet/SANode.cpp b/SA_POP/SANet/SANode.cpp index 13956f4850d..2a8838043a8 100644 --- a/SA_POP/SANet/SANode.cpp +++ b/SA_POP/SANet/SANode.cpp @@ -449,11 +449,6 @@ bool TaskNode::update (void) // Update step (at end of step for task node). step_++; -// if(this->ID_ == 20){ -// this->pos_util_.utility = 100; -// } - - // Return boolean changed value based on change flags. return (prob_changed_ || util_changed_); diff --git a/SA_POP/SANet/SANode.h b/SA_POP/SANet/SANode.h index d52b938f058..4a205e86183 100644 --- a/SA_POP/SANet/SANode.h +++ b/SA_POP/SANet/SANode.h @@ -451,7 +451,7 @@ namespace SANet { */ virtual void add_pre_link (TaskID ID, TaskNode *node, LinkWeight weight); - /// update pre-link. + /// Update pre-link. /** * @param ID Node ID. * diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h index daf36b0919e..5cf91c6b04d 100644 --- a/SA_POP/SA_POP_Types.h +++ b/SA_POP/SA_POP_Types.h @@ -30,13 +30,13 @@ #endif /* SA_POP_HAS_ACE */ -#define SA_POP_DEBUG_VERBOSE 1 -#define SA_POP_DEBUG_NORMAL 5 -#define SA_POP_DEBUG_MINIMAL 9 -#define SA_POP_DEBUG_HIGH 10 +#define SA_POP_DEBUG_TEMP 1 +#define SA_POP_DEBUG_QUIET 10 +#define SA_POP_DEBUG_NORMAL 20 +#define SA_POP_DEBUG_VERBOSE 30 // SET current SA-POP Debug output level. -#define SA_POP_DEBUG_LEVEL SA_POP_DEBUG_MINIMAL +#define SA_POP_DEBUG_LEVEL SA_POP_DEBUG_QUIET #define _CRTDBG_MAP_ALLOC #if defined (SA_POP_HAS_ACE) diff --git a/SA_POP/SA_WorkingPlan.cpp b/SA_POP/SA_WorkingPlan.cpp index 540f09d03d5..27a99e46735 100644 --- a/SA_POP/SA_WorkingPlan.cpp +++ b/SA_POP/SA_WorkingPlan.cpp @@ -357,7 +357,7 @@ void SA_WorkingPlan::generate_all_threats(void) debug_text <<" Task (" <<threat_possibility_taskid << ")"<< ": Inst (" <<iterator->first << ")" << std::endl; } debug_text<<std::endl; - SA_POP_DEBUG_STR (SA_POP_DEBUG_MINIMAL, debug_text.str ()); + SA_POP_DEBUG_STR (SA_POP_DEBUG_QUIET, debug_text.str ()); debug_text.str(""); debug_text << "SA_WorkingPlan::generate_all_threats: All Causal Threats: " << std::endl; diff --git a/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_SchedStrategy.cpp b/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_SchedStrategy.cpp index ed166b95314..3aa16132409 100644 --- a/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_SchedStrategy.cpp +++ b/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_SchedStrategy.cpp @@ -59,7 +59,7 @@ bool Exp_EU_SchedStrategy::satisfy_sched (TaskInstID task_inst) CommandID cur_cmd_id = this->planner_->cur_command_id(); this->cur_seq_num_=1; - SA_POP_DEBUG (SA_POP_DEBUG_MINIMAL, "NO SCHEDULING with ROADBLOCK SCHEDULER"); + SA_POP_DEBUG (SA_POP_DEBUG_NORMAL, "NO SCHEDULING with ROADBLOCK SCHEDULER"); // Don't do any propagation for roadblock scheduler. /* // Do the energy propogation for this task instance |