summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-05 07:09:45 +0000
committerbpodgursky <bpodgursky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-05 07:09:45 +0000
commitae09af60763c398cb2646d5c64c01a4929bb9cbd (patch)
tree95118fe4635582bb0f08b2efc357702791c363b4
parentce01c7d1341c7ba53deca80ce74e3a5986a2402a (diff)
downloadATCD-ae09af60763c398cb2646d5c64c01a4929bb9cbd.tar.gz
Sat Dec 5 07:07:45 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
-rw-r--r--SA_POP/C2W/C2W_Demo.cpp2
-rw-r--r--SA_POP/ChangeLog22
-rw-r--r--SA_POP/PlanHeuristics.h3
-rw-r--r--SA_POP/Planner.cpp19
-rw-r--r--SA_POP/Planner.h2
-rw-r--r--SA_POP/SA_POP_Types.h7
-rw-r--r--SA_POP/SA_PlanHeuristics.cpp74
-rw-r--r--SA_POP/SA_PlanHeuristics.h3
-rw-r--r--SA_POP/SA_PlanStrategy.cpp22
-rw-r--r--SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java84
-rw-r--r--SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java16
11 files changed, 188 insertions, 66 deletions
diff --git a/SA_POP/C2W/C2W_Demo.cpp b/SA_POP/C2W/C2W_Demo.cpp
index fb9bbb70abb..43c56781fc3 100644
--- a/SA_POP/C2W/C2W_Demo.cpp
+++ b/SA_POP/C2W/C2W_Demo.cpp
@@ -263,6 +263,8 @@ int main (int argc, char* argv[])
//planner->add_out_adapter (&screen_out);
planner->plan (15, goal);
+
+
//}
/*
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog
index 2b7856a2ade..7cf6097d71e 100644
--- a/SA_POP/ChangeLog
+++ b/SA_POP/ChangeLog
@@ -1,3 +1,21 @@
+Sat Dec 5 07:07:45 UTC 2009 Ben Podgursky <bpodgursky@gmail.com>
+
+ * C2W/C2W_Demo.cpp:
+
+ * PlanHeuristics.h:
+ * Planner.h:
+ * Planner.cpp:
+ * SA_POP_Types.h:
+ * SA_PlanHeuristics.h:
+ * SA_PlanHeuristics.cpp:
+ * SA_PlanStrategy.cpp:
+
+ * utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java:
+
+ * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java:
+
+ 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>
* SANet/SANet.h:
@@ -5,8 +23,8 @@ Fri Dec 4 18:16:57 UTC 2009 Daniel L.C. Mack <daniel.l.mack@vanderbilt.edu>
* SANet/SANode.h:
* SANet/SANode.cpp:
- These files were modified to take the new active and disabled flags
- for computing expected utilities of plans.
+ These files were modified to take the new active and disabled flags
+ for computing expected utilities of plans.
Tue Nov 10 21:55:22 UTC 2009 Daniel L.C. Mack <daniel.l.mack@vanderbilt.edu>
diff --git a/SA_POP/PlanHeuristics.h b/SA_POP/PlanHeuristics.h
index 7468e1458ee..9a2875eb3f2 100644
--- a/SA_POP/PlanHeuristics.h
+++ b/SA_POP/PlanHeuristics.h
@@ -91,6 +91,9 @@ namespace SA_POP {
*/
virtual TaskChoiceList choose_task_fair (Condition open_cond) = 0;
+ virtual TaskChoiceList choose_task_once(Condition open_cond) = 0;
+
+
protected:
/// Pointer to Planner object.
SA_POP::Planner *planner_;
diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp
index 38b0e1f6337..3c9379dfb2e 100644
--- a/SA_POP/Planner.cpp
+++ b/SA_POP/Planner.cpp
@@ -126,6 +126,7 @@ bool Planner::plan (size_t sa_max_steps, SA_POP::Goal goal)
if (this->plan_strat_->satisfy_open_conds ()) {
this->plan_ = this->working_plan_->get_plan ();
+
this->notify_plan_changed ();
return true;
}
@@ -511,6 +512,24 @@ void Planner::notify_plan_changed (void)
}
};
+void Planner::calculate_plan_utility(size_t sa_max_steps)
+{
+ sanet_->set_nodes_state(false);
+
+ for(CLSet::iterator it = this->plan_.causal_links.begin(); it !=
+ this->plan_.causal_links.end(); it++){
+
+ this->sanet_->set_task_state((*it).first, true);
+ this->sanet_->set_task_state((*it).second, true);
+ this->sanet_->set_cond_state((*it).cond.id, true);
+ }
+
+ sanet_->update(sa_max_steps);
+
+ //TODO the rest
+
+}
+
/// Get the Task instances in a particular set of the specified task instance
const TaskInstSet* Planner::get_prec_insts (TaskInstID task_inst, PrecedenceRelation prec_rel)
{
diff --git a/SA_POP/Planner.h b/SA_POP/Planner.h
index 03efa10247a..9b46f06cdcd 100644
--- a/SA_POP/Planner.h
+++ b/SA_POP/Planner.h
@@ -519,6 +519,8 @@ namespace SA_POP {
virtual void set_backtrack_cmd_id(CommandID cmd){backtrack_cmd = cmd;};
+ virtual void Planner::calculate_plan_utility(size_t sa_max_steps);
+
protected:
/// Threshold for current probability of a condition to be satisfied.
const Probability cond_prob_thresh_;
diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h
index 705a63fced4..daf36b0919e 100644
--- a/SA_POP/SA_POP_Types.h
+++ b/SA_POP/SA_POP_Types.h
@@ -30,10 +30,10 @@
#endif /* SA_POP_HAS_ACE */
-#define SA_POP_DEBUG_MINIMAL 2
+#define SA_POP_DEBUG_VERBOSE 1
#define SA_POP_DEBUG_NORMAL 5
-#define SA_POP_DEBUG_VERBOSE 10
-#define SA_POP_DEBUG_HIGH 15
+#define SA_POP_DEBUG_MINIMAL 9
+#define SA_POP_DEBUG_HIGH 10
// SET current SA-POP Debug output level.
#define SA_POP_DEBUG_LEVEL SA_POP_DEBUG_MINIMAL
@@ -197,7 +197,6 @@ namespace SA_POP {
TaskID task_id;
};
-
/// Initial state (as task) implementation ID (for placeholder in planning/scheduling).
const TaskImplID INIT_TASK_IMPL_ID = "init_impl";
diff --git a/SA_POP/SA_PlanHeuristics.cpp b/SA_POP/SA_PlanHeuristics.cpp
index 88bd07bee3a..dfc0fc568de 100644
--- a/SA_POP/SA_PlanHeuristics.cpp
+++ b/SA_POP/SA_PlanHeuristics.cpp
@@ -98,7 +98,7 @@ Condition SA_CondStrategy::choose_cond_suspension_most_constrained (const OpenCo
return iter->first;
}
- std::map<int, std::pair<Condition, TaskInstID> > by_num_satisfying;
+ std::multimap<int, std::pair<Condition, TaskInstID> > by_num_satisfying;
for(OpenCondMap::const_iterator iter = open_conds.begin();
iter != open_conds.end(); iter++){
@@ -111,7 +111,7 @@ Condition SA_CondStrategy::choose_cond_suspension_most_constrained (const OpenCo
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++){
+ for(std::multimap<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)){
@@ -259,6 +259,72 @@ TaskChoiceList SA_TaskStrategy::choose_task_fair (Condition open_cond)
};
+TaskChoiceList SA_TaskStrategy::choose_task_once(Condition open_cond){
+ TaskSet tasks = this->planner_->get_satisfying_tasks (open_cond);
+
+ // Add tasks to map with EU (to sort).
+ std::multimap<EUCalc, TaskID> task_map;
+ task_map.clear ();
+ for (TaskSet::iterator iter = tasks.begin (); iter != tasks.end (); iter++)
+ {
+ task_map.insert (std::make_pair (
+ this->planner_->get_task_future_eu (*iter), *iter));
+ }
+
+ std::multimap<TaskID, TaskInstID> tasks_to_insts;
+
+ SA_WorkingPlan* working_plan = (SA_WorkingPlan*)this->planner_->get_working_plan();
+
+ InstToTaskMap inst_task_map = working_plan->get_task_insts();
+
+ for(InstToTaskMap::iterator it = inst_task_map.begin();
+ it != inst_task_map.end(); it++){
+ tasks_to_insts.insert(std::pair<TaskID, TaskInstID>(it->second, it->first));
+ }
+
+ // Add tasks to list in reverse order of map (highest EU first).
+ TaskChoiceList task_list;
+ task_list.clear ();
+
+ //If init can handle it, put it on here first
+ if(this->planner_->get_cond_val(open_cond.id) == open_cond.value){
+ TaskChoice init_choice;
+ init_choice.choice = REUSE_INST;
+ init_choice.task_id = INIT_TASK_ID;
+ init_choice.task_inst_id = INIT_TASK_INST_ID;
+
+ task_list.push_back(init_choice);
+ }
+
+
+ for (std::multimap<EUCalc, TaskID>::reverse_iterator iter = task_map.rbegin ();
+ iter != task_map.rend (); iter++)
+ {
+
+ for(std::multimap<TaskID, TaskInstID>::iterator it = tasks_to_insts.lower_bound(iter->second); it != tasks_to_insts.upper_bound(iter->second);
+ it++){
+
+ TaskChoice task_choice;
+ task_choice.choice = REUSE_INST;
+ task_choice.task_id = it->first;
+ task_choice.task_inst_id = it->second;
+
+ task_list.push_back(task_choice);
+ }
+
+ if(tasks_to_insts.find(iter->second) == tasks_to_insts.end())
+ {
+ TaskChoice task_choice;
+ task_choice.choice = NEW_INST;
+ task_choice.task_id = iter->second;
+ task_choice.task_inst_id = -2;
+
+ task_list.push_back(task_choice);
+ }
+}
+
+ return task_list;
+}
@@ -266,10 +332,6 @@ TaskChoiceList SA_TaskStrategy::choose_task_fair (Condition open_cond)
TaskChoiceList SA_TaskStrategy::choose_task (Condition open_cond)
{
TaskSet tasks = this->planner_->get_satisfying_tasks (open_cond);
-
-// if(this->planner_->init_added){
-// tasks.erase(INIT_TASK_ID);
-// }
// Add tasks to map with EU (to sort).
std::multimap<EUCalc, TaskID> task_map;
diff --git a/SA_POP/SA_PlanHeuristics.h b/SA_POP/SA_PlanHeuristics.h
index 9604719baee..28892fcac96 100644
--- a/SA_POP/SA_PlanHeuristics.h
+++ b/SA_POP/SA_PlanHeuristics.h
@@ -84,6 +84,9 @@ namespace SA_POP {
* @return Sorted list of tasks that satisfy given condition.
*/
virtual TaskChoiceList choose_task_fair (Condition open_cond);
+
+ virtual TaskChoiceList choose_task_once(Condition open_cond);
+
};
/**
diff --git a/SA_POP/SA_PlanStrategy.cpp b/SA_POP/SA_PlanStrategy.cpp
index 6f3fe552835..6bdbdda60d4 100644
--- a/SA_POP/SA_PlanStrategy.cpp
+++ b/SA_POP/SA_PlanStrategy.cpp
@@ -201,20 +201,20 @@ bool SA_PlanStrategy::satisfy_open_conds (void)
}
//Do not execute if the condition has been noted before and not helped
- std::pair<bool, CommandID> return_data =
- this->store_map.should_continue(add_task_cmd->get_id(),
- add_task_cmd->get_condition(),
- stored_task,
- this->open_conds_,
- this->planner_->get_working_plan()->get_task_insts());
-
- if(return_data.first)
- {
+ //std::pair<bool, CommandID> return_data =
+ // this->store_map.should_continue(add_task_cmd->get_id(),
+ // add_task_cmd->get_condition(),
+ // stored_task,
+ // this->open_conds_,
+ // this->planner_->get_working_plan()->get_task_insts());
+
+ //if(return_data.first)
+ //{
// Try to satisfy threats and continue recursive planning.
if (this->satisfy_everything())
return true;
- }
+ //}
this->store_map.undo_binding(add_task_cmd->get_id(), add_task_cmd->get_condition(), stored_task);
@@ -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_fair (open_cond);
+ TaskChoiceList task_list = this->task_choice_->choose_task_once (open_cond);
add_task_cmd->set_id (this->get_next_cmd_id ());
add_task_cmd->set_tasks (task_list);
diff --git a/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java b/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java
index 341b4162ac9..c1a96f2fa1c 100644
--- a/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java
+++ b/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java
@@ -23,7 +23,8 @@ import pddl4j.RequireKey;
import pddl4j.Source;
import pddl4j.ErrorManager.Message;
-public class PDDLtoSAN {
+public class PDDLtoSAN
+{
/**
* @param args
@@ -63,6 +64,8 @@ public class PDDLtoSAN {
StatisticsCompilation all_stat_compl = new StatisticsCompilation();
+ int all_count = 0;
+
for(String domain_path: domains_to_problems.keySet()){
StatisticsCompilation stat_compl = new StatisticsCompilation();
@@ -106,72 +109,81 @@ public class PDDLtoSAN {
System.out.println("Translating: "+ problem_file+ " " + domain_file);
System.out.println();
- PDDL_Translator n = new PDDL_Translator(obj, 1, false);
+ PDDL_Translator n = new PDDL_Translator(obj, 3, false);
System.out.println("Done translating");
System.out.println(" SAN number of conditions: "+ n.getConditonNodeCount());
System.out.println(" SAN number of actions: " + n.getActionNodeCount());
- stat_compl.all_reports.add(n.getStatReport());
- all_stat_compl.all_reports.add(n.getStatReport());
+ // stat_compl.all_reports.add(n.getStatReport());
+ // all_stat_compl.all_reports.add(n.getStatReport());
// n.printSAN();
- // n.write_SAN_to_xml(domain.getDomainName()+"_"+problem.getProblemName()+"-san.xml");
- // n.write_TM_to_xml(domain.getDomainName()+"_"+problem.getProblemName()+"-tm.xml");
- // n.write_goals_to_file(domain.getDomainName()+"_"+problem.getProblemName()+"-goals");
+
+ int this_count = all_count++;
+
+ n.write_SAN_to_xml("output\\"+this_count+"_"+domain.getDomainName()+"_"+problem.getProblemName()+"-san.xml");
+ n.write_TM_to_xml("output\\"+this_count+"_"+domain.getDomainName()+"_"+problem.getProblemName()+"-tm.xml");
+ n.write_goals_to_file("output\\"+this_count+"_"+domain.getDomainName()+"_"+problem.getProblemName()+"-goals");
}
}
- try {
- FileWriter fileout = new FileWriter(new File(domain_path+args[1]));
- fileout.write(stat_compl.toString());
- fileout.close();
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// try {
+// // FileWriter fileout = new FileWriter(new File(domain_path+args[1]));
+// // fileout.write(stat_compl.toString());
+// // fileout.close();
+//
+// } catch (IOException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
}
- FileWriter fileout;
- try {
- fileout = new FileWriter(new File(args[1]));
- fileout.write(all_stat_compl.toString());
- fileout.close();
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// FileWriter fileout;
+// try {
+// fileout = new FileWriter(new File(args[1]));
+// fileout.write(all_stat_compl.toString());
+// fileout.close();
+//
+// } catch (IOException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
// System.out.println(stat_compl.toString());
}
-
- public static Map<String, List<String>> read_input_file(String filename){
+
+ public static Map<String, List<String>> read_input_file(String filename)
+ {
//TODO make this work properly
Map<String, List<String>> to_ret = new LinkedHashMap<String, List<String>>();
Scanner scan = null;
- try {
+ try
+ {
scan = new Scanner(new FileReader(new File(filename)));
- } catch (FileNotFoundException e) {
+ }
+ catch (FileNotFoundException e)
+ {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- while(scan.hasNext()){
+
+ while (scan.hasNext())
+ {
String domain_name = scan.next();
-
+
String next = scan.next();
List<String> problems = new LinkedList<String>();
-
- while(!next.equals("END")){
+
+ while (!next.equals("END"))
+ {
problems.add(next);
next = scan.next();
}
to_ret.put(domain_name, problems);
}
-
+
return to_ret;
}
} \ No newline at end of file
diff --git a/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java b/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java
index 5fd7e8a9099..48b8c817d03 100644
--- a/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java
+++ b/SA_POP/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java
@@ -145,7 +145,7 @@ public class PDDL_Translator {
//of the conditions can come true
setup_initial_action(init_act);
- calculateNetworkStatistics("before_impossibility_removal");
+ // calculateNetworkStatistics("before_impossibility_removal");
System.out.println("Before optimizing: "+ this.task_nodes.size()+" tasks "+ this.condition_nodes.size()+" conditions");
System.out.println("Elapsed: "+ (new Date().getTime()-start_time));
@@ -170,9 +170,9 @@ public class PDDL_Translator {
//TODO maybe try something like a kmap here?
- calculateNetworkStatistics("before_cond_combining");
+ // calculateNetworkStatistics("before_cond_combining");
- // combine_conditions(condition_combine_levels);
+ combine_conditions(condition_combine_levels);
// calculateNetworkStatistics("after_cond_combining");
@@ -2241,7 +2241,13 @@ public class PDDL_Translator {
private void record_task_impls(){
for(TaskNode t: this.task_nodes.values()){
+
+ if(t.getName().equals("initact")){
+ continue;
+ }
+
task_impls.put(t.getName(), new TaskImpl(t.getName()+"_impl"));
+
task_to_impl_links.add(new TaskToImpl(t.getNodeID(), (t.getName()+"_impl"), "1"));
for(String c: task_to_resources.get(t)){
@@ -2653,10 +2659,6 @@ public class PDDL_Translator {
for(TaskToImpl t: task_to_impl_links){
- if(!init_act_visible && t.getTaskID().equals("20")){
- continue;
- }
-
Element taskToImpl = doc.createElement("taskToImpl");
Element taskID = doc.createElement("taskID");