summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-11 23:57:44 +0000
committerbpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-11 23:57:44 +0000
commite5143f6445021c57a72751c126a9829612c4cd0c (patch)
treee797b9d620b8b61a8bac118c0d65b6da272b0097
parente4193e82c30817a82b64b4cbfe432ac05c40fddd (diff)
downloadATCD-e5143f6445021c57a72751c126a9829612c4cd0c.tar.gz
Fri Dec 11 23:54:51 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
-rw-r--r--SA_POP/ChangeLog13
-rw-r--r--SA_POP/Planner.cpp12
-rw-r--r--SA_POP/SANet/SANet.cpp42
-rw-r--r--SA_POP/SANet/SANet.h17
4 files changed, 79 insertions, 5 deletions
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog
index 6b26e078c1a..4c4f7531860 100644
--- a/SA_POP/ChangeLog
+++ b/SA_POP/ChangeLog
@@ -1,3 +1,12 @@
+Fri Dec 11 23:54:51 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
+
+ * Planner.cpp:
+
+ * SANet/SANet.h:
+ * SANet/SANet.cpp:
+
+ Fixed (hopefully) plan EU calculations
+
Fri Dec 11 05:37:26 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
* C2W/C2W_Demo.cpp:
@@ -11,8 +20,8 @@ Fri Dec 11 05:37:26 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
* 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.
+ 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>
diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp
index 84dac981129..b96bbe14453 100644
--- a/SA_POP/Planner.cpp
+++ b/SA_POP/Planner.cpp
@@ -521,9 +521,14 @@ double Planner::calculate_plan_utility(size_t sa_max_steps)
this->plan_.causal_links.end(); it++){
if((*it).first != INIT_TASK_INST_ID){
this->sanet_->set_task_state(this->working_plan_->get_task_from_inst((*it).first), true);
- 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_->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);
+
+
+
std::cout<<(*it).cond.id<<" cond, "<<(*it).first<<" first, "<<(*it).second<<" second"<<std::endl;
}
@@ -535,7 +540,9 @@ 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_->update(sa_max_steps);
+ sanet_->restrict_prop_to_clinks(false);
double conj_utils = 0;
for(GoalMap::iterator it = goals.begin(); it != goals.end(); it++){
@@ -546,6 +553,7 @@ double Planner::calculate_plan_utility(size_t sa_max_steps)
std::cout<<"Plan utility: "<<conj_utils<<std::endl;
+ sanet_->set_nodes_state(true);
//TODO the rest
return conj_utils;
diff --git a/SA_POP/SANet/SANet.cpp b/SA_POP/SANet/SANet.cpp
index 2b32b0c66dc..7ca2e00c957 100644
--- a/SA_POP/SANet/SANet.cpp
+++ b/SA_POP/SANet/SANet.cpp
@@ -17,12 +17,13 @@
#include "SANet.h"
#include "SANode.h"
#include "SANet_Exceptions.h"
+#include "SA_POP_Types.h"
using namespace SANet;
SANet::Network::Network (void)
-: step_ (0)
+: step_ (0), restrict_prop_to_clinks_(false)
{
// Clear maps.
this->task_nodes_.clear ();
@@ -53,6 +54,10 @@ SANet::Network::~Network ()
}
};
+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)
{
@@ -90,6 +95,41 @@ 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);
+ it != causal_links_by_first_.upper_bound(task); it++){
+ SA_POP::CausalLink clink = it->second;
+ if(clink.cond.id == cond){
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool SANet::Network::is_clink_first_to_cond_by_cond(CondID cond, TaskID task){
+ for(std::multimap<SANet::CondID, SA_POP::CausalLink>::iterator it = causal_links_by_cond_.lower_bound(task);
+ it != causal_links_by_cond_.upper_bound(cond); it++){
+ SA_POP::CausalLink clink = it->second;
+
+ if(clink.first == task){
+ return true;
+ }
+ }
+
+ return false;
+}
+*/
+
Probability SANet::Network::get_prior(TaskID ID)
{
TaskNodeMap::iterator task_iter = task_nodes_.find (ID);
diff --git a/SA_POP/SANet/SANet.h b/SA_POP/SANet/SANet.h
index 488ee75eb45..26fe0f56865 100644
--- a/SA_POP/SANet/SANet.h
+++ b/SA_POP/SANet/SANet.h
@@ -20,6 +20,7 @@
#include <stdexcept>
#include "SANet_Types.h"
#include "SANode.h"
+#include "SA_POP_Types.h"
namespace SANet {
/// Map from task node ID to pointer.
@@ -396,6 +397,10 @@ namespace SANet {
int get_step();
+ void note_causal_link(SA_POP::CausalLink clink);
+
+ void restrict_prop_to_clinks(bool val);
+
protected:
/// Map from ID to node pointer for all task nodes in network.
TaskNodeMap task_nodes_;
@@ -426,6 +431,18 @@ namespace SANet {
/// Current step.
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_;
};
};