diff options
author | bpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-11 05:59:52 +0000 |
---|---|---|
committer | bpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-11 05:59:52 +0000 |
commit | e4193e82c30817a82b64b4cbfe432ac05c40fddd (patch) | |
tree | 8c75547f7033b5e50e0576fa73d55b5a76df8b19 | |
parent | d423488a7fc3ef8ad77fd875ed8abf3686400f3e (diff) | |
download | ATCD-e4193e82c30817a82b64b4cbfe432ac05c40fddd.tar.gz |
Fri Dec 11 05:37:26 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
-rw-r--r-- | SA_POP/C2W/C2W_Demo.cpp | 2 | ||||
-rw-r--r-- | SA_POP/ChangeLog | 18 | ||||
-rw-r--r-- | SA_POP/Planner.cpp | 13 | ||||
-rw-r--r-- | SA_POP/SANet/SANet.cpp | 11 | ||||
-rw-r--r-- | SA_POP/SANet/SANet.h | 4 | ||||
-rw-r--r-- | SA_POP/SANet/SANode.cpp | 39 | ||||
-rw-r--r-- | SA_POP/SANet/SANode.h | 4 | ||||
-rw-r--r-- | SA_POP/SA_PlanStrategy.cpp | 2 |
8 files changed, 78 insertions, 15 deletions
diff --git a/SA_POP/C2W/C2W_Demo.cpp b/SA_POP/C2W/C2W_Demo.cpp index 8f7c9651833..3e2f3c96ebe 100644 --- a/SA_POP/C2W/C2W_Demo.cpp +++ b/SA_POP/C2W/C2W_Demo.cpp @@ -263,7 +263,7 @@ int main (int argc, char* argv[]) //planner->add_out_adapter (&screen_out); planner->plan (15, goal); - planner->calculate_plan_utility(115); + planner->calculate_plan_utility(15); //} /* diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog index 7cf6097d71e..6b26e078c1a 100644 --- a/SA_POP/ChangeLog +++ b/SA_POP/ChangeLog @@ -1,3 +1,19 @@ +Fri Dec 11 05:37:26 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> + + * C2W/C2W_Demo.cpp: + + * Planner.cpp: + + * SANet/SANet.h: + * SANet/SANet.cpp: + * SANet/SANode.h: + * SANet/SANode.cpp: + + * SA_PlanStrategy.cpp: + + Update in spreading activation now only affects those conditions/tasks which are active. Added calculate_plan_utility + method to planner which returns the expected utility of the current plan. + Sat Dec 5 07:07:45 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> * C2W/C2W_Demo.cpp: @@ -14,7 +30,7 @@ Sat Dec 5 07:07:45 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java: - Added choose-task-once strategy, other cleanup. Metrics gathering in translator + Added choose-task-once strategy, other cleanup. Metrics gathering in translator Fri Dec 4 18:16:57 UTC 2009 Daniel L.C. Mack <daniel.l.mack@vanderbilt.edu> diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp index a6d6710d937..84dac981129 100644 --- a/SA_POP/Planner.cpp +++ b/SA_POP/Planner.cpp @@ -524,15 +524,24 @@ 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); } + std::cout<<(*it).cond.id<<" cond, "<<(*it).first<<" first, "<<(*it).second<<" second"<<std::endl; + } - sanet_->update(sa_max_steps); GoalMap goals = this->get_goals(); + for(GoalMap::iterator it = goals.begin(); it != goals.end(); it++){ + this->sanet_->set_cond_state(it->first, true); + } + + sanet_->update(sa_max_steps); + double conj_utils = 0; for(GoalMap::iterator it = goals.begin(); it != goals.end(); it++){ - conj_utils+=(it->second * this->get_cond_val(it->first)); + 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<<"Plan utility: "<<conj_utils<<std::endl; diff --git a/SA_POP/SANet/SANet.cpp b/SA_POP/SANet/SANet.cpp index 2f9fcef0ff4..2b32b0c66dc 100644 --- a/SA_POP/SANet/SANet.cpp +++ b/SA_POP/SANet/SANet.cpp @@ -32,6 +32,10 @@ SANet::Network::Network (void) this->goals_.clear (); }; +int SANet::Network::get_step(){ + return step_; +} + SANet::Network::~Network () { // Deallocate task nodes. @@ -481,6 +485,13 @@ 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){ + CondNodeMap::iterator iter = this->cond_nodes_.find(cond_id); + if(iter == this->cond_nodes_.end()) + throw "SANet::Network::get_cond_val (): Unknown condition node."; + return iter->second->get_prob (step).probability; +} + // Get all goals. const GoalMap& SANet::Network::get_goals (void) { diff --git a/SA_POP/SANet/SANet.h b/SA_POP/SANet/SANet.h index 9373ad5be80..488ee75eb45 100644 --- a/SA_POP/SANet/SANet.h +++ b/SA_POP/SANet/SANet.h @@ -392,6 +392,10 @@ namespace SANet { void reset_step(); + Probability get_current_cond_val(int step, CondID cond_id); + + int get_step(); + protected: /// Map from ID to node pointer for all task nodes in network. TaskNodeMap task_nodes_; diff --git a/SA_POP/SANet/SANode.cpp b/SA_POP/SANet/SANode.cpp index 55a26486d5c..13956f4850d 100644 --- a/SA_POP/SANet/SANode.cpp +++ b/SA_POP/SANet/SANode.cpp @@ -199,6 +199,10 @@ bool TaskNode::update (void) cur_ID = node_iter->first; cur_node = (CondNode *) node_iter->second; + if(!(cur_node->is_active())){ + continue; + } + // Get current link info. link_iter = pre_links_.find(cur_ID); if (link_iter == pre_links_.end ()) { @@ -303,6 +307,10 @@ bool TaskNode::update (void) cur_ID = node_iter->first; cur_node = (CondNode *) node_iter->second; + if(!(cur_node->is_active())){ + continue; + } + // Update util_changed_ flag if necessary. if (cur_node->util_changed ()) { util_changed_ = true; @@ -1000,6 +1008,7 @@ bool CondNode::update (void) //Check to see if node is active before updating if(!active) { + step_++; //the node should return as not changing the network return false; } @@ -1048,6 +1057,10 @@ bool CondNode::update (void) cur_ID = node_iter->first; cur_node = (TaskNode *) node_iter->second; + if(!(cur_node->is_active())){ + continue; + } + // Update util_changed_ flag if necessary. if (cur_node->util_changed ()) { util_changed_ = true; @@ -1251,6 +1264,7 @@ bool CondNode::update (void) } cur_node = (TaskNode *) temp_node_iter->second; + // Get current link info. link_iter = pre_links_.find(this->false_prob_from_); if (link_iter == pre_links_.end ()) { @@ -1314,6 +1328,10 @@ bool CondNode::update (void) cur_ID = node_iter->first; cur_node = (TaskNode *) node_iter->second; + if(!(cur_node->is_active())){ + continue; + } + // Get current link info. link_iter = pre_links_.find(cur_ID); if (link_iter == pre_links_.end ()) { @@ -1329,17 +1347,18 @@ bool CondNode::update (void) } // Get current probability info. - try { + //try { cur_prob = cur_node->get_prob (step_); - } catch (Invalid_Step e) { - std::cerr << "Error in condition node update: Invalid step value."; - std::cerr << std::endl; - return false; - } catch (...) { - std::cerr << "Unexpected exception thrown in condition node update."; - std::cerr << std::endl; - return false; - } + //} catch (Invalid_Step e) { + // std::cerr << "Error in condition node update: Invalid step value."; + // std::cerr << std::endl; + // return false; + //} + //catch (...) { + // std::cerr << "Unexpected exception thrown in condition node update."; + // std::cerr << std::endl; + // return false; + //} // Update probability based on current multiplier. cur_prob.probability = cur_mult * cur_prob.probability; diff --git a/SA_POP/SANet/SANode.h b/SA_POP/SANet/SANode.h index 96366a7a75d..d52b938f058 100644 --- a/SA_POP/SANet/SANode.h +++ b/SA_POP/SANet/SANode.h @@ -164,6 +164,10 @@ namespace SANet { void reset_step(); + bool is_active(){ + return active; + } + protected: /// Unique ID of node (for identification within network). NodeID ID_; diff --git a/SA_POP/SA_PlanStrategy.cpp b/SA_POP/SA_PlanStrategy.cpp index 6bdbdda60d4..65334b6679e 100644 --- a/SA_POP/SA_PlanStrategy.cpp +++ b/SA_POP/SA_PlanStrategy.cpp @@ -579,7 +579,7 @@ AddTaskCmd *SA_PlanStrategy::satisfy_cond (Condition open_cond) // Get add task command. AddTaskCmd *add_task_cmd = static_cast<AddTaskCmd *> (this->add_task_cmd_->clone ()); - TaskChoiceList task_list = this->task_choice_->choose_task_once (open_cond); + TaskChoiceList task_list = this->task_choice_->choose_task_fair (open_cond); add_task_cmd->set_id (this->get_next_cmd_id ()); add_task_cmd->set_tasks (task_list); |