summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-08-04 22:17:05 +0000
committerbpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-08-04 22:17:05 +0000
commit4ed0a3e1cb9a305b2336ddc90c4d887d1d76de9b (patch)
tree86ad0e729e274a4317029af0ff42386cdd41bada
parenta3a21e7f5bf4ad3af22e30d47fb40743f871b00b (diff)
downloadATCD-4ed0a3e1cb9a305b2336ddc90c4d887d1d76de9b.tar.gz
Tue Aug 4 22:14:56 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
-rw-r--r--ChangeLog31
-rw-r--r--SANet/SANetFileIn.cpp4
-rw-r--r--SA_POP_Types.h12
-rw-r--r--SA_PlanHeuristics.cpp47
-rw-r--r--SA_PlanHeuristics.h2
-rw-r--r--SA_PlanStrategy.cpp8
6 files changed, 85 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 54a8bc1859b..4f7797dbfe6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Tue Aug 4 22:14:56 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
+
+ * SANet/SANetFileIn.cpp:
+
+ * SA_POP_Types.h:
+ * SA_PlanHeuristics.h:
+ * SA_PlanHeuristics.cpp:
+ * SA_PlanStrategy.cpp:
+
+ Various fixes that make SAPOP correctly handle situations with negative preconditions
+ /goals. Changed Condition equality to handle value, changed SANetFileIn to give conditions
+ correct initial values, and initial action effects all conditions now
+
Wed Jul 29 20:06:21 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
* C2W/C2W_Demo.cpp:
@@ -12,12 +25,12 @@ Wed Jul 29 20:06:21 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
* SANet/SANode.h:
* SANet/SANode.cpp:
- Now adds an initial action with an effect of setting all true conditions true.
- So the loop in get unsat preconditions that eliminates preconditions true in the environment
- is gone, since it could generate incorrect plans in environments with threats
+ Now adds an initial action with an effect of setting all true conditions true.
+ So the loop in get unsat preconditions that eliminates preconditions true in the environment
+ is gone, since it could generate incorrect plans in environments with threats
- SANet also sets the utility of this initial condition higher than all other actions, as it should
- be the first try always
+ SANet also sets the utility of this initial condition higher than all other actions, as it should
+ be the first try always
* SA_POP_Types.h:
* SA_PlanCommands.h:
@@ -31,10 +44,10 @@ Wed Jul 29 20:06:21 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
* SA_WorkingPlan.cpp:
* TaskMapFileIn.cpp:
- Map from last commit has been fixed.
-
- Implements a suspended condition map for fixing looping
-
+ Map from last commit has been fixed.
+
+ Implements a suspended condition map for fixing looping
+
Thu Jul 16 06:13:54 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
diff --git a/SANet/SANetFileIn.cpp b/SANet/SANetFileIn.cpp
index 467b3bc0f86..1d6fbea107e 100644
--- a/SANet/SANetFileIn.cpp
+++ b/SANet/SANetFileIn.cpp
@@ -206,9 +206,9 @@ void SANetFileIn::build_net (std::string filename, SA_POP::Builder *builder)
else if(cond_kind==cond_kind.SYSTEM) cond=::SA_POP::SYSTEM;
else cond=::SA_POP::DATA;
//Note: 0 here because of the initial action. Changed from probTrue--Ben
- builder->add_cond (nodeID, utility, 0, name, cond);
+ builder->add_cond (nodeID, utility, probTrue, name, cond);
- if((probTrue-.5)*2 > 0)
+// if((probTrue-.5)*2 > 0)
builder->set_effect(20, nodeID, "", (probTrue-.5)*2);
}
diff --git a/SA_POP_Types.h b/SA_POP_Types.h
index d25830d85d6..cbd9a3d3e77 100644
--- a/SA_POP_Types.h
+++ b/SA_POP_Types.h
@@ -72,7 +72,7 @@ namespace SA_POP {
CondID id;
CondValue value;
CondKind kind;
- bool operator== (const Condition &s) const { return this->id == s.id; };
+ bool operator== (const Condition &s) const { return this->id == s.id && this->value == s.value; };
bool operator!= (const Condition &s) const { return !(*this == s); };
bool operator< (const Condition &s) const { return this->id < s.id; };
};
@@ -529,17 +529,20 @@ namespace SA_POP {
Condition satisfied_cond;
TaskID satisfying_task;
+ bool satisfied_to;
StoredCondition(){};
StoredCondition(Condition cond, TaskID task){
this->satisfied_cond = cond;
+ this->satisfied_to = cond.value;
this->satisfying_task = task;
}
bool operator==(const StoredCondition & s)const{
return (satisfied_cond == s.satisfied_cond &&
- satisfying_task == s.satisfying_task);
+ satisfying_task == s.satisfying_task &&
+ satisfied_to == s.satisfied_to);
};
bool operator<(const StoredCondition & s) const{
@@ -621,8 +624,6 @@ namespace SA_POP {
for(StoredConditionSet::iterator it2 = old_open_conds.begin();
it2 != old_open_conds.end(); it2++)
{
- if((*it2).satisfying_task == -1)
- bool breakkk = 0;
std::pair<OpenCondMap::iterator, OpenCondMap::iterator>
@@ -639,7 +640,8 @@ namespace SA_POP {
else{
if((*it3).second == -1)
{}
- else if((*it2).satisfying_task == task_insts.find((*it3).second)->second){
+ else if((*it2).satisfying_task == task_insts.find((*it3).second)->second &&
+ (*it2).satisfied_to == ((*it3).first).value){
found_no_equiv_in_open = false;
}
}
diff --git a/SA_PlanHeuristics.cpp b/SA_PlanHeuristics.cpp
index 7fd50172445..afd4561d09f 100644
--- a/SA_PlanHeuristics.cpp
+++ b/SA_PlanHeuristics.cpp
@@ -83,6 +83,53 @@ Condition SA_CondStrategy::choose_cond_suspension (const OpenCondMap &open_conds
// return open_conds.front().first;
};
+// Choose the next open condition to satisfy.
+Condition SA_CondStrategy::choose_cond_suspension_most_constrained (const OpenCondMap &open_conds)
+{
+
+ if (open_conds.empty ())
+ throw "SA_POP::SA_CondStrategy::choose_cond (): Empty condition list.";
+
+ // Return first data condition.
+ for (OpenCondMap::const_iterator iter = open_conds.begin ();
+ iter != open_conds.end (); iter++)
+ {
+ if (iter->first.kind == SA_POP::DATA)
+ return iter->first;
+ }
+
+ std::map<int, std::pair<Condition, TaskInstID>> by_num_satisfying;
+
+ for(OpenCondMap::const_iterator iter = open_conds.begin();
+ iter != open_conds.end(); iter++){
+
+ int num_sat = this->planner_->get_satisfying_tasks(iter->first).size();
+
+
+ by_num_satisfying.insert(std::pair<int, std::pair<Condition, TaskInstID>>(num_sat, *iter));
+ }
+
+ SA_WorkingPlan* working_plan = (SA_WorkingPlan*)this->planner_->get_working_plan();
+
+ for(std::map<int, std::pair<Condition, TaskInstID>>::iterator it = by_num_satisfying.begin(); it != by_num_satisfying.end(); it++){
+
+
+ if(!working_plan->condition_in_suspended(it->second.first, it->second.second)){
+
+ Condition cond = it->second.first;
+
+ return cond;
+ }else{
+ bool grah = true;
+ }
+ }
+
+ return working_plan->get_no_condition();
+
+ // If no data conditions, just return first condition.
+// return open_conds.front().first;
+};
+
// Constructor.
diff --git a/SA_PlanHeuristics.h b/SA_PlanHeuristics.h
index 216d7391c76..9604719baee 100644
--- a/SA_PlanHeuristics.h
+++ b/SA_PlanHeuristics.h
@@ -47,6 +47,8 @@ namespace SA_POP {
virtual Condition choose_cond (const OpenCondMap &open_conds);
virtual Condition choose_cond_suspension (const OpenCondMap &open_conds);
+
+ virtual Condition choose_cond_suspension_most_constrained (const OpenCondMap &open_conds);
};
/**
diff --git a/SA_PlanStrategy.cpp b/SA_PlanStrategy.cpp
index e6cbb685b12..e3023bff98a 100644
--- a/SA_PlanStrategy.cpp
+++ b/SA_PlanStrategy.cpp
@@ -142,7 +142,7 @@ bool SA_PlanStrategy::satisfy_open_conds (void)
// If all open conditions have been satisfied, then return true for success.
if (this->open_conds_.empty ())
return this->planner_->full_sched();
-//))!(this->planner_->get_working_plan()->get_all_insts().size() > 8)
+//))//!(this->planner_->get_working_plan()->get_all_insts().size() > 8))
if(true){
// Increment step counter.
this->cur_step_++;
@@ -634,8 +634,10 @@ AddTaskCmd *SA_PlanStrategy::satisfy_cond (Condition open_cond)
for (OpenCondMap::iterator iter = this->open_conds_.lower_bound (open_cond);
iter != this->open_conds_.upper_bound (open_cond); iter++)
{
- inst_set.insert (iter->second);
- break;
+ if(iter->first.value == open_cond.value){
+ inst_set.insert (iter->second);
+ break;
+ }
}
add_task_cmd->set_causal_info (open_cond, inst_set);