summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-10-13 20:46:12 +0000
committerjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-10-13 20:46:12 +0000
commit9319746e4f863c3ea67fc1d8c70068eec59408b1 (patch)
treec563b39a3eb6fafdac7ca117dc2278c2fef5d905
parentc41c7f2c353323962537cc5abea7a3acc0bd8ed9 (diff)
downloadATCD-9319746e4f863c3ea67fc1d8c70068eec59408b1.tar.gz
-rw-r--r--SA_POP/Builder.h160
-rw-r--r--SA_POP/Converter.cpp134
-rw-r--r--SA_POP/Converter.h39
-rw-r--r--SA_POP/Driver.cpp404
-rw-r--r--SA_POP/LogFileOut.cpp170
-rw-r--r--SA_POP/LogFileOut.h58
-rw-r--r--SA_POP/LogScreenOut.cpp166
-rw-r--r--SA_POP/LogScreenOut.h59
-rw-r--r--SA_POP/OutAdapter.h54
-rw-r--r--SA_POP/PlanCommands.h370
-rw-r--r--SA_POP/PlanHeuristics.h123
-rw-r--r--SA_POP/PlanStrategy.h110
-rw-r--r--SA_POP/Planner.cpp459
-rw-r--r--SA_POP/Planner.h511
-rw-r--r--SA_POP/SANet/SANet.cpp476
-rw-r--r--SA_POP/SANet/SANet.h328
-rw-r--r--SA_POP/SANet/SANetFileIn.cpp219
-rw-r--r--SA_POP/SANet/SANetFileIn.h64
-rw-r--r--SA_POP/SANet/SANet_Exceptions.cpp47
-rw-r--r--SA_POP/SANet/SANet_Exceptions.h79
-rw-r--r--SA_POP/SANet/SANet_Types.h208
-rw-r--r--SA_POP/SANet/SANode.cpp1020
-rw-r--r--SA_POP/SANet/SANode.h393
-rw-r--r--SA_POP/SANet/XML_SANet.cpp3467
-rw-r--r--SA_POP/SANet/XML_SANet.hpp1830
-rw-r--r--SA_POP/SA_Builder.cpp166
-rw-r--r--SA_POP/SA_Builder.h202
-rw-r--r--SA_POP/SA_POP.mpc85
-rw-r--r--SA_POP/SA_POP_Exceptions.cpp157
-rw-r--r--SA_POP/SA_POP_Exceptions.h157
-rw-r--r--SA_POP/SA_POP_Types.h428
-rw-r--r--SA_POP/SA_PlanCommands.cpp816
-rw-r--r--SA_POP/SA_PlanCommands.h732
-rw-r--r--SA_POP/SA_PlanHeuristics.cpp125
-rw-r--r--SA_POP/SA_PlanHeuristics.h107
-rw-r--r--SA_POP/SA_PlanStrategy.cpp474
-rw-r--r--SA_POP/SA_PlanStrategy.h337
-rw-r--r--SA_POP/SA_SchedStrategy.cpp814
-rw-r--r--SA_POP/SA_SchedStrategy.h189
-rw-r--r--SA_POP/SA_WorkingPlan.cpp1447
-rw-r--r--SA_POP/SA_WorkingPlan.h451
-rw-r--r--SA_POP/SPACE.san.xml357
-rw-r--r--SA_POP/SPACE.tm.xml194
-rw-r--r--SA_POP/SPACE_Goal1.san.xml357
-rw-r--r--SA_POP/SPACE_Goal2.san.xml357
-rw-r--r--SA_POP/SchedStrategy.h66
-rw-r--r--SA_POP/TaskImpl.cpp80
-rw-r--r--SA_POP/TaskImpl.h101
-rw-r--r--SA_POP/TaskMap.cpp122
-rw-r--r--SA_POP/TaskMap.h147
-rw-r--r--SA_POP/TaskMapFileIn.cpp173
-rw-r--r--SA_POP/TaskMapFileIn.h52
-rw-r--r--SA_POP/WorkingPlan.h192
-rw-r--r--SA_POP/XML_TaskMap.cpp3259
-rw-r--r--SA_POP/XML_TaskMap.hpp1703
55 files changed, 24795 insertions, 0 deletions
diff --git a/SA_POP/Builder.h b/SA_POP/Builder.h
new file mode 100644
index 00000000000..9097115887d
--- /dev/null
+++ b/SA_POP/Builder.h
@@ -0,0 +1,160 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file Builder.h
+ *
+ * This file contains the Builder abstract base class definition for
+ * SA-POP builders, which handle creation and configuration of Planner objects
+ * and the associated objects they use/mediate-between.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_BUILDER_H_
+#define SA_POP_BUILDER_H_
+
+#include "SA_POP_Types.h"
+#include "Planner.h"
+
+namespace SA_POP {
+
+ /**
+ * @class Builder
+ *
+ * @brief Abstract base class of SA-POP builders, which handle creation and
+ * configuration of Planner and associated objects.
+ */
+ class Builder {
+ public:
+ /// Constructor.
+ Builder (void) {};
+
+ /// Destructor.
+ virtual ~Builder (void) {};
+
+ /// Reset for building a new set of SA-POP objects.
+ virtual void reset (void) = 0;
+
+ /// Get Planner object.
+ /**
+ * @return Pointer to the configured planner object.
+ */
+ virtual Planner *get_planner (void) = 0;
+
+
+ // ************************************************************************
+ // Problem construction methods (tasks, conditions, & links between them).
+ // ************************************************************************
+
+ /// Add a task.
+ /**
+ * @param id The unique task id.
+ *
+ * @param prior_prob The prior probability of this task succeeding.
+ *
+ * @param name The task name.
+ *
+ * @exception Duplicate_Task The given task id already exists.
+ */
+ virtual void add_task (TaskID id, double prior_prob,
+ std::string name = "") = 0;
+
+ /// Add a condition.
+ /**
+ * @param id The unique condition id.
+ *
+ * @param name The condition name.
+ *
+ * @param utility The (goal) utility of the condition.
+ *
+ * @param init_prob_true The initial probability that the condition
+ * is true.
+ *
+ * @param cond_kind The type of condition
+ *
+ * @exception Duplicate_Cond The given condition id already exists.
+ */
+ virtual void add_cond (CondID id, Utility utility = 0,
+ double init_prob_true = 0, std::string name = "", CondKind cond_kind = SA_POP::DATA) = 0;
+
+ /// Add a link between a precondition and task.
+ /**
+ * @param cond_id The precondition id.
+ *
+ * @param task_id The task id.
+ *
+ * @param port The receiving port id (on the task for this precondition).
+ *
+ * @param true_prob Conditional probability of task success given
+ * condition = true.
+ *
+ * @param false_prob Conditional probability of task success given
+ * condition = false.
+ *
+ * @exception Unknown_Cond Unknown condition id.
+ */
+ virtual void set_precond (CondID cond_id, TaskID task_id,
+ PortID port, double true_prob, double false_prob) = 0;
+
+ /// Add a link between a task and an effect.
+ /**
+ * @param cond_id The effect condition id.
+ *
+ * @param task_id The task id.
+ *
+ * @param port The sending port id (on the task for this effect).
+ *
+ * @param weight Positive probability that task sets condition to true, or
+ * negative of probability that task sets condition to false.
+ */
+ virtual void set_effect (TaskID task_id, CondID cond_id,
+ PortID port, double weight) = 0;
+
+
+
+ // ************************************************************************
+ // TaskMap construction methods (resources, task->implementations,
+ // and implementation->resources).
+ // ************************************************************************
+
+ /// Add a resource.
+ /**
+ * @param resource The resource info.
+ */
+ virtual void add_resource (Resource resource) = 0;
+
+ /// Add an implementation.
+ /**
+ * @param task_impl The task implementation info.
+ */
+ virtual void add_task_impl (TaskImpl *task_impl) = 0;
+
+ /// Associate a task with a task implementation.
+ /**
+ * @param task_id ID of the task.
+ *
+ * @param task_impl_id ID of the task implementation.
+ *
+ * @param duration The duration of the task implementation for this task.
+ */
+ virtual void assoc_task_with_impl (TaskID task_id, TaskImplID task_impl_id,
+ TimeValue duration) = 0;
+
+ /// Associate a task implementation with its utilization of a resource.
+ /**
+ * @param impl_id ID of the task implementation.
+ *
+ * @param resource_id ID of the associated resource.
+ *
+ * @param resource_usage The quantity of resource used.
+ */
+ virtual void assoc_impl_with_resource (TaskImplID impl_id,
+ ResourceID resource_id, ResourceValue resource_usage) = 0;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_BUILDER_H_ */
diff --git a/SA_POP/Converter.cpp b/SA_POP/Converter.cpp
new file mode 100644
index 00000000000..02353142f86
--- /dev/null
+++ b/SA_POP/Converter.cpp
@@ -0,0 +1,134 @@
+#include "Converter.h"
+namespace CIAO
+{
+
+ namespace RACE
+ {
+
+ Converter::Converter (int argc, char **argv)
+ : iia_name_ ("RACE::InteractiveInput"),
+ history_ (false)
+ {
+ try
+ {
+ this->orb_ = CORBA::ORB_init (argc, argv, "");
+ // Resolve naming service
+ CORBA::Object_var ns_tmp =
+ this->orb_->resolve_initial_references ("NameService");
+ ::CosNaming::NamingContext_var ns =
+ ::CosNaming::NamingContext::_narrow (ns_tmp.in ());
+ ::CosNaming::Name ns_name;
+ CORBA::ULong i = 0;
+ ACE_Tokenizer tok (this->iia_name_.rep ());
+ tok.delimiter_replace (':', 0);
+ tok.delimiter_replace ('/', 0);
+ char *name_element = 0;
+ while ((name_element = tok.next ()) != 0)
+ {
+ ns_name.length (ns_name.length () + 1);
+ ns_name[i].id = CORBA::string_dup (name_element);
+ ++i;
+ }
+
+ /// now try to resolve the reference to the IIA.
+ CORBA::Object_var iia_tmp = ns->resolve (ns_name);
+ this->iia_ =
+ ::CIAO::RACE::Interactive_Input_Adapter::_narrow (iia_tmp.in ());
+
+ this->plan_gen_.init (this->orb_);
+
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ACE_PRINT_EXCEPTION (ex, "Error in initializing the Injector!\n");
+ }
+
+ }
+
+ Converter::~Converter ()
+ {}
+
+
+ int
+ Converter::convert (OperationalString &op_string,
+ ::Deployment::DeploymentPlan &plan)
+ {
+ plan.label = op_string.name;
+
+ plan.UUID = op_string.UUID;
+
+ plan.connection = op_string.dataLinks;
+
+ plan.infoProperty = op_string.properties;
+
+ int position;
+
+ for (CORBA::ULong itr = 0; itr < op_string.instances.length (); ++itr)
+ {
+ ::CIAO::RACE::InstanceDescription op_instance =
+ op_string.instances [itr];
+ if (this->plan_gen_.generate_plan
+ (plan,
+ op_instance.suggestedImpl.in (),
+ position))
+ {
+ ::Deployment::InstanceDeploymentDescription instance;
+ instance.name = op_instance.name;
+ instance.node = CORBA::string_dup ("Satellite");
+ instance.implementationRef = position;
+ instance.configProperty = op_instance.configProperty;
+ CORBA::ULong cur_len = plan.instance.length ();
+ plan.instance.length (cur_len+1);
+ plan.instance [cur_len] = instance;
+
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "Given suggested type is not available "
+ "in the Repoman!!\n Bailing out....\n"));
+ return -1;
+ }
+ }
+
+ return 0;
+ }
+
+ int
+ Converter::deploy_plan (::Deployment::DeploymentPlan &plan)
+ {
+ CIAO::RACE::Metadata_var metadata = new OBV_CIAO::RACE::Metadata;
+
+ try
+ {
+
+ if (this->history_)
+ {
+ metadata->command (::CIAO::RACE::TEARDOWN);
+ metadata->plan (this->previous_);
+ this->iia_->get_consumer_meta_data ()->push_Metadata (metadata.in ());
+ }
+
+ metadata->command (::CIAO::RACE::DEPLOY);
+ metadata->plan (plan);
+ this->iia_->get_consumer_meta_data ()->push_Metadata (metadata.in ());
+ this->history_ = true;
+ this->previous_ = plan;
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ACE_PRINT_EXCEPTION (ex, "Exception caught\n");
+ return -1;
+ }
+
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Injector: Unknown exception\n"));
+ return -1;
+ }
+
+ return 0;
+ }
+
+ }
+}
+
diff --git a/SA_POP/Converter.h b/SA_POP/Converter.h
new file mode 100644
index 00000000000..bb150884cd1
--- /dev/null
+++ b/SA_POP/Converter.h
@@ -0,0 +1,39 @@
+#include "Interactive_Input_AdapterC.h"
+#include "ace/OS.h"
+#include "ace/SString.h"
+#include "orbsvcs/CosNamingC.h"
+#include "RACE/common/OpStringC.h"
+#include "Plan_Generator_impl.h"
+namespace CIAO
+{
+ namespace RACE
+ {
+
+ class Converter
+ {
+ public:
+ Converter (int argc, char **argv);
+
+ virtual ~Converter ();
+
+ virtual int convert (OperationalString &op_string,
+ ::Deployment::DeploymentPlan &plan);
+
+ virtual int deploy_plan (::Deployment::DeploymentPlan &plan);
+
+ private:
+ ::CIAO::Plan_Generator::Plan_Generator_i plan_gen_;
+
+ ACE_CString iia_name_;
+
+ CORBA::ORB_var orb_;
+
+ CIAO::RACE::Interactive_Input_Adapter_var iia_;
+
+ bool history_;
+
+ ::Deployment::DeploymentPlan previous_;
+ };
+
+ }
+}
diff --git a/SA_POP/Driver.cpp b/SA_POP/Driver.cpp
new file mode 100644
index 00000000000..78b13905706
--- /dev/null
+++ b/SA_POP/Driver.cpp
@@ -0,0 +1,404 @@
+#include "Converter.h"
+#include "ace/Get_Opt.h"
+#include "ace/UUID.h"
+
+#include <iostream>
+#include <string>
+#include <map>
+#include <set>
+#include "SA_POP_Types.h"
+#include "SA_Builder.h"
+#include "TaskMapFileIn.h"
+#include "SANet/SANetFileIn.h"
+#include "LogScreenOut.h"
+
+int main (int argc, char **argv)
+{
+
+ try {
+ ::CIAO::RACE::Converter converter (argc, argv);
+ }
+
+
+ CIAO::RACE::OperationalString opstring;
+ std::string sanet_str;
+ std::string taskmap_str;
+
+ ACE_Get_Opt get_opts (argc, argv, "s:t:");
+ int c = 0;
+ while ((c = get_opts ()) != -1)
+ {
+ switch (c) {
+ case 's':
+ sanet_str = get_opts.opt_arg ();
+ break;
+
+ case 't':
+ taskmap_str = get_opts.opt_arg ();
+ break;
+ default:
+ break;
+ }
+ }
+
+ SA_POP_DEBUG (SA_POP_DEBUG_NORMAL, "\nSA-POP START\n");
+
+ SA_POP::SA_Builder builder;
+ SANet::SANetFileIn sanet_in;
+ SA_POP::TaskMapFileIn tm_in;
+
+ sanet_in.build_net (sanet_str, &builder);
+ tm_in.build_task_map (taskmap_str, &builder);
+
+ SA_POP::Planner *planner = builder.get_planner ();
+
+ // Log output plan to screen.
+ SA_POP::LogScreenOut screen_out (std::cout);
+ planner->add_out_adapter (&screen_out);
+
+ // Run planner (with a maximum of 50 steps of spreading activation).
+ planner->plan (50);
+
+ SA_POP::Plan plan = planner->get_plan ();
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get ID from Goal or Plan)
+ // Create and set the opstring ID.
+ ACE_Utils::UUID uuid;
+ ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (uuid);
+ opstring.UUID = CORBA::string_dup (uuid.to_string()->c_str ());
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set opstring name.
+ opstring.name = CORBA::string_dup (plan.name.c_str ());
+
+ // Set opstring time windows.
+ opstring.startWindow.Earliest.sec = plan.start_window.first;
+ opstring.startWindow.Earliest.usec = 0;
+ opstring.startWindow.Latest.sec = plan.start_window.second;
+ opstring.startWindow.Latest.usec = 0;
+ opstring.endWindow.Earliest.sec = plan.end_window.first;
+ opstring.endWindow.Earliest.usec = 0;
+ opstring.endWindow.Latest.sec = plan.end_window.second;
+ opstring.endWindow.Latest.usec = 0;
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get from expected utility)
+// long priority;
+ // (Get from goal)
+// QoSSpecifications QoSRequirements;
+ // (???)
+// ::Deployment::Properties properties;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+
+ // Map from instance IDs to instance index.
+ typedef std::map <SA_POP::TaskInstID, CORBA::ULong> InstToIndexMap;
+ InstToIndexMap inst_to_index;
+ inst_to_index.clear ();
+
+ // Buffer for strings.
+ char buffer[64];
+
+ // Add instances to opstring.
+ for (SA_POP::PlanInstSet::iterator inst_iter = plan.task_insts.begin ();
+ inst_iter != plan.task_insts.end (); inst_iter++)
+ {
+ SA_POP::PlanTaskInst inst = *inst_iter;
+
+ // Instance description to populate.
+ CIAO::RACE::InstanceDescription inst_desc;
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get instance ID from instance in plan)
+ // Create and set task instance ID.
+ ACE_Utils::UUID inst_uuid;
+ ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (inst_uuid);
+ inst_desc.UUID = CORBA::string_dup (inst_uuid.to_string()->c_str());
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get from repoman)
+// ::Deployment::Properties configProperty;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set instance name, task ID, supported type ID, and suggested implementation ID.
+ inst_desc.name = CORBA::string_dup (inst.name.c_str());
+ inst_desc.taskId = CORBA::string_dup (itoa (inst.task_id, buffer, 64));
+ inst_desc.taskTypeId = CORBA::string_dup (inst.type_id.c_str ());
+ inst_desc.suggestedImpl = CORBA::string_dup (inst.suggested_impl.c_str ());
+
+ // Set instance time windows.
+ inst_desc.startWindow.Earliest.sec = inst.start_window.first;
+ inst_desc.startWindow.Earliest.usec = 0;
+ inst_desc.startWindow.Latest.sec = inst.start_window.second;
+ inst_desc.startWindow.Latest.usec = 0;
+ inst_desc.endWindow.Earliest.sec = inst.end_window.first;
+ inst_desc.endWindow.Earliest.usec = 0;
+ inst_desc.endWindow.Latest.sec = inst.end_window.second;
+ inst_desc.endWindow.Latest.usec = 0;
+
+ // Add instance to opstring and record index.
+ CORBA::ULong inst_len = opstring.instances.length ();
+ opstring.instances.length (inst_len + 1);
+ opstring.instances[inst_len] = inst_desc;
+ inst_to_index.insert (std::make_pair (inst.inst_id, inst_len));
+ }
+
+ // Add plan data links.
+ CORBA::ULong conns_index = 0;
+ for (SA_POP::PlanConnSet::iterator conn_iter = plan.connections.begin ();
+ conn_iter != plan.connections.end (); conn_iter++)
+ {
+ SA_POP::PlanConnection conn = *conn_iter;
+
+ // Connection description to populate.
+ Deployment::PlanConnectionDescription conn_desc;
+
+ // Get plan instance and port IDS for connection.
+ SA_POP::TaskInstID taskA = conn.first_task_inst;
+ SA_POP::TaskInstID taskB = conn.second_task_inst;
+ SA_POP::PortID taskAport = conn.first_port;
+ SA_POP::PortID taskBport = conn.second_port;
+
+ // Get deployment plan instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create connection name.
+ std::string conn_name = "";
+ conn_name += itoa (taskAinst, buffer, 64);
+ conn_name += "_";
+ conn_name += taskAport;
+ conn_name += "___";
+ conn_name += itoa (taskBinst, buffer, 64);
+ conn_name += "_";
+ conn_name += taskBport;
+
+ // Create connection endpoints.
+ conn_desc.internalEndpoint.length (2);
+ conn_desc.internalEndpoint[0].instanceRef = taskAinst;
+ conn_desc.internalEndpoint[0].portName = CORBA::string_dup (taskAport.c_str ());
+ conn_desc.internalEndpoint[0].provider = 1;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get kind from data link in plan)
+ conn_desc.internalEndpoint[0].kind = Deployment::EventPublisher;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ conn_desc.internalEndpoint[1].instanceRef = taskBinst;
+ conn_desc.internalEndpoint[1].portName = CORBA::string_dup (taskBport.c_str ());
+ conn_desc.internalEndpoint[1].provider = 0;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get kind from data link in plan)
+ conn_desc.internalEndpoint[1].kind = Deployment::EventConsumer;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set connection name.
+ conn_desc.name = CORBA::string_dup (conn_name.c_str ());
+
+ // Add data link to opstring.
+ opstring.dataLinks.length (conns_index + 1);
+ opstring.dataLinks[conns_index] = conn_desc;
+
+ // Increment connection index.
+ conns_index++;
+ }
+
+ // Add scheduling links.
+ CORBA::ULong links_index = 0;
+ for (SA_POP::SchedLinkSet::iterator sched_iter = plan.sched_links.begin ();
+ sched_iter != plan.sched_links.end (); sched_iter++)
+ {
+ SA_POP::SchedLink link = *sched_iter;
+
+ // Link to populate.
+ CIAO::RACE::OrderLinkDescription link_desc;
+
+ // Set link type.
+ link_desc.type = CIAO::RACE::SCHEDULING;
+
+ // Get plan instance and port IDS for link.
+ SA_POP::TaskInstID taskA = link.first;
+ SA_POP::TaskInstID taskB = link.second;
+
+ // Get deployment plan instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create link name.
+ std::string link_name = "";
+ link_name += itoa (taskAinst, buffer, 64);
+ link_name += "___";
+ link_name += itoa (taskBinst, buffer, 64);
+
+ // Create link endpoints.
+ link_desc.internalEndpoint.length (2);
+ link_desc.internalEndpoint[0].instanceRef = taskAinst;
+ link_desc.internalEndpoint[0].provider = 1;
+ link_desc.internalEndpoint[1].instanceRef = taskBinst;
+ link_desc.internalEndpoint[1].provider = 0;
+
+ // Set link name.
+ link_desc.name = CORBA::string_dup (link_name.c_str ());
+
+ // Add data link to opstring.
+ opstring.orderLinks.length (links_index + 1);
+ opstring.orderLinks[links_index] = link_desc;
+
+ // Increment link index.
+ links_index++;
+ }
+
+ // Add threat links.
+ links_index = opstring.orderLinks.length ();
+ for (SA_POP::ThreatLinkSet::iterator threat_iter = plan.threat_links.begin ();
+ threat_iter != plan.threat_links.end (); threat_iter++)
+ {
+ SA_POP::ThreatLink link = *threat_iter;
+
+ // Link to populate.
+ CIAO::RACE::OrderLinkDescription link_desc;
+
+ // Set link type.
+ link_desc.type = CIAO::RACE::THREAT;
+
+ // Get plan instance and port IDS for link.
+ SA_POP::TaskInstID taskA = link.first;
+ SA_POP::TaskInstID taskB = link.second;
+
+ // Get deployment plan instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create link name.
+ std::string link_name = "";
+ link_name += itoa (taskAinst, buffer, 64);
+ link_name += "___";
+ link_name += itoa (taskBinst, buffer, 64);
+
+ // Create link endpoints.
+ link_desc.internalEndpoint.length (2);
+ link_desc.internalEndpoint[0].instanceRef = taskAinst;
+ link_desc.internalEndpoint[0].provider = 1;
+ link_desc.internalEndpoint[1].instanceRef = taskBinst;
+ link_desc.internalEndpoint[1].provider = 0;
+
+ // Set link name.
+ link_desc.name = CORBA::string_dup (link_name.c_str ());
+
+ // Add data link to opstring.
+ opstring.orderLinks.length (links_index + 1);
+ opstring.orderLinks[links_index] = link_desc;
+
+ // Increment link index.
+ links_index++;
+ }
+
+ // Add causal links.
+ links_index = opstring.orderLinks.length ();
+ for (SA_POP::CLSet::iterator cl_iter = plan.causal_links.begin ();
+ cl_iter != plan.causal_links.end (); cl_iter++)
+ {
+ SA_POP::CausalLink link = *cl_iter;
+
+ // Link to populate.
+ CIAO::RACE::OrderLinkDescription link_desc;
+
+ // Set link type.
+ link_desc.type = CIAO::RACE::CAUSAL;
+
+ // Get plan instance and port IDS for link.
+ SA_POP::TaskInstID taskA = link.first;
+ SA_POP::TaskInstID taskB = link.second;
+
+ // Get deployment plan instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create link name.
+ std::string link_name = "";
+ link_name += itoa (taskAinst, buffer, 64);
+ link_name += "___";
+ link_name += itoa (taskBinst, buffer, 64);
+
+ // Create link endpoints.
+ link_desc.internalEndpoint.length (2);
+ link_desc.internalEndpoint[0].instanceRef = taskAinst;
+ link_desc.internalEndpoint[0].provider = 1;
+ link_desc.internalEndpoint[1].instanceRef = taskBinst;
+ link_desc.internalEndpoint[1].provider = 0;
+
+ // Set link name.
+ link_desc.name = CORBA::string_dup (link_name.c_str ());
+
+ // Add data link to opstring.
+ opstring.orderLinks.length (links_index + 1);
+ opstring.orderLinks[links_index] = link_desc;
+
+ // Increment link index.
+ links_index++;
+ }
+
+/*
+ // Print out opstring instances.
+ std::cout << "Opstring Instances:" << std::endl;
+ if (opstring.instances.length () > 0) {
+ for (CORBA::ULong i (0); i < opstring.instances.length (); ++i) {
+ CORBA::String_var impl = CORBA::string_dup (opstring.instances[i].suggestedImpl);
+ std::cout << "Inst: " << i << " -> Impl: " << impl << std::endl;
+ }
+ }
+ std::cout << std::endl;
+
+ // Print out opstring connections.
+ Deployment::PlanConnectionDescriptions check_conns = opstring.dataLinks;
+ std::cout << "Opstring Connections:" << std::endl;
+ for (CORBA::ULong i (0); i < check_conns.length (); ++i) {
+ std::cout << "name " << check_conns[i].name << std::endl;
+ std::cout << "InstA " << check_conns[i].internalEndpoint[0].instanceRef << "; ";
+ std::cout << "PortA " << check_conns[i].internalEndpoint[0].portName << "; ";
+ std::cout << "ProviderA " << check_conns[i].internalEndpoint[0].provider << "; ";
+ std::cout << "KindA " << check_conns[i].internalEndpoint[0].kind << "; ";
+ std::cout << std::endl << " -> " << std::endl;
+ std::cout << "InstB " << check_conns[i].internalEndpoint[1].instanceRef << "; ";
+ std::cout << "PortB " << check_conns[i].internalEndpoint[1].portName << "; ";
+ std::cout << "ProviderB " << check_conns[i].internalEndpoint[1].provider << "; ";
+ std::cout << "KindB " << check_conns[i].internalEndpoint[1].kind << "; ";
+ std::cout << std::endl << std::endl;
+ }
+*/
+
+ // Planner no longer needed.
+ delete planner;
+
+ SA_POP_DEBUG (SA_POP_DEBUG_NORMAL, "\nSA-POP END\n");
+
+ try
+ {
+
+ ::Deployment::DeploymentPlan deploy_plan;
+
+ if (converter.convert (opstring, deploy_plan) == 0)
+ {
+ converter.deploy_plan (deploy_plan);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Unknown exception\n"));
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/SA_POP/LogFileOut.cpp b/SA_POP/LogFileOut.cpp
new file mode 100644
index 00000000000..ab1af922a16
--- /dev/null
+++ b/SA_POP/LogFileOut.cpp
@@ -0,0 +1,170 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file LogFileOut.cpp
+ *
+ * This file contains the LogFileOut class implementation for the output adapter
+ * that logs plan changes to a file.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <fstream>
+#include <time.h>
+#include "SA_POP_Types.h"
+#include "LogFileOut.h"
+#include "Planner.h"
+
+using namespace SA_POP;
+
+// Constructor.
+LogFileOut::LogFileOut (const char *filename)
+: outfile_ (filename)
+{
+ if (this->outfile_ == 0){
+ std::string msg = "Unable to open ";
+ msg += filename;
+ msg += " for writing.";
+ throw msg;
+ }
+};
+
+// Destructor.
+LogFileOut::~LogFileOut (void)
+{
+ this->outfile_.close ();
+};
+
+// Notify about task future expected utility changes.
+void LogFileOut::notify_eu (SA_POP::Planner *planner)
+{
+ time_t cur_time = time(0);
+ this->outfile_ << std::endl;
+ this->outfile_ << "EU Changes (" << ctime (&cur_time) << "):" << std::endl;
+
+ TaskEUMap eu_changes = planner->get_eu_changes ();
+ for (TaskEUMap::iterator iter = eu_changes.begin ();
+ iter != eu_changes.end ();
+ iter++)
+ {
+ this->outfile_ << "Task " << iter->first << " = " << iter->second;
+ this->outfile_ << std::endl;
+ }
+};
+
+// Notify about plan changes.
+void LogFileOut::notify_plan (SA_POP::Planner *planner)
+{
+ Plan plan = planner->get_plan ();
+
+ time_t cur_time = time(0);
+
+ this->outfile_ << std::endl;
+ this->outfile_ << "Plan (" << plan.name << ") Changed at " << std::endl;
+ this->outfile_ << ctime (&cur_time) << std::endl;
+ this->outfile_ << "ID: " << plan.plan_id << std::endl;
+
+ this->outfile_ << "Start Window: [" << plan.start_window.first << ", ";
+ this->outfile_ << plan.start_window.second << "]" << std::endl;
+
+ this->outfile_ << "End Window: [" << plan.end_window.first << ", ";
+ this->outfile_ << plan.end_window.second << "]" << std::endl;
+
+ for (PlanInstSet::iterator inst_iter = plan.task_insts.begin ();
+ inst_iter != plan.task_insts.end ();
+ inst_iter++)
+ {
+ PlanTaskInst inst = *inst_iter;
+ this->outfile_ << "Task Instance (" << inst.name << "):" << std::endl;
+
+ this->outfile_ << " ID: " << inst.inst_id << std::endl;
+
+ this->outfile_ << " Start Window: [" << inst.start_window.first << ", ";
+ this->outfile_ << inst.start_window.second << "]" << std::endl;
+
+ this->outfile_ << " End Window: [" << inst.end_window.first << ", ";
+ this->outfile_ << inst.end_window.second << "]" << std::endl;
+
+ this->outfile_ << " Task ID: " << inst.task_id << std::endl;
+
+ this->outfile_ << " Task Type: " << inst.type_id << std::endl;
+
+ this->outfile_ << " Suggested Implementation: ";
+ this->outfile_ << inst.suggested_impl << std::endl;
+ }
+
+ this->outfile_ << std::endl;
+
+ for (PlanConnSet::iterator conn_iter = plan.connections.begin ();
+ conn_iter != plan.connections.end ();
+ conn_iter++)
+ {
+ PlanConnection conn = *conn_iter;
+ this->outfile_ << "Data Connection:" << std::endl;
+ this->outfile_ << " " << conn.first_task_inst << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (conn.first_task_inst)) << "--";
+ this->outfile_ << conn.first_port << ") -";
+ this->outfile_ << "(" << planner->get_cond_name (conn.cond) << ")-> ";
+ this->outfile_ << conn.second_task_inst << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (conn.second_task_inst)) << "--";
+ this->outfile_ << conn.second_port << ")" << std::endl;
+ }
+
+ this->outfile_ << std::endl;
+
+ for (CLSet::iterator cl_iter = plan.causal_links.begin ();
+ cl_iter != plan.causal_links.end ();
+ cl_iter++)
+ {
+ CausalLink clink = *cl_iter;
+ this->outfile_ << "Causal Link:" << std::endl;
+ this->outfile_ << " " << clink.first << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (clink.first)) << ") -";
+ this->outfile_ << "(" << planner->get_cond_name (clink.cond.id) << ")-> ";
+ this->outfile_ << clink.second << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (clink.second)) << ")" << std::endl;
+ }
+
+ this->outfile_ << std::endl;
+
+ for (SchedLinkSet::iterator sched_iter = plan.sched_links.begin ();
+ sched_iter != plan.sched_links.end ();
+ sched_iter++)
+ {
+ SchedLink sched_link = (*sched_iter);
+ this->outfile_ << "Scheduling Link:" << std::endl;
+ this->outfile_ << " " << sched_link.first << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (sched_link.first)) << ") -> ";
+ this->outfile_ << sched_link.second << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (sched_link.second)) << ")" << std::endl;
+
+ }
+
+ this->outfile_ << std::endl;
+
+ for (ThreatLinkSet::iterator threat_iter = plan.threat_links.begin ();
+ threat_iter != plan.threat_links.end ();
+ threat_iter++)
+ {
+ ThreatLink threat_link = (*threat_iter);
+ this->outfile_ << "Threat Link:" << std::endl;
+ this->outfile_ << " " << threat_link.first << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (threat_link.first)) << ") -> ";
+ this->outfile_ << threat_link.second << " (";
+ this->outfile_ << planner->get_task_name (
+ planner->get_task_from_inst (threat_link.second)) << ")" << std::endl;
+
+ }
+
+ this->outfile_ << std::endl;
+};
diff --git a/SA_POP/LogFileOut.h b/SA_POP/LogFileOut.h
new file mode 100644
index 00000000000..8a714f3152a
--- /dev/null
+++ b/SA_POP/LogFileOut.h
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file LogFileOut.h
+ *
+ * This file contains the LogFileOut class definition for the output adapter
+ * that logs plan changes to a file.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_LOG_FILE_OUT_H_
+#define SA_POP_LOG_FILE_OUT_H_
+
+#include <fstream>
+#include "OutAdapter.h"
+
+namespace SA_POP {
+
+ /**
+ * @class LogFileOut
+ *
+ * @brief Output adapter that logs plan changes to a file.
+ */
+ class LogFileOut : public OutAdapter {
+ public:
+ /// Constructor.
+ /**
+ * @param filename Name of file to log to.
+ */
+ LogFileOut (const char *filename);
+
+ /// Destructor.
+ virtual ~LogFileOut (void);
+
+ /// Notify about task future expected utility changes.
+ /**
+ * @param planner Planner for which changes have occurred.
+ */
+ virtual void notify_eu (SA_POP::Planner *planner);
+
+ /// Notify about plan changes.
+ /**
+ * @param planner Planner for which changes have occurred.
+ */
+ virtual void notify_plan (SA_POP::Planner *planner);
+
+ protected:
+ /// Output file handle.
+ std::ofstream outfile_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_LOG_FILE_OUT_H_ */
diff --git a/SA_POP/LogScreenOut.cpp b/SA_POP/LogScreenOut.cpp
new file mode 100644
index 00000000000..531c4f9e3ae
--- /dev/null
+++ b/SA_POP/LogScreenOut.cpp
@@ -0,0 +1,166 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file LogScreenOut.cpp
+ *
+ * This file contains the LogScreenOut class implementation for the output adapter
+ * that displays plan changes on the screen as they occur.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <iostream>
+#include <time.h>
+#include "SA_POP_Types.h"
+#include "LogScreenOut.h"
+#include "Planner.h"
+
+using namespace SA_POP;
+
+// Constructor.
+LogScreenOut::LogScreenOut (std::ostream &out)
+: out_ (out)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+LogScreenOut::~LogScreenOut (void)
+{
+ // Nothing to do.
+};
+
+// Notify about task future expected utility changes.
+void LogScreenOut::notify_eu (SA_POP::Planner *planner)
+{
+ time_t cur_time = time(0);
+ this->out_ << std::endl;
+ this->out_ << "EU Changes:" << std::endl;
+ this->out_ << ctime (&cur_time) << std::endl;
+
+ TaskEUMap eu_changes = planner->get_eu_changes ();
+ for (TaskEUMap::iterator iter = eu_changes.begin ();
+ iter != eu_changes.end ();
+ iter++)
+ {
+ this->out_ << "Task " << iter->first << " = " << iter->second;
+ this->out_ << std::endl;
+ }
+};
+
+// Notify about plan changes.
+void LogScreenOut::notify_plan (SA_POP::Planner *planner)
+{
+ Plan plan = planner->get_plan ();
+
+ time_t cur_time = time(0);
+
+ this->out_ << std::endl;
+ this->out_ << "Plan (" << plan.name << ") Changed at " << std::endl;
+ this->out_ << ctime (&cur_time) << std::endl;
+ this->out_ << "ID: " << plan.plan_id << std::endl;
+
+ this->out_ << "Start Window: [" << plan.start_window.first << ", ";
+ this->out_ << plan.start_window.second << "]" << std::endl;
+
+ this->out_ << "End Window: [" << plan.end_window.first << ", ";
+ this->out_ << plan.end_window.second << "]" << std::endl;
+
+ for (PlanInstSet::iterator inst_iter = plan.task_insts.begin ();
+ inst_iter != plan.task_insts.end ();
+ inst_iter++)
+ {
+ PlanTaskInst inst = *inst_iter;
+ this->out_ << "Task Instance (" << inst.name << "):" << std::endl;
+
+ this->out_ << " ID: " << inst.inst_id << std::endl;
+
+ this->out_ << " Start Window: [" << inst.start_window.first << ", ";
+ this->out_ << inst.start_window.second << "]" << std::endl;
+
+ this->out_ << " End Window: [" << inst.end_window.first << ", ";
+ this->out_ << inst.end_window.second << "]" << std::endl;
+
+ this->out_ << " Task ID: " << inst.task_id << std::endl;
+
+ this->out_ << " Task Type: " << inst.type_id << std::endl;
+
+ this->out_ << " Suggested Implementation: ";
+ this->out_ << inst.suggested_impl << std::endl;
+ }
+
+ this->out_ << std::endl;
+
+ for (PlanConnSet::iterator conn_iter = plan.connections.begin ();
+ conn_iter != plan.connections.end ();
+ conn_iter++)
+ {
+ PlanConnection conn = *conn_iter;
+ this->out_ << "Data Connection:" << std::endl;
+ this->out_ << " " << conn.first_task_inst << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (conn.first_task_inst)) << "--";
+ this->out_ << conn.first_port << ") -";
+ this->out_ << "(" << planner->get_cond_name (conn.cond) << ")-> ";
+ this->out_ << conn.second_task_inst << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (conn.second_task_inst)) << "--";
+ this->out_ << conn.second_port << ")" << std::endl;
+ }
+
+ this->out_ << std::endl;
+
+ for (CLSet::iterator cl_iter = plan.causal_links.begin ();
+ cl_iter != plan.causal_links.end ();
+ cl_iter++)
+ {
+ CausalLink clink = *cl_iter;
+ this->out_ << "Causal Link:" << std::endl;
+ this->out_ << " " << clink.first << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (clink.first)) << ") -";
+ this->out_ << "(" << planner->get_cond_name (clink.cond.id) << ")-> ";
+ this->out_ << clink.second << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (clink.second)) << ")" << std::endl;
+ }
+
+ this->out_ << std::endl;
+
+ for (SchedLinkSet::iterator sched_iter = plan.sched_links.begin ();
+ sched_iter != plan.sched_links.end ();
+ sched_iter++)
+ {
+ SchedLink sched_link = (*sched_iter);
+ this->out_ << "Scheduling Link:" << std::endl;
+ this->out_ << " " << sched_link.first << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (sched_link.first)) << ") -> ";
+ this->out_ << sched_link.second << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (sched_link.second)) << ")" << std::endl;
+
+ }
+
+ this->out_ << std::endl;
+
+ for (ThreatLinkSet::iterator threat_iter = plan.threat_links.begin ();
+ threat_iter != plan.threat_links.end ();
+ threat_iter++)
+ {
+ ThreatLink threat_link = (*threat_iter);
+ this->out_ << "Threat Link:" << std::endl;
+ this->out_ << " " << threat_link.first << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (threat_link.first)) << ") -> ";
+ this->out_ << threat_link.second << " (";
+ this->out_ << planner->get_task_name (
+ planner->get_task_from_inst (threat_link.second)) << ")" << std::endl;
+
+ }
+
+ this->out_ << std::endl;
+};
diff --git a/SA_POP/LogScreenOut.h b/SA_POP/LogScreenOut.h
new file mode 100644
index 00000000000..9ae7322e0ab
--- /dev/null
+++ b/SA_POP/LogScreenOut.h
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file LogScreenOut.h
+ *
+ * This file contains the LogScreenOut class definition for the output adapter
+ * that displays plan changes on the screen as they occur.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_LOG_SCREEN_OUT_H_
+#define SA_POP_LOG_SCREEN_OUT_H_
+
+#include <iostream>
+#include "OutAdapter.h"
+
+namespace SA_POP {
+
+ /**
+ * @class LogScreenOut
+ *
+ * @brief Output adapter that displays plan changes on the screen as they
+ * occur.
+ */
+ class LogScreenOut : public OutAdapter {
+ public:
+ /// Constructor.
+ /**
+ * @param strm Output stream to log to.
+ */
+ LogScreenOut (std::ostream &out);
+
+ /// Destructor.
+ virtual ~LogScreenOut (void);
+
+ /// Notify about task future expected utility changes.
+ /**
+ * @param planner Planner for which changes have occurred.
+ */
+ virtual void notify_eu (SA_POP::Planner *planner);
+
+ /// Notify about plan changes.
+ /**
+ * @param planner Planner for which changes have occurred.
+ */
+ virtual void notify_plan (SA_POP::Planner *planner);
+
+ protected:
+ /// Output stream to log to.
+ std::ostream &out_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_LOG_SCREEN_OUT_H_ */
diff --git a/SA_POP/OutAdapter.h b/SA_POP/OutAdapter.h
new file mode 100644
index 00000000000..437eb283f00
--- /dev/null
+++ b/SA_POP/OutAdapter.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file OutAdapter.h
+ *
+ * This file contains the OutAdapter abstract base class definition for output
+ * adapters.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_OUT_ADAPTER_H_
+#define SA_POP_OUT_ADAPTER_H_
+
+#include "SA_POP_Types.h"
+
+namespace SA_POP {
+
+ // Forward declaration of Planner.
+ class Planner;
+
+ /**
+ * @class OutAdapter
+ *
+ * @brief Abstract base class for output adapters.
+ */
+ class OutAdapter {
+ public:
+ /// Constructor.
+ OutAdapter (void) { };
+
+ /// Destructor.
+ virtual ~OutAdapter (void) { };
+
+ /// Notify about task future expected utility changes.
+ /**
+ * @param planner Planner for which changes have occurred.
+ */
+ virtual void notify_eu (SA_POP::Planner *planner) = 0;
+
+ /// Notify about plan changes.
+ /**
+ * @param planner Planner for which changes have occurred.
+ */
+ virtual void notify_plan (SA_POP::Planner *planner) = 0;
+
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_OUT_ADAPTER_H_ */
diff --git a/SA_POP/PlanCommands.h b/SA_POP/PlanCommands.h
new file mode 100644
index 00000000000..fc1553b4c6c
--- /dev/null
+++ b/SA_POP/PlanCommands.h
@@ -0,0 +1,370 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file PlanCommand.h
+ *
+ * This file contains the PlanCommand abstract base class definition for
+ * encapsulation of a command to modify a WorkingPlan.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_PLAN_COMMAND_H_
+#define SA_POP_PLAN_COMMAND_H_
+
+#include <string>
+#include "SA_POP_Types.h"
+
+namespace SA_POP {
+
+ /**
+ * @class PlanCommand
+ *
+ * @brief Abstract base class for the encapsulation of a command to modify a
+ * WorkingPlan.
+ */
+ class PlanCommand {
+ public:
+ /// Constructor.
+ PlanCommand (void)
+ : prev_ (0)
+ { id_.step = -1; id_.decision_pt = -1; id_.seq_num = -1; };
+
+ /// Destructor.
+ virtual ~PlanCommand (void) { };
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void) = 0;
+
+ /// Set id (i.e. info on when this command was created during planning).
+ /**
+ * @param id The command id.
+ */
+ virtual void set_id (CommandID id) { this->id_ = id; };
+
+ /// Get id (i.e. info on when this command was created during planning).
+ /**
+ * @return The command id.
+ */
+ virtual CommandID get_id (void) { return this->id_; };
+
+ /// Set pointer to previous command.
+ /**
+ * @param prev Pointer to the previous command.
+ */
+ virtual void set_prev (PlanCommand *prev) { this->prev_ = prev; };
+
+ /// Get pointer to previous command.
+ /**
+ * @return Pointer to the previous command.
+ */
+ virtual PlanCommand *get_prev (void) { return this->prev_; };
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void) = 0;
+
+ /// Undo this command.
+ /**
+ * @return True if undo succeeded, false otherwise.
+ */
+ virtual void undo (void) = 0;
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void) = 0;
+
+ protected:
+ /// ID of this command.
+ CommandID id_;
+
+ /// Pointer to previous command.
+ PlanCommand *prev_;
+
+ };
+
+ /**
+ * @class AdjustMinTimesCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to adjust
+ * the start-min and end-min times of a task instance in the plan.
+ */
+ class AdjustMinTimesCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ AdjustMinTimesCmd (void) { };
+
+ /// Destructor.
+ virtual ~AdjustMinTimesCmd (void) { };
+
+ /// Set the task instance and window adjustment.
+ /**
+ * @param task_inst The task instance for which to adjust to the window.
+ *
+ * @param start_min The new start-min time.
+ *
+ * @param end_min The new end-min time.
+ */
+ virtual void set_times (TaskInstID task_inst, TimeValue start_min,
+ TimeValue end_min) = 0;
+ };
+
+ /**
+ * @class AdjustMaxTimesCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to adjust
+ * the start-max and end-max times of a task instance in the plan.
+ */
+ class AdjustMaxTimesCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ AdjustMaxTimesCmd (void) { };
+
+ /// Destructor.
+ virtual ~AdjustMaxTimesCmd (void) { };
+
+ /// Set the task instance and window adjustment.
+ /**
+ * @param task_inst The task instance for which to adjust to the window.
+ *
+ * @param start_max The new start-max time.
+ *
+ * @param end_max The new end-max time.
+ */
+ virtual void set_times (TaskInstID task_inst, TimeValue start_max,
+ TimeValue end_max) = 0;
+ };
+
+ /**
+ * @class AddTaskCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to add a
+ * task to the current plan.
+ */
+ class AddTaskCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ AddTaskCmd (void) { };
+
+ /// Destructor.
+ virtual ~AddTaskCmd (void) { };
+
+ /// Set (ordered) list of tasks to add (one per execution) to the plan.
+ /**
+ * @param tasks Ordered list of tasks.
+ */
+ virtual void set_tasks (const TaskList &tasks) = 0;
+
+ /// Set causal link info to add to the plan with task.
+ /**
+ * @param cond Condition this task satisifies.
+ *
+ * @param task_insts Set of task instances that this task satisifes
+ * the given precondition.
+ */
+ virtual void set_causal_info (Condition cond, TaskInstSet task_insts) = 0;
+
+ /// Get ID of last task added to the plan by this command.
+ /**
+ * @return ID of last task added to the plan by this command.
+ */
+ virtual TaskID get_task (void) = 0;
+
+ /// Get ID of instance of last task added to the plan by this command.
+ /**
+ * @return ID of instance of last task added to the plan by this command.
+ */
+ virtual TaskInstID get_task_inst (void) = 0;
+
+ /// Check if the instance id used by the task of this command already exists.
+ /**
+ * @return True if this command is using an already existing instance id.
+ */
+ virtual bool inst_exists (void) = 0;
+ };
+
+ /**
+ * @class AssocTaskImplCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to
+ * associate an implementation with a task instance in the plan.
+ */
+ class AssocTaskImplCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ AssocTaskImplCmd (void) { };
+
+ /// Destructor.
+ virtual ~AssocTaskImplCmd (void) { };
+
+ /// Set the task->implementation associate.
+ /**
+ * @param task_inst The task instance.
+ *
+ * @param impl_list The task implementations to try for this instance.
+ */
+ virtual void set_assoc (TaskInstID task_inst, TaskImplList impl_list) = 0;
+ /// Get ID of instance of this command.
+ /**
+ * @return ID of instance of this command.
+ */
+ virtual TaskInstID get_task_inst (void) = 0;
+ };
+
+ /**
+ * @class AddOpenCondsCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to add
+ * open conditions to the current planning strategy.
+ */
+ class AddOpenCondsCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ AddOpenCondsCmd (void) { };
+
+ /// Destructor.
+ virtual ~AddOpenCondsCmd (void) { };
+
+ /// Set the open conditions to add.
+ /**
+ * @param conds Set of open conditions to add.
+ */
+ virtual void set_conds (const CondSet &conds) = 0;
+
+ /// Set the task instance for which these are preconditions.
+ /**
+ * @param task_inst Task instance for which these are preconditions.
+ */
+ virtual void set_task_inst (TaskInstID) = 0;
+ };
+
+ /**
+ * @class RemoveOpenCondsCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to remove
+ * open conditions from the current planning strategy.
+ */
+ class RemoveOpenCondsCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ RemoveOpenCondsCmd (void) { };
+
+ /// Destructor.
+ virtual ~RemoveOpenCondsCmd (void) { };
+
+ /// Set the open conditions to remove.
+ /**
+ * @param conds Set of open conditions to remove.
+ */
+ virtual void set_conds (const CondSet &conds) = 0;
+ };
+
+ /**
+ * @class AddOpenThreatsCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to add
+ * open causal link threats to the current planning strategy.
+ */
+ class AddOpenThreatsCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ AddOpenThreatsCmd (void) { };
+
+ /// Destructor.
+ virtual ~AddOpenThreatsCmd (void) { };
+
+ /// Set the open threats to add.
+ /**
+ * @param conds Set of open threats to add.
+ */
+ virtual void set_threats (const CLThreatSet &threats) = 0;
+ };
+
+ /**
+ * @class RemoveOpenThreatsCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to remove
+ * open causal link threats from the current planning strategy.
+ */
+ class RemoveOpenThreatsCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ RemoveOpenThreatsCmd (void) { };
+
+ /// Destructor.
+ virtual ~RemoveOpenThreatsCmd (void) { };
+
+ /// Set the open threats to remove.
+ /**
+ * @param conds Set of open threats to remove.
+ */
+ virtual void set_threats (const CLThreatSet &threats) = 0;
+ };
+
+ /**
+ * @class ResolveCLThreatCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to resolve
+ * a causal link threat in the plan.
+ */
+ class ResolveCLThreatCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ ResolveCLThreatCmd (void) { };
+
+ /// Destructor.
+ virtual ~ResolveCLThreatCmd (void) { };
+
+ /// Set the causal link threat to resolve.
+ /**
+ * @param threat The causal link threat to resolve.
+ */
+ virtual void set_threat (CLThreat &threat) = 0;
+ };
+
+ /**
+ * @class ResolveSchedOrderCmd
+ *
+ * @brief Abstract base class for the encapsulation of a command to add
+ * a non-causal-link ordering constraint (promotion or demotion)
+ * between two task instances in the plan.
+ */
+ class ResolveSchedOrderCmd : public PlanCommand {
+ public:
+ /// Constructor.
+ ResolveSchedOrderCmd (void) { };
+
+ /// Destructor.
+ virtual ~ResolveSchedOrderCmd (void) { };
+
+ /// Set the task instances to order.
+ /**
+ * @param task_inst_a One task instance.
+ *
+ * @param task_inst_b The other task instance.
+ */
+ virtual void set_task_insts (TaskInstID task_inst_a,
+ TaskInstID task_inst_b) = 0;
+ /// Get the affected task instances.
+ /**
+ * @return A set of the affected task instances.
+ */
+ virtual TaskInstSet get_affected_insts () = 0;
+ };
+
+
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_PLAN_COMMAND_H_ */
diff --git a/SA_POP/PlanHeuristics.h b/SA_POP/PlanHeuristics.h
new file mode 100644
index 00000000000..941e60089cf
--- /dev/null
+++ b/SA_POP/PlanHeuristics.h
@@ -0,0 +1,123 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file PlanHeuristic.h
+ *
+ * This file contains the class definitions for the encapsulations of
+ * algorithms corresponding to planning/scheduling substeps.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_PLAN_STEP_H_
+#define SA_POP_PLAN_STEP_H_
+
+#include "SA_POP_Types.h"
+#include "PlanStrategy.h"
+
+namespace SA_POP {
+
+ // Forward declaration of Planner.
+ class Planner;
+
+ /**
+ * @class CondStrategy
+ *
+ * @brief CondStrategy abstract base class for a PlanHeuristic that
+ * chooses an open condition in the plan to satisfy next.
+ */
+ class CondStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ CondStrategy (SA_POP::Planner *planner)
+ : planner_ (planner) { };
+
+ /// Destructor.
+ virtual ~CondStrategy (void) { };
+
+ /// Choose the next open condition to satisfy.
+ /**
+ * @param open_conds Open conditions in the plan.
+ *
+ * @return Next open condition to satisfy.
+ */
+ virtual Condition choose_cond (const OpenCondMap &open_conds) = 0;
+
+ protected:
+ /// Pointer to Planner object.
+ SA_POP::Planner *planner_;
+ };
+
+ /**
+ * @class TaskStrategy
+ *
+ * @brief TaskStrategy abstract base class for a PlanHeuristic that
+ * chooses an ordering of tasks for the choice to satisfy an
+ * open condition.
+ */
+ class TaskStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ TaskStrategy (SA_POP::Planner *planner)
+ : planner_ (planner) { };
+
+ /// Destructor.
+ virtual ~TaskStrategy (void) { };
+
+ /// Choose the (ordering of) task(s) to satisfy an open condition.
+ /**
+ * @param open_cond Open condition to satisfy.
+ *
+ * @return Sorted list of tasks that satisfy given condition.
+ */
+ virtual TaskList choose_task (Condition open_cond) = 0;
+
+ protected:
+ /// Pointer to Planner object.
+ SA_POP::Planner *planner_;
+ };
+
+ /**
+ * @class ImplStrategy
+ *
+ * @brief ImplStrategy abstract base class for a PlanHeuristic that
+ * chooses an ordering of implementations to try for a given
+ * task instance.
+ */
+ class ImplStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ ImplStrategy (SA_POP::Planner *planner)
+ : planner_ (planner) { };
+
+ /// Destructor.
+ virtual ~ImplStrategy (void) { };
+
+ /// Choose the (ordering of) task implementation(s) for a task instance.
+ /**
+ * @param task_inst Task instance for which to choose implementations.
+ *
+ * @return Ordered list of implementations for the given task instance.
+ */
+ virtual TaskImplList choose_impl (TaskInstID task_inst) = 0;
+
+ protected:
+ /// Pointer to Planner object.
+ SA_POP::Planner *planner_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_PLAN_STEP_H_ */
diff --git a/SA_POP/PlanStrategy.h b/SA_POP/PlanStrategy.h
new file mode 100644
index 00000000000..1a966207f5f
--- /dev/null
+++ b/SA_POP/PlanStrategy.h
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file PlanStrategy.h
+ *
+ * This file contains the PlanStrategy abstract base class definition for
+ * the high-level planning algorithm.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_PLAN_STRATEGY_H_
+#define SA_POP_PLAN_STRATEGY_H_
+
+#include "SA_POP_Types.h"
+#include "PlanCommands.h"
+
+namespace SA_POP {
+
+ // Forward declaration of Planner.
+ class Planner;
+
+ /**
+ * @class PlanStrategy
+ *
+ * @brief Abstract base class for the high-level planning/scheduling
+ * algorithm.
+ */
+ class PlanStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ PlanStrategy (SA_POP::Planner *planner)
+ : planner_ (planner) { };
+
+ /// Destructor.
+ virtual ~PlanStrategy (void) { };
+
+
+
+ // ************************************************************************
+ // Planning methods.
+ // ************************************************************************
+
+ /// Set goals.
+ /**
+ * @param goals Set of goals and associated utilities.
+ */
+ virtual void set_goals (GoalMap goals) = 0;
+
+ /// Get command ID to use for next command.
+ /**
+ * @return Command ID to use for next command.
+ */
+ virtual CommandID get_next_cmd_id (void) = 0;
+
+ /// Recursively satisfy all open conditions (including recursive
+ /// scheduling constraint satisfaction through call back).
+ /**
+ * @return True if all open conditions were satisfied, false otherwise.
+ */
+ virtual bool satisfy_open_conds (void) = 0;
+
+
+ // ************************************************************************
+ // Methods for obtaining prototypes of commands that work on this strategy.
+ // ************************************************************************
+
+ /// Get a PlanCommand prototype for adding open conditions,
+ /// which works on this strategy.
+ /**
+ * @return An AddOpenCondsCmd prototype for this strategy.
+ */
+ virtual AddOpenCondsCmd *get_AddOpenCondsCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for removing open conditions,
+ /// which works on this strategy.
+ /**
+ * @return A RemoveOpenCondsCmd prototype for this strategy.
+ */
+ virtual RemoveOpenCondsCmd *get_RemoveOpenCondsCmd (void) = 0;
+
+ /// Get an command prototype for adding causal link threats, which works on
+ /// this strategy.
+ /**
+ * @return An AddOpenThreatsCmd prototype for this strategy.
+ */
+ virtual AddOpenThreatsCmd *get_AddOpenThreatsCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for removing causal link threats,
+ /// which works on this strategy.
+ /**
+ * @return A RemoveOpenThreatsCmd prototype for this strategy.
+ */
+ virtual RemoveOpenThreatsCmd *get_RemoveOpenThreatsCmd (void) = 0;
+
+ protected:
+ /// Pointer to Planner object.
+ SA_POP::Planner *planner_;
+
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_PLAN_STRATEGY_H_ */
diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp
new file mode 100644
index 00000000000..783e2506eaa
--- /dev/null
+++ b/SA_POP/Planner.cpp
@@ -0,0 +1,459 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file Planner.cpp
+ *
+ * This file contains the Planner abstract base class implementation for planners,
+ * which direct planning and mediate communication between other planning
+ * objects.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <string>
+#include <set>
+#include <stdlib.h>
+#include <fstream>
+#include "SA_POP_Types.h"
+#include "Planner.h"
+#include "PlanStrategy.h"
+#include "SchedStrategy.h"
+#include "WorkingPlan.h"
+#include "TaskMap.h"
+#include "OutAdapter.h"
+#include "PlanCommands.h"
+
+using namespace SA_POP;
+
+// Constructor.
+Planner::Planner (void)
+: cond_prob_thresh_ (0.9),
+has_objs_ (false),
+sanet_ (0),
+plan_strat_ (0),
+sched_strat_ (0),
+working_plan_ (0),
+task_map_ (0),
+cur_cmd_ (0)
+{
+ this->out_adapters_.clear ();
+ this->eu_changes_.clear ();
+
+ // Clear plan.
+ this->plan_.causal_links.clear ();
+ this->plan_.connections.clear ();
+ this->plan_.sched_links.clear ();
+ this->plan_.task_insts.clear ();
+ this->plan_.threat_links.clear ();
+};
+
+
+/// Destructor.
+Planner::~Planner (void)
+{
+ delete this->sanet_;
+ delete this->plan_strat_;
+ delete this->sched_strat_;
+ delete this->working_plan_;
+ delete this->task_map_;
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****
+ // Delete output adapters??????
+}
+
+
+
+// Add planning objects.
+void Planner::set_objects (SANet::Network *sanet, PlanStrategy *plan_strat,
+SchedStrategy *sched_strat, WorkingPlan *working_plan, TaskMap *task_map)
+{
+ this->has_objs_ = true;
+
+ if (sanet != 0)
+ this->sanet_ = sanet;
+ else if (this->sanet_ == 0)
+ this->has_objs_ = false;
+
+ if (plan_strat != 0)
+ this->plan_strat_ = plan_strat;
+ else if (this->plan_strat_ == 0)
+ this->has_objs_ = false;
+
+ if (sched_strat != 0)
+ this->sched_strat_ = sched_strat;
+ else if (this->sched_strat_ == 0)
+ this->has_objs_ = false;
+
+ if (working_plan != 0)
+ this->working_plan_ = working_plan;
+ else if (this->working_plan_ == 0)
+ this->has_objs_ = false;
+
+ if (task_map != 0)
+ this->task_map_ = task_map;
+ else if (this->task_map_ == 0)
+ this->has_objs_ = false;
+};
+
+// Add output adapter.
+void Planner::add_out_adapter (OutAdapter *out)
+{
+ this->out_adapters_.insert (out);
+};
+
+// Run planning.
+bool Planner::plan (size_t sa_max_steps)
+{
+ this->sanet_->update (sa_max_steps);
+ std::ofstream fout("output.txt");
+ this->sanet_->print(fout,true);
+ fout.close();
+ this->plan_strat_->set_goals (this->sanet_->get_goals ());
+ if (this->plan_strat_->satisfy_open_conds ()) {
+ this->plan_ = this->working_plan_->get_plan ();
+ this->notify_plan_changed ();
+ return true;
+ }
+
+ return false;
+};
+
+// Get current plan.
+const Plan& Planner::get_plan (void)
+{
+ return this->plan_;
+};
+
+// Get last set of expected utility changes.
+const TaskEUMap& Planner::get_eu_changes (void)
+{
+ return this->eu_changes_;
+};
+
+// Print network.
+void Planner::print_sanet (std::basic_ostream<char, std::char_traits<char> >& strm,
+ bool verbose)
+{
+ this->sanet_->print (strm, verbose);
+}
+
+// Recursively plan (satisfy all open conditions & schedule constraints).
+bool Planner::recurse_plan (void)
+{
+ return this->plan_strat_->satisfy_open_conds ();
+};
+
+// Recursively schedule (satisfy schedule constraints and continue
+// recursive planning).
+bool Planner::recurse_sched (TaskInstID task_inst)
+{
+ return this->sched_strat_->satisfy_sched (task_inst);
+};
+
+// Satisfy scheduling constraints in fully instantiated plan (no
+// recursive call backs).
+bool Planner::full_sched ()
+{
+ return this->sched_strat_->satisfy_full_sched ();
+};
+
+// Execute a command (adding it as the current command).
+void Planner::execute_command (PlanCommand *command)
+{
+ command->set_prev (this->cur_cmd_);
+ this->cur_cmd_ = command;
+ this->cur_cmd_->execute_next ();
+};
+
+// Undo and remove command.
+void Planner::undo_command (CommandID id)
+{
+ if (this->cur_cmd_->get_id () != id)
+ this->undo_through (id);
+
+ if (this->cur_cmd_ == 0) {
+ char char_buf[35];
+ sprintf(char_buf, "%d.%d.%d", id.step, id.decision_pt, id.seq_num);
+ std::string msg = "Planner::undo_command (): no command history ";
+ msg += "(command id ";
+ msg += char_buf;
+ msg += ")";
+ throw msg;
+ }
+
+ this->cur_cmd_->undo ();
+ this->cur_cmd_ = this->cur_cmd_->get_prev ();
+};
+
+// Add a command to be executed later with execute_next().
+void Planner::add_command (PlanCommand *command)
+{
+ command->set_prev (this->cur_cmd_);
+ this->cur_cmd_ = command;
+};
+
+// On current command, undo last execution (if any) & execute next option.
+bool Planner::try_next (CommandID id)
+{
+ if (this->cur_cmd_->get_id () != id) {
+ char char_buf[35];
+ sprintf(char_buf, "%d.%d.%d", id.step, id.decision_pt, id.seq_num);
+ std::string msg = "Planner::try_next (): command id ";
+ msg += char_buf;
+ msg += " is not current command in history.";
+ throw msg;
+ }
+
+ return this->cur_cmd_->execute_next ();
+};
+
+// Undo and remove all commands back to specified point.
+void Planner::undo_through (CommandID id)
+{
+ if (this->cur_cmd_ == 0) {
+ char char_buf[35];
+ sprintf(char_buf, "%d.%d.%d", id.step, id.decision_pt, id.seq_num);
+ std::string msg = "Planner::undo_through (): command id ";
+ msg += char_buf;
+ msg += " could not be found.";
+ throw msg;
+ }
+
+ if (this->cur_cmd_->get_id () == id)
+ return;
+
+ PlanCommand *temp = this->cur_cmd_;
+ temp->undo ();
+ this->cur_cmd_ = temp->get_prev ();
+ this->undo_through (id);
+};
+/// Get the current command id.
+CommandID Planner::cur_command_id()
+{
+ return this->cur_cmd_->get_id();
+}
+
+// Update a condition's current value (probability of being true).
+void Planner::update_cond_val (CondID cond_id, double true_prob)
+{
+ this->sanet_->update_cond_val (cond_id, true_prob);
+};
+
+// Update a condition's (goal) utility.
+void Planner::update_cond_util (CondID cond_id, double utility)
+{
+ this->sanet_->update_cond_util (cond_id, utility);
+};
+
+// Update all condition utilities based on new goal set.
+void Planner::update_goals (GoalMap goals)
+{
+ this->sanet_->update_goals (goals);
+};
+
+// Get a condition's current value (probability of being true).
+double Planner::get_cond_val (CondID cond_id)
+{
+ return this->sanet_->get_cond_val (cond_id);
+};
+
+// Get all goals.
+const GoalMap& Planner::get_goals (void)
+{
+ return this->sanet_->get_goals ();
+};
+
+// Get a task's name.
+std::string Planner::get_task_name (TaskID task_id)
+{
+ return this->sanet_->get_task_name (task_id);
+};
+
+// Get a condition's name.
+std::string Planner::get_cond_name (CondID cond_id)
+{
+ return this->sanet_->get_cond_name (cond_id);
+};
+
+// Get a condition's type/kind.
+CondKind Planner::get_cond_type (CondID cond_id)
+{
+ return this->sanet_->get_cond_type (cond_id);
+};
+
+// Get a task's current expected utility.
+double Planner::get_task_current_eu (TaskID task_id)
+{
+ return this->sanet_->get_task_current_eu (task_id);
+};
+
+// Get a task's future expected utility.
+double Planner::get_task_future_eu (TaskID task_id)
+{
+ return this->sanet_->get_task_future_eu (task_id);
+};
+
+// Get all preconditions of a task.
+CondSet Planner::get_preconds (TaskID task_id)
+{
+ return this->sanet_->get_preconds (task_id);
+};
+
+// Get currently unsatisfied preconditions of a task.
+CondSet Planner::get_unsat_preconds (TaskID task_id)
+{
+ CondSet temp = this->get_preconds (task_id);
+
+ // Remove satisfied preconditions.
+ for (CondSet::iterator iter = temp.begin ();
+ iter != temp.end (); )
+ {
+ CondSet::iterator prev_iter = iter;
+ iter++;
+
+ // Get current probability of needed value for condition.
+ Probability cur_prob = this->get_cond_val ((*prev_iter).id);
+ if (!(*prev_iter).value)
+ cur_prob = 1 - cur_prob;
+
+ // Remove condition if probability is greater than threshold.
+ if (cur_prob > this->cond_prob_thresh_)
+ temp.erase (prev_iter);
+ }
+
+ return temp;
+}
+
+
+// Get all effects of a task.
+CondSet Planner::get_effects (TaskID task_id)
+{
+ return this->sanet_->get_effects (task_id);
+};
+
+// Get all tasks that satisfy a condition.
+TaskSet Planner::get_satisfying_tasks (Condition cond)
+{
+ return this->sanet_->get_satisfying_tasks (cond);
+};
+
+// Get ports for a causal link.
+LinkPorts Planner::get_clink_ports (TaskID task1_id, CondID cond_id,
+ TaskID task2_id)
+{
+ return this->sanet_->get_clink_ports(task1_id, cond_id, task2_id);
+};
+
+// Get task id of a task instance.
+TaskID Planner::get_task_from_inst (TaskInstID inst_id)
+{
+ return this->working_plan_->get_task_from_inst (inst_id);
+};
+
+// Get all current causal link threats.
+CLThreatSet Planner::get_all_threats (void)
+{
+ return this->working_plan_->get_all_threats ();
+};
+
+// Get all implementations of a task.
+TaskImplSet Planner::get_all_impls (TaskID task_id)
+{
+ return this->task_map_->get_all_impls (task_id);
+};
+
+// Get task implementation.
+TaskImpl *Planner::get_impl (TaskImplID impl_id)
+{
+ return this->task_map_->get_impl (impl_id);
+};
+
+// Get utilization info of a task implementation for a resource.
+ResourceValue Planner::get_resource_usage (TaskImplID impl_id,
+ResourceID resource_id)
+{
+ return this->task_map_->get_resource_usage (impl_id, resource_id);
+};
+
+// Get all resources used by a task implementation.
+ResourceMap Planner::get_all_resources (TaskImplID impl_id)
+{
+ return this->task_map_->get_all_resources (impl_id);
+};
+
+void Planner::notify_plan_changed (void)
+{
+ for (std::set<OutAdapter *>::iterator iter = this->out_adapters_.begin ();
+ iter != this->out_adapters_.end (); iter++)
+ {
+ (*iter)->notify_plan (this);
+ }
+};
+
+/// 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)
+{
+ return this->working_plan_->get_prec_set(task_inst,prec_rel);
+}
+
+/// Get the Start Window of the Task instance
+TimeWindow Planner::get_start_window (TaskInstID task_inst)
+{
+ return this->working_plan_->get_start_window(task_inst);
+}
+
+/// Get the End Window of the Task instance
+TimeWindow Planner::get_end_window (TaskInstID task_inst)
+{
+ return this->working_plan_->get_end_window(task_inst);
+}
+
+/// Get task implementation id of a task instance.
+TaskImplID Planner::get_task_impl_from_inst (TaskInstID inst_id)
+{
+ return this->working_plan_->get_task_impl_from_inst(inst_id);
+}
+
+/// Get the capacity of a resource.
+ResourceValue Planner::get_capacity (ResourceID res_id)
+{
+ return this->task_map_->get_capacity(res_id);
+}
+
+//Get the duration of a task instance
+TimeValue Planner::get_duration(TaskInstID task_inst)
+{
+ return this->working_plan_->get_duration(task_inst);
+}
+/// Get the Causal and Scheduling orderings from this task instance
+TaskInstSet Planner::after_orderings (TaskInstID inst_id)
+{
+ return this->working_plan_->after_orderings(inst_id);
+}
+
+/// Get the Causal and Scheduling orderings to this task instance
+TaskInstSet Planner::before_orderings (TaskInstID inst_id)
+{
+ return this->working_plan_->before_orderings(inst_id);
+}
+
+/// Get all the task instances
+TaskInstSet Planner::get_all_insts()
+{
+ return this->working_plan_->get_all_insts();
+}
+
+/// Check if the instance id already exists and is being reused.
+bool Planner::inst_exists (TaskInstID task_inst)
+{
+ return this->working_plan_->inst_exists(task_inst);
+}
+
+/// Get task implementation for a task instance.
+TaskImplID Planner::get_impl_id (TaskInstID task_inst)
+{
+ return this->working_plan_->get_impl_id(task_inst);
+}
diff --git a/SA_POP/Planner.h b/SA_POP/Planner.h
new file mode 100644
index 00000000000..1a904158c89
--- /dev/null
+++ b/SA_POP/Planner.h
@@ -0,0 +1,511 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file Planner.h
+ *
+ * This file contains the Planner abstract base class definition for planners,
+ * which direct planning and mediate communication between other planning
+ * objects.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_PLANNER_H_
+#define SA_POP_PLANNER_H_
+
+
+#include <string>
+#include <set>
+#include "SA_POP_Types.h"
+#include "PlanStrategy.h"
+#include "SchedStrategy.h"
+#include "WorkingPlan.h"
+#include "TaskMap.h"
+#include "OutAdapter.h"
+#include "PlanCommands.h"
+#include "SANet/SANet.h"
+
+namespace SA_POP {
+
+ /**
+ * @class Planner
+ *
+ * @brief Abstract base class for planners, which direct planning and
+ * mediate communication between other planning objects.
+ */
+ class Planner {
+ public:
+ /// Constructor.
+ Planner (void);
+
+ /// Destructor.
+ virtual ~Planner (void);
+
+
+
+ // ************************************************************************
+ // Initialization methods.
+ // ************************************************************************
+
+ /// Add planning objects.
+ /**
+ * @param sanet Spreading activation network.
+ *
+ * @param plan_strat PlanStrategy object for planning.
+ *
+ * @param sched_strat SchedStrategy object for scheduling.
+ *
+ * @param working_plan WorkingPlan object for holding plan in progress.
+ *
+ * @param task_map TaskMap object for associating tasks with
+ * implementations and resources.
+ */
+ virtual void set_objects (SANet::Network *sanet, PlanStrategy *plan_strat,
+ SchedStrategy *sched_strat, WorkingPlan *working_plan,
+ TaskMap *task_map);
+
+ /// Add output adapter.
+ /**
+ * @param out OutAdapter to add.
+ */
+ virtual void add_out_adapter (OutAdapter *out);
+
+
+
+ // ************************************************************************
+ // Planning and changed planning info accessor methods.
+ // ************************************************************************
+
+ /// Run planning.
+ /**
+ * @param sa_max_steps Maximum steps to run spreading activation.
+ *
+ * @return True if planning succeeded, false otherwise.
+ */
+ virtual bool plan (size_t sa_max_steps);
+
+ /// Get current plan.
+ /**
+ * @return Reference to current plan.
+ */
+ virtual const Plan& get_plan (void);
+
+ /// Get last set of expected utility changes.
+ /**
+ * @return Reference to last set of expected utility changes.
+ */
+ virtual const TaskEUMap& get_eu_changes (void);
+
+ /// Print network.
+ /**
+ * @param strm Output stream on which to print network representation.
+ *
+ * @param verbose Whether to print verbose representation.
+ */
+ virtual void print_sanet (std::basic_ostream<char, std::char_traits<char> >& strm
+ = std::cout, bool verbose = false);
+
+
+
+ // ************************************************************************
+ // Recursive planning/scheduling methods.
+ // ************************************************************************
+
+ /// Recursively plan (satisfy all open conditions & schedule constraints).
+ /**
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool recurse_plan (void);
+
+ /// Recursively schedule (satisfy schedule constraints and continue
+ /// recursive planning).
+ /**
+ * @param task_inst Current task instance being tried in the plan.
+ *
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool recurse_sched (TaskInstID task_inst);
+
+ /// Satisfy scheduling constraints in fully instantiated plan (no
+ /// recursive call backs).
+ /**
+ * @param task_inst Current task instance being tried in the plan.
+ *
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool full_sched ();
+
+
+
+ // ************************************************************************
+ // Planning/scheduling command execution and undo methods.
+ // ************************************************************************
+
+ /// Execute a command (adding it as the current command).
+ /**
+ * @param command The command to add and execute.
+ */
+ virtual void execute_command (PlanCommand *command);
+
+ /// Undo and remove command.
+ /**
+ * @param id The id of the command to undo and remove.
+ *
+ * @exception InvalidCommand The id provided does not correspond to top
+ * command.
+ */
+ virtual void undo_command (CommandID id);
+
+ /// Add a command to be executed later with execute_next().
+ /**
+ * @param command The command to add for execution.
+ */
+ virtual void add_command (PlanCommand *command);
+
+ /// On current command, undo last execution (if any) & execute next option.
+ /**
+ * @param id The id of the command to undo and remove.
+ *
+ * @exception InvalidCommand The id provided does not correspond to top
+ * command.
+ *
+ * @return True if command had an option to execute, false otherwise.
+ */
+ virtual bool try_next (CommandID id);
+
+ /// Undo and remove all commands back to specified point.
+ /**
+ * @param id The id of the command to undo and remove through.
+ */
+ virtual void undo_through (CommandID id);
+
+ /// Get the current command id.
+ /**
+ * @return The id of the current command
+ */
+ virtual CommandID cur_command_id();
+
+
+ // ************************************************************************
+ // Condition update methods (environment/system state or goal changes).
+ // ************************************************************************
+
+ /// Update a condition's current value (probability of being true).
+ /**
+ * @param cond_id The condition id.
+ *
+ * @param true_prob New probability that condition is true.
+ */
+ virtual void update_cond_val (CondID cond_id, double true_prob);
+
+ /// Update a condition's (goal) utility.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @param utility New goal utility of condition.
+ */
+ virtual void update_cond_util (CondID cond_id, double utility);
+
+ /// Update all condition utilities based on new goal set.
+ /**
+ * @param goals Set of goal condition ids and associated utilities.
+ */
+ virtual void update_goals (GoalMap goals);
+
+
+
+ // ************************************************************************
+ // General task/condition accessor methods.
+ // ************************************************************************
+
+ /// Get a condition's current value (probability of being true).
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Probability that condition is true.
+ */
+ virtual double get_cond_val (CondID cond_id);
+
+ /// Get all goals.
+ /**
+ * @return Set of condition ids and associated utilities.
+ */
+ virtual const GoalMap& get_goals (void);
+
+ /// Get a task's name.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Task name.
+ */
+ virtual std::string get_task_name (TaskID task_id);
+
+ /// Get a condition's name.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Condition name.
+ */
+ virtual std::string get_cond_name (CondID cond_id);
+
+ /// Get a condition's type/kind.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Condition type.
+ */
+ virtual CondKind get_cond_type (CondID cond_id);
+
+ /// Get a task's current expected utility.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Current task expected utility.
+ */
+ virtual double get_task_current_eu (TaskID task_id);
+
+ /// Get a task's future expected utility.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Future task expected utility.
+ */
+ virtual double get_task_future_eu (TaskID task_id);
+
+ /// Get all preconditions of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Set of all preconditions with associated values.
+ */
+ virtual CondSet get_preconds (TaskID task_id);
+
+ /// Get currently unsatisfied preconditions of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Set of all unsatisfied preconditions with associated values.
+ */
+ virtual CondSet get_unsat_preconds (TaskID task_id);
+
+ /// Get all effects of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Set of all effects with associated values.
+ */
+ virtual CondSet get_effects (TaskID task_id);
+
+ /// Get all tasks that satisfy a condition.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Set of all tasks that satisfy the given condition.
+ */
+ virtual TaskSet get_satisfying_tasks (Condition cond);
+
+ /// Get ports for a causal link.
+ /**
+ * @param task1_id ID of start task node in causal link.
+ *
+ * @param cond_id ID of condition node in both precondition and effect
+ * links.
+ *
+ * @param task2_id ID of end task node in causal link.
+ */
+ virtual LinkPorts get_clink_ports (TaskID task1_id, CondID cond_id,
+ TaskID task2_id);
+
+
+
+ // ************************************************************************
+ // Planning task/condition info accessor methods.
+ // ************************************************************************
+
+ /// Get task id of a task instance.
+ /**
+ * @param inst_id The task instance id.
+ *
+ * @return The task id of this task instance.
+ */
+ virtual TaskID get_task_from_inst (TaskInstID inst_id);
+
+ /// Get all current causal link threats.
+ /**
+ * @return Set of all current causal link threats.
+ */
+ virtual CLThreatSet get_all_threats (void);
+
+
+
+ // ************************************************************************
+ // TaskMap accessor methods (resources, task->implementations,
+ // and implementation->resources).
+ // ************************************************************************
+
+ /// Get all implementations of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return The set of all implementations (ids) for the given task.
+ */
+ virtual TaskImplSet get_all_impls (TaskID task_id);
+
+ /// Get task implementation.
+ /**
+ * @param impl_id The task implementation id.
+ *
+ * @return Reference to the task implementation.
+ */
+ virtual TaskImpl *get_impl (TaskImplID impl_id);
+
+ /// Get utilization info of a task implementation for a resource.
+ /**
+ * @param impl_id The task implementation id.
+ *
+ * @param resource_id The resource id.
+ *
+ * @return The quantity of resource used.
+ */
+ virtual ResourceValue get_resource_usage (TaskImplID impl_id,
+ ResourceID resource_id);
+
+ /// Get all resources used by a task implementation.
+ /**
+ * @param impl_id The task implementation id.
+ *
+ * @return The set of all resources used (with associated usage values).
+ */
+ virtual ResourceMap get_all_resources (TaskImplID impl_id);
+
+ // ************************************************************************
+ // Scheduling Precedence Graph/Time Windows/Resources accessor methods.
+ // ************************************************************************
+
+
+ /// Get the Task instances in a particular set of the specified task instance
+ /**
+ * @param task_inst The Task Instance whose Precedence Set has been queried
+ *
+ * @param prec_rel The Precedence relation to the task_inst
+ *
+ * @return A pointer to the Task Instance Set that has the relation prec_rel to task_inst
+ */
+ virtual const TaskInstSet* get_prec_insts (TaskInstID task_inst, PrecedenceRelation prec_rel);
+
+ /// Get the Start Window of the Task instance
+ /**
+ * @param task_inst The Task Instance whose Start Window is required
+ *
+ * @return The Start Window of task_inst
+ */
+ virtual TimeWindow get_start_window (TaskInstID task_inst);
+
+ /// Get the End Window of the Task instance
+ /**
+ * @param task_inst The Task Instance whose End Window is required
+ *
+ * @return The End Window of task_inst
+ */
+ virtual TimeWindow get_end_window (TaskInstID task_inst);
+
+ //Get the duration of a task instance
+ /**
+ * @param task_inst The task instance of which the duration is returned
+ *
+ * @return The duration of the task instance
+ */
+ virtual TimeValue get_duration(TaskInstID task_inst);
+
+ /// Get task implementation id of a task instance.
+ /**
+ * @param inst_id The task instance id.
+ *
+ * @return The task implementation id of this task instance.
+ */
+ /// Get task implementation id of a task instance.
+ virtual TaskImplID get_task_impl_from_inst (TaskInstID inst_id);
+
+ /// Get the capacity of a resource.
+ /**
+ * @param res_id The resource id whose capacity that we want to get.
+ *
+ * @return The capacity of the resource
+ */
+ virtual ResourceValue get_capacity (ResourceID res_id);
+
+ /// Get the Causal and Scheduling orderings to this task instance
+ /**
+ * @param inst_id The task instance to which all orderings are required
+ */
+ virtual TaskInstSet before_orderings (TaskInstID inst_id);
+
+ /// Get the Causal and Scheduling orderings from this task instance
+ /**
+ * @param inst_id The task instance from which all orderings are required
+ */
+ virtual TaskInstSet after_orderings (TaskInstID inst_id);
+
+ /// Get all the task instances
+ virtual TaskInstSet get_all_insts();
+
+ /// Check if the instance id already exists and is being reused.
+ /**
+ * @param task_inst The task instance being checked
+ *
+ * @return True If this task instance already exists.
+ */
+ virtual bool inst_exists (TaskInstID task_inst);
+
+ /// Get task implementation for a task instance.
+ /**
+ * @param task_inst The task instance.
+ *
+ * @return The task implementation id.
+ */
+ virtual TaskImplID get_impl_id (TaskInstID task_inst);
+
+ protected:
+ /// Threshold for current probability of a condition to be satisfied.
+ const Probability cond_prob_thresh_;
+
+ /// Flag for whether planning objects have been set.
+ bool has_objs_;
+
+ /// Spreading activation network.
+ SANet::Network *sanet_;
+
+ /// PlanStrategy object for planning.
+ PlanStrategy *plan_strat_;
+
+ /// SchedStrategy object for scheduling.
+ SchedStrategy *sched_strat_;
+
+ /// WorkingPlan object for holding plan in progress.
+ WorkingPlan *working_plan_;
+
+ /// TaskMap object for associating tasks with implementations and resources.
+ TaskMap *task_map_;
+
+ /// OutAdapter objects.
+ std::set <OutAdapter *> out_adapters_;
+
+ /// Current complete plan.
+ Plan plan_;
+
+ /// Last set of expected utility changes.
+ TaskEUMap eu_changes_;
+
+ /// Current command.
+ PlanCommand *cur_cmd_;
+
+ /// Notify all output adapters that plans have changed.
+ virtual void notify_plan_changed (void);
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_PLANNER_H_ */
diff --git a/SA_POP/SANet/SANet.cpp b/SA_POP/SANet/SANet.cpp
new file mode 100644
index 00000000000..e46f0d94f23
--- /dev/null
+++ b/SA_POP/SANet/SANet.cpp
@@ -0,0 +1,476 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file SANet.cpp
+ *
+ * This file contains the Network class implementation for spreading
+ * activation networks.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <map>
+#include <iostream>
+#include "SANet_Types.h"
+#include "SANet.h"
+#include "SANode.h"
+#include "SANet_Exceptions.h"
+
+#if !defined (SANET_STANDALONE)
+#include "SA_POP_Types.h"
+#endif /* SANET_STANDALONE not defined */
+
+using namespace SANet;
+
+
+SANet::Network::Network (void)
+: step_ (0)
+{
+ // Clear maps.
+ this->task_nodes_.clear ();
+ this->cond_nodes_.clear ();
+ this->precond_links_.clear ();
+ this->effect_links_.clear ();
+ this->goals_.clear ();
+};
+
+SANet::Network::~Network ()
+{
+ // Deallocate task nodes.
+ for (TaskNodeMap::iterator node_iter = task_nodes_.begin ();
+ node_iter != task_nodes_.end (); node_iter++)
+ {
+ delete node_iter->second;
+ }
+
+ // Deallocate condition nodes.
+ for (CondNodeMap::iterator node_iter = cond_nodes_.begin ();
+ node_iter != cond_nodes_.end (); node_iter++)
+ {
+ delete node_iter->second;
+ }
+};
+
+void SANet::Network::add_task (TaskID ID, std::string name, MultFactor atten_factor,
+ TaskCost cost, Probability prior_prob)
+{
+ // If this ID has already been used, throw exception.
+ if (task_nodes_.find (ID) != task_nodes_.end ()) {
+ throw Duplicate_ID ();
+ }
+ if (cond_nodes_.find (ID) != cond_nodes_.end ()) {
+ throw Duplicate_ID ();
+ }
+
+ // Task node pointer.
+ TaskNode *node;
+
+ // Add task node, throwing exception if insertion fails.
+ node = new TaskNode (ID, name, atten_factor, cost, prior_prob);
+ if (!(task_nodes_.insert (std::make_pair (ID, node))).second)
+ {
+ throw Insertion_Error ();
+ }
+};
+
+
+void SANet::Network::add_cond (CondID ID, std::string name, MultFactor atten_factor,
+ Probability true_prob, Probability false_prob,
+ Utility goal_util, CondKind cond_kind)
+{
+ // If this ID has already been used, throw exception.
+ if (task_nodes_.find (ID) != task_nodes_.end ()) {
+ throw Duplicate_ID ();
+ }
+ if (cond_nodes_.find (ID) != cond_nodes_.end ()) {
+ throw Duplicate_ID ();
+ }
+
+ // Condition node pointer.
+ CondNode *node;
+
+ // Add condition node, throwing exception if insertion fails.
+ node = new CondNode (ID, name, atten_factor,
+ true_prob, false_prob, goal_util, cond_kind);
+ if (!(cond_nodes_.insert (std::make_pair (ID, node))).second)
+ {
+ throw Insertion_Error ();
+ }
+
+ if (goal_util != 0)
+ this->goals_.insert (std::make_pair (ID, goal_util));
+};
+
+void SANet::Network::add_precond_link (CondID cond_ID, TaskID task_ID,
+ Probability true_prob, Probability false_prob,
+ PortID port_ID)
+{
+ // Find task node pointer, throwing exception if not found.
+ TaskNodeMap::iterator task_iter = task_nodes_.find (task_ID);
+ if (task_iter == task_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+ TaskNode *task_node = task_iter->second;
+
+ // Find condition node pointer, throwing exception if not found.
+ CondNodeMap::iterator cond_iter = cond_nodes_.find (cond_ID);
+ if (cond_iter == cond_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+ CondNode *cond_node = cond_iter->second;
+
+ // Add link to task node.
+ task_node->add_precond (cond_ID, cond_node, true_prob, false_prob);
+
+ // Add link to port map.
+ this->precond_links_.insert (std::make_pair (std::make_pair (cond_ID,
+ task_ID), port_ID));
+};
+
+void SANet::Network::add_effect_link (TaskID task_ID, CondID cond_ID,
+ LinkWeight weight, PortID port_ID)
+{
+ // Find task node pointer, throwing exception if not found.
+ TaskNodeMap::iterator task_iter = task_nodes_.find (task_ID);
+ if (task_iter == task_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+ TaskNode *task_node = task_iter->second;
+
+ // Find condition node pointer, throwing exception if not found.
+ CondNodeMap::iterator cond_iter = cond_nodes_.find (cond_ID);
+ if (cond_iter == cond_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+ CondNode *cond_node = cond_iter->second;
+
+ // Add link.
+ task_node->add_effect (cond_ID, cond_node, weight);
+
+ // Add link to port map.
+ this->effect_links_.insert (std::make_pair (std::make_pair (task_ID,
+ cond_ID), port_ID));
+};
+
+void SANet::Network::print (std::basic_ostream<char, std::char_traits<char> >& strm,
+ bool verbose)
+{
+ // Print current step.
+ strm << "Current Step: " << step_ << std::endl << std::endl;
+
+ // Print all task nodes.
+ for (TaskNodeMap::iterator node_iter = task_nodes_.begin ();
+ node_iter != task_nodes_.end (); node_iter++)
+ {
+ node_iter->second->print (strm, verbose);
+ strm << std::endl;
+ }
+
+ // Print all condition nodes.
+ for (CondNodeMap::iterator node_iter = cond_nodes_.begin ();
+ node_iter != cond_nodes_.end (); node_iter++)
+ {
+ node_iter->second->print (strm, verbose);
+ strm << std::endl;
+ }
+ strm << std::endl;
+};
+
+// Print links and ports.
+void SANet::Network::print_link_ports (std::basic_ostream<char,
+ std::char_traits<char> >& strm,
+ bool verbose)
+{
+
+ // Print all precondition links.
+ strm << "Precondition Links: " << std::endl;
+ for (PrecondLinkPortMap::iterator precond_iter = precond_links_.begin ();
+ precond_iter != precond_links_.end (); precond_iter++)
+ {
+ strm << " " << "Cond " << precond_iter->first.first;
+ strm << " -> " << "Task " << precond_iter->first.second << "(";
+ strm << precond_iter->second << ")" << std::endl;
+ }
+
+ // Print all effect links.
+ strm << "Effect Links: " << std::endl;
+ for (EffectLinkPortMap::iterator effect_iter = effect_links_.begin ();
+ effect_iter != effect_links_.end (); effect_iter++)
+ {
+ strm << " " << "Task " << effect_iter->first.first << "(";
+ strm << effect_iter->second << ") -> " << "Cond ";
+ strm << effect_iter->first.second << std::endl;
+ }
+ strm << std::endl;
+};
+
+void SANet::Network::update (int max_steps)
+{
+ // Flag for whether network changed on last step, initially true.
+ bool net_changed = true;
+
+ // Set step limit.
+ int step_limit = step_ + max_steps;
+
+ // Run spreading activation until step limit is reached or no changes made.
+ while (net_changed && (step_ < step_limit)) {
+ // Update step.
+ step_++;
+
+ // Reset net_changed flag.
+ net_changed = false;
+
+#if defined (SANET_DEBUG)
+ std::cout << std::endl << "DEBUG in SANet::Network::update()... step_=" << step_ << std::endl << std::endl;
+#endif /* SANET_DEBUG */
+ // Update all task nodes.
+ for (TaskNodeMap::iterator node_iter = task_nodes_.begin ();
+ node_iter != task_nodes_.end (); node_iter++)
+ {
+ // Update node, setting net_changed flag if node changed.
+ if (node_iter->second->update ()) {
+ net_changed = true;
+ }
+ }
+
+ // Update all condition nodes.
+ for (CondNodeMap::iterator node_iter = cond_nodes_.begin ();
+ node_iter != cond_nodes_.end (); node_iter++)
+ {
+ // Update node, setting net_changed flag if node changed.
+ if (node_iter->second->update ()) {
+ net_changed = true;
+ }
+ }
+ }
+};
+
+// Update a condition's current value (probability of being true).
+void SANet::Network::update_cond_val (CondID cond_id, Probability true_prob)
+{
+ CondNodeMap::iterator iter = this->cond_nodes_.find (cond_id);
+ if (iter == this->cond_nodes_.end ())
+ throw "SANet::Network::update_cond_val (): Unknown condition node.";
+ iter->second->set_init_prob (true_prob);
+};
+
+// Update a condition's (goal) utility.
+void SANet::Network::update_cond_util (CondID cond_id, Probability utility)
+{
+ // ****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ throw "Plan monitoring/updating/replanning not yet implemented: SANet::SANet::Network::updated_cond_val ().";
+};
+
+// Update all condition utilities based on new goal set.
+void SANet::Network::update_goals (GoalMap goals)
+{
+ // ****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ throw "Plan monitoring/updating/replanning not yet implemented: SANet::SANet::Network::update_goals ().";
+};
+
+// Get a condition's current value (probability of being true).
+Probability SANet::Network::get_cond_val (CondID cond_id)
+{
+ 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_init_prob ();
+};
+
+// Get all goals.
+const GoalMap& SANet::Network::get_goals (void)
+{
+ return this->goals_;
+};
+
+// Get a task's name.
+std::string SANet::Network::get_task_name (TaskID task_id)
+{
+ // Find task node.
+ TaskNodeMap::iterator task_iter = task_nodes_.find (task_id);
+ if (task_iter == task_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+
+ return task_iter->second->get_name ();
+};
+
+// Get a condition's name.
+std::string SANet::Network::get_cond_name (CondID cond_id)
+{
+ // Find condition node.
+ CondNodeMap::iterator cond_iter = cond_nodes_.find (cond_id);
+ if (cond_iter == cond_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+
+ return cond_iter->second->get_name ();
+};
+
+// Get a condition's type/kind.
+CondKind SANet::Network::get_cond_type (CondID cond_id)
+{
+ // Find condition node.
+ CondNodeMap::iterator cond_iter = cond_nodes_.find (cond_id);
+ if (cond_iter == cond_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+
+ return cond_iter->second->get_cond_kind ();
+};
+
+// Get a task's current expected utility.
+Utility SANet::Network::get_task_current_eu (TaskID task_id)
+{
+ // ****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ throw "Plan monitoring/updating/replanning not yet implemented: SANet::SANet::Network::get_task_current_eu ().";
+};
+
+// Get a task's future expected utility.
+Utility SANet::Network::get_task_future_eu (TaskID task_id)
+{
+ TaskNodeMap::iterator task_iter = task_nodes_.find (task_id);
+ if (task_iter == task_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+ return task_iter->second->get_utility (this->step_);
+};
+
+// Get all preconditions of a task.
+CondSet SANet::Network::get_preconds (TaskID task_id)
+{
+ // Find task node.
+ TaskNodeMap::iterator task_iter = task_nodes_.find (task_id);
+ if (task_iter == task_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+
+ // Create set of preconditions from pre-nodes set.
+ CondSet preconds;
+ preconds.clear ();
+ LinkMap pre_links = task_iter->second->get_pre ();
+ for (LinkMap::iterator iter = pre_links.begin (); iter != pre_links.end ();
+ iter++)
+ {
+ Condition cond;
+ cond.id = iter->first;
+ CondNode* cond_node = this->cond_nodes_.find(iter->first)->second;
+ cond.kind = cond_node->get_cond_kind();
+
+ if (iter->second > 0)
+ cond.value = true;
+ else
+ cond.value = false;
+ preconds.insert (cond);
+ }
+
+ return preconds;
+};
+
+// Get all effects of a task.
+CondSet SANet::Network::get_effects (TaskID task_id)
+{
+ // Find task node.
+ TaskNodeMap::iterator task_iter = task_nodes_.find (task_id);
+ if (task_iter == task_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+
+ // Create set of effects from pre-nodes set.
+ CondSet effects;
+ effects.clear ();
+ LinkMap post_links = task_iter->second->get_post ();
+ for (LinkMap::iterator iter = post_links.begin (); iter != post_links.end ();
+ iter++)
+ {
+ Condition cond;
+ cond.id = iter->first;
+ // ****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+#if defined (SANET_STANDALONE)
+ cond.kind = SANet::DATA;
+#else // SANET_STANDALONE not defined
+ cond.kind = SA_POP::DATA;
+#endif /* SANET_STANDALONE */
+ // ****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ if (iter->second > 0)
+ cond.value = true;
+ else
+ cond.value = false;
+ effects.insert (cond);
+ }
+
+ return effects;
+};
+
+// Get the duration of a task.
+TimeValue SANet::Network::get_duration (TaskID task_id)
+{
+ TaskNode *temp = this->task_nodes_.find(task_id)->second;
+ return NULL_TIME;
+}
+
+// Get all tasks that satisfy a condition.
+TaskSet SANet::Network::get_satisfying_tasks (Condition cond)
+{
+ // Find condition node.
+ CondNodeMap::iterator cond_iter = this->cond_nodes_.find (cond.id);
+ if (cond_iter == this->cond_nodes_.end ()) {
+ throw UnknownNode ();
+ }
+
+ // Create set of tasks from pre-nodes set.
+ TaskSet tasks;
+ tasks.clear ();
+ LinkMap pre_links = cond_iter->second->get_pre ();
+ for (LinkMap::iterator iter = pre_links.begin (); iter != pre_links.end ();
+ iter++)
+ {
+ // Add tasks with positive link weights for true condition or
+ // tasks with negative link weights for false condition.
+ if (cond.value) {
+ if (iter->second > 0)
+ tasks.insert (iter->first);
+ } else {
+ if (iter->second < 0)
+ tasks.insert (iter->first);
+ }
+ }
+
+ return tasks;
+};
+
+// Get effect link port.
+PortID SANet::Network::get_effect_port (TaskID task_id, CondID cond_id)
+{
+ // Find port, throwing exception if not found.
+ EffectLinkPortMap::iterator iter = this->effect_links_.find (
+ std::make_pair (task_id, cond_id));
+ if (iter == this->effect_links_.end ()) {
+ throw UnknownNode ();
+ }
+
+ return iter->second;
+};
+
+// Get precondition link port.
+PortID SANet::Network::get_precond_port (CondID cond_id, TaskID task_id)
+{
+ // Find port, throwing exception if not found.
+ PrecondLinkPortMap::iterator iter = this->precond_links_.find (
+ std::make_pair (cond_id, task_id));
+ if (iter == this->precond_links_.end ()) {
+ throw UnknownNode ();
+ }
+
+ return iter->second;
+};
+
+// Get ports for a causal link.
+LinkPorts SANet::Network::get_clink_ports (TaskID task1_id, CondID cond_id,
+ TaskID task2_id)
+{
+ return std::make_pair (this->get_effect_port (task1_id, cond_id),
+ this->get_precond_port (cond_id, task2_id));
+};
diff --git a/SA_POP/SANet/SANet.h b/SA_POP/SANet/SANet.h
new file mode 100644
index 00000000000..50a8eb8c98f
--- /dev/null
+++ b/SA_POP/SANet/SANet.h
@@ -0,0 +1,328 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file SANet.h
+ *
+ * This file contains the Network class definition for spreading activation
+ * networks.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_NETWORK_H_
+#define SA_NETWORK_H_
+
+#include <iostream>
+#include <map>
+#include <stdexcept>
+#include "SANet_Types.h"
+#include "SANode.h"
+
+namespace SANet {
+ /// Map from task node ID to pointer.
+ typedef std::map<TaskID, TaskNode *> TaskNodeMap;
+
+ /// Map from condition node ID to pointer.
+ typedef std::map<CondID, CondNode *> CondNodeMap;
+
+ /// Map of precondition links to ports.
+ typedef std::map<PrecondLink, PortID> PrecondLinkPortMap;
+
+ /// Map of effect links to ports.
+ typedef std::map<EffectLink, PortID> EffectLinkPortMap;
+
+ /**
+ * @class Network
+ *
+ * @brief Spreading activation network class.
+ */
+ class Network {
+ public:
+ /// Constructor.
+ Network (void);
+
+ /// Destructor.
+ virtual ~Network ();
+
+
+
+ // ************************************************************************
+ // Network creations methods.
+ // ************************************************************************
+
+ /// Add a new task node to the network.
+ /**
+ * @param ID Node ID.
+ *
+ * @param name Node name.
+ *
+ * @param atten_factor Attenuation factor (to bias toward shorter plans).
+ *
+ * @param cost Cost of performing task.
+ *
+ * @param prior_prob Prior probability of success.
+ */
+ virtual void add_task (TaskID ID, std::string name,
+ MultFactor atten_factor, TaskCost cost, Probability prior_prob);
+
+ /// Add a new condition node to the network.
+ /**
+ * @param ID Node ID.
+ *
+ * @param name Node name.
+ *
+ * @param atten_factor Attenuation factor (to bias toward shorter plans).
+ *
+ * @param true_prob Initial probability that value is true.
+ *
+ * @param false_prob Initial probability that value is false.
+ *
+ * @param cond_kind The type of condition
+ *
+ * @param goal_util Initial utility (positive for goals, zero otherwise).
+ */
+ virtual void add_cond (CondID ID, std::string name,
+ MultFactor atten_factor, Probability true_prob, Probability false_prob,
+ Utility goal_util, CondKind cond_kind);
+
+ /// Add condition to task link.
+ /**
+ * @param cond_ID Condition node ID.
+ *
+ * @param task_ID Task node ID.
+ *
+ * @param true_prob Conditional probability of task success given
+ * condition node = true.
+ *
+ * @param false_prob Conditional probability of task success given
+ * condition node = false.
+ *
+ * @param port_ID ID of port (on task) associated with this condition
+ * (used for data nodes).
+ */
+ virtual void add_precond_link (CondID cond_ID, TaskID task_ID,
+ Probability true_prob, Probability false_prob, PortID port_ID = "");
+
+ /// Add 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 add_effect_link (TaskID task_ID, CondID cond_ID,
+ LinkWeight weight, PortID port_ID = "");
+
+
+
+ // ************************************************************************
+ // Print methods.
+ // ************************************************************************
+
+ /// Print network.
+ /**
+ * @param strm Output stream on which to print network representation.
+ *
+ * @param verbose Whether to print verbose representation.
+ */
+ virtual void print (std::basic_ostream<char, std::char_traits<char> >& strm
+ = std::cout, bool verbose = false);
+
+ /// Print links and ports.
+ /**
+ * @param strm Output stream on which to print network representation.
+ *
+ * @param verbose Whether to print verbose representation.
+ */
+ virtual void print_link_ports (std::basic_ostream<char,
+ std::char_traits<char> >& strm = std::cout, bool verbose = false);
+
+
+
+ // ************************************************************************
+ // Network update methods (spreading activation, environment/system state
+ // changes, and goal changes).
+ // ************************************************************************
+
+ /// Run spreading activation.
+ /**
+ * @param max_steps Maximum steps for which to run spreading activation.
+ */
+ virtual void update (int max_steps);
+
+ /// Update a condition's current value (probability of being true).
+ /**
+ * @param cond_id The condition id.
+ *
+ * @param true_prob New probability that condition is true.
+ */
+ virtual void update_cond_val (CondID cond_id, Probability true_prob);
+
+ /// Update a condition's (goal) utility.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @param utility New goal utility of condition.
+ */
+ virtual void update_cond_util (CondID cond_id, Utility utility);
+
+ /// Update all condition utilities based on new goal set.
+ /**
+ * @param goals Set of goal condition ids and associated utilities.
+ */
+ virtual void update_goals (GoalMap goals);
+
+
+
+ // ************************************************************************
+ // General task/condition accessor methods.
+ // ************************************************************************
+
+ /// Get a task's name.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Task name.
+ */
+ virtual std::string get_task_name (TaskID task_id);
+
+ /// Get a condition's name.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Condition name.
+ */
+ virtual std::string get_cond_name (CondID cond_id);
+
+ /// Get a condition's type/kind.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Condition type.
+ */
+ virtual CondKind get_cond_type (CondID cond_id);
+
+ /// Get a condition's current value (probability of being true).
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Probability that condition is true.
+ */
+ virtual Probability get_cond_val (CondID cond_id);
+
+ /// Get all goals.
+ /**
+ * @return Set of condition ids and associated utilities.
+ */
+ virtual const GoalMap& get_goals (void);
+
+ /// Get a task's current expected utility.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Current task expected utility.
+ */
+ virtual Utility get_task_current_eu (TaskID task_id);
+
+ /// Get a task's future expected utility.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Future task expected utility.
+ */
+ virtual Utility get_task_future_eu (TaskID task_id);
+
+ /// Get all preconditions of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Set of all preconditions with associated values.
+ */
+ virtual CondSet get_preconds (TaskID task_id);
+
+ /// Get all effects of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return Set of all effects with associated values.
+ */
+ virtual CondSet get_effects (TaskID task_id);
+
+ /// Get all tasks that satisfy a condition.
+ /**
+ * @param cond_id The condition id.
+ *
+ * @return Set of all tasks that satisfy the given condition.
+ */
+ virtual TaskSet get_satisfying_tasks (Condition cond);
+
+ /// Get the name of the port associated with a precondition of a task.
+ /**
+ * @param cond_id The precondition id.
+ *
+ * @param task_id The task id.
+ *
+ * @return Port id.
+ */
+ virtual PortID get_precond_port (CondID cond_id, TaskID task_id);
+
+ /// Get the name of the port associated with an effect of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @param cond_id The effect condition id.
+ *
+ * @return Port id.
+ */
+ virtual PortID get_effect_port (TaskID task_id, CondID cond_id);
+
+ /// Get ports for a causal link.
+ /**
+ * @param task1_id ID of start task node in causal link.
+ *
+ * @param cond_id ID of condition node in both precondition and effect
+ * links.
+ *
+ * @param task2_id ID of end task node in causal link.
+ */
+ 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);
+
+ protected:
+ /// 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_;
+
+ /// Goals.
+ GoalMap goals_;
+
+ /// Current step.
+ int step_;
+ };
+};
+
+
+#endif /* SA_NETWORK_H_ */
diff --git a/SA_POP/SANet/SANetFileIn.cpp b/SA_POP/SANet/SANetFileIn.cpp
new file mode 100644
index 00000000000..6105985f440
--- /dev/null
+++ b/SA_POP/SANet/SANetFileIn.cpp
@@ -0,0 +1,219 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SANetFileIn.cpp
+ *
+ * This file contains the SANetFileIn class implementation for the input adapter
+ * that initializes a SANet object using an XML SANet file.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SANet_Types.h"
+#include "SANetFileIn.h"
+
+#if !defined (SANET_STANDALONE)
+#include "Builder.h"
+#endif
+
+#include "Utils/XML_Helper.h"
+#include "XML_SANet.hpp"
+
+using namespace SANet;
+
+// Constructor.
+SANetFileIn::SANetFileIn (void)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+SANetFileIn::~SANetFileIn (void)
+{
+ // Nothing to do.
+};
+
+// Build network from XML file.
+Network *SANetFileIn::build_net (std::string filename)
+{
+ CIAO::Config_Handlers::XML_Helper helper;
+ if (!helper.is_initialized ())
+ return 0;
+
+ // Parse file with Xerces.
+ XERCES_CPP_NAMESPACE::DOMDocument *dom =
+#if defined (SA_POP_HAS_CIAO)
+ helper.create_dom (filename.c_str ());
+#else
+ helper.create_dom (filename.c_str (), "");
+#endif /* SA_POP_HAS_CIAO */
+ if (!dom)
+ return 0;
+
+ SANet::XML::Network xml_net = SANet::XML::network (dom);
+
+ SANet::Network *net = new SANet::Network ();
+
+ // Get task nodes.
+ for (SANet::XML::Network::taskNode_iterator iter = xml_net.begin_taskNode ();
+ iter != xml_net.end_taskNode (); iter++)
+ {
+ TaskID nodeID = (*iter).nodeID ();
+ Probability priorProb = (*iter).priorProb ();
+ MultFactor attenFactor = (*iter).attenFactor ();
+ TaskCost cost = (*iter).cost ();
+// TimeValue dur =
+ char name[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (name, (*iter).name ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ net->add_task (nodeID, name, attenFactor, cost, priorProb);
+ }
+
+ // Get condition nodes.
+ for (SANet::XML::Network::condNode_iterator iter = xml_net.begin_condNode ();
+ iter != xml_net.end_condNode (); iter++)
+ {
+ CondID nodeID = (*iter).nodeID ();
+ Probability probTrue = (*iter).probTrue ();
+ Utility utility = (*iter).utility ();
+ MultFactor attenFactor = (*iter).attenFactor ();
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// CondKind
+ char name[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (name, (*iter).name ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ SANet::XML::CondKind cond_kind = (*iter).kind();
+ ::SA_POP::CondKind cond;
+ if(cond_kind==cond_kind.ENVIRON) cond=::SA_POP::ENVIRON;
+ else if(cond_kind==cond_kind.SYSTEM) cond=::SA_POP::SYSTEM;
+ else cond=::SA_POP::DATA;
+
+ net->add_cond (nodeID, name, attenFactor,
+ probTrue, 1.0 - probTrue, utility, cond);
+ }
+
+ // Get precondition->task links.
+ for (SANet::XML::Network::precondLink_iterator iter = xml_net.begin_precondLink ();
+ iter != xml_net.end_precondLink (); iter++)
+ {
+ CondID condID = (*iter).condID ();
+ TaskID taskID = (*iter).taskID ();
+ Probability trueProb = (*iter).trueProb ();
+ Probability falseProb = (*iter).falseProb ();
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ char portID[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (portID, (*iter).portID ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ net->add_precond_link (condID, taskID, trueProb, falseProb);
+ }
+
+ // Get task->effect links.
+ for (SANet::XML::Network::effectLink_iterator iter = xml_net.begin_effectLink ();
+ iter != xml_net.end_effectLink (); iter++)
+ {
+ TaskID taskID = (*iter).taskID ();
+ CondID condID = (*iter).condID ();
+ Probability weight = (*iter).weight ();
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ char portID[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (portID, (*iter).portID ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ net->add_effect_link (taskID, condID, weight);
+ }
+
+ return net;
+};
+
+#if !defined (SANET_STANDALONE)
+// Build network from XML file.
+void SANetFileIn::build_net (std::string filename, SA_POP::Builder *builder)
+{
+ CIAO::Config_Handlers::XML_Helper helper;
+ if (!helper.is_initialized ())
+ return;
+
+ // Parse file with Xerces.
+ XERCES_CPP_NAMESPACE::DOMDocument *dom =
+#if defined (SA_POP_HAS_CIAO)
+ helper.create_dom (filename.c_str ());
+#else
+ helper.create_dom (filename.c_str (), "");
+#endif /* SA_POP_HAS_CIAO */
+ if (!dom)
+ return;
+
+ SANet::XML::Network xml_net = SANet::XML::network (dom);
+
+ // Get task nodes.
+ for (SANet::XML::Network::taskNode_iterator iter = xml_net.begin_taskNode ();
+ iter != xml_net.end_taskNode (); iter++)
+ {
+ TaskID nodeID = (*iter).nodeID ();
+ Probability priorProb = (*iter).priorProb ();
+ MultFactor attenFactor = (*iter).attenFactor ();
+ TaskCost cost = (*iter).cost ();
+
+ char name[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (name, (*iter).name ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ builder->add_task (nodeID, priorProb, name);
+ }
+
+ // Get condition nodes.
+ for (SANet::XML::Network::condNode_iterator iter = xml_net.begin_condNode ();
+ iter != xml_net.end_condNode (); iter++)
+ {
+ CondID nodeID = (*iter).nodeID ();
+ Probability probTrue = (*iter).probTrue ();
+ Utility utility = (*iter).utility ();
+ MultFactor attenFactor = (*iter).attenFactor ();
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// CondKind
+ char name[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (name, (*iter).name ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+ SANet::XML::CondKind cond_kind = (*iter).kind();
+ SA_POP::CondKind cond;
+ if(cond_kind==cond_kind.ENVIRON) cond=::SA_POP::ENVIRON;
+ else if(cond_kind==cond_kind.SYSTEM) cond=::SA_POP::SYSTEM;
+ else cond=::SA_POP::DATA;
+ builder->add_cond (nodeID, utility, probTrue, name, cond);
+ }
+
+ // Get precondition->task links.
+ for (SANet::XML::Network::precondLink_iterator iter = xml_net.begin_precondLink ();
+ iter != xml_net.end_precondLink (); iter++)
+ {
+ CondID condID = (*iter).condID ();
+ TaskID taskID = (*iter).taskID ();
+ Probability trueProb = (*iter).trueProb ();
+ Probability falseProb = (*iter).falseProb ();
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ char portID[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (portID, (*iter).portID ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ builder->set_precond (condID, taskID, portID, trueProb, falseProb);
+ }
+
+ // Get task->effect links.
+ for (SANet::XML::Network::effectLink_iterator iter = xml_net.begin_effectLink ();
+ iter != xml_net.end_effectLink (); iter++)
+ {
+ TaskID taskID = (*iter).taskID ();
+ CondID condID = (*iter).condID ();
+ Probability weight = (*iter).weight ();
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ char portID[SANet::SANetFileIn::STR_BUF_SIZE];
+ wcstombs (portID, (*iter).portID ().c_str (), SANet::SANetFileIn::STR_BUF_SIZE);
+
+ builder->set_effect (taskID, condID, portID, weight);
+ }
+};
+#endif /* SANET_STANDALONE */
diff --git a/SA_POP/SANet/SANetFileIn.h b/SA_POP/SANet/SANetFileIn.h
new file mode 100644
index 00000000000..97e019644e0
--- /dev/null
+++ b/SA_POP/SANet/SANetFileIn.h
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SANetFileIn.h
+ *
+ * This file contains the SANetFileIn class definition for the input adapter
+ * that initializes a SANet object using an XML SANet file.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SANET_SANET_FILE_IN_H_
+#define SANET_SANET_FILE_IN_H_
+
+#include "SANet_Types.h"
+#include "SANet.h"
+
+#if !defined (SANET_STANDALONE)
+#include "Builder.h"
+#endif
+
+namespace SANet {
+
+ /**
+ * @class SANetFileIn
+ *
+ * @brief Input adapter that initializes a SANet object using an XML
+ * SANet file.
+ */
+ class SANetFileIn {
+ public:
+ /// Constructor.
+ SANetFileIn (void);
+
+ /// Destructor.
+ virtual ~SANetFileIn (void);
+
+ /// Buffer size for string conversion.
+ const static size_t STR_BUF_SIZE = 129;
+
+ /// Create network from XML file.
+ /**
+ * @param filename Name of XML SANet network file.
+ *
+ * @return New SANet network.
+ */
+ virtual Network *build_net (std::string filename);
+
+#if !defined (SANET_STANDALONE)
+ /// Build network from XML file.
+ /**
+ * @param filename Name of XML SANet network file.
+ *
+ * @param builder SA-POP builder to use in building the SANet network.
+ */
+ virtual void build_net (std::string filename, SA_POP::Builder *builder);
+#endif /* SANET_STANDALONE not defined */
+ };
+}; /* SANet namespace */
+
+#endif /* SANET_SANET_FILE_IN_H_ */
diff --git a/SA_POP/SANet/SANet_Exceptions.cpp b/SA_POP/SANet/SANet_Exceptions.cpp
new file mode 100644
index 00000000000..e394a8767f7
--- /dev/null
+++ b/SA_POP/SANet/SANet_Exceptions.cpp
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SANet_Exceptions.cpp
+ *
+ * This file contains the exception implementations for spreading activation
+ * networks.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SANet_Exceptions.h"
+
+using namespace SANet;
+
+Invalid_Step::Invalid_Step (void)
+: std::invalid_argument ("Invalid step argument")
+{
+ // Nothing to do.
+};
+
+Update_Error::Update_Error (void)
+: std::logic_error ("Update error")
+{
+ // Nothing to do.
+};
+
+Duplicate_ID::Duplicate_ID (void)
+: std::invalid_argument ("Duplicate ID provided for node creation")
+{
+ // Nothing to do.
+};
+
+Insertion_Error::Insertion_Error (void)
+: std::logic_error ("Error while attempting to insert a value in map or set")
+{
+ // Nothing to do.
+};
+
+UnknownNode::UnknownNode (void)
+: std::invalid_argument ("Unknown node lookup")
+{
+ // Nothing to do.
+};
diff --git a/SA_POP/SANet/SANet_Exceptions.h b/SA_POP/SANet/SANet_Exceptions.h
new file mode 100644
index 00000000000..1934cdbc789
--- /dev/null
+++ b/SA_POP/SANet/SANet_Exceptions.h
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SANet_Exceptions.h
+ *
+ * This file contains the exception definitions for spreading activation
+ * networks.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SANET_EXCEPTIONS_H_
+#define SANET_EXCEPTIONS_H_
+
+#include <stdexcept>
+
+namespace SANet {
+ /**
+ * @class Invalid_Step
+ *
+ * @brief Exception class for invalid step arguments.
+ */
+ class Invalid_Step : public std::invalid_argument {
+ public:
+ /// Constructor.
+ Invalid_Step (void);
+ };
+
+ /**
+ * @class Update_Error
+ *
+ * @brief Exception class for unrecoverable update errors.
+ */
+ class Update_Error : public std::logic_error {
+ public:
+ /// Constructor.
+ Update_Error (void);
+ };
+
+ /**
+ * @class Duplicate_ID
+ *
+ * @brief Exception class for duplicate ID value during node creation.
+ */
+ class Duplicate_ID : public std::invalid_argument {
+ public:
+ /// Constructor.
+ Duplicate_ID (void);
+ };
+
+ /**
+ * @class Insertion_Error
+ *
+ * @brief Exception class for unknown errors during map/set insertion.
+ */
+ class Insertion_Error : public std::logic_error {
+ public:
+ /// Constructor.
+ Insertion_Error (void);
+ };
+
+ /**
+ * @class UnknownNode
+ *
+ * @brief Exception class for unknown node error when looking up a node.
+ */
+ class UnknownNode : public std::invalid_argument {
+ public:
+ /// Constructor.
+ UnknownNode (void);
+ };
+
+}; /* SANet namespace */
+
+
+#endif /* SANET_EXCEPTIONS_H_ */
diff --git a/SA_POP/SANet/SANet_Types.h b/SA_POP/SANet/SANet_Types.h
new file mode 100644
index 00000000000..c4f20f090f9
--- /dev/null
+++ b/SA_POP/SANet/SANet_Types.h
@@ -0,0 +1,208 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SANet_Types.h
+ *
+ * This file contains the definitions of types used throughout SANet.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SANET_TYPES_H_
+#define SANET_TYPES_H_
+
+#include <string>
+#include <set>
+#include <list>
+#include <map>
+#include <utility>
+
+
+#if !defined (SANET_STANDALONE)
+
+#include "SA_POP_Types.h"
+
+namespace SANet {
+ /// Type of a node id (tasks and conditions).
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef SA_POP::NodeID NodeID;
+
+ /// Type of a condition id.
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef SA_POP::CondID CondID;
+
+ /// Type of a condition value.
+ typedef SA_POP::CondValue CondValue;
+
+ /// Type of a condition kind/type.
+ typedef SA_POP::CondKind CondKind;
+
+ /// Type of a condition.
+ typedef SA_POP::Condition Condition;
+
+ /// Type of a task ID.
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef SA_POP::TaskID TaskID;
+
+ /// NULL task ID (for unknown/uninitialized tasks).
+ const TaskID NULL_TASK_ID = SA_POP::NULL_TASK_ID;
+
+ /// NULL condition ID (for unknown/uninitialized conditions).
+ const CondID NULL_COND_ID = SA_POP::NULL_TASK_ID;
+
+ /// Type of a port id.
+ typedef SA_POP::PortID PortID;
+
+ /// Type of an expected utility calculation (basetype for others).
+ /// (N.B. this must be a double or float to handle [0,1] range probabilities
+ /// and multiplication factors).
+ typedef SA_POP::EUCalc EUCalc;
+
+ /// Type of a condition utility.
+ typedef SA_POP::Utility Utility;
+
+ /// Type of a probability.
+ typedef SA_POP::Probability Probability;
+
+ /// Type of a (precondition or effect) link weight.
+ typedef SA_POP::LinkWeight LinkWeight;
+
+ /// Type of a task cost.
+ typedef SA_POP::TaskCost TaskCost;
+
+ /// Type of a multiplicative factor (e.g. attenuation factor).
+ typedef SA_POP::MultFactor MultFactor;
+
+ /// Type of a precondition link.
+ typedef SA_POP::PrecondLink PrecondLink;
+
+ /// Type of an effect link.
+ typedef SA_POP::EffectLink EffectLink;
+
+ /// Type of a pair of ports for a link.
+ typedef SA_POP::LinkPorts LinkPorts;
+
+ /// Type of a list of tasks.
+ typedef SA_POP::TaskList TaskList;
+
+ /// Type of a set of goal conditions with associated utilities.
+ typedef SA_POP::GoalMap GoalMap;
+
+ /// Type of a set of tasks with associated expected utilities.
+ typedef SA_POP::TaskEUMap TaskEUMap;
+
+ /// Type of a set of conditions (condition & value).
+ typedef SA_POP::CondSet CondSet;
+
+ /// Type of a set of task ids.
+ typedef SA_POP::TaskSet TaskSet;
+
+ /// Type of duration
+ typedef SA_POP::TimeValue TimeValue;
+
+ /// NULL time (for unknown or unconstrained times).
+ #define NULL_TIME -1
+
+}; /* SANet namespace */
+
+#endif /* SANET_STANDALONE not defined */
+
+
+#if defined (SANET_STANDALONE)
+
+namespace SANet {
+
+ /// Type of a node id (tasks and conditions).
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef int NodeID;
+
+ /// Type of a condition id.
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef NodeID CondID;
+
+ /// Type of a condition value.
+ typedef bool CondValue;
+
+ /// Type of a condition kind/type.
+ enum CondKind {ENVIRON, SYSTEM, DATA};
+
+ /// Type of a condition.
+ struct Condition {
+ 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 == s); };
+ bool operator< (const Condition &s) const { return this->id < s.id; };
+ };
+
+ /// Type of a task ID.
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef NodeID TaskID;
+
+ /// NULL task ID (for unknown/uninitialized tasks).
+ const TaskID NULL_TASK_ID = 0;
+
+ /// NULL condition ID (for unknown/uninitialized conditions).
+ const CondID NULL_COND_ID = 0;
+
+ /// Type of a port id.
+ typedef std::string PortID;
+
+ /// Type of an expected utility calculation (basetype for others).
+ /// (N.B. this must be a double or float to handle [0,1] range probabilities
+ /// and multiplication factors).
+ typedef double EUCalc;
+
+ /// Type of a condition utility.
+ typedef EUCalc Utility;
+
+ /// Type of a probability.
+ typedef EUCalc Probability;
+
+ /// Type of a (precondition or effect) link weight.
+ typedef EUCalc LinkWeight;
+
+ /// Type of a task cost.
+ typedef EUCalc TaskCost;
+
+ /// Type of a multiplicative factor (e.g. attenuation factor).
+ typedef EUCalc MultFactor;
+
+ /// Type of duration
+ typedef int TimeValue;
+
+ /// NULL time (for unknown or unconstrained times).
+ #define NULL_TIME -1
+
+ /// Type of a precondition link.
+ typedef std::pair<CondID, TaskID> PrecondLink;
+
+ /// Type of an effect link.
+ typedef std::pair<TaskID, CondID> EffectLink;
+
+ /// Type of a pair of ports for a link.
+ typedef std::pair<PortID, PortID> LinkPorts;
+
+ /// Type of a list of tasks.
+ typedef std::list<TaskID> TaskList;
+
+ /// Type of a set of goal conditions with associated utilities.
+ typedef std::map<CondID, Utility> GoalMap;
+
+ /// Type of a set of tasks with associated expected utilities.
+ typedef std::map<TaskID, Utility> TaskEUMap;
+
+ /// Type of a set of conditions (condition & value).
+ typedef std::set<Condition> CondSet;
+
+ /// Type of a set of task ids.
+ typedef std::set<TaskID> TaskSet;
+
+}; /* SANet namespace */
+#endif /* SANET_STANDALONE */
+
+#endif /* SANET_TYPES_H_ */
diff --git a/SA_POP/SANet/SANode.cpp b/SA_POP/SANet/SANode.cpp
new file mode 100644
index 00000000000..4ce882526d0
--- /dev/null
+++ b/SA_POP/SANet/SANode.cpp
@@ -0,0 +1,1020 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file SANode.cpp
+ *
+ * This file contains the Node, CondNode, & TaskNode class
+ * implementations for spreading activation network nodes.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SANode.h"
+#include "SANet_Exceptions.h"
+#include <utility>
+#include <iostream>
+
+using namespace SANet;
+
+Node::Node (NodeID ID, std::string name, MultFactor atten_factor)
+: ID_ (ID),
+ name_ (name),
+ atten_factor_ (atten_factor),
+ step_ (0),
+ prob_changed_ (false),
+ util_changed_ (false)
+{
+ // Initialize probability and utility info.
+ pos_util_.utility = 0;
+ pos_util_.common.clear ();
+ neg_util_.utility = 0;
+ neg_util_.common.clear ();
+ true_prob_.probability = 0;
+ true_prob_.common.clear ();
+ false_prob_.probability = 0;
+ false_prob_.common.clear ();
+
+ // Initialize (empty) pre and post node maps and links.
+ pre_nodes_.clear ();
+ pre_links_.clear ();
+ post_nodes_.clear ();
+ post_links_.clear ();
+};
+
+Node::~Node ()
+{
+ // Nothing to do.
+};
+
+Utility_Info Node::get_reward (int step)
+{
+ // Check to ensure step is the current step, or else throw exception
+ if (step != step_) {
+ throw Invalid_Step ();
+ }
+
+ // Return positive utility info.
+ return pos_util_;
+};
+
+Probability_Info Node::get_prob (int step, bool value)
+{
+ // Check to ensure step is the current step, or else throw exception
+ if (step != step_) {
+ throw Invalid_Step ();
+ }
+
+ // Return probability for true if value is true.
+ if (value) {
+ return true_prob_;
+ }
+ // Otherwise return probability for false.
+ return false_prob_;
+};
+
+bool Node::prob_changed (void)
+{
+ return prob_changed_;
+};
+
+bool Node::util_changed (void)
+{
+ return util_changed_;
+};
+
+std::string Node::get_name (void)
+{
+ return name_;
+};
+
+NodeID Node::get_ID (void)
+{
+ return ID_;
+};
+
+// Get pre-links (nodes with links to this node).
+const LinkMap& Node::get_pre (void)
+{
+ return this->pre_links_;
+};
+
+// Get post-links (nodes with links from this node).
+const LinkMap& Node::get_post (void)
+{
+ return this->post_links_;
+};
+
+TaskNode::TaskNode (NodeID ID, std::string name, MultFactor atten_factor,
+ TaskCost cost, Probability prior_prob)
+: Node (ID, name, atten_factor),
+ cost_ (cost),
+ prior_prob_ (prior_prob)
+{
+ // Nothing to do.
+};
+
+TaskNode::~TaskNode (void)
+{
+ // Nothing to do.
+};
+
+bool TaskNode::update (void)
+{
+ // Reset change flags.
+ prob_changed_ = false;
+ util_changed_ = false;
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // Probability flag is not being set correctly, so run to max steps...
+ prob_changed_ = true;
+ util_changed_ = true;
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Flag for detection of loops.
+ bool is_loop = false;
+
+ // Variables for current node and link in updates.
+ CondNode *cur_node;
+ CondID cur_ID;
+ LinkMap::iterator link_iter;
+ LinkWeight cur_weight;
+ MultFactor cur_mult;
+
+ // Variables for current probability value.
+ Probability_Info cur_prob;
+ ProbabilityMap::iterator true_prob_iter;
+ ProbabilityMap::iterator false_prob_iter;
+ ProbabilityMap::iterator prev_prob_iter;
+
+ // Reset probability info.
+ true_prob_.probability = prior_prob_;
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // clearing common probabilities set removes self (if "loop" found where
+ // this node is receiving utility from same goal on multiple paths). so
+ // will never realize that nothing has changed.
+ // and (possible) common probabilities are never removed from the set once
+ // detected so this does not need to be cleared as long as any
+ // changed probabilities are appropriately changed in common set... right???
+ true_prob_.common.clear ();
+
+ // Update probability.
+ for (NodeMap::iterator node_iter = pre_nodes_.begin ();
+ node_iter != pre_nodes_.end (); node_iter++)
+ {
+ // Get current node info.
+ cur_ID = node_iter->first;
+ cur_node = (CondNode *) node_iter->second;
+
+ // Get current link info.
+ link_iter = pre_links_.find(cur_ID);
+ if (link_iter == pre_links_.end ()) {
+ throw Update_Error ();
+ }
+ cur_weight = link_iter->second;
+
+ // Get current probability info.
+ try {
+ if (cur_weight >= 0) {
+ cur_prob = cur_node->get_prob (step_, true);
+ } else {
+ cur_prob = cur_node->get_prob (step_, false);
+ }
+ } catch (Invalid_Step e) {
+ std::cerr << "Error in task node update: Invalid step value.";
+ std::cerr << std::endl;
+ return false;
+ } catch (...) {
+ std::cerr << "Unexpected exception thrown in task node update.";
+ std::cerr << std::endl;
+ return false;
+ }
+
+ // Get conditional probability of success for true precondition.
+ true_prob_iter = pre_true_probs_.find (cur_ID);
+ if (true_prob_iter == pre_true_probs_.end ()) {
+ throw Update_Error ();
+ }
+
+ // Get conditional probability of success for false precondition.
+ false_prob_iter = pre_false_probs_.find (cur_ID);
+ if (false_prob_iter == pre_false_probs_.end ()) {
+ throw Update_Error ();
+ }
+
+ // Update true probability depending on sign of link weight.
+ if (cur_weight >= 0) {
+ // Update conditional probability of success given this node.
+ cur_prob.probability = ((cur_prob.probability * true_prob_iter->second) +
+ ((1 - cur_prob.probability) * false_prob_iter->second));
+
+ // Update probability.
+ true_prob_.probability = true_prob_.probability * cur_prob.probability /
+ prior_prob_;
+ } else {
+ // Update conditional probability of success given this node.
+ cur_prob.probability = ((cur_prob.probability * false_prob_iter->second)
+ + ((1 - cur_prob.probability) * true_prob_iter->second));
+
+ // Update probability.
+ true_prob_.probability = true_prob_.probability * cur_prob.probability /
+ prior_prob_;
+ }
+
+ // Update prob_changed_ flag if necessary.
+ if (cur_node->prob_changed ()) {
+ prob_changed_ = true;
+ }
+
+ // Update common probabilities and handle duplicates.
+ for (ProbabilityMap::iterator prob_iter = cur_prob.common.begin ();
+ prob_iter != cur_prob.common.end (); prob_iter++)
+ {
+ prev_prob_iter = true_prob_.common.find (prob_iter->first);
+
+ // If a common probability is already in the probability map,
+ // divide from probability, otherwise add it to the probability map.
+ if (prev_prob_iter != true_prob_.common.end ())
+ {
+#if defined (SANET_DEBUG)
+ std::cout << std::endl << "DEBUG in TaskNode::update()... (" << ID_ << ") Duplicate common probability found:" << std::endl;
+ std::cout << "Probability from " << prev_prob_iter->first << " = " << prev_prob_iter->second << std::endl << std::endl;
+#endif /* SANET_DEBUG */
+ true_prob_.probability = true_prob_.probability /
+ prev_prob_iter->second;
+ } else {
+ true_prob_.common.insert (std::make_pair (prob_iter->first,
+ prob_iter->second));
+ }
+ }
+ }
+
+ // Variables for current utility updates.
+ Utility_Info cur_util;
+ UtilityMap::iterator prev_util_iter;
+
+ // Reset utility info.
+ pos_util_.utility = 0;
+ pos_util_.common.clear ();
+ neg_util_.utility = 0;
+ neg_util_.common.clear ();
+
+ // Update utility.
+ for (NodeMap::iterator node_iter = post_nodes_.begin ();
+ node_iter != post_nodes_.end (); node_iter++)
+ {
+ // Get current node info.
+ cur_ID = node_iter->first;
+ cur_node = (CondNode *) node_iter->second;
+
+ // Update util_changed_ flag if necessary.
+ if (cur_node->util_changed ()) {
+ util_changed_ = true;
+ }
+
+ // Get current link info.
+ link_iter = post_links_.find(cur_ID);
+ if (link_iter == post_links_.end ()) {
+ throw Update_Error ();
+ }
+ cur_weight = link_iter->second;
+
+ // Set multiplier as attenuation factor times link weight, probability
+ // that task will succeed, and probability that effect node has the
+ // opposite value from what task would change it to.
+ if (cur_weight >= 0) {
+ cur_mult = atten_factor_ * cur_weight * true_prob_.probability *
+ cur_node->get_prob (step_, false).probability;
+ } else {
+ cur_mult = atten_factor_ * cur_weight * true_prob_.probability *
+ cur_node->get_prob (step_, true).probability;
+ }
+
+ // Get current utility info.
+ try {
+ cur_util = cur_node->get_reward (step_);
+ } catch (Invalid_Step e) {
+ std::cerr << "Error in task node update: Invalid step value.";
+ std::cerr << std::endl;
+ return false;
+ } catch (...) {
+ std::cerr << "Unexpected exception thrown in task node update.";
+ std::cerr << std::endl;
+ return false;
+ }
+
+ // Updated utility based on current multiplier.
+ cur_util.utility = cur_mult * cur_util.utility;
+
+ // Update positive or negative utilities depending on sign of link weight.
+ if (cur_weight >= 0) {
+ // Add utility to expected utility value.
+ pos_util_.utility += cur_util.utility;
+
+ // Update all component utilities based on link weight, and handle
+ // utilities from common goals.
+ for (UtilityMap::iterator util_iter = cur_util.common.begin ();
+ util_iter != cur_util.common.end (); util_iter++)
+ {
+ util_iter->second = cur_mult * util_iter->second;
+ prev_util_iter = pos_util_.common.find (util_iter->first);
+
+ // If a utility from this goal is already in the utility map,
+ // delete smaller utility value, otherwise add the utility from this
+ // goal to the utility map.
+ if (prev_util_iter != pos_util_.common.end ())
+ {
+#if defined (SANET_DEBUG)
+ std::cout << std::endl << "DEBUG in TaskNode::update()... (" << ID_ << ") Duplicate utility from goal found:" << std::endl;
+ std::cout << "Utility from " << prev_util_iter->first << " = " << prev_util_iter->second << std::endl << std::endl;
+#endif /* SANET_DEBUG */
+ if (prev_util_iter->second < util_iter->second) {
+ pos_util_.utility -= prev_util_iter->second;
+ } else {
+ pos_util_.utility -= util_iter->second;
+ }
+ // Set loop flag.
+ is_loop = true;
+ } else {
+ pos_util_.common.insert (std::make_pair (util_iter->first,
+ util_iter->second));
+ }
+ }
+ } else {
+ // Add utility to expected utility value.
+ neg_util_.utility += cur_util.utility;
+
+ // Update all component utilities based on link weight, and handle
+ // utilities from common goals.
+ for (UtilityMap::iterator util_iter = cur_util.common.begin ();
+ util_iter != cur_util.common.end (); util_iter++)
+ {
+ util_iter->second = cur_mult * util_iter->second;
+ prev_util_iter = neg_util_.common.find (util_iter->first);
+
+ // If a utility from this goal is already in the utility map,
+ // delete larger (less negative) utility value, otherwise add the
+ // utility from this goal to the utility map.
+ if (prev_util_iter != neg_util_.common.end ())
+ {
+ if (prev_util_iter->second > util_iter->second) {
+ neg_util_.utility -= prev_util_iter->second;
+ } else {
+ neg_util_.utility -= util_iter->second;
+ }
+ // Set loop flag.
+ is_loop = true;
+ } else {
+ neg_util_.common.insert (std::make_pair (util_iter->first,
+ util_iter->second));
+ }
+ }
+ }
+ }
+
+//*****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****
+ // Include cost in current expected utility.
+// pos_util_.utility -= cost_;
+//*****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****DEBUG****
+
+ // If a loop was detected, add current probability to common probabilities.
+ if (is_loop) {
+#if defined (SANET_DEBUG)
+ if (DEBUG) {
+ std::cout << std::endl << "DEBUG in TaskNode::update()... (" << ID_ << ") Loop detected, adding this node to common probabilities" << std::endl << std::endl;
+#endif /* SANET_DEBUG */
+ // Update common probabilities for true probability.
+ ProbabilityMap::iterator prob_iter = true_prob_.common.find (ID_);
+ if (prob_iter != true_prob_.common.end ()) {
+ if (prob_iter->second != true_prob_.probability) {
+ prob_iter->second = true_prob_.probability;
+ prob_changed_ = true;
+ }
+ } else {
+ true_prob_.common.insert (std::make_pair (ID_,
+ true_prob_.probability));
+ // Update prob_changed_ flag.
+ prob_changed_ = true;
+ }
+ }
+
+ // Set false probability (i.e. probability of task failure) to 1 minus
+ // probability of success.
+ false_prob_.probability = 1 - true_prob_.probability;
+
+ // Update step (at end of step for task node).
+ step_++;
+
+ // Return boolean changed value based on change flags.
+ return (prob_changed_ || util_changed_);
+
+};
+
+Utility TaskNode::get_utility (int step)
+{
+ // Check to ensure step is the current step, or else throw exception
+ if (step != step_) {
+ throw Invalid_Step ();
+ }
+
+ // Variable for summing expected utility.
+ Utility utility = 0;
+
+ // Add positive expected utility, negative expected utility values, and
+ // subtract cost.
+ utility += pos_util_.utility + neg_util_.utility - cost_;
+
+ return utility;
+};
+
+void TaskNode::print (std::basic_ostream<char, std::char_traits<char> >&
+ strm, bool verbose)
+{
+ // Print node name and ID.
+ strm << "Task Node \"" << name_ << "\":" << std::endl;
+ strm << " ID: " << ID_ << std::endl;
+
+ // Print cost and expected utility.
+ strm << " Cost: " << cost_ << std::endl;
+ strm << " Expected Utility: " << get_utility (step_) << std::endl;
+
+ // If verbose, print positive and negative component utilities from goals.
+ if (verbose) {
+ // Print positive utility and its component utilities.
+ strm << " Positive utility received: " << pos_util_.utility << std::endl;
+ for (UtilityMap::iterator iter = pos_util_.common.begin ();
+ iter != pos_util_.common.end (); iter++)
+ {
+ strm << " Component expected utility from goal " << iter->first;
+ strm << " = " << iter->second;
+ strm << std::endl;
+ }
+
+ // Print negative utility and its component utilities.
+ strm << " Negative utility received: " << neg_util_.utility << std::endl;
+ for (UtilityMap::iterator iter = neg_util_.common.begin ();
+ iter != neg_util_.common.end (); iter++)
+ {
+ strm << " Component expected utility from goal " << iter->first;
+ strm << " = " << iter->second;
+ strm << std::endl;
+ }
+ }
+
+ // Print probability of task success.
+ strm << " Probability (success): " << true_prob_.probability << std::endl;
+
+ // If verbose, print common utility
+ if (verbose) {
+ for (ProbabilityMap::iterator iter = true_prob_.common.begin ();
+ iter != true_prob_.common.end (); iter++)
+ {
+ strm << " Component probability (possible loops only) from ";
+ strm << iter->first << " = " << iter->second;
+ strm << std::endl;
+ }
+ }
+
+ // If verbose, print probability of task failure.
+ if (verbose) {
+ strm << " Probability (failure): " << false_prob_.probability;
+ strm << std::endl;
+ }
+
+ // Current link map iterator input and output link printing loops.
+ LinkMap::iterator cur_link_iter;
+
+ // Print node input links.
+ strm << " In Links (preconditions):" << std::endl;
+ for (NodeMap::iterator node_iter = pre_nodes_.begin ();
+ node_iter != pre_nodes_.end (); node_iter++)
+ {
+ // Print input node name and ID.
+ strm << " " << node_iter->first << " ";
+ strm << "(" << node_iter->second->get_name () << "); ";
+
+ // Find link for this node.
+ cur_link_iter = pre_links_.find (node_iter->first);
+
+ // If this node couldn't be found in pre_links_ print error,
+ // otherwise print link weight.
+ if (cur_link_iter == pre_links_.end ()) {
+ strm << "ERROR: weight not found";
+ } else {
+ strm << "weight = " << cur_link_iter->second;
+ }
+ strm << std::endl;
+
+ // If verbose, print conditional probabilities of success for precondition.
+ if (verbose) {
+ strm << " Conditional probability if true: ";
+ strm << pre_true_probs_.find (node_iter->first)->second << std::endl;
+ strm << " Conditional probability if false: ";
+ strm << pre_false_probs_.find (node_iter->first)->second << std::endl;
+ }
+ }
+
+ // Print node output links.
+ strm << " Out Links (effects):" << std::endl;
+ for (NodeMap::iterator node_iter = post_nodes_.begin ();
+ node_iter != post_nodes_.end (); node_iter++)
+ {
+ // Print output node name and ID.
+ strm << " " << node_iter->first << " ";
+ strm << "(" << node_iter->second->get_name () << "); ";
+
+ // Find link for this node.
+ cur_link_iter = post_links_.find (node_iter->first);
+
+ // If this node couldn't be found in post_links_ print error,
+ // otherwise print link weight.
+ if (cur_link_iter == post_links_.end ()) {
+ strm << "ERROR: weight not found";
+ } else {
+ strm << "weight = " << cur_link_iter->second;
+ }
+ strm << std::endl;
+ }
+};
+
+void TaskNode::add_precond (CondID ID, CondNode *node, Probability true_prob,
+ Probability false_prob)
+{
+ // Add node to pre-nodes.
+ pre_nodes_.insert (std::make_pair (ID, node));
+
+ // Add probabilities.
+ pre_true_probs_.insert (std::make_pair (ID, true_prob));
+ pre_false_probs_.insert (std::make_pair (ID, false_prob));
+
+ // Add link weight.
+ LinkWeight weight = (true_prob - false_prob)/(true_prob + false_prob);
+ pre_links_.insert (std::make_pair (ID, weight));
+
+ // Add link for precondition node.
+ node->add_post_link (ID_, this, weight);
+};
+
+void TaskNode::add_effect (CondID ID, CondNode *node, LinkWeight weight)
+{
+ // Add node to post-nodes.
+ post_nodes_.insert (std::make_pair (ID, node));
+
+ // Add link weight.
+ post_links_.insert (std::make_pair (ID, weight));
+
+ // Add link for precondition node.
+ node->add_pre_link (ID_, this, weight);
+};
+
+CondNode::CondNode (CondID ID, std::string name, MultFactor atten_factor,
+ Probability true_prob, Probability false_prob, Utility goal_util, CondKind condkind)
+: Node (ID, name, atten_factor),
+ goal_util_ (goal_util),
+ init_true_prob_ (true_prob),
+ true_prob_from_ (ID),
+ false_prob_from_ (ID),
+ cond_kind_ (condkind)
+{
+ // Set initial probabilities.
+ true_prob_.probability = true_prob;
+ false_prob_.probability = false_prob;
+
+ // Set prob_changed_ flag.
+ prob_changed_ = true;
+
+ // If this node is a goal, set util_changed_ flag and add goal utility
+ // to positive utilities.
+ if (goal_util > 0) {
+ util_changed_ = true;
+ pos_util_.utility = goal_util;
+ pos_util_.common.insert (std::make_pair (ID, goal_util));
+ }
+};
+
+CondNode::~CondNode (void)
+{
+ // Nothing to do.
+};
+
+// Get initial/current probability.
+Probability CondNode::get_init_prob (bool value)
+{
+ if (value)
+ return this->init_true_prob_;
+
+ return (1.0 - this->init_true_prob_);
+};
+
+// Update initial/current probability.
+void CondNode::set_init_prob (Probability init_true_prob)
+{
+ this->init_true_prob_ = init_true_prob;
+ this->prob_changed_ = true;
+};
+
+void CondNode::print (std::basic_ostream<char, std::char_traits<char> >&
+ strm, bool verbose)
+{
+ // Print node name and ID.
+ strm << "Condition Node \"" << name_ << "\":" << std::endl;
+ strm << " ID: " << ID_ << std::endl;
+
+ // Print goal utility.
+ strm << " Goal utility: " << goal_util_ << std::endl;
+
+ // Print positive utility.
+ strm << " Expected utility for true value: " << pos_util_.utility;
+ strm << std::endl;
+
+ // If verbose, print component utilities from all goals.
+ if (verbose) {
+ for (UtilityMap::iterator iter = pos_util_.common.begin ();
+ iter != pos_util_.common.end (); iter++)
+ {
+ strm << " Component expected utility from goal " << iter->first;
+ strm << " = " << iter->second;
+ strm << std::endl;
+ }
+ }
+
+ // Print negative utility.
+ strm << " Expected utility for false value: " << neg_util_.utility;
+ strm << std::endl;
+
+ // If verbose, print component utilities from all goals.
+ if (verbose) {
+ for (UtilityMap::iterator iter = neg_util_.common.begin ();
+ iter != neg_util_.common.end (); iter++)
+ {
+ strm << " Component expected utility from goal " << iter->first;
+ strm << " = " << iter->second;
+ strm << std::endl;
+ }
+ }
+
+ // Print probability (maximum) that condition is true.
+ strm << " Probability (true): " << true_prob_.probability << std::endl;
+
+ // If verbose, print component probabilities for loops.
+ if (verbose) {
+ for (ProbabilityMap::iterator iter = true_prob_.common.begin ();
+ iter != true_prob_.common.end (); iter++)
+ {
+ strm << " Component probability (possible loops only) from ";
+ strm << iter->first << " = " << iter->second;
+ strm << std::endl;
+ }
+ }
+
+ // Print probability (maximum) that condition is false.
+ strm << " Probability (false): " << false_prob_.probability << std::endl;
+
+ // If verbose, print component probabilities for loops.
+ if (verbose) {
+ for (ProbabilityMap::iterator iter = false_prob_.common.begin ();
+ iter != false_prob_.common.end (); iter++)
+ {
+ strm << " Component probability (possible loops only) from ";
+ strm << iter->first << " = " << iter->second;
+ strm << std::endl;
+ }
+ }
+
+ // Current link map iterator input and output link printing loops.
+ LinkMap::iterator cur_link_iter;
+
+ // Print node input links.
+ strm << " In Links (tasks that change this condition):" << std::endl;
+ for (NodeMap::iterator node_iter = pre_nodes_.begin ();
+ node_iter != pre_nodes_.end (); node_iter++)
+ {
+ // Print input node name and ID.
+ strm << " " << node_iter->first << " ";
+ strm << "(" << node_iter->second->get_name () << "); ";
+
+ // Find link for this node.
+ cur_link_iter = pre_links_.find (node_iter->first);
+
+ // If this node couldn't be found in pre_links_ print error,
+ // otherwise print link weight.
+ if (cur_link_iter == pre_links_.end ()) {
+ strm << "ERROR: weight not found";
+ } else {
+ strm << "weight = " << cur_link_iter->second;
+ }
+ strm << std::endl;
+ }
+
+ // Print node output links.
+ strm << " Out Links (tasks that have this precondition):" << std::endl;
+ for (NodeMap::iterator node_iter = post_nodes_.begin ();
+ node_iter != post_nodes_.end (); node_iter++)
+ {
+ // Print output node name and ID.
+ strm << " " << node_iter->first << " ";
+ strm << "(" << node_iter->second->get_name () << "); ";
+
+ // Find link for this node.
+ cur_link_iter = post_links_.find (node_iter->first);
+
+ // If this node couldn't be found in post_links_ print error,
+ // otherwise print link weight.
+ if (cur_link_iter == post_links_.end ()) {
+ strm << "ERROR: weight not found";
+ } else {
+ strm << "weight = " << cur_link_iter->second;
+ }
+ strm << std::endl;
+ }
+};
+
+bool CondNode::update (void)
+{
+ // Reset change flags.
+ prob_changed_ = false;
+ util_changed_ = false;
+
+ // Update step (at beginning of step for condition node).
+ step_++;
+
+ // Flag for detection of loops.
+ bool is_loop = false;
+
+ // Variables for current node and link in updates.
+ TaskNode *cur_node;
+ TaskID cur_ID;
+ LinkMap::iterator link_iter;
+ LinkWeight cur_weight;
+ MultFactor cur_mult;
+
+ // Reset utility info.
+ pos_util_.utility = 0;
+ pos_util_.common.clear ();
+ neg_util_.utility = 0;
+ neg_util_.common.clear ();
+ // If this node is a goal, set add goal utility to positive utilities.
+ if (goal_util_ > 0) {
+ pos_util_.utility = goal_util_;
+ pos_util_.common.insert (std::make_pair (ID_, goal_util_));
+ };
+
+ // Variables for current utility updates.
+ Utility_Info cur_util;
+ UtilityMap::iterator prev_util_iter;
+
+ // Update utility.
+ for (NodeMap::iterator node_iter = post_nodes_.begin ();
+ node_iter != post_nodes_.end (); node_iter++)
+ {
+ // Get current node info.
+ cur_ID = node_iter->first;
+ cur_node = (TaskNode *) node_iter->second;
+
+ // Update util_changed_ flag if necessary.
+ if (cur_node->util_changed ()) {
+ util_changed_ = true;
+ }
+
+ // Get current link info.
+ link_iter = post_links_.find(cur_ID);
+ if (link_iter == post_links_.end ()) {
+ throw Update_Error ();
+ }
+ cur_weight = link_iter->second;
+
+ // Set multiplier as attenuation factor times link weight.
+ cur_mult = atten_factor_ * cur_weight;
+
+ // Get current utility info.
+ try {
+ cur_util = cur_node->get_reward (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;
+ }
+
+ // Updated utility based on current multiplier.
+ cur_util.utility = cur_mult * cur_util.utility;
+
+ // Update positive or negative utilities depending on sign of link weight.
+ if (cur_weight >= 0) {
+ // Add utility to expected utility value.
+ pos_util_.utility += cur_util.utility;
+
+ // Update all component utilities based on link weight, and handle
+ // utilities from common goals.
+ for (UtilityMap::iterator util_iter = cur_util.common.begin ();
+ util_iter != cur_util.common.end (); util_iter++)
+ {
+ util_iter->second = cur_mult * util_iter->second;
+ prev_util_iter = pos_util_.common.find (util_iter->first);
+
+ // If a utility from this goal is already in the utility map,
+ // delete smaller utility value, otherwise add the utility from this
+ // goal to the utility map.
+ if (prev_util_iter != pos_util_.common.end ())
+ {
+#if defined (SANET_DEBUG)
+ std::cout << std::endl << "DEBUG in CondNode::update()... (" << ID_ << ") Duplicate utility from goal found:" << std::endl;
+ std::cout << "Utility from " << prev_util_iter->first << " = " << prev_util_iter->second << std::endl << std::endl;
+#endif /* SANET_DEBUG */
+ if (prev_util_iter->second < util_iter->second) {
+ pos_util_.utility -= prev_util_iter->second;
+ } else {
+ pos_util_.utility -= util_iter->second;
+ }
+ // Set loop flag.
+ is_loop = true;
+ } else {
+ pos_util_.common.insert (std::make_pair (util_iter->first,
+ util_iter->second));
+ }
+ }
+ } else {
+ // Add utility to expected utility value.
+ neg_util_.utility += cur_util.utility;
+
+ // Update all component utilities based on link weight, and handle
+ // utilities from common goals.
+ for (UtilityMap::iterator util_iter = cur_util.common.begin ();
+ util_iter != cur_util.common.end (); util_iter++)
+ {
+ util_iter->second = cur_mult * util_iter->second;
+ prev_util_iter = neg_util_.common.find (util_iter->first);
+
+ // If a utility from this goal is already in the utility map,
+ // delete larger (less negative) utility value, otherwise add the
+ // utility from this goal to the utility map.
+ if (prev_util_iter != neg_util_.common.end ())
+ {
+ if (prev_util_iter->second > util_iter->second) {
+ neg_util_.utility -= prev_util_iter->second;
+ } else {
+ neg_util_.utility -= util_iter->second;
+ }
+ // Set loop flag.
+ is_loop = true;
+ } else {
+ neg_util_.common.insert (std::make_pair (util_iter->first,
+ util_iter->second));
+ }
+ }
+ }
+ }
+
+ // Variables for current probability value.
+ Probability_Info cur_prob;
+ ProbabilityMap::iterator prob_iter;
+
+ // Update probability.
+ for (NodeMap::iterator node_iter = pre_nodes_.begin ();
+ node_iter != pre_nodes_.end (); node_iter++)
+ {
+ // Get current node info.
+ cur_ID = node_iter->first;
+ cur_node = (TaskNode *) node_iter->second;
+
+ // Get current link info.
+ link_iter = pre_links_.find(cur_ID);
+ if (link_iter == pre_links_.end ()) {
+ throw Update_Error ();
+ }
+ cur_weight = link_iter->second;
+
+ // Set multiplier as absolute value of link weight.
+ if (cur_weight >= 0) {
+ cur_mult = cur_weight;
+ } else {
+ cur_mult = -1 * cur_weight;
+ }
+
+ // Get current probability info.
+ 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;
+ }
+
+ // Update probability based on current multiplier.
+ cur_prob.probability = cur_mult * cur_prob.probability;
+
+ // Update true or false probability depending on sign of link weight.
+ if (cur_weight >= 0) {
+ // Change true probability if this probability is higher than previous.
+ if (cur_prob.probability > true_prob_.probability) {
+ true_prob_ = cur_prob;
+ true_prob_from_ = cur_ID;
+
+ // Update prob_changed_ flag.
+ prob_changed_ = true;
+ }
+ // Otherwise check for newly detected common probabilities if current
+ // probability is from this node.
+ else if (true_prob_from_ == cur_ID) {
+ for (prob_iter = cur_prob.common.begin ();
+ prob_iter != cur_prob.common.end (); prob_iter++)
+ {
+ // If this common probability is not in current common probability
+ // map, add it.
+ if (true_prob_.common.find (prob_iter->first) ==
+ true_prob_.common.end ())
+ {
+ // Add common probability.
+ true_prob_.common.insert (std::make_pair (prob_iter->first,
+ prob_iter->second));
+
+ // Update prob_changed_ flag.
+ prob_changed_ = true;
+ }
+ }
+ }
+ } else {
+ // Change false probability if this probability is higher than previous.
+ if (cur_prob.probability > false_prob_.probability) {
+ false_prob_ = cur_prob;
+ false_prob_from_ = cur_ID;
+
+ // Update prob_changed_ flag.
+ prob_changed_ = true;
+ }
+ // Otherwise check for newly detected common probabilities if current
+ // probability is from this node.
+ else if (false_prob_from_ == cur_ID) {
+ for (prob_iter = cur_prob.common.begin ();
+ prob_iter != cur_prob.common.end (); prob_iter++)
+ {
+ // If this common probability is not in current common probability
+ // map, add it.
+ if (false_prob_.common.find (prob_iter->first) ==
+ false_prob_.common.end ())
+ {
+ // Add common probability.
+ false_prob_.common.insert (std::make_pair (prob_iter->first,
+ prob_iter->second));
+
+ // Update prob_changed_ flag.
+ prob_changed_ = true;
+ }
+ }
+ }
+ }
+ }
+
+ // If a loop was detected, add current probability to common probabilities.
+ if (is_loop) {
+#if defined (SANET_DEBUG)
+ std::cout << std::endl << "DEBUG in CondNode::update()... (" << ID_ << ") Loop detected, adding this node to common probabilities" << std::endl << std::endl;
+#endif /* SANET_DEBUG */
+ // Update common probabilities for true probability.
+ prob_iter = true_prob_.common.find (ID_);
+ if (prob_iter != true_prob_.common.end ()) {
+ prob_iter->second = true_prob_.probability;
+ } else {
+ true_prob_.common.insert (std::make_pair (ID_,
+ true_prob_.probability));
+ // Update prob_changed_ flag.
+ prob_changed_ = true;
+ }
+ }
+
+ // Return boolean changed value based on change flags.
+ return (prob_changed_ || util_changed_);
+};
+
+void CondNode::add_pre_link (TaskID ID, TaskNode *node, LinkWeight weight)
+{
+ // Add node to pre-nodes.
+ pre_nodes_.insert (std::make_pair (ID, node));
+
+ // Add link weight.
+ pre_links_.insert (std::make_pair (ID, weight));
+};
+
+void CondNode::add_post_link (TaskID ID, TaskNode *node, LinkWeight weight)
+{
+ // Add node to post-nodes.
+ post_nodes_.insert (std::make_pair (ID, node));
+
+ // Add link weight.
+ post_links_.insert (std::make_pair (ID, weight));
+};
+
+/// Get the kind
+CondKind CondNode::get_cond_kind()
+{
+ return this->cond_kind_;
+}
+
diff --git a/SA_POP/SANet/SANode.h b/SA_POP/SANet/SANode.h
new file mode 100644
index 00000000000..92788ddb91e
--- /dev/null
+++ b/SA_POP/SANet/SANode.h
@@ -0,0 +1,393 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file SANode.h
+ *
+ * This file contains the Node, CondNode, TaskNode and class
+ * definitions for spreading activation network nodes.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_NODE_H_
+#define SA_NODE_H_
+
+#include <map>
+#include <string>
+#include <stdexcept>
+#include <iostream>
+#include "SANet_Types.h"
+
+namespace SANet {
+ // Forward declaration of Node class.
+ class Node;
+
+ /// Map from node ID to pointer.
+ typedef std::map<NodeID, Node *> NodeMap;
+
+ /// Map from node ID to link weight or conditional probability.
+ typedef std::map<NodeID, LinkWeight> LinkMap;
+
+ /// Map from node ID to expected utility.
+ typedef std::map<NodeID, Utility> UtilityMap;
+
+ /// Expected utility info for a single node (at a particular step).
+ typedef struct {
+ /// Composite utility value.
+ Utility utility;
+
+ /// Map of goal node ID's to expected utilities (to avoid loops).
+ UtilityMap common;
+ } Utility_Info;
+
+ /// Probability map from node ID to probability (positive ID's indicate
+ /// probability node value is true and negative ID's indicate probability
+ /// node value is false).
+ typedef std::map<CondID, Probability> ProbabilityMap;
+
+ /// Probability info for a single node (at a particular step).
+ struct Probability_Info {
+ /// Composite probability value for the node (maximum probability for
+ /// condition nodes or conditional probability divided by prior
+ /// probability for task nodes).
+ Probability probability;
+
+ /// Map of node ID's to component probabilities needed to avoid loops.
+ ProbabilityMap common;
+ };
+
+
+
+ /**
+ * @class Node
+ *
+ * @brief Abstract base class for nodes in the network.
+ */
+ class Node {
+ public:
+ /// Constructor.
+ /**
+ * @param ID Node ID.
+ *
+ * @param name Node name.
+ *
+ * @param atten_factor Attenuation factor (to bias toward shorter plans).
+ */
+ Node (NodeID ID, std::string name, MultFactor atten_factor);
+
+ /// Destructor.
+ virtual ~Node ();
+
+ /// Get (positive) expected utility info (from goals) for a given step.
+ /**
+ * @param step Step for which to get reward map.
+ *
+ * @return Positive expected utility info.
+ */
+ virtual Utility_Info get_reward (int step);
+
+ /// Get (maximum) probability info for a given step and true/false value.
+ /**
+ * @param step Step for which to get probability info.
+ *
+ * @param value Value for which to get probability (default = true).
+ *
+ * @return Probability info.
+ */
+ virtual Probability_Info get_prob (int step, bool value = true);
+
+ /// Update node to next step.
+ /**
+ * @return True if node changed probability or utility, false otherwise.
+ */
+ virtual bool update (void) = 0;
+
+ /// Did node change probability info on last update?
+ /**
+ * @return True if node changed probability info, false otherwise.
+ */
+ virtual bool prob_changed (void);
+
+ /// Did node change utility info on last update?
+ /**
+ * @return True if node changed utility info, false otherwise.
+ */
+ virtual bool util_changed (void);
+
+ /// Get node name.
+ /**
+ * @return Name of node.
+ */
+ virtual std::string get_name (void);
+
+ /// Get node ID.
+ /**
+ * @return ID of node.
+ */
+ virtual NodeID get_ID (void);
+
+ /// Get pre-links (nodes with links to this node).
+ /**
+ * @return Map of pre-node IDs to link weights.
+ */
+ virtual const LinkMap& get_pre (void);
+
+ /// Get post-links (nodes with links from this node).
+ /**
+ * @return Map of post-node IDs to link weights.
+ */
+ virtual const LinkMap& get_post (void);
+
+ /// Print node.
+ /**
+ * @param strm Output stream on which to print node representation.
+ *
+ * @param verbose Whether to print verbose representation.
+ */
+ virtual void print (std::basic_ostream<char, std::char_traits<char> >& strm
+ = std::cout, bool verbose = false) = 0;
+
+ protected:
+ /// Unique ID of node (for identification within network).
+ NodeID ID_;
+
+ /// Name of node (descriptive only).
+ std::string name_;
+
+ /// Attenuation factor (to bias toward shorter plans).
+ MultFactor atten_factor_;
+
+ /// Current step.
+ int step_;
+
+ /// Nodes with links TO this node.
+ NodeMap pre_nodes_;
+
+ /// Nodes with links FROM this node.
+ NodeMap post_nodes_;
+
+ /// Link weights for pre-nodes.
+ LinkMap pre_links_;
+
+ /// Link weights for post-nodes.
+ LinkMap post_links_;
+
+ /// Flag for whether probability info was changed on last update.
+ bool prob_changed_;
+
+ /// Flag for whether utility info was changed on last update.
+ bool util_changed_;
+
+ /// Positive expected utility info.
+ Utility_Info pos_util_;
+
+ /// Negative expected utility info.
+ Utility_Info neg_util_;
+
+ /// Probability that value is true (equivalent to success for tasks).
+ Probability_Info true_prob_;
+
+ /// Probability that value is false (equivalent to failure for tasks).
+ Probability_Info false_prob_;
+ };
+
+ // Forward declaration of CondNode class.
+ class CondNode;
+
+ /**
+ * @class TaskNode
+ *
+ * @brief Task nodes in the network.
+ */
+ class TaskNode : public Node {
+ public:
+ /// Constructor.
+ /**
+ * @param ID Node ID.
+ *
+ * @param name Node name.
+ *
+ * @param atten_factor Attenuation factor (to bias toward shorter plans).
+ *
+ * @param cost Cost of performing task.
+ *
+ * @param prior_prob Prior probability of success.
+ */
+ TaskNode (TaskID ID, std::string name, MultFactor atten_factor, TaskCost cost,
+ Probability prior_prob);
+
+ /// Destructor.
+ virtual ~TaskNode (void);
+
+ /// Print node.
+ /**
+ * @param strm Output stream on which to print node representation.
+ *
+ * @param verbose Whether to print verbose representation.
+ */
+ virtual void print (std::basic_ostream<char, std::char_traits<char> >& strm
+ = std::cout, bool verbose = false);
+
+ /// Update node to next step.
+ /**
+ * @return True if node changed probability or utility, false otherwise.
+ */
+ virtual bool update (void);
+
+ /// Get expected utility for a given step.
+ /**
+ * @param step Step for which to get expected utility.
+ *
+ * @return Expected utility.
+ */
+ virtual Utility get_utility (int step);
+
+ /// Add precondition link.
+ /**
+ * @param ID Node ID.
+ *
+ * @param node Node pointer.
+ *
+ * @param true_prob Conditional probability of success given
+ * node = true.
+ *
+ * @param false_prob Conditional probability of success given
+ * node = false.
+ */
+ virtual void add_precond (CondID ID, CondNode *node, Probability true_prob,
+ Probability false_prob);
+
+ /// Add effect link.
+ /**
+ * @param ID Node ID.
+ *
+ * @param node Node pointer.
+ *
+ * @param weight Link weight (probability task sets condition to
+ * true, or negative of the probability task sets condition to false).
+ */
+ virtual void add_effect (CondID ID, CondNode *node, LinkWeight weight);
+
+ protected:
+ /// Unconditional prior probability of success.
+ Probability prior_prob_;
+
+ /// Cost of performing task.
+ TaskCost cost_;
+
+ /// Conditional probabilities of success for pre-nodes having true values.
+ LinkMap pre_true_probs_;
+
+ /// Conditional probabilities of success for pre-nodes having false values.
+ LinkMap pre_false_probs_;
+ };
+
+ /**
+ * @class CondNode
+ *
+ * @brief Condition nodes in the network.
+ */
+ class CondNode : public Node {
+ public:
+ /// Constructor.
+ /**
+ * @param ID Node ID.
+ *
+ * @param name Node name.
+ *
+ * @param atten_factor Attenuation factor (to bias toward shorter plans).
+ *
+ * @param true_prob Initial probability that value is true.
+ *
+ * @param false_prob Initial probability that value is false.
+ *
+ * @param goal_util Initial utility (positive for goals, zero otherwise).
+ *
+ * @param cond_kind The type of condition.
+ *
+ */
+ CondNode (CondID ID, std::string name, MultFactor atten_factor,
+ Probability true_prob, Probability false_prob, Utility goal_util, CondKind cond_kind);
+
+ /// Destructor.
+ virtual ~CondNode (void);
+
+ /// Get initial/current probability.
+ /**
+ * @param value Value for which to get probability (default = true).
+ *
+ * @return Initial probability of given value.
+ */
+ virtual Probability get_init_prob (bool value = true);
+
+ /// Update initial/current probability.
+ /**
+ * @param init_true_prob Initial/current probability of truth.
+ */
+ virtual void set_init_prob (Probability init_true_prob);
+
+ /// Print node.
+ /**
+ * @param strm Output stream on which to print node representation.
+ *
+ * @param verbose Whether to print verbose representation.
+ */
+ virtual void print (std::basic_ostream<char, std::char_traits<char> >& strm
+ = std::cout, bool verbose = false);
+
+ /// Update node to next step.
+ /**
+ * @return True if node changed probability or utility, false otherwise.
+ */
+ virtual bool update (void);
+
+ /// Add pre-link.
+ /**
+ * @param ID Node ID.
+ *
+ * @param node Node pointer.
+ *
+ * @param weight Link weight.
+ */
+ virtual void add_pre_link (TaskID ID, TaskNode *node, LinkWeight weight);
+
+ /// Add post-link.
+ /**
+ * @param ID Node ID.
+ *
+ * @param node Node pointer.
+ *
+ * @param weight Link weight.
+ */
+ virtual void add_post_link (TaskID ID, TaskNode *node, LinkWeight weight);
+
+ /// Get the kind/type of condition.
+ /**
+ * @return The kind of the condition.
+ */
+ virtual CondKind get_cond_kind();
+
+ protected:
+ /// Goal utility for this node.
+ Utility goal_util_;
+
+ /// Initial probability (of truth/success) for this node.
+ Probability init_true_prob_;
+
+ /// Which node (ID) the current true probability value came from.
+ TaskID true_prob_from_;
+
+ /// Which node (ID) the current false probability value came from.
+ TaskID false_prob_from_;
+
+ /// Kind/type of the condition.
+ CondKind cond_kind_;
+ };
+
+
+};
+
+
+#endif /* SA_NODE_H_ */
diff --git a/SA_POP/SANet/XML_SANet.cpp b/SA_POP/SANet/XML_SANet.cpp
new file mode 100644
index 00000000000..6739be66f72
--- /dev/null
+++ b/SA_POP/SANet/XML_SANet.cpp
@@ -0,0 +1,3467 @@
+#include "XML_SANet.hpp"
+
+namespace SANet
+{
+ namespace XML
+ {
+ // NodeID
+ //
+
+ NodeID::
+ NodeID (::XMLSchema::int_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ NodeID::
+ NodeID (::SANet::XML::NodeID const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::NodeID& NodeID::
+ operator= (::SANet::XML::NodeID const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // PortID
+ //
+
+ PortID::
+ PortID (::XMLSchema::string< wchar_t > const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ PortID::
+ PortID (::SANet::XML::PortID const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::PortID& PortID::
+ operator= (::SANet::XML::PortID const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // TaskCost
+ //
+
+ TaskCost::
+ TaskCost (::XMLSchema::double_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ TaskCost::
+ TaskCost (::SANet::XML::TaskCost const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::TaskCost& TaskCost::
+ operator= (::SANet::XML::TaskCost const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // CondUtil
+ //
+
+ CondUtil::
+ CondUtil (::XMLSchema::double_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ CondUtil::
+ CondUtil (::SANet::XML::CondUtil const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::CondUtil& CondUtil::
+ operator= (::SANet::XML::CondUtil const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // CondKind
+ //
+
+ CondKind::Value CondKind::
+ integral () const
+ {
+ return v_;
+ }
+
+ bool
+ operator== (::SANet::XML::CondKind const& a, ::SANet::XML::CondKind const& b)
+ {
+ return a.v_ == b.v_;
+ }
+
+ bool
+ operator!= (::SANet::XML::CondKind const& a, ::SANet::XML::CondKind const& b)
+ {
+ return a.v_ != b.v_;
+ }
+
+ CondKind::
+ CondKind (CondKind::Value v)
+ : v_ (v)
+ {
+ }
+
+ // Probability
+ //
+
+ Probability::
+ Probability (::XMLSchema::double_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ Probability::
+ Probability (::SANet::XML::Probability const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::Probability& Probability::
+ operator= (::SANet::XML::Probability const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // LinkWeight
+ //
+
+ LinkWeight::
+ LinkWeight (::XMLSchema::double_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ LinkWeight::
+ LinkWeight (::SANet::XML::LinkWeight const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::LinkWeight& LinkWeight::
+ operator= (::SANet::XML::LinkWeight const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // MultFactor
+ //
+
+ MultFactor::
+ MultFactor (::XMLSchema::double_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ MultFactor::
+ MultFactor (::SANet::XML::MultFactor const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SANet::XML::MultFactor& MultFactor::
+ operator= (::SANet::XML::MultFactor const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // TaskNode
+ //
+
+ TaskNode::
+ TaskNode (::SANet::XML::NodeID const& nodeID__,
+ ::XMLSchema::string< wchar_t > const& name__,
+ ::SANet::XML::Probability const& priorProb__,
+ ::SANet::XML::MultFactor const& attenFactor__,
+ ::SANet::XML::TaskCost const& cost__)
+ :
+ ::XSCRT::Type (),
+ nodeID_ (new ::SANet::XML::NodeID (nodeID__)),
+ name_ (new ::XMLSchema::string< wchar_t > (name__)),
+ priorProb_ (new ::SANet::XML::Probability (priorProb__)),
+ attenFactor_ (new ::SANet::XML::MultFactor (attenFactor__)),
+ cost_ (new ::SANet::XML::TaskCost (cost__)),
+ regulator__ ()
+ {
+ nodeID_->container (this);
+ name_->container (this);
+ priorProb_->container (this);
+ attenFactor_->container (this);
+ cost_->container (this);
+ }
+
+ TaskNode::
+ TaskNode (::SANet::XML::TaskNode const& s)
+ :
+ ::XSCRT::Type (),
+ nodeID_ (new ::SANet::XML::NodeID (*s.nodeID_)),
+ name_ (new ::XMLSchema::string< wchar_t > (*s.name_)),
+ priorProb_ (new ::SANet::XML::Probability (*s.priorProb_)),
+ attenFactor_ (new ::SANet::XML::MultFactor (*s.attenFactor_)),
+ cost_ (new ::SANet::XML::TaskCost (*s.cost_)),
+ regulator__ ()
+ {
+ nodeID_->container (this);
+ name_->container (this);
+ priorProb_->container (this);
+ attenFactor_->container (this);
+ cost_->container (this);
+ }
+
+ ::SANet::XML::TaskNode& TaskNode::
+ operator= (::SANet::XML::TaskNode const& s)
+ {
+ nodeID (s.nodeID ());
+
+ name (s.name ());
+
+ priorProb (s.priorProb ());
+
+ attenFactor (s.attenFactor ());
+
+ cost (s.cost ());
+
+ return *this;
+ }
+
+
+ // TaskNode
+ //
+ ::SANet::XML::NodeID const& TaskNode::
+ nodeID () const
+ {
+ return *nodeID_;
+ }
+
+ void TaskNode::
+ nodeID (::SANet::XML::NodeID const& e)
+ {
+ *nodeID_ = e;
+ }
+
+ // TaskNode
+ //
+ ::XMLSchema::string< wchar_t > const& TaskNode::
+ name () const
+ {
+ return *name_;
+ }
+
+ void TaskNode::
+ name (::XMLSchema::string< wchar_t > const& e)
+ {
+ *name_ = e;
+ }
+
+ // TaskNode
+ //
+ ::SANet::XML::Probability const& TaskNode::
+ priorProb () const
+ {
+ return *priorProb_;
+ }
+
+ void TaskNode::
+ priorProb (::SANet::XML::Probability const& e)
+ {
+ *priorProb_ = e;
+ }
+
+ // TaskNode
+ //
+ ::SANet::XML::MultFactor const& TaskNode::
+ attenFactor () const
+ {
+ return *attenFactor_;
+ }
+
+ void TaskNode::
+ attenFactor (::SANet::XML::MultFactor const& e)
+ {
+ *attenFactor_ = e;
+ }
+
+ // TaskNode
+ //
+ ::SANet::XML::TaskCost const& TaskNode::
+ cost () const
+ {
+ return *cost_;
+ }
+
+ void TaskNode::
+ cost (::SANet::XML::TaskCost const& e)
+ {
+ *cost_ = e;
+ }
+
+
+ // CondNode
+ //
+
+ CondNode::
+ CondNode (::SANet::XML::NodeID const& nodeID__,
+ ::XMLSchema::string< wchar_t > const& name__,
+ ::SANet::XML::Probability const& probTrue__,
+ ::SANet::XML::CondUtil const& utility__,
+ ::SANet::XML::CondKind const& kind__,
+ ::SANet::XML::MultFactor const& attenFactor__)
+ :
+ ::XSCRT::Type (),
+ nodeID_ (new ::SANet::XML::NodeID (nodeID__)),
+ name_ (new ::XMLSchema::string< wchar_t > (name__)),
+ probTrue_ (new ::SANet::XML::Probability (probTrue__)),
+ utility_ (new ::SANet::XML::CondUtil (utility__)),
+ kind_ (new ::SANet::XML::CondKind (kind__)),
+ attenFactor_ (new ::SANet::XML::MultFactor (attenFactor__)),
+ regulator__ ()
+ {
+ nodeID_->container (this);
+ name_->container (this);
+ probTrue_->container (this);
+ utility_->container (this);
+ kind_->container (this);
+ attenFactor_->container (this);
+ }
+
+ CondNode::
+ CondNode (::SANet::XML::CondNode const& s)
+ :
+ ::XSCRT::Type (),
+ nodeID_ (new ::SANet::XML::NodeID (*s.nodeID_)),
+ name_ (new ::XMLSchema::string< wchar_t > (*s.name_)),
+ probTrue_ (new ::SANet::XML::Probability (*s.probTrue_)),
+ utility_ (new ::SANet::XML::CondUtil (*s.utility_)),
+ kind_ (new ::SANet::XML::CondKind (*s.kind_)),
+ attenFactor_ (new ::SANet::XML::MultFactor (*s.attenFactor_)),
+ regulator__ ()
+ {
+ nodeID_->container (this);
+ name_->container (this);
+ probTrue_->container (this);
+ utility_->container (this);
+ kind_->container (this);
+ attenFactor_->container (this);
+ }
+
+ ::SANet::XML::CondNode& CondNode::
+ operator= (::SANet::XML::CondNode const& s)
+ {
+ nodeID (s.nodeID ());
+
+ name (s.name ());
+
+ probTrue (s.probTrue ());
+
+ utility (s.utility ());
+
+ kind (s.kind ());
+
+ attenFactor (s.attenFactor ());
+
+ return *this;
+ }
+
+
+ // CondNode
+ //
+ ::SANet::XML::NodeID const& CondNode::
+ nodeID () const
+ {
+ return *nodeID_;
+ }
+
+ void CondNode::
+ nodeID (::SANet::XML::NodeID const& e)
+ {
+ *nodeID_ = e;
+ }
+
+ // CondNode
+ //
+ ::XMLSchema::string< wchar_t > const& CondNode::
+ name () const
+ {
+ return *name_;
+ }
+
+ void CondNode::
+ name (::XMLSchema::string< wchar_t > const& e)
+ {
+ *name_ = e;
+ }
+
+ // CondNode
+ //
+ ::SANet::XML::Probability const& CondNode::
+ probTrue () const
+ {
+ return *probTrue_;
+ }
+
+ void CondNode::
+ probTrue (::SANet::XML::Probability const& e)
+ {
+ *probTrue_ = e;
+ }
+
+ // CondNode
+ //
+ ::SANet::XML::CondUtil const& CondNode::
+ utility () const
+ {
+ return *utility_;
+ }
+
+ void CondNode::
+ utility (::SANet::XML::CondUtil const& e)
+ {
+ *utility_ = e;
+ }
+
+ // CondNode
+ //
+ ::SANet::XML::CondKind const& CondNode::
+ kind () const
+ {
+ return *kind_;
+ }
+
+ void CondNode::
+ kind (::SANet::XML::CondKind const& e)
+ {
+ *kind_ = e;
+ }
+
+ // CondNode
+ //
+ ::SANet::XML::MultFactor const& CondNode::
+ attenFactor () const
+ {
+ return *attenFactor_;
+ }
+
+ void CondNode::
+ attenFactor (::SANet::XML::MultFactor const& e)
+ {
+ *attenFactor_ = e;
+ }
+
+
+ // PrecondLink
+ //
+
+ PrecondLink::
+ PrecondLink (::SANet::XML::NodeID const& condID__,
+ ::SANet::XML::NodeID const& taskID__,
+ ::SANet::XML::PortID const& portID__,
+ ::SANet::XML::Probability const& trueProb__,
+ ::SANet::XML::Probability const& falseProb__)
+ :
+ ::XSCRT::Type (),
+ condID_ (new ::SANet::XML::NodeID (condID__)),
+ taskID_ (new ::SANet::XML::NodeID (taskID__)),
+ portID_ (new ::SANet::XML::PortID (portID__)),
+ trueProb_ (new ::SANet::XML::Probability (trueProb__)),
+ falseProb_ (new ::SANet::XML::Probability (falseProb__)),
+ regulator__ ()
+ {
+ condID_->container (this);
+ taskID_->container (this);
+ portID_->container (this);
+ trueProb_->container (this);
+ falseProb_->container (this);
+ }
+
+ PrecondLink::
+ PrecondLink (::SANet::XML::PrecondLink const& s)
+ :
+ ::XSCRT::Type (),
+ condID_ (new ::SANet::XML::NodeID (*s.condID_)),
+ taskID_ (new ::SANet::XML::NodeID (*s.taskID_)),
+ portID_ (new ::SANet::XML::PortID (*s.portID_)),
+ trueProb_ (new ::SANet::XML::Probability (*s.trueProb_)),
+ falseProb_ (new ::SANet::XML::Probability (*s.falseProb_)),
+ regulator__ ()
+ {
+ condID_->container (this);
+ taskID_->container (this);
+ portID_->container (this);
+ trueProb_->container (this);
+ falseProb_->container (this);
+ }
+
+ ::SANet::XML::PrecondLink& PrecondLink::
+ operator= (::SANet::XML::PrecondLink const& s)
+ {
+ condID (s.condID ());
+
+ taskID (s.taskID ());
+
+ portID (s.portID ());
+
+ trueProb (s.trueProb ());
+
+ falseProb (s.falseProb ());
+
+ return *this;
+ }
+
+
+ // PrecondLink
+ //
+ ::SANet::XML::NodeID const& PrecondLink::
+ condID () const
+ {
+ return *condID_;
+ }
+
+ void PrecondLink::
+ condID (::SANet::XML::NodeID const& e)
+ {
+ *condID_ = e;
+ }
+
+ // PrecondLink
+ //
+ ::SANet::XML::NodeID const& PrecondLink::
+ taskID () const
+ {
+ return *taskID_;
+ }
+
+ void PrecondLink::
+ taskID (::SANet::XML::NodeID const& e)
+ {
+ *taskID_ = e;
+ }
+
+ // PrecondLink
+ //
+ ::SANet::XML::PortID const& PrecondLink::
+ portID () const
+ {
+ return *portID_;
+ }
+
+ void PrecondLink::
+ portID (::SANet::XML::PortID const& e)
+ {
+ *portID_ = e;
+ }
+
+ // PrecondLink
+ //
+ ::SANet::XML::Probability const& PrecondLink::
+ trueProb () const
+ {
+ return *trueProb_;
+ }
+
+ void PrecondLink::
+ trueProb (::SANet::XML::Probability const& e)
+ {
+ *trueProb_ = e;
+ }
+
+ // PrecondLink
+ //
+ ::SANet::XML::Probability const& PrecondLink::
+ falseProb () const
+ {
+ return *falseProb_;
+ }
+
+ void PrecondLink::
+ falseProb (::SANet::XML::Probability const& e)
+ {
+ *falseProb_ = e;
+ }
+
+
+ // EffectLink
+ //
+
+ EffectLink::
+ EffectLink (::SANet::XML::NodeID const& taskID__,
+ ::SANet::XML::NodeID const& condID__,
+ ::SANet::XML::PortID const& portID__,
+ ::SANet::XML::LinkWeight const& weight__)
+ :
+ ::XSCRT::Type (),
+ taskID_ (new ::SANet::XML::NodeID (taskID__)),
+ condID_ (new ::SANet::XML::NodeID (condID__)),
+ portID_ (new ::SANet::XML::PortID (portID__)),
+ weight_ (new ::SANet::XML::LinkWeight (weight__)),
+ regulator__ ()
+ {
+ taskID_->container (this);
+ condID_->container (this);
+ portID_->container (this);
+ weight_->container (this);
+ }
+
+ EffectLink::
+ EffectLink (::SANet::XML::EffectLink const& s)
+ :
+ ::XSCRT::Type (),
+ taskID_ (new ::SANet::XML::NodeID (*s.taskID_)),
+ condID_ (new ::SANet::XML::NodeID (*s.condID_)),
+ portID_ (new ::SANet::XML::PortID (*s.portID_)),
+ weight_ (new ::SANet::XML::LinkWeight (*s.weight_)),
+ regulator__ ()
+ {
+ taskID_->container (this);
+ condID_->container (this);
+ portID_->container (this);
+ weight_->container (this);
+ }
+
+ ::SANet::XML::EffectLink& EffectLink::
+ operator= (::SANet::XML::EffectLink const& s)
+ {
+ taskID (s.taskID ());
+
+ condID (s.condID ());
+
+ portID (s.portID ());
+
+ weight (s.weight ());
+
+ return *this;
+ }
+
+
+ // EffectLink
+ //
+ ::SANet::XML::NodeID const& EffectLink::
+ taskID () const
+ {
+ return *taskID_;
+ }
+
+ void EffectLink::
+ taskID (::SANet::XML::NodeID const& e)
+ {
+ *taskID_ = e;
+ }
+
+ // EffectLink
+ //
+ ::SANet::XML::NodeID const& EffectLink::
+ condID () const
+ {
+ return *condID_;
+ }
+
+ void EffectLink::
+ condID (::SANet::XML::NodeID const& e)
+ {
+ *condID_ = e;
+ }
+
+ // EffectLink
+ //
+ ::SANet::XML::PortID const& EffectLink::
+ portID () const
+ {
+ return *portID_;
+ }
+
+ void EffectLink::
+ portID (::SANet::XML::PortID const& e)
+ {
+ *portID_ = e;
+ }
+
+ // EffectLink
+ //
+ ::SANet::XML::LinkWeight const& EffectLink::
+ weight () const
+ {
+ return *weight_;
+ }
+
+ void EffectLink::
+ weight (::SANet::XML::LinkWeight const& e)
+ {
+ *weight_ = e;
+ }
+
+
+ // Network
+ //
+
+ Network::
+ Network (::SANet::XML::MultFactor const& defaultAttenFactor__,
+ ::SANet::XML::TaskCost const& defaultTaskCost__,
+ ::SANet::XML::CondUtil const& defaultCondUtil__,
+ ::SANet::XML::Probability const& defaultCondProbTrue__,
+ ::SANet::XML::LinkWeight const& linkThresh__)
+ :
+ ::XSCRT::Type (),
+ defaultAttenFactor_ (new ::SANet::XML::MultFactor (defaultAttenFactor__)),
+ defaultTaskCost_ (new ::SANet::XML::TaskCost (defaultTaskCost__)),
+ defaultCondUtil_ (new ::SANet::XML::CondUtil (defaultCondUtil__)),
+ defaultCondProbTrue_ (new ::SANet::XML::Probability (defaultCondProbTrue__)),
+ linkThresh_ (new ::SANet::XML::LinkWeight (linkThresh__)),
+ regulator__ ()
+ {
+ defaultAttenFactor_->container (this);
+ defaultTaskCost_->container (this);
+ defaultCondUtil_->container (this);
+ defaultCondProbTrue_->container (this);
+ linkThresh_->container (this);
+ }
+
+ Network::
+ Network (::SANet::XML::Network const& s)
+ :
+ ::XSCRT::Type (),
+ defaultAttenFactor_ (new ::SANet::XML::MultFactor (*s.defaultAttenFactor_)),
+ defaultTaskCost_ (new ::SANet::XML::TaskCost (*s.defaultTaskCost_)),
+ defaultCondUtil_ (new ::SANet::XML::CondUtil (*s.defaultCondUtil_)),
+ defaultCondProbTrue_ (new ::SANet::XML::Probability (*s.defaultCondProbTrue_)),
+ linkThresh_ (new ::SANet::XML::LinkWeight (*s.linkThresh_)),
+ regulator__ ()
+ {
+ defaultAttenFactor_->container (this);
+ defaultTaskCost_->container (this);
+ defaultCondUtil_->container (this);
+ defaultCondProbTrue_->container (this);
+ linkThresh_->container (this);
+ {
+ for (taskNode_const_iterator i (s.taskNode_.begin ());i != s.taskNode_.end ();++i) add_taskNode (*i);
+ }
+
+ {
+ for (condNode_const_iterator i (s.condNode_.begin ());i != s.condNode_.end ();++i) add_condNode (*i);
+ }
+
+ {
+ for (precondLink_const_iterator i (s.precondLink_.begin ());i != s.precondLink_.end ();++i) add_precondLink (*i);
+ }
+
+ {
+ for (effectLink_const_iterator i (s.effectLink_.begin ());i != s.effectLink_.end ();++i) add_effectLink (*i);
+ }
+ }
+
+ ::SANet::XML::Network& Network::
+ operator= (::SANet::XML::Network const& s)
+ {
+ defaultAttenFactor (s.defaultAttenFactor ());
+
+ defaultTaskCost (s.defaultTaskCost ());
+
+ defaultCondUtil (s.defaultCondUtil ());
+
+ defaultCondProbTrue (s.defaultCondProbTrue ());
+
+ linkThresh (s.linkThresh ());
+
+ taskNode_.clear ();
+ {
+ for (taskNode_const_iterator i (s.taskNode_.begin ());i != s.taskNode_.end ();++i) add_taskNode (*i);
+ }
+
+ condNode_.clear ();
+ {
+ for (condNode_const_iterator i (s.condNode_.begin ());i != s.condNode_.end ();++i) add_condNode (*i);
+ }
+
+ precondLink_.clear ();
+ {
+ for (precondLink_const_iterator i (s.precondLink_.begin ());i != s.precondLink_.end ();++i) add_precondLink (*i);
+ }
+
+ effectLink_.clear ();
+ {
+ for (effectLink_const_iterator i (s.effectLink_.begin ());i != s.effectLink_.end ();++i) add_effectLink (*i);
+ }
+
+ return *this;
+ }
+
+
+ // Network
+ //
+ ::SANet::XML::MultFactor const& Network::
+ defaultAttenFactor () const
+ {
+ return *defaultAttenFactor_;
+ }
+
+ void Network::
+ defaultAttenFactor (::SANet::XML::MultFactor const& e)
+ {
+ *defaultAttenFactor_ = e;
+ }
+
+ // Network
+ //
+ ::SANet::XML::TaskCost const& Network::
+ defaultTaskCost () const
+ {
+ return *defaultTaskCost_;
+ }
+
+ void Network::
+ defaultTaskCost (::SANet::XML::TaskCost const& e)
+ {
+ *defaultTaskCost_ = e;
+ }
+
+ // Network
+ //
+ ::SANet::XML::CondUtil const& Network::
+ defaultCondUtil () const
+ {
+ return *defaultCondUtil_;
+ }
+
+ void Network::
+ defaultCondUtil (::SANet::XML::CondUtil const& e)
+ {
+ *defaultCondUtil_ = e;
+ }
+
+ // Network
+ //
+ ::SANet::XML::Probability const& Network::
+ defaultCondProbTrue () const
+ {
+ return *defaultCondProbTrue_;
+ }
+
+ void Network::
+ defaultCondProbTrue (::SANet::XML::Probability const& e)
+ {
+ *defaultCondProbTrue_ = e;
+ }
+
+ // Network
+ //
+ ::SANet::XML::LinkWeight const& Network::
+ linkThresh () const
+ {
+ return *linkThresh_;
+ }
+
+ void Network::
+ linkThresh (::SANet::XML::LinkWeight const& e)
+ {
+ *linkThresh_ = e;
+ }
+
+ // Network
+ //
+ Network::taskNode_iterator Network::
+ begin_taskNode ()
+ {
+ return taskNode_.begin ();
+ }
+
+ Network::taskNode_iterator Network::
+ end_taskNode ()
+ {
+ return taskNode_.end ();
+ }
+
+ Network::taskNode_const_iterator Network::
+ begin_taskNode () const
+ {
+ return taskNode_.begin ();
+ }
+
+ Network::taskNode_const_iterator Network::
+ end_taskNode () const
+ {
+ return taskNode_.end ();
+ }
+
+ void Network::
+ add_taskNode (::SANet::XML::TaskNode const& e)
+ {
+ taskNode_.push_back (e);
+ }
+
+ size_t Network::
+ count_taskNode(void) const
+ {
+ return taskNode_.size ();
+ }
+
+ // Network
+ //
+ Network::condNode_iterator Network::
+ begin_condNode ()
+ {
+ return condNode_.begin ();
+ }
+
+ Network::condNode_iterator Network::
+ end_condNode ()
+ {
+ return condNode_.end ();
+ }
+
+ Network::condNode_const_iterator Network::
+ begin_condNode () const
+ {
+ return condNode_.begin ();
+ }
+
+ Network::condNode_const_iterator Network::
+ end_condNode () const
+ {
+ return condNode_.end ();
+ }
+
+ void Network::
+ add_condNode (::SANet::XML::CondNode const& e)
+ {
+ condNode_.push_back (e);
+ }
+
+ size_t Network::
+ count_condNode(void) const
+ {
+ return condNode_.size ();
+ }
+
+ // Network
+ //
+ Network::precondLink_iterator Network::
+ begin_precondLink ()
+ {
+ return precondLink_.begin ();
+ }
+
+ Network::precondLink_iterator Network::
+ end_precondLink ()
+ {
+ return precondLink_.end ();
+ }
+
+ Network::precondLink_const_iterator Network::
+ begin_precondLink () const
+ {
+ return precondLink_.begin ();
+ }
+
+ Network::precondLink_const_iterator Network::
+ end_precondLink () const
+ {
+ return precondLink_.end ();
+ }
+
+ void Network::
+ add_precondLink (::SANet::XML::PrecondLink const& e)
+ {
+ precondLink_.push_back (e);
+ }
+
+ size_t Network::
+ count_precondLink(void) const
+ {
+ return precondLink_.size ();
+ }
+
+ // Network
+ //
+ Network::effectLink_iterator Network::
+ begin_effectLink ()
+ {
+ return effectLink_.begin ();
+ }
+
+ Network::effectLink_iterator Network::
+ end_effectLink ()
+ {
+ return effectLink_.end ();
+ }
+
+ Network::effectLink_const_iterator Network::
+ begin_effectLink () const
+ {
+ return effectLink_.begin ();
+ }
+
+ Network::effectLink_const_iterator Network::
+ end_effectLink () const
+ {
+ return effectLink_.end ();
+ }
+
+ void Network::
+ add_effectLink (::SANet::XML::EffectLink const& e)
+ {
+ effectLink_.push_back (e);
+ }
+
+ size_t Network::
+ count_effectLink(void) const
+ {
+ return effectLink_.size ();
+ }
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ // NodeID
+ //
+
+ NodeID::
+ NodeID (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ NodeID::
+ NodeID (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // PortID
+ //
+
+ PortID::
+ PortID (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ PortID::
+ PortID (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // TaskCost
+ //
+
+ TaskCost::
+ TaskCost (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ TaskCost::
+ TaskCost (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // CondUtil
+ //
+
+ CondUtil::
+ CondUtil (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ CondUtil::
+ CondUtil (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // CondKind
+ //
+
+ CondKind::
+ CondKind (::XSCRT::XML::Element< wchar_t > const& e)
+ : ::XSCRT::Type (e)
+ {
+ ::std::basic_string< wchar_t > v (e.value ());
+
+ if (v == L"ENVIRON") v_ = ENVIRON_l;
+ else if (v == L"SYSTEM") v_ = SYSTEM_l;
+ else if (v == L"DATA") v_ = DATA_l;
+ else
+ {
+ }
+ }
+
+ CondKind::
+ CondKind (::XSCRT::XML::Attribute< wchar_t > const& a)
+ : ::XSCRT::Type (a)
+ {
+ ::std::basic_string< wchar_t > v (a.value ());
+
+ if (v == L"ENVIRON") v_ = ENVIRON_l;
+ else if (v == L"SYSTEM") v_ = SYSTEM_l;
+ else if (v == L"DATA") v_ = DATA_l;
+ else
+ {
+ }
+ }
+
+ CondKind const CondKind::ENVIRON (CondKind::ENVIRON_l);
+ CondKind const CondKind::SYSTEM (CondKind::SYSTEM_l);
+ CondKind const CondKind::DATA (CondKind::DATA_l);
+
+ // Probability
+ //
+
+ Probability::
+ Probability (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ Probability::
+ Probability (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // LinkWeight
+ //
+
+ LinkWeight::
+ LinkWeight (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ LinkWeight::
+ LinkWeight (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // MultFactor
+ //
+
+ MultFactor::
+ MultFactor (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ MultFactor::
+ MultFactor (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // TaskNode
+ //
+
+ TaskNode::
+ TaskNode (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"nodeID")
+ {
+ nodeID_ = ::std::auto_ptr< ::SANet::XML::NodeID > (new ::SANet::XML::NodeID (e));
+ nodeID_->container (this);
+ }
+
+ else if (n == L"name")
+ {
+ name_ = ::std::auto_ptr< ::XMLSchema::string< wchar_t > > (new ::XMLSchema::string< wchar_t > (e));
+ name_->container (this);
+ }
+
+ else if (n == L"priorProb")
+ {
+ priorProb_ = ::std::auto_ptr< ::SANet::XML::Probability > (new ::SANet::XML::Probability (e));
+ priorProb_->container (this);
+ }
+
+ else if (n == L"attenFactor")
+ {
+ attenFactor_ = ::std::auto_ptr< ::SANet::XML::MultFactor > (new ::SANet::XML::MultFactor (e));
+ attenFactor_->container (this);
+ }
+
+ else if (n == L"cost")
+ {
+ cost_ = ::std::auto_ptr< ::SANet::XML::TaskCost > (new ::SANet::XML::TaskCost (e));
+ cost_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // CondNode
+ //
+
+ CondNode::
+ CondNode (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"nodeID")
+ {
+ nodeID_ = ::std::auto_ptr< ::SANet::XML::NodeID > (new ::SANet::XML::NodeID (e));
+ nodeID_->container (this);
+ }
+
+ else if (n == L"name")
+ {
+ name_ = ::std::auto_ptr< ::XMLSchema::string< wchar_t > > (new ::XMLSchema::string< wchar_t > (e));
+ name_->container (this);
+ }
+
+ else if (n == L"probTrue")
+ {
+ probTrue_ = ::std::auto_ptr< ::SANet::XML::Probability > (new ::SANet::XML::Probability (e));
+ probTrue_->container (this);
+ }
+
+ else if (n == L"utility")
+ {
+ utility_ = ::std::auto_ptr< ::SANet::XML::CondUtil > (new ::SANet::XML::CondUtil (e));
+ utility_->container (this);
+ }
+
+ else if (n == L"kind")
+ {
+ kind_ = ::std::auto_ptr< ::SANet::XML::CondKind > (new ::SANet::XML::CondKind (e));
+ kind_->container (this);
+ }
+
+ else if (n == L"attenFactor")
+ {
+ attenFactor_ = ::std::auto_ptr< ::SANet::XML::MultFactor > (new ::SANet::XML::MultFactor (e));
+ attenFactor_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // PrecondLink
+ //
+
+ PrecondLink::
+ PrecondLink (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"condID")
+ {
+ condID_ = ::std::auto_ptr< ::SANet::XML::NodeID > (new ::SANet::XML::NodeID (e));
+ condID_->container (this);
+ }
+
+ else if (n == L"taskID")
+ {
+ taskID_ = ::std::auto_ptr< ::SANet::XML::NodeID > (new ::SANet::XML::NodeID (e));
+ taskID_->container (this);
+ }
+
+ else if (n == L"portID")
+ {
+ portID_ = ::std::auto_ptr< ::SANet::XML::PortID > (new ::SANet::XML::PortID (e));
+ portID_->container (this);
+ }
+
+ else if (n == L"trueProb")
+ {
+ trueProb_ = ::std::auto_ptr< ::SANet::XML::Probability > (new ::SANet::XML::Probability (e));
+ trueProb_->container (this);
+ }
+
+ else if (n == L"falseProb")
+ {
+ falseProb_ = ::std::auto_ptr< ::SANet::XML::Probability > (new ::SANet::XML::Probability (e));
+ falseProb_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // EffectLink
+ //
+
+ EffectLink::
+ EffectLink (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"taskID")
+ {
+ taskID_ = ::std::auto_ptr< ::SANet::XML::NodeID > (new ::SANet::XML::NodeID (e));
+ taskID_->container (this);
+ }
+
+ else if (n == L"condID")
+ {
+ condID_ = ::std::auto_ptr< ::SANet::XML::NodeID > (new ::SANet::XML::NodeID (e));
+ condID_->container (this);
+ }
+
+ else if (n == L"portID")
+ {
+ portID_ = ::std::auto_ptr< ::SANet::XML::PortID > (new ::SANet::XML::PortID (e));
+ portID_->container (this);
+ }
+
+ else if (n == L"weight")
+ {
+ weight_ = ::std::auto_ptr< ::SANet::XML::LinkWeight > (new ::SANet::XML::LinkWeight (e));
+ weight_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // Network
+ //
+
+ Network::
+ Network (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"defaultAttenFactor")
+ {
+ defaultAttenFactor_ = ::std::auto_ptr< ::SANet::XML::MultFactor > (new ::SANet::XML::MultFactor (e));
+ defaultAttenFactor_->container (this);
+ }
+
+ else if (n == L"defaultTaskCost")
+ {
+ defaultTaskCost_ = ::std::auto_ptr< ::SANet::XML::TaskCost > (new ::SANet::XML::TaskCost (e));
+ defaultTaskCost_->container (this);
+ }
+
+ else if (n == L"defaultCondUtil")
+ {
+ defaultCondUtil_ = ::std::auto_ptr< ::SANet::XML::CondUtil > (new ::SANet::XML::CondUtil (e));
+ defaultCondUtil_->container (this);
+ }
+
+ else if (n == L"defaultCondProbTrue")
+ {
+ defaultCondProbTrue_ = ::std::auto_ptr< ::SANet::XML::Probability > (new ::SANet::XML::Probability (e));
+ defaultCondProbTrue_->container (this);
+ }
+
+ else if (n == L"linkThresh")
+ {
+ linkThresh_ = ::std::auto_ptr< ::SANet::XML::LinkWeight > (new ::SANet::XML::LinkWeight (e));
+ linkThresh_->container (this);
+ }
+
+ else if (n == L"taskNode")
+ {
+ ::SANet::XML::TaskNode t (e);
+ add_taskNode (t);
+ }
+
+ else if (n == L"condNode")
+ {
+ ::SANet::XML::CondNode t (e);
+ add_condNode (t);
+ }
+
+ else if (n == L"precondLink")
+ {
+ ::SANet::XML::PrecondLink t (e);
+ add_precondLink (t);
+ }
+
+ else if (n == L"effectLink")
+ {
+ ::SANet::XML::EffectLink t (e);
+ add_effectLink (t);
+ }
+
+ else
+ {
+ }
+ }
+ }
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ ::SANet::XML::Network
+ network (xercesc::DOMDocument const* d)
+ {
+ std::cout << "In create netwokr!\n";
+ ::XSCRT::XML::Element< wchar_t > e (d->getDocumentElement ());
+ std::cout << "Got the element from the network!\n";
+ if (e.name () == L"network")
+ {
+
+ ::SANet::XML::Network r (e);
+ std::cout << "Done creating the network\n";
+ return r;
+ }
+
+ else
+ {
+ std::wcout << "The network name is not equal to network, but it is " << e.name().c_str() << std::endl;
+ throw 1;
+ }
+ }
+ }
+}
+
+#include "XMLSchema/TypeInfo.hpp"
+
+namespace SANet
+{
+ namespace XML
+ {
+ namespace
+ {
+ ::XMLSchema::TypeInfoInitializer < wchar_t > XMLSchemaTypeInfoInitializer_ (::XSCRT::extended_type_info_map ());
+
+ struct NodeIDTypeInfoInitializer
+ {
+ NodeIDTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (NodeID));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::int_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ NodeIDTypeInfoInitializer NodeIDTypeInfoInitializer_;
+
+ struct PortIDTypeInfoInitializer
+ {
+ PortIDTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (PortID));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::string< wchar_t >));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ PortIDTypeInfoInitializer PortIDTypeInfoInitializer_;
+
+ struct TaskCostTypeInfoInitializer
+ {
+ TaskCostTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskCost));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::double_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskCostTypeInfoInitializer TaskCostTypeInfoInitializer_;
+
+ struct CondUtilTypeInfoInitializer
+ {
+ CondUtilTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (CondUtil));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::double_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ CondUtilTypeInfoInitializer CondUtilTypeInfoInitializer_;
+
+ struct CondKindTypeInfoInitializer
+ {
+ CondKindTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (CondKind));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ CondKindTypeInfoInitializer CondKindTypeInfoInitializer_;
+
+ struct ProbabilityTypeInfoInitializer
+ {
+ ProbabilityTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (Probability));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::double_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ProbabilityTypeInfoInitializer ProbabilityTypeInfoInitializer_;
+
+ struct LinkWeightTypeInfoInitializer
+ {
+ LinkWeightTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (LinkWeight));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::double_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ LinkWeightTypeInfoInitializer LinkWeightTypeInfoInitializer_;
+
+ struct MultFactorTypeInfoInitializer
+ {
+ MultFactorTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (MultFactor));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::double_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ MultFactorTypeInfoInitializer MultFactorTypeInfoInitializer_;
+
+ struct TaskNodeTypeInfoInitializer
+ {
+ TaskNodeTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskNode));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskNodeTypeInfoInitializer TaskNodeTypeInfoInitializer_;
+
+ struct CondNodeTypeInfoInitializer
+ {
+ CondNodeTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (CondNode));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ CondNodeTypeInfoInitializer CondNodeTypeInfoInitializer_;
+
+ struct PrecondLinkTypeInfoInitializer
+ {
+ PrecondLinkTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (PrecondLink));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ PrecondLinkTypeInfoInitializer PrecondLinkTypeInfoInitializer_;
+
+ struct EffectLinkTypeInfoInitializer
+ {
+ EffectLinkTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (EffectLink));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ EffectLinkTypeInfoInitializer EffectLinkTypeInfoInitializer_;
+
+ struct NetworkTypeInfoInitializer
+ {
+ NetworkTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (Network));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ NetworkTypeInfoInitializer NetworkTypeInfoInitializer_;
+ }
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ namespace Traversal
+ {
+ // NodeID
+ //
+ //
+
+ void NodeID::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void NodeID::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void NodeID::
+ pre (Type&)
+ {
+ }
+
+ void NodeID::
+ pre (Type const&)
+ {
+ }
+
+ void NodeID::
+ post (Type&)
+ {
+ }
+
+ void NodeID::
+ post (Type const&)
+ {
+ }
+
+ // PortID
+ //
+ //
+
+ void PortID::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void PortID::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void PortID::
+ pre (Type&)
+ {
+ }
+
+ void PortID::
+ pre (Type const&)
+ {
+ }
+
+ void PortID::
+ post (Type&)
+ {
+ }
+
+ void PortID::
+ post (Type const&)
+ {
+ }
+
+ // TaskCost
+ //
+ //
+
+ void TaskCost::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TaskCost::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TaskCost::
+ pre (Type&)
+ {
+ }
+
+ void TaskCost::
+ pre (Type const&)
+ {
+ }
+
+ void TaskCost::
+ post (Type&)
+ {
+ }
+
+ void TaskCost::
+ post (Type const&)
+ {
+ }
+
+ // CondUtil
+ //
+ //
+
+ void CondUtil::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void CondUtil::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void CondUtil::
+ pre (Type&)
+ {
+ }
+
+ void CondUtil::
+ pre (Type const&)
+ {
+ }
+
+ void CondUtil::
+ post (Type&)
+ {
+ }
+
+ void CondUtil::
+ post (Type const&)
+ {
+ }
+
+ // Probability
+ //
+ //
+
+ void Probability::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void Probability::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void Probability::
+ pre (Type&)
+ {
+ }
+
+ void Probability::
+ pre (Type const&)
+ {
+ }
+
+ void Probability::
+ post (Type&)
+ {
+ }
+
+ void Probability::
+ post (Type const&)
+ {
+ }
+
+ // LinkWeight
+ //
+ //
+
+ void LinkWeight::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void LinkWeight::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void LinkWeight::
+ pre (Type&)
+ {
+ }
+
+ void LinkWeight::
+ pre (Type const&)
+ {
+ }
+
+ void LinkWeight::
+ post (Type&)
+ {
+ }
+
+ void LinkWeight::
+ post (Type const&)
+ {
+ }
+
+ // MultFactor
+ //
+ //
+
+ void MultFactor::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void MultFactor::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void MultFactor::
+ pre (Type&)
+ {
+ }
+
+ void MultFactor::
+ pre (Type const&)
+ {
+ }
+
+ void MultFactor::
+ post (Type&)
+ {
+ }
+
+ void MultFactor::
+ post (Type const&)
+ {
+ }
+
+ // TaskNode
+ //
+ //
+
+ void TaskNode::
+ traverse (Type& o)
+ {
+ pre (o);
+ nodeID (o);
+ name (o);
+ priorProb (o);
+ attenFactor (o);
+ cost (o);
+ post (o);
+ }
+
+ void TaskNode::
+ traverse (Type const& o)
+ {
+ pre (o);
+ nodeID (o);
+ name (o);
+ priorProb (o);
+ attenFactor (o);
+ cost (o);
+ post (o);
+ }
+
+ void TaskNode::
+ pre (Type&)
+ {
+ }
+
+ void TaskNode::
+ pre (Type const&)
+ {
+ }
+
+ void TaskNode::
+ nodeID (Type& o)
+ {
+ dispatch (o.nodeID ());
+ }
+
+ void TaskNode::
+ nodeID (Type const& o)
+ {
+ dispatch (o.nodeID ());
+ }
+
+ void TaskNode::
+ name (Type& o)
+ {
+ dispatch (o.name ());
+ }
+
+ void TaskNode::
+ name (Type const& o)
+ {
+ dispatch (o.name ());
+ }
+
+ void TaskNode::
+ priorProb (Type& o)
+ {
+ dispatch (o.priorProb ());
+ }
+
+ void TaskNode::
+ priorProb (Type const& o)
+ {
+ dispatch (o.priorProb ());
+ }
+
+ void TaskNode::
+ attenFactor (Type& o)
+ {
+ dispatch (o.attenFactor ());
+ }
+
+ void TaskNode::
+ attenFactor (Type const& o)
+ {
+ dispatch (o.attenFactor ());
+ }
+
+ void TaskNode::
+ cost (Type& o)
+ {
+ dispatch (o.cost ());
+ }
+
+ void TaskNode::
+ cost (Type const& o)
+ {
+ dispatch (o.cost ());
+ }
+
+ void TaskNode::
+ post (Type&)
+ {
+ }
+
+ void TaskNode::
+ post (Type const&)
+ {
+ }
+
+ // CondNode
+ //
+ //
+
+ void CondNode::
+ traverse (Type& o)
+ {
+ pre (o);
+ nodeID (o);
+ name (o);
+ probTrue (o);
+ utility (o);
+ kind (o);
+ attenFactor (o);
+ post (o);
+ }
+
+ void CondNode::
+ traverse (Type const& o)
+ {
+ pre (o);
+ nodeID (o);
+ name (o);
+ probTrue (o);
+ utility (o);
+ kind (o);
+ attenFactor (o);
+ post (o);
+ }
+
+ void CondNode::
+ pre (Type&)
+ {
+ }
+
+ void CondNode::
+ pre (Type const&)
+ {
+ }
+
+ void CondNode::
+ nodeID (Type& o)
+ {
+ dispatch (o.nodeID ());
+ }
+
+ void CondNode::
+ nodeID (Type const& o)
+ {
+ dispatch (o.nodeID ());
+ }
+
+ void CondNode::
+ name (Type& o)
+ {
+ dispatch (o.name ());
+ }
+
+ void CondNode::
+ name (Type const& o)
+ {
+ dispatch (o.name ());
+ }
+
+ void CondNode::
+ probTrue (Type& o)
+ {
+ dispatch (o.probTrue ());
+ }
+
+ void CondNode::
+ probTrue (Type const& o)
+ {
+ dispatch (o.probTrue ());
+ }
+
+ void CondNode::
+ utility (Type& o)
+ {
+ dispatch (o.utility ());
+ }
+
+ void CondNode::
+ utility (Type const& o)
+ {
+ dispatch (o.utility ());
+ }
+
+ void CondNode::
+ kind (Type& o)
+ {
+ dispatch (o.kind ());
+ }
+
+ void CondNode::
+ kind (Type const& o)
+ {
+ dispatch (o.kind ());
+ }
+
+ void CondNode::
+ attenFactor (Type& o)
+ {
+ dispatch (o.attenFactor ());
+ }
+
+ void CondNode::
+ attenFactor (Type const& o)
+ {
+ dispatch (o.attenFactor ());
+ }
+
+ void CondNode::
+ post (Type&)
+ {
+ }
+
+ void CondNode::
+ post (Type const&)
+ {
+ }
+
+ // PrecondLink
+ //
+ //
+
+ void PrecondLink::
+ traverse (Type& o)
+ {
+ pre (o);
+ condID (o);
+ taskID (o);
+ portID (o);
+ trueProb (o);
+ falseProb (o);
+ post (o);
+ }
+
+ void PrecondLink::
+ traverse (Type const& o)
+ {
+ pre (o);
+ condID (o);
+ taskID (o);
+ portID (o);
+ trueProb (o);
+ falseProb (o);
+ post (o);
+ }
+
+ void PrecondLink::
+ pre (Type&)
+ {
+ }
+
+ void PrecondLink::
+ pre (Type const&)
+ {
+ }
+
+ void PrecondLink::
+ condID (Type& o)
+ {
+ dispatch (o.condID ());
+ }
+
+ void PrecondLink::
+ condID (Type const& o)
+ {
+ dispatch (o.condID ());
+ }
+
+ void PrecondLink::
+ taskID (Type& o)
+ {
+ dispatch (o.taskID ());
+ }
+
+ void PrecondLink::
+ taskID (Type const& o)
+ {
+ dispatch (o.taskID ());
+ }
+
+ void PrecondLink::
+ portID (Type& o)
+ {
+ dispatch (o.portID ());
+ }
+
+ void PrecondLink::
+ portID (Type const& o)
+ {
+ dispatch (o.portID ());
+ }
+
+ void PrecondLink::
+ trueProb (Type& o)
+ {
+ dispatch (o.trueProb ());
+ }
+
+ void PrecondLink::
+ trueProb (Type const& o)
+ {
+ dispatch (o.trueProb ());
+ }
+
+ void PrecondLink::
+ falseProb (Type& o)
+ {
+ dispatch (o.falseProb ());
+ }
+
+ void PrecondLink::
+ falseProb (Type const& o)
+ {
+ dispatch (o.falseProb ());
+ }
+
+ void PrecondLink::
+ post (Type&)
+ {
+ }
+
+ void PrecondLink::
+ post (Type const&)
+ {
+ }
+
+ // EffectLink
+ //
+ //
+
+ void EffectLink::
+ traverse (Type& o)
+ {
+ pre (o);
+ taskID (o);
+ condID (o);
+ portID (o);
+ weight (o);
+ post (o);
+ }
+
+ void EffectLink::
+ traverse (Type const& o)
+ {
+ pre (o);
+ taskID (o);
+ condID (o);
+ portID (o);
+ weight (o);
+ post (o);
+ }
+
+ void EffectLink::
+ pre (Type&)
+ {
+ }
+
+ void EffectLink::
+ pre (Type const&)
+ {
+ }
+
+ void EffectLink::
+ taskID (Type& o)
+ {
+ dispatch (o.taskID ());
+ }
+
+ void EffectLink::
+ taskID (Type const& o)
+ {
+ dispatch (o.taskID ());
+ }
+
+ void EffectLink::
+ condID (Type& o)
+ {
+ dispatch (o.condID ());
+ }
+
+ void EffectLink::
+ condID (Type const& o)
+ {
+ dispatch (o.condID ());
+ }
+
+ void EffectLink::
+ portID (Type& o)
+ {
+ dispatch (o.portID ());
+ }
+
+ void EffectLink::
+ portID (Type const& o)
+ {
+ dispatch (o.portID ());
+ }
+
+ void EffectLink::
+ weight (Type& o)
+ {
+ dispatch (o.weight ());
+ }
+
+ void EffectLink::
+ weight (Type const& o)
+ {
+ dispatch (o.weight ());
+ }
+
+ void EffectLink::
+ post (Type&)
+ {
+ }
+
+ void EffectLink::
+ post (Type const&)
+ {
+ }
+
+ // Network
+ //
+ //
+
+ void Network::
+ traverse (Type& o)
+ {
+ pre (o);
+ defaultAttenFactor (o);
+ defaultTaskCost (o);
+ defaultCondUtil (o);
+ defaultCondProbTrue (o);
+ linkThresh (o);
+ taskNode (o);
+ condNode (o);
+ precondLink (o);
+ effectLink (o);
+ post (o);
+ }
+
+ void Network::
+ traverse (Type const& o)
+ {
+ pre (o);
+ defaultAttenFactor (o);
+ defaultTaskCost (o);
+ defaultCondUtil (o);
+ defaultCondProbTrue (o);
+ linkThresh (o);
+ taskNode (o);
+ condNode (o);
+ precondLink (o);
+ effectLink (o);
+ post (o);
+ }
+
+ void Network::
+ pre (Type&)
+ {
+ }
+
+ void Network::
+ pre (Type const&)
+ {
+ }
+
+ void Network::
+ defaultAttenFactor (Type& o)
+ {
+ dispatch (o.defaultAttenFactor ());
+ }
+
+ void Network::
+ defaultAttenFactor (Type const& o)
+ {
+ dispatch (o.defaultAttenFactor ());
+ }
+
+ void Network::
+ defaultTaskCost (Type& o)
+ {
+ dispatch (o.defaultTaskCost ());
+ }
+
+ void Network::
+ defaultTaskCost (Type const& o)
+ {
+ dispatch (o.defaultTaskCost ());
+ }
+
+ void Network::
+ defaultCondUtil (Type& o)
+ {
+ dispatch (o.defaultCondUtil ());
+ }
+
+ void Network::
+ defaultCondUtil (Type const& o)
+ {
+ dispatch (o.defaultCondUtil ());
+ }
+
+ void Network::
+ defaultCondProbTrue (Type& o)
+ {
+ dispatch (o.defaultCondProbTrue ());
+ }
+
+ void Network::
+ defaultCondProbTrue (Type const& o)
+ {
+ dispatch (o.defaultCondProbTrue ());
+ }
+
+ void Network::
+ linkThresh (Type& o)
+ {
+ dispatch (o.linkThresh ());
+ }
+
+ void Network::
+ linkThresh (Type const& o)
+ {
+ dispatch (o.linkThresh ());
+ }
+
+ void Network::
+ taskNode (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::taskNode_iterator b (o.begin_taskNode()), e (o.end_taskNode());
+
+ if (b != e)
+ {
+ taskNode_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) taskNode_next (o);
+ }
+
+ taskNode_post (o);
+ }
+ }
+
+ void Network::
+ taskNode (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::taskNode_const_iterator b (o.begin_taskNode()), e (o.end_taskNode());
+
+ if (b != e)
+ {
+ taskNode_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) taskNode_next (o);
+ }
+
+ taskNode_post (o);
+ }
+ }
+
+ void Network::
+ taskNode_pre (Type&)
+ {
+ }
+
+ void Network::
+ taskNode_pre (Type const&)
+ {
+ }
+
+ void Network::
+ taskNode_next (Type&)
+ {
+ }
+
+ void Network::
+ taskNode_next (Type const&)
+ {
+ }
+
+ void Network::
+ taskNode_post (Type&)
+ {
+ }
+
+ void Network::
+ taskNode_post (Type const&)
+ {
+ }
+
+ void Network::
+ condNode (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::condNode_iterator b (o.begin_condNode()), e (o.end_condNode());
+
+ if (b != e)
+ {
+ condNode_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) condNode_next (o);
+ }
+
+ condNode_post (o);
+ }
+ }
+
+ void Network::
+ condNode (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::condNode_const_iterator b (o.begin_condNode()), e (o.end_condNode());
+
+ if (b != e)
+ {
+ condNode_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) condNode_next (o);
+ }
+
+ condNode_post (o);
+ }
+ }
+
+ void Network::
+ condNode_pre (Type&)
+ {
+ }
+
+ void Network::
+ condNode_pre (Type const&)
+ {
+ }
+
+ void Network::
+ condNode_next (Type&)
+ {
+ }
+
+ void Network::
+ condNode_next (Type const&)
+ {
+ }
+
+ void Network::
+ condNode_post (Type&)
+ {
+ }
+
+ void Network::
+ condNode_post (Type const&)
+ {
+ }
+
+ void Network::
+ precondLink (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::precondLink_iterator b (o.begin_precondLink()), e (o.end_precondLink());
+
+ if (b != e)
+ {
+ precondLink_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) precondLink_next (o);
+ }
+
+ precondLink_post (o);
+ }
+ }
+
+ void Network::
+ precondLink (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::precondLink_const_iterator b (o.begin_precondLink()), e (o.end_precondLink());
+
+ if (b != e)
+ {
+ precondLink_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) precondLink_next (o);
+ }
+
+ precondLink_post (o);
+ }
+ }
+
+ void Network::
+ precondLink_pre (Type&)
+ {
+ }
+
+ void Network::
+ precondLink_pre (Type const&)
+ {
+ }
+
+ void Network::
+ precondLink_next (Type&)
+ {
+ }
+
+ void Network::
+ precondLink_next (Type const&)
+ {
+ }
+
+ void Network::
+ precondLink_post (Type&)
+ {
+ }
+
+ void Network::
+ precondLink_post (Type const&)
+ {
+ }
+
+ void Network::
+ effectLink (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::effectLink_iterator b (o.begin_effectLink()), e (o.end_effectLink());
+
+ if (b != e)
+ {
+ effectLink_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) effectLink_next (o);
+ }
+
+ effectLink_post (o);
+ }
+ }
+
+ void Network::
+ effectLink (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ Network::Type::effectLink_const_iterator b (o.begin_effectLink()), e (o.end_effectLink());
+
+ if (b != e)
+ {
+ effectLink_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) effectLink_next (o);
+ }
+
+ effectLink_post (o);
+ }
+ }
+
+ void Network::
+ effectLink_pre (Type&)
+ {
+ }
+
+ void Network::
+ effectLink_pre (Type const&)
+ {
+ }
+
+ void Network::
+ effectLink_next (Type&)
+ {
+ }
+
+ void Network::
+ effectLink_next (Type const&)
+ {
+ }
+
+ void Network::
+ effectLink_post (Type&)
+ {
+ }
+
+ void Network::
+ effectLink_post (Type const&)
+ {
+ }
+
+ void Network::
+ post (Type&)
+ {
+ }
+
+ void Network::
+ post (Type const&)
+ {
+ }
+ }
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ namespace Writer
+ {
+ // NodeID
+ //
+ //
+
+ NodeID::
+ NodeID (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ NodeID::
+ NodeID ()
+ {
+ }
+
+ void NodeID::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >::traverse (o);
+ Traversal::NodeID::traverse (o);
+ }
+
+ // PortID
+ //
+ //
+
+ PortID::
+ PortID (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ PortID::
+ PortID ()
+ {
+ }
+
+ void PortID::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >::traverse (o);
+ Traversal::PortID::traverse (o);
+ }
+
+ // TaskCost
+ //
+ //
+
+ TaskCost::
+ TaskCost (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskCost::
+ TaskCost ()
+ {
+ }
+
+ void TaskCost::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >::traverse (o);
+ Traversal::TaskCost::traverse (o);
+ }
+
+ // CondUtil
+ //
+ //
+
+ CondUtil::
+ CondUtil (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ CondUtil::
+ CondUtil ()
+ {
+ }
+
+ void CondUtil::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >::traverse (o);
+ Traversal::CondUtil::traverse (o);
+ }
+
+ // CondKind
+ //
+ //
+
+ CondKind::
+ CondKind (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ CondKind::
+ CondKind ()
+ {
+ }
+
+ void CondKind::
+ traverse (Type const& o)
+ {
+ ::std::basic_string< wchar_t > s;
+
+ if (o == ::SANet::XML::CondKind::ENVIRON) s = L"ENVIRON";
+ else if (o == ::SANet::XML::CondKind::SYSTEM) s = L"SYSTEM";
+ else if (o == ::SANet::XML::CondKind::DATA) s = L"DATA";
+ else
+ {
+ }
+
+ if (::XSCRT::XML::Attribute< wchar_t >* a = attr_ ())
+ {
+ a->value (s);
+ }
+
+ else
+ {
+ top_().value (s);
+ }
+ }
+
+ // Probability
+ //
+ //
+
+ Probability::
+ Probability (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ Probability::
+ Probability ()
+ {
+ }
+
+ void Probability::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >::traverse (o);
+ Traversal::Probability::traverse (o);
+ }
+
+ // LinkWeight
+ //
+ //
+
+ LinkWeight::
+ LinkWeight (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ LinkWeight::
+ LinkWeight ()
+ {
+ }
+
+ void LinkWeight::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >::traverse (o);
+ Traversal::LinkWeight::traverse (o);
+ }
+
+ // MultFactor
+ //
+ //
+
+ MultFactor::
+ MultFactor (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ MultFactor::
+ MultFactor ()
+ {
+ }
+
+ void MultFactor::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >::traverse (o);
+ Traversal::MultFactor::traverse (o);
+ }
+
+ // TaskNode
+ //
+ //
+
+ TaskNode::
+ TaskNode (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskNode::
+ TaskNode ()
+ {
+ }
+
+ void TaskNode::
+ traverse (Type const& o)
+ {
+ Traversal::TaskNode::traverse (o);
+ }
+
+ void TaskNode::
+ nodeID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"nodeID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::TaskNode::nodeID (o);
+ pop_ ();
+ }
+
+ void TaskNode::
+ name (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"name", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::TaskNode::name (o);
+ pop_ ();
+ }
+
+ void TaskNode::
+ priorProb (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"priorProb", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::TaskNode::priorProb (o);
+ pop_ ();
+ }
+
+ void TaskNode::
+ attenFactor (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"attenFactor", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::TaskNode::attenFactor (o);
+ pop_ ();
+ }
+
+ void TaskNode::
+ cost (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"cost", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::TaskNode::cost (o);
+ pop_ ();
+ }
+
+ // CondNode
+ //
+ //
+
+ CondNode::
+ CondNode (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ CondNode::
+ CondNode ()
+ {
+ }
+
+ void CondNode::
+ traverse (Type const& o)
+ {
+ Traversal::CondNode::traverse (o);
+ }
+
+ void CondNode::
+ nodeID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"nodeID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::CondNode::nodeID (o);
+ pop_ ();
+ }
+
+ void CondNode::
+ name (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"name", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::CondNode::name (o);
+ pop_ ();
+ }
+
+ void CondNode::
+ probTrue (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"probTrue", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::CondNode::probTrue (o);
+ pop_ ();
+ }
+
+ void CondNode::
+ utility (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"utility", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::CondNode::utility (o);
+ pop_ ();
+ }
+
+ void CondNode::
+ kind (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"kind", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::CondNode::kind (o);
+ pop_ ();
+ }
+
+ void CondNode::
+ attenFactor (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"attenFactor", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::CondNode::attenFactor (o);
+ pop_ ();
+ }
+
+ // PrecondLink
+ //
+ //
+
+ PrecondLink::
+ PrecondLink (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ PrecondLink::
+ PrecondLink ()
+ {
+ }
+
+ void PrecondLink::
+ traverse (Type const& o)
+ {
+ Traversal::PrecondLink::traverse (o);
+ }
+
+ void PrecondLink::
+ condID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"condID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::PrecondLink::condID (o);
+ pop_ ();
+ }
+
+ void PrecondLink::
+ taskID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"taskID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::PrecondLink::taskID (o);
+ pop_ ();
+ }
+
+ void PrecondLink::
+ portID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"portID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::PrecondLink::portID (o);
+ pop_ ();
+ }
+
+ void PrecondLink::
+ trueProb (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"trueProb", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::PrecondLink::trueProb (o);
+ pop_ ();
+ }
+
+ void PrecondLink::
+ falseProb (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"falseProb", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::PrecondLink::falseProb (o);
+ pop_ ();
+ }
+
+ // EffectLink
+ //
+ //
+
+ EffectLink::
+ EffectLink (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ EffectLink::
+ EffectLink ()
+ {
+ }
+
+ void EffectLink::
+ traverse (Type const& o)
+ {
+ Traversal::EffectLink::traverse (o);
+ }
+
+ void EffectLink::
+ taskID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"taskID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::EffectLink::taskID (o);
+ pop_ ();
+ }
+
+ void EffectLink::
+ condID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"condID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::EffectLink::condID (o);
+ pop_ ();
+ }
+
+ void EffectLink::
+ portID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"portID", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::EffectLink::portID (o);
+ pop_ ();
+ }
+
+ void EffectLink::
+ weight (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"weight", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::EffectLink::weight (o);
+ pop_ ();
+ }
+
+ // Network
+ //
+ //
+
+ Network::
+ Network (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ Network::
+ Network ()
+ {
+ }
+
+ void Network::
+ traverse (Type const& o)
+ {
+ Traversal::Network::traverse (o);
+ }
+
+ void Network::
+ defaultAttenFactor (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"defaultAttenFactor", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::Network::defaultAttenFactor (o);
+ pop_ ();
+ }
+
+ void Network::
+ defaultTaskCost (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"defaultTaskCost", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::Network::defaultTaskCost (o);
+ pop_ ();
+ }
+
+ void Network::
+ defaultCondUtil (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"defaultCondUtil", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::Network::defaultCondUtil (o);
+ pop_ ();
+ }
+
+ void Network::
+ defaultCondProbTrue (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"defaultCondProbTrue", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::Network::defaultCondProbTrue (o);
+ pop_ ();
+ }
+
+ void Network::
+ linkThresh (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"linkThresh", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ Traversal::Network::linkThresh (o);
+ pop_ ();
+ }
+
+ void Network::
+ taskNode_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"taskNode", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ }
+
+ void Network::
+ taskNode_next (Type const& o)
+ {
+ taskNode_post (o);
+ taskNode_pre (o);
+ }
+
+ void Network::
+ taskNode_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ void Network::
+ condNode_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"condNode", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ }
+
+ void Network::
+ condNode_next (Type const& o)
+ {
+ condNode_post (o);
+ condNode_pre (o);
+ }
+
+ void Network::
+ condNode_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ void Network::
+ precondLink_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"precondLink", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ }
+
+ void Network::
+ precondLink_next (Type const& o)
+ {
+ precondLink_post (o);
+ precondLink_pre (o);
+ }
+
+ void Network::
+ precondLink_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ void Network::
+ effectLink_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"effectLink", L"http://www.vanderbilt.edu/SANet", top_ ()));
+ }
+
+ void Network::
+ effectLink_next (Type const& o)
+ {
+ effectLink_post (o);
+ effectLink_pre (o);
+ }
+
+ void Network::
+ effectLink_post (Type const&)
+ {
+ pop_ ();
+ }
+ }
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ void
+ network (::SANet::XML::Network const& s, xercesc::DOMDocument* d)
+ {
+ ::XSCRT::XML::Element< wchar_t > e (d->getDocumentElement ());
+ if (e.name () != L"network")
+ {
+ throw 1;
+ }
+
+ struct W : virtual ::SANet::XML::Writer::Network,
+ virtual ::SANet::XML::Writer::MultFactor,
+ virtual ::SANet::XML::Writer::TaskCost,
+ virtual ::SANet::XML::Writer::CondUtil,
+ virtual ::SANet::XML::Writer::Probability,
+ virtual ::SANet::XML::Writer::LinkWeight,
+ virtual ::SANet::XML::Writer::TaskNode,
+ virtual ::SANet::XML::Writer::NodeID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::SANet::XML::Writer::CondNode,
+ virtual ::SANet::XML::Writer::CondKind,
+ virtual ::SANet::XML::Writer::PrecondLink,
+ virtual ::SANet::XML::Writer::PortID,
+ virtual ::SANet::XML::Writer::EffectLink,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ W (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+ };
+
+ W w (e);
+ w.dispatch (s);
+ }
+ }
+}
+
diff --git a/SA_POP/SANet/XML_SANet.hpp b/SA_POP/SANet/XML_SANet.hpp
new file mode 100644
index 00000000000..865926a9a36
--- /dev/null
+++ b/SA_POP/SANet/XML_SANet.hpp
@@ -0,0 +1,1830 @@
+#ifndef XML_SANET_HPP
+#define XML_SANET_HPP
+
+// Forward declarations.
+//
+namespace SANet
+{
+ namespace XML
+ {
+ class NodeID;
+ class PortID;
+ class TaskCost;
+ class CondUtil;
+ class CondKind;
+ class Probability;
+ class LinkWeight;
+ class MultFactor;
+ class TaskNode;
+ class CondNode;
+ class PrecondLink;
+ class EffectLink;
+ class Network;
+ }
+}
+
+#include <memory>
+#include <list>
+#include "XMLSchema/Types.hpp"
+
+namespace SANet
+{
+ namespace XML
+ {
+ class NodeID : public ::XMLSchema::int_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::int_ Base__;
+
+ public:
+ NodeID (::XMLSchema::int_ const& b__);
+
+ NodeID (::XSCRT::XML::Element< wchar_t > const&);
+ NodeID (::XSCRT::XML::Attribute< wchar_t > const&);
+ NodeID (NodeID const& s);
+
+ NodeID&
+ operator= (NodeID const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class PortID : public ::XMLSchema::string< wchar_t >
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::string< wchar_t > Base__;
+
+ public:
+ PortID (::XMLSchema::string< wchar_t > const& b__);
+
+ PortID (::XSCRT::XML::Element< wchar_t > const&);
+ PortID (::XSCRT::XML::Attribute< wchar_t > const&);
+ PortID (PortID const& s);
+
+ PortID&
+ operator= (PortID const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class TaskCost : public ::XMLSchema::double_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::double_ Base__;
+
+ public:
+ TaskCost (::XMLSchema::double_ const& b__);
+
+ TaskCost (::XSCRT::XML::Element< wchar_t > const&);
+ TaskCost (::XSCRT::XML::Attribute< wchar_t > const&);
+ TaskCost (TaskCost const& s);
+
+ TaskCost&
+ operator= (TaskCost const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class CondUtil : public ::XMLSchema::double_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::double_ Base__;
+
+ public:
+ CondUtil (::XMLSchema::double_ const& b__);
+
+ CondUtil (::XSCRT::XML::Element< wchar_t > const&);
+ CondUtil (::XSCRT::XML::Attribute< wchar_t > const&);
+ CondUtil (CondUtil const& s);
+
+ CondUtil&
+ operator= (CondUtil const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class CondKind : public ::XSCRT::Type
+ {
+ public:
+ CondKind (::XSCRT::XML::Element< wchar_t > const&);
+ CondKind (::XSCRT::XML::Attribute< wchar_t > const&);
+
+ static CondKind const ENVIRON;
+ static CondKind const SYSTEM;
+ static CondKind const DATA;
+
+ enum Value
+ {
+ ENVIRON_l,SYSTEM_l,DATA_l,
+ };
+
+
+ Value
+ integral () const;
+
+ friend bool
+ operator== (CondKind const& a, CondKind const& b);
+
+ friend bool
+ operator!= (CondKind const& a, CondKind const& b);
+
+ private:
+ CondKind (Value v);
+
+ Value v_;
+ };
+
+ bool operator== (CondKind const &a, CondKind const &b);
+
+ bool operator!= (CondKind const &a, CondKind const &b);
+
+
+ class Probability : public ::XMLSchema::double_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::double_ Base__;
+
+ public:
+ Probability (::XMLSchema::double_ const& b__);
+
+ Probability (::XSCRT::XML::Element< wchar_t > const&);
+ Probability (::XSCRT::XML::Attribute< wchar_t > const&);
+ Probability (Probability const& s);
+
+ Probability&
+ operator= (Probability const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class LinkWeight : public ::XMLSchema::double_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::double_ Base__;
+
+ public:
+ LinkWeight (::XMLSchema::double_ const& b__);
+
+ LinkWeight (::XSCRT::XML::Element< wchar_t > const&);
+ LinkWeight (::XSCRT::XML::Attribute< wchar_t > const&);
+ LinkWeight (LinkWeight const& s);
+
+ LinkWeight&
+ operator= (LinkWeight const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class MultFactor : public ::XMLSchema::double_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::double_ Base__;
+
+ public:
+ MultFactor (::XMLSchema::double_ const& b__);
+
+ MultFactor (::XSCRT::XML::Element< wchar_t > const&);
+ MultFactor (::XSCRT::XML::Attribute< wchar_t > const&);
+ MultFactor (MultFactor const& s);
+
+ MultFactor&
+ operator= (MultFactor const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class TaskNode : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // nodeID
+ //
+ public:
+ ::SANet::XML::NodeID const& nodeID () const;
+ void nodeID (::SANet::XML::NodeID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::NodeID > nodeID_;
+
+ // name
+ //
+ public:
+ ::XMLSchema::string< wchar_t > const& name () const;
+ void name (::XMLSchema::string< wchar_t > const& );
+
+ protected:
+ ::std::auto_ptr< ::XMLSchema::string< wchar_t > > name_;
+
+ // priorProb
+ //
+ public:
+ ::SANet::XML::Probability const& priorProb () const;
+ void priorProb (::SANet::XML::Probability const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::Probability > priorProb_;
+
+ // attenFactor
+ //
+ public:
+ ::SANet::XML::MultFactor const& attenFactor () const;
+ void attenFactor (::SANet::XML::MultFactor const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::MultFactor > attenFactor_;
+
+ // cost
+ //
+ public:
+ ::SANet::XML::TaskCost const& cost () const;
+ void cost (::SANet::XML::TaskCost const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::TaskCost > cost_;
+
+ public:
+ TaskNode (::SANet::XML::NodeID const& nodeID__,
+ ::XMLSchema::string< wchar_t > const& name__,
+ ::SANet::XML::Probability const& priorProb__,
+ ::SANet::XML::MultFactor const& attenFactor__,
+ ::SANet::XML::TaskCost const& cost__);
+
+ TaskNode (::XSCRT::XML::Element< wchar_t > const&);
+ TaskNode (TaskNode const& s);
+
+ TaskNode&
+ operator= (TaskNode const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class CondNode : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // nodeID
+ //
+ public:
+ ::SANet::XML::NodeID const& nodeID () const;
+ void nodeID (::SANet::XML::NodeID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::NodeID > nodeID_;
+
+ // name
+ //
+ public:
+ ::XMLSchema::string< wchar_t > const& name () const;
+ void name (::XMLSchema::string< wchar_t > const& );
+
+ protected:
+ ::std::auto_ptr< ::XMLSchema::string< wchar_t > > name_;
+
+ // probTrue
+ //
+ public:
+ ::SANet::XML::Probability const& probTrue () const;
+ void probTrue (::SANet::XML::Probability const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::Probability > probTrue_;
+
+ // utility
+ //
+ public:
+ ::SANet::XML::CondUtil const& utility () const;
+ void utility (::SANet::XML::CondUtil const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::CondUtil > utility_;
+
+ // kind
+ //
+ public:
+ ::SANet::XML::CondKind const& kind () const;
+ void kind (::SANet::XML::CondKind const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::CondKind > kind_;
+
+ // attenFactor
+ //
+ public:
+ ::SANet::XML::MultFactor const& attenFactor () const;
+ void attenFactor (::SANet::XML::MultFactor const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::MultFactor > attenFactor_;
+
+ public:
+ CondNode (::SANet::XML::NodeID const& nodeID__,
+ ::XMLSchema::string< wchar_t > const& name__,
+ ::SANet::XML::Probability const& probTrue__,
+ ::SANet::XML::CondUtil const& utility__,
+ ::SANet::XML::CondKind const& kind__,
+ ::SANet::XML::MultFactor const& attenFactor__);
+
+ CondNode (::XSCRT::XML::Element< wchar_t > const&);
+ CondNode (CondNode const& s);
+
+ CondNode&
+ operator= (CondNode const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class PrecondLink : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // condID
+ //
+ public:
+ ::SANet::XML::NodeID const& condID () const;
+ void condID (::SANet::XML::NodeID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::NodeID > condID_;
+
+ // taskID
+ //
+ public:
+ ::SANet::XML::NodeID const& taskID () const;
+ void taskID (::SANet::XML::NodeID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::NodeID > taskID_;
+
+ // portID
+ //
+ public:
+ ::SANet::XML::PortID const& portID () const;
+ void portID (::SANet::XML::PortID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::PortID > portID_;
+
+ // trueProb
+ //
+ public:
+ ::SANet::XML::Probability const& trueProb () const;
+ void trueProb (::SANet::XML::Probability const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::Probability > trueProb_;
+
+ // falseProb
+ //
+ public:
+ ::SANet::XML::Probability const& falseProb () const;
+ void falseProb (::SANet::XML::Probability const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::Probability > falseProb_;
+
+ public:
+ PrecondLink (::SANet::XML::NodeID const& condID__,
+ ::SANet::XML::NodeID const& taskID__,
+ ::SANet::XML::PortID const& portID__,
+ ::SANet::XML::Probability const& trueProb__,
+ ::SANet::XML::Probability const& falseProb__);
+
+ PrecondLink (::XSCRT::XML::Element< wchar_t > const&);
+ PrecondLink (PrecondLink const& s);
+
+ PrecondLink&
+ operator= (PrecondLink const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class EffectLink : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // taskID
+ //
+ public:
+ ::SANet::XML::NodeID const& taskID () const;
+ void taskID (::SANet::XML::NodeID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::NodeID > taskID_;
+
+ // condID
+ //
+ public:
+ ::SANet::XML::NodeID const& condID () const;
+ void condID (::SANet::XML::NodeID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::NodeID > condID_;
+
+ // portID
+ //
+ public:
+ ::SANet::XML::PortID const& portID () const;
+ void portID (::SANet::XML::PortID const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::PortID > portID_;
+
+ // weight
+ //
+ public:
+ ::SANet::XML::LinkWeight const& weight () const;
+ void weight (::SANet::XML::LinkWeight const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::LinkWeight > weight_;
+
+ public:
+ EffectLink (::SANet::XML::NodeID const& taskID__,
+ ::SANet::XML::NodeID const& condID__,
+ ::SANet::XML::PortID const& portID__,
+ ::SANet::XML::LinkWeight const& weight__);
+
+ EffectLink (::XSCRT::XML::Element< wchar_t > const&);
+ EffectLink (EffectLink const& s);
+
+ EffectLink&
+ operator= (EffectLink const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class Network : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // defaultAttenFactor
+ //
+ public:
+ ::SANet::XML::MultFactor const& defaultAttenFactor () const;
+ void defaultAttenFactor (::SANet::XML::MultFactor const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::MultFactor > defaultAttenFactor_;
+
+ // defaultTaskCost
+ //
+ public:
+ ::SANet::XML::TaskCost const& defaultTaskCost () const;
+ void defaultTaskCost (::SANet::XML::TaskCost const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::TaskCost > defaultTaskCost_;
+
+ // defaultCondUtil
+ //
+ public:
+ ::SANet::XML::CondUtil const& defaultCondUtil () const;
+ void defaultCondUtil (::SANet::XML::CondUtil const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::CondUtil > defaultCondUtil_;
+
+ // defaultCondProbTrue
+ //
+ public:
+ ::SANet::XML::Probability const& defaultCondProbTrue () const;
+ void defaultCondProbTrue (::SANet::XML::Probability const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::Probability > defaultCondProbTrue_;
+
+ // linkThresh
+ //
+ public:
+ ::SANet::XML::LinkWeight const& linkThresh () const;
+ void linkThresh (::SANet::XML::LinkWeight const& );
+
+ protected:
+ ::std::auto_ptr< ::SANet::XML::LinkWeight > linkThresh_;
+
+ // taskNode
+ //
+ public:
+ typedef ::std::list< ::SANet::XML::TaskNode >::iterator taskNode_iterator;
+ typedef ::std::list< ::SANet::XML::TaskNode >::const_iterator taskNode_const_iterator;
+ taskNode_iterator begin_taskNode ();
+ taskNode_iterator end_taskNode ();
+ taskNode_const_iterator begin_taskNode () const;
+ taskNode_const_iterator end_taskNode () const;
+ void add_taskNode (::SANet::XML::TaskNode const& );
+ size_t count_taskNode (void) const;
+
+ protected:
+ ::std::list< ::SANet::XML::TaskNode > taskNode_;
+
+ // condNode
+ //
+ public:
+ typedef ::std::list< ::SANet::XML::CondNode >::iterator condNode_iterator;
+ typedef ::std::list< ::SANet::XML::CondNode >::const_iterator condNode_const_iterator;
+ condNode_iterator begin_condNode ();
+ condNode_iterator end_condNode ();
+ condNode_const_iterator begin_condNode () const;
+ condNode_const_iterator end_condNode () const;
+ void add_condNode (::SANet::XML::CondNode const& );
+ size_t count_condNode (void) const;
+
+ protected:
+ ::std::list< ::SANet::XML::CondNode > condNode_;
+
+ // precondLink
+ //
+ public:
+ typedef ::std::list< ::SANet::XML::PrecondLink >::iterator precondLink_iterator;
+ typedef ::std::list< ::SANet::XML::PrecondLink >::const_iterator precondLink_const_iterator;
+ precondLink_iterator begin_precondLink ();
+ precondLink_iterator end_precondLink ();
+ precondLink_const_iterator begin_precondLink () const;
+ precondLink_const_iterator end_precondLink () const;
+ void add_precondLink (::SANet::XML::PrecondLink const& );
+ size_t count_precondLink (void) const;
+
+ protected:
+ ::std::list< ::SANet::XML::PrecondLink > precondLink_;
+
+ // effectLink
+ //
+ public:
+ typedef ::std::list< ::SANet::XML::EffectLink >::iterator effectLink_iterator;
+ typedef ::std::list< ::SANet::XML::EffectLink >::const_iterator effectLink_const_iterator;
+ effectLink_iterator begin_effectLink ();
+ effectLink_iterator end_effectLink ();
+ effectLink_const_iterator begin_effectLink () const;
+ effectLink_const_iterator end_effectLink () const;
+ void add_effectLink (::SANet::XML::EffectLink const& );
+ size_t count_effectLink (void) const;
+
+ protected:
+ ::std::list< ::SANet::XML::EffectLink > effectLink_;
+
+ public:
+ Network (::SANet::XML::MultFactor const& defaultAttenFactor__,
+ ::SANet::XML::TaskCost const& defaultTaskCost__,
+ ::SANet::XML::CondUtil const& defaultCondUtil__,
+ ::SANet::XML::Probability const& defaultCondProbTrue__,
+ ::SANet::XML::LinkWeight const& linkThresh__);
+
+ Network (::XSCRT::XML::Element< wchar_t > const&);
+ Network (Network const& s);
+
+ Network&
+ operator= (Network const& s);
+
+ private:
+ char regulator__;
+ };
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ ::SANet::XML::Network
+ network (xercesc::DOMDocument const*);
+ }
+}
+
+#include "XMLSchema/Traversal.hpp"
+
+namespace SANet
+{
+ namespace XML
+ {
+ namespace Traversal
+ {
+ struct NodeID : ::XMLSchema::Traversal::Traverser< ::SANet::XML::NodeID >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct PortID : ::XMLSchema::Traversal::Traverser< ::SANet::XML::PortID >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TaskCost : ::XMLSchema::Traversal::Traverser< ::SANet::XML::TaskCost >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct CondUtil : ::XMLSchema::Traversal::Traverser< ::SANet::XML::CondUtil >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ typedef
+ ::XMLSchema::Traversal::Traverser< ::SANet::XML::CondKind >
+ CondKind;
+
+ struct Probability : ::XMLSchema::Traversal::Traverser< ::SANet::XML::Probability >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct LinkWeight : ::XMLSchema::Traversal::Traverser< ::SANet::XML::LinkWeight >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct MultFactor : ::XMLSchema::Traversal::Traverser< ::SANet::XML::MultFactor >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TaskNode : ::XMLSchema::Traversal::Traverser< ::SANet::XML::TaskNode >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ nodeID (Type&);
+
+ virtual void
+ nodeID (Type const&);
+
+ virtual void
+ name (Type&);
+
+ virtual void
+ name (Type const&);
+
+ virtual void
+ priorProb (Type&);
+
+ virtual void
+ priorProb (Type const&);
+
+ virtual void
+ attenFactor (Type&);
+
+ virtual void
+ attenFactor (Type const&);
+
+ virtual void
+ cost (Type&);
+
+ virtual void
+ cost (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct CondNode : ::XMLSchema::Traversal::Traverser< ::SANet::XML::CondNode >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ nodeID (Type&);
+
+ virtual void
+ nodeID (Type const&);
+
+ virtual void
+ name (Type&);
+
+ virtual void
+ name (Type const&);
+
+ virtual void
+ probTrue (Type&);
+
+ virtual void
+ probTrue (Type const&);
+
+ virtual void
+ utility (Type&);
+
+ virtual void
+ utility (Type const&);
+
+ virtual void
+ kind (Type&);
+
+ virtual void
+ kind (Type const&);
+
+ virtual void
+ attenFactor (Type&);
+
+ virtual void
+ attenFactor (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct PrecondLink : ::XMLSchema::Traversal::Traverser< ::SANet::XML::PrecondLink >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ condID (Type&);
+
+ virtual void
+ condID (Type const&);
+
+ virtual void
+ taskID (Type&);
+
+ virtual void
+ taskID (Type const&);
+
+ virtual void
+ portID (Type&);
+
+ virtual void
+ portID (Type const&);
+
+ virtual void
+ trueProb (Type&);
+
+ virtual void
+ trueProb (Type const&);
+
+ virtual void
+ falseProb (Type&);
+
+ virtual void
+ falseProb (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct EffectLink : ::XMLSchema::Traversal::Traverser< ::SANet::XML::EffectLink >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ taskID (Type&);
+
+ virtual void
+ taskID (Type const&);
+
+ virtual void
+ condID (Type&);
+
+ virtual void
+ condID (Type const&);
+
+ virtual void
+ portID (Type&);
+
+ virtual void
+ portID (Type const&);
+
+ virtual void
+ weight (Type&);
+
+ virtual void
+ weight (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct Network : ::XMLSchema::Traversal::Traverser< ::SANet::XML::Network >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ defaultAttenFactor (Type&);
+
+ virtual void
+ defaultAttenFactor (Type const&);
+
+ virtual void
+ defaultTaskCost (Type&);
+
+ virtual void
+ defaultTaskCost (Type const&);
+
+ virtual void
+ defaultCondUtil (Type&);
+
+ virtual void
+ defaultCondUtil (Type const&);
+
+ virtual void
+ defaultCondProbTrue (Type&);
+
+ virtual void
+ defaultCondProbTrue (Type const&);
+
+ virtual void
+ linkThresh (Type&);
+
+ virtual void
+ linkThresh (Type const&);
+
+ virtual void
+ taskNode (Type&);
+
+ virtual void
+ taskNode (Type const&);
+
+ virtual void
+ taskNode_pre (Type&);
+
+ virtual void
+ taskNode_pre (Type const&);
+
+ virtual void
+ taskNode_next (Type&);
+
+ virtual void
+ taskNode_next (Type const&);
+
+ virtual void
+ taskNode_post (Type&);
+
+ virtual void
+ taskNode_post (Type const&);
+
+ virtual void
+ condNode (Type&);
+
+ virtual void
+ condNode (Type const&);
+
+ virtual void
+ condNode_pre (Type&);
+
+ virtual void
+ condNode_pre (Type const&);
+
+ virtual void
+ condNode_next (Type&);
+
+ virtual void
+ condNode_next (Type const&);
+
+ virtual void
+ condNode_post (Type&);
+
+ virtual void
+ condNode_post (Type const&);
+
+ virtual void
+ precondLink (Type&);
+
+ virtual void
+ precondLink (Type const&);
+
+ virtual void
+ precondLink_pre (Type&);
+
+ virtual void
+ precondLink_pre (Type const&);
+
+ virtual void
+ precondLink_next (Type&);
+
+ virtual void
+ precondLink_next (Type const&);
+
+ virtual void
+ precondLink_post (Type&);
+
+ virtual void
+ precondLink_post (Type const&);
+
+ virtual void
+ effectLink (Type&);
+
+ virtual void
+ effectLink (Type const&);
+
+ virtual void
+ effectLink_pre (Type&);
+
+ virtual void
+ effectLink_pre (Type const&);
+
+ virtual void
+ effectLink_next (Type&);
+
+ virtual void
+ effectLink_next (Type const&);
+
+ virtual void
+ effectLink_post (Type&);
+
+ virtual void
+ effectLink_post (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+ }
+ }
+}
+
+#include "XMLSchema/Writer.hpp"
+
+namespace SANet
+{
+ namespace XML
+ {
+ namespace Writer
+ {
+ struct NodeID : Traversal::NodeID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::NodeID Type;
+ NodeID (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ NodeID ();
+ };
+
+ struct PortID : Traversal::PortID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::PortID Type;
+ PortID (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ PortID ();
+ };
+
+ struct TaskCost : Traversal::TaskCost,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::TaskCost Type;
+ TaskCost (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ TaskCost ();
+ };
+
+ struct CondUtil : Traversal::CondUtil,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::CondUtil Type;
+ CondUtil (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ CondUtil ();
+ };
+
+ struct CondKind : Traversal::CondKind,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ CondKind (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ CondKind ();
+ };
+
+ struct Probability : Traversal::Probability,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::Probability Type;
+ Probability (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ Probability ();
+ };
+
+ struct LinkWeight : Traversal::LinkWeight,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::LinkWeight Type;
+ LinkWeight (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ LinkWeight ();
+ };
+
+ struct MultFactor : Traversal::MultFactor,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::double_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::MultFactor Type;
+ MultFactor (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ MultFactor ();
+ };
+
+ struct TaskNode : Traversal::TaskNode,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::TaskNode Type;
+ TaskNode (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ nodeID (Type &o)
+ {
+
+ this->nodeID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ nodeID (Type const&);
+
+ virtual void
+ name (Type &o)
+ {
+
+ this->name (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ name (Type const&);
+
+ virtual void
+ priorProb (Type &o)
+ {
+
+ this->priorProb (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ priorProb (Type const&);
+
+ virtual void
+ attenFactor (Type &o)
+ {
+
+ this->attenFactor (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ attenFactor (Type const&);
+
+ virtual void
+ cost (Type &o)
+ {
+
+ this->cost (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ cost (Type const&);
+
+ protected:
+ TaskNode ();
+ };
+
+ struct CondNode : Traversal::CondNode,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::CondNode Type;
+ CondNode (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ nodeID (Type &o)
+ {
+
+ this->nodeID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ nodeID (Type const&);
+
+ virtual void
+ name (Type &o)
+ {
+
+ this->name (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ name (Type const&);
+
+ virtual void
+ probTrue (Type &o)
+ {
+
+ this->probTrue (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ probTrue (Type const&);
+
+ virtual void
+ utility (Type &o)
+ {
+
+ this->utility (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ utility (Type const&);
+
+ virtual void
+ kind (Type &o)
+ {
+
+ this->kind (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ kind (Type const&);
+
+ virtual void
+ attenFactor (Type &o)
+ {
+
+ this->attenFactor (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ attenFactor (Type const&);
+
+ protected:
+ CondNode ();
+ };
+
+ struct PrecondLink : Traversal::PrecondLink,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::PrecondLink Type;
+ PrecondLink (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ condID (Type &o)
+ {
+
+ this->condID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ condID (Type const&);
+
+ virtual void
+ taskID (Type &o)
+ {
+
+ this->taskID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskID (Type const&);
+
+ virtual void
+ portID (Type &o)
+ {
+
+ this->portID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ portID (Type const&);
+
+ virtual void
+ trueProb (Type &o)
+ {
+
+ this->trueProb (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ trueProb (Type const&);
+
+ virtual void
+ falseProb (Type &o)
+ {
+
+ this->falseProb (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ falseProb (Type const&);
+
+ protected:
+ PrecondLink ();
+ };
+
+ struct EffectLink : Traversal::EffectLink,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::EffectLink Type;
+ EffectLink (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ taskID (Type &o)
+ {
+
+ this->taskID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskID (Type const&);
+
+ virtual void
+ condID (Type &o)
+ {
+
+ this->condID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ condID (Type const&);
+
+ virtual void
+ portID (Type &o)
+ {
+
+ this->portID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ portID (Type const&);
+
+ virtual void
+ weight (Type &o)
+ {
+
+ this->weight (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ weight (Type const&);
+
+ protected:
+ EffectLink ();
+ };
+
+ struct Network : Traversal::Network,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SANet::XML::Network Type;
+ Network (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ defaultAttenFactor (Type &o)
+ {
+
+ this->defaultAttenFactor (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ defaultAttenFactor (Type const&);
+
+ virtual void
+ defaultTaskCost (Type &o)
+ {
+
+ this->defaultTaskCost (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ defaultTaskCost (Type const&);
+
+ virtual void
+ defaultCondUtil (Type &o)
+ {
+
+ this->defaultCondUtil (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ defaultCondUtil (Type const&);
+
+ virtual void
+ defaultCondProbTrue (Type &o)
+ {
+
+ this->defaultCondProbTrue (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ defaultCondProbTrue (Type const&);
+
+ virtual void
+ linkThresh (Type &o)
+ {
+
+ this->linkThresh (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ linkThresh (Type const&);
+
+ virtual void
+ taskNode_pre (Type &o)
+ {
+
+ this->taskNode_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskNode_pre (Type const&);
+
+ virtual void
+ taskNode_next (Type &o)
+ {
+
+ this->taskNode_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskNode_next (Type const&);
+
+ virtual void
+ taskNode_post (Type &o)
+ {
+
+ this->taskNode_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskNode_post (Type const&);
+
+ virtual void
+ condNode_pre (Type &o)
+ {
+
+ this->condNode_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ condNode_pre (Type const&);
+
+ virtual void
+ condNode_next (Type &o)
+ {
+
+ this->condNode_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ condNode_next (Type const&);
+
+ virtual void
+ condNode_post (Type &o)
+ {
+
+ this->condNode_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ condNode_post (Type const&);
+
+ virtual void
+ precondLink_pre (Type &o)
+ {
+
+ this->precondLink_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ precondLink_pre (Type const&);
+
+ virtual void
+ precondLink_next (Type &o)
+ {
+
+ this->precondLink_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ precondLink_next (Type const&);
+
+ virtual void
+ precondLink_post (Type &o)
+ {
+
+ this->precondLink_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ precondLink_post (Type const&);
+
+ virtual void
+ effectLink_pre (Type &o)
+ {
+
+ this->effectLink_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ effectLink_pre (Type const&);
+
+ virtual void
+ effectLink_next (Type &o)
+ {
+
+ this->effectLink_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ effectLink_next (Type const&);
+
+ virtual void
+ effectLink_post (Type &o)
+ {
+
+ this->effectLink_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ effectLink_post (Type const&);
+
+ protected:
+ Network ();
+ };
+ }
+ }
+}
+
+namespace SANet
+{
+ namespace XML
+ {
+ void
+ network (::SANet::XML::Network const&, xercesc::DOMDocument*);
+ }
+}
+
+#endif // XML_SANET_HPP
diff --git a/SA_POP/SA_Builder.cpp b/SA_POP/SA_Builder.cpp
new file mode 100644
index 00000000000..de79b7d0ee4
--- /dev/null
+++ b/SA_POP/SA_Builder.cpp
@@ -0,0 +1,166 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_Builder.cpp
+ *
+ * This file contains the implementation of the SA_Builder concrete class,
+ * which implements a Builder creating SA_Planner and associated
+ * objects for planning with spreading activation networks and scheduling
+ * with precedence graphs.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "SA_Builder.h"
+#include "Planner.h"
+#include "SANet/SANet.h"
+#include "SA_PlanHeuristics.h"
+#include "SA_PlanStrategy.h"
+#include "SA_SchedStrategy.h"
+#include "SA_WorkingPlan.h"
+#include "TaskMap.h"
+
+using namespace SA_POP;
+
+// Constructor.
+SA_Builder::SA_Builder (void)
+: planner_ (0),
+sanet_ (0),
+cond_choice_ (0),
+task_choice_ (0),
+impl_choice_ (0),
+plan_strat_ (0),
+sched_strat_ (0),
+working_plan_ (0),
+task_map_ (0)
+{
+ this->init ();
+};
+
+// Destructor.
+SA_Builder::~SA_Builder (void)
+{
+ // Nothing to do because client deletes Planner and Planner
+ // handles deletion of the rest of the objects.
+};
+
+// Reset for building a new set of SA-POP objects.
+void SA_Builder::reset (void)
+{
+ // Reset planning object pointers to null.
+ this->planner_ = 0;
+ this->sanet_ = 0;
+ this->cond_choice_ = 0;
+ this->task_choice_ = 0;
+ this->impl_choice_ = 0;
+ this->plan_strat_ = 0;
+ this->sched_strat_ = 0;
+ this->working_plan_ = 0;
+ this->task_map_ = 0;
+
+ // Create and initialize planning objects.
+ this->init ();
+};
+
+// Get Planner object.
+Planner *SA_Builder::get_planner (void)
+{
+ return this->planner_;
+};
+
+// Add a task.
+void SA_Builder::add_task (TaskID id, double prior_prob,
+std::string name)
+{
+ this->sanet_->add_task (id, name, 1, 0, prior_prob);
+};
+
+// Add a condition.
+void SA_Builder::add_cond (CondID id, Utility utility,
+double init_prob_true, std::string name, CondKind cond_kind)
+{
+ this->sanet_->add_cond (id, name, 1,
+ init_prob_true, 1.0 - init_prob_true, utility, cond_kind);
+};
+
+// Add a link between a precondition and task.
+void SA_Builder::set_precond (CondID cond_id, TaskID task_id,
+PortID port, double true_prob, double false_prob)
+{
+ this->sanet_->add_precond_link (cond_id, task_id,
+ true_prob, false_prob, port);
+};
+
+// Add a link between a task and an effect.
+void SA_Builder::set_effect (TaskID task_id, CondID cond_id,
+PortID port, double weight)
+{
+ this->sanet_->add_effect_link (task_id, cond_id, weight, port);
+};
+
+// Add a resource.
+void SA_Builder::add_resource (Resource resource)
+{
+ this->task_map_->add_resource (resource);
+};
+
+// Add an implementation.
+void SA_Builder::add_task_impl (TaskImpl *task_impl)
+{
+ this->task_map_->add_task_impl (task_impl);
+};
+
+// Associate a task with a task implementation.
+void SA_Builder::assoc_task_with_impl (TaskID task_id, TaskImplID task_impl_id,
+ TimeValue duration)
+{
+ this->task_map_->assoc_task_with_impl (task_id, task_impl_id, duration);
+};
+
+// Associate a task implementation with its utilization of a resource.
+void SA_Builder::assoc_impl_with_resource (TaskImplID impl_id,
+ResourceID resource_id, ResourceValue resource_usage)
+{
+ this->task_map_->assoc_impl_with_resource (impl_id, resource_id,
+ resource_usage);
+};
+
+// Create SA-POP objects.
+void SA_Builder::init (void)
+{
+ // Create objects.
+ this->planner_ = new Planner ();
+ this->sanet_ = new SANet::Network ();
+ this->cond_choice_ = new SA_CondStrategy (this->planner_);
+ this->task_choice_ = new SA_TaskStrategy (this->planner_);
+ this->impl_choice_ = new SA_ImplStrategy (this->planner_);
+ this->plan_strat_ = new SA_PlanStrategy (this->planner_,
+ this->cond_choice_, this->task_choice_, this->impl_choice_);
+ this->sched_strat_ = new SA_SchedStrategy (this->planner_);
+ this->working_plan_ = new SA_WorkingPlan (this->planner_);
+ this->task_map_ = new TaskMap ();
+
+ // Provide PlanCommand prototypes to objects.
+ this->plan_strat_->set_commands (
+ this->working_plan_->get_AddTaskCmd (),
+ this->working_plan_->get_AssocTaskImplCmd (),
+ this->working_plan_->get_ResolveCLThreatCmd());
+ this->sched_strat_->set_commands (
+ this->working_plan_->get_ResolveSchedOrderCmd (),
+ this->working_plan_->get_AdjustMinTimesCmd (),
+ this->working_plan_->get_AdjustMaxTimesCmd ());
+ this->working_plan_->set_commands (
+ this->plan_strat_->get_AddOpenThreatsCmd ());
+
+ // Provide planning objects to Planner.
+ this->planner_->set_objects (
+ this->sanet_,
+ this->plan_strat_,
+ this->sched_strat_,
+ this->working_plan_,
+ this->task_map_);
+};
diff --git a/SA_POP/SA_Builder.h b/SA_POP/SA_Builder.h
new file mode 100644
index 00000000000..db77243a441
--- /dev/null
+++ b/SA_POP/SA_Builder.h
@@ -0,0 +1,202 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_Builder.h
+ *
+ * This file contains the definition of the SA_Builder concrete class,
+ * which implements a Builder creating SA_Planner and associated
+ * objects for planning with spreading activation networks and scheduling
+ * with precedence graphs.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SA_BUILDER_H_
+#define SA_POP_SA_BUILDER_H_
+
+#include "SA_POP_Types.h"
+#include "Builder.h"
+#include "Planner.h"
+#include "SANet/SANet.h"
+#include "SA_PlanHeuristics.h"
+#include "SA_PlanStrategy.h"
+#include "SA_SchedStrategy.h"
+#include "SA_WorkingPlan.h"
+#include "TaskMap.h"
+
+
+namespace SA_POP {
+
+ /**
+ * @class SA_Builder
+ *
+ * @brief Builder concrete class for creating SA_Planner and
+ * associated objects for planning with spreading activation networks
+ * and scheduling with precedence graphs.
+ */
+ class SA_Builder : public Builder {
+ public:
+ /// Constructor.
+ SA_Builder (void);
+
+ /// Destructor.
+ virtual ~SA_Builder (void);
+
+ /// Reset for building a new set of SA-POP objects.
+ virtual void reset (void);
+
+ /// Get Planner object.
+ /**
+ * @return Pointer to the configured planner object.
+ */
+ virtual Planner *get_planner (void);
+
+
+ // ************************************************************************
+ // Problem construction methods (tasks, conditions, & links between them).
+ // ************************************************************************
+
+ /// Add a task.
+ /**
+ * @param id The unique task id.
+ *
+ * @param prior_prob The prior probability of this task succeeding.
+ *
+ * @param name The task name.
+ *
+ * @exception Duplicate_Task The given task id already exists.
+ */
+ virtual void add_task (TaskID id, double prior_prob,
+ std::string name = "");
+
+ /// Add a condition.
+ /**
+ * @param id The unique condition id.
+ *
+ * @param name The condition name.
+ *
+ * @param utility The (goal) utility of the condition.
+ *
+ * @param init_prob_true The initial probability that the condition
+ * is true.
+ *
+ * @param cond_kind The type of condition.
+ *
+ * @exception Duplicate_Cond The given condition id already exists.
+ */
+ virtual void add_cond (CondID id, Utility utility = 0,
+ double init_prob_true = 0, std::string name = "", CondKind cond_kind = SA_POP::DATA);
+
+ /// Add a link between a precondition and task.
+ /**
+ * @param cond_id The precondition id.
+ *
+ * @param task_id The task id.
+ *
+ * @param port The receiving port id (on the task for this precondition).
+ *
+ * @param true_prob Conditional probability of task success given
+ * condition = true.
+ *
+ * @param false_prob Conditional probability of task success given
+ * condition = false.
+ *
+ * @exception Unknown_Cond Unknown condition id.
+ */
+ virtual void set_precond (CondID cond_id, TaskID task_id,
+ PortID port, double true_prob, double false_prob);
+
+ /// Add a link between a task and an effect.
+ /**
+ * @param cond_id The effect condition id.
+ *
+ * @param task_id The task id.
+ *
+ * @param port The sending port id (on the task for this effect).
+ *
+ * @param weight Positive probability that task sets condition to true, or
+ * negative of probability that task sets condition to false.
+ */
+ virtual void set_effect (TaskID task_id, CondID cond_id,
+ PortID port, double weight);
+
+
+
+ // ************************************************************************
+ // TaskMap construction methods (resources, task->implementations,
+ // and implementation->resources).
+ // ************************************************************************
+
+ /// Add a resource.
+ /**
+ * @param resource The resource info.
+ */
+ virtual void add_resource (Resource resource);
+
+ /// Add an implementation.
+ /**
+ * @param task_impl The task implementation info.
+ */
+ virtual void add_task_impl (TaskImpl *task_impl);
+
+ /// Associate a task with a task implementation.
+ /**
+ * @param task_id ID of the task.
+ *
+ * @param task_impl_id ID of the task implementation.
+ *
+ * @param duration The duration of the task implementation for this task.
+ */
+ virtual void assoc_task_with_impl (TaskID task_id, TaskImplID task_impl_id,
+ TimeValue duration);
+
+ /// Associate a task implementation with its utilization of a resource.
+ /**
+ * @param impl_id ID of the task implementation.
+ *
+ * @param resource_id ID of the associated resource.
+ *
+ * @param resource_usage The quantity of resource used.
+ */
+ virtual void assoc_impl_with_resource (TaskImplID impl_id,
+ ResourceID resource_id, ResourceValue resource_usage);
+
+ protected:
+ /// Planner object to centralize/mediate planning.
+ Planner *planner_;
+
+ /// Spreading activation network.
+ SANet::Network *sanet_;
+
+ /// Condition choice strategy used by PlanStrategy.
+ SA_CondStrategy *cond_choice_;
+
+ /// Task choice strategy used by PlanStrategy.
+ SA_TaskStrategy *task_choice_;
+
+ /// Task implementation choice strategy used by PlanStrategy.
+ SA_ImplStrategy *impl_choice_;
+
+ /// PlanStrategy object for planning.
+ SA_PlanStrategy *plan_strat_;
+
+ /// SchedStrategy object for scheduling.
+ SA_SchedStrategy *sched_strat_;
+
+ /// WorkingPlan object for holding plan in progress.
+ SA_WorkingPlan *working_plan_;
+
+ /// TaskMap object for associating tasks with implementations and resources.
+ TaskMap *task_map_;
+
+
+ /// Create SA-POP objects.
+ virtual void init (void);
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_SA_BUILDER_H_ */
diff --git a/SA_POP/SA_POP.mpc b/SA_POP/SA_POP.mpc
new file mode 100644
index 00000000000..2b6f26701bd
--- /dev/null
+++ b/SA_POP/SA_POP.mpc
@@ -0,0 +1,85 @@
+project(SA_POP_Driver) : ciao_component_dnc, ciao_race_component, taoexe, ciao_plan_generator, ciao_config_handlers, xerces {
+ after += Interactive_Input_Adapter_stub OpString_stub XSC_Config_Handlers
+ exename = driver
+ includes += $(CIAO_ROOT)/RACE/Input_Adapters/Interactive_Input_Adapter $(CIAO_ROOT)/tools/Config_Handlers $(CIAO_ROOT)/RACE/SA_POP
+ libs += Interactive_Input_Adapter_stub \
+ Input_Adapter_stub \
+ Plan_Analyzer_Interface_stub\
+ OpString_stub
+
+ macros = SA_POP_HAS_ACE SA_POP_HAS_CIAO
+
+
+ IDL_Files {
+ }
+
+ Header_Files {
+ Converter.h
+
+ SA_POP_Types.h
+ SA_POP_Exceptions.h
+
+ Builder.h
+ SA_Builder.h
+
+ Planner.h
+
+ TaskMap.h
+ TaskImpl.h
+
+ WorkingPlan.h
+ SA_WorkingPlan.h
+ SchedStrategy.h
+ SA_SchedStrategy.h
+ PlanStrategy.h
+ SA_PlanStrategy.h
+ PlanHeuristics.h
+ SA_PlanHeuristics.h
+ PlanCommands.h
+ SA_PlanCommands.h
+
+ SANet/SANet_Types.h
+ SANet/SANet.h
+ SANet/SANode.h
+ SANet/SANet_Exceptions.h
+
+ OutAdapter.h
+ LogScreenOut.h
+ LogFileOut.h
+
+ SANet/SANetFileIn.h
+ TaskMapFileIn.h
+ }
+
+ Source_Files {
+ Converter.cpp
+ Driver.cpp
+
+ SA_POP_Exceptions.cpp
+
+ SA_Builder.cpp
+
+ Planner.cpp
+
+ TaskMap.cpp
+ TaskImpl.cpp
+
+ SA_WorkingPlan.cpp
+ SA_SchedStrategy.cpp
+ SA_PlanStrategy.cpp
+ SA_PlanHeuristics.cpp
+ SA_PlanCommands.cpp
+
+ SANet/SANet.cpp
+ SANet/SANode.cpp
+ SANet/SANet_Exceptions.cpp
+
+ LogScreenOut.cpp
+ LogFileOut.cpp
+
+ SANet/SANetFileIn.cpp
+ SANet/XML_SANet.cpp
+ TaskMapFileIn.cpp
+ XML_TaskMap.cpp
+ }
+}
diff --git a/SA_POP/SA_POP_Exceptions.cpp b/SA_POP/SA_POP_Exceptions.cpp
new file mode 100644
index 00000000000..7cec42c7e32
--- /dev/null
+++ b/SA_POP/SA_POP_Exceptions.cpp
@@ -0,0 +1,157 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_POP_Exceptions.cpp
+ *
+ * This file contains the class implementations for SA-POP exceptions.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <stdexcept>
+#include <string>
+#include "SA_POP_Types.h"
+#include "SA_POP_Exceptions.h"
+
+
+using namespace SA_POP;
+
+
+// Default constructor.
+InvalidTask::InvalidTask (void)
+: std::invalid_argument ("SA-POP Invalid task ID.")
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Constructor with task id info for exception message.
+InvalidTask::InvalidTask (TaskID task_id)
+: std::invalid_argument (create_msg (task_id))
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+InvalidTask::~InvalidTask (void) throw ()
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create exception message string.
+std::string InvalidTask::create_msg(TaskID )
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ return "Temp";
+};
+
+
+
+// Default constructor.
+DuplicateTask::DuplicateTask (void)
+: std::invalid_argument ("SA-POP Duplicate task ID.")
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Constructor with task id info for exception message.
+DuplicateTask::DuplicateTask (TaskID task_id)
+: std::invalid_argument (create_msg (task_id))
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+DuplicateTask::~DuplicateTask (void) throw ()
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create exception message string.
+std::string DuplicateTask::create_msg (TaskID )
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ return "Temp";
+};
+
+
+
+// Default constructor.
+DuplicateCond::DuplicateCond (void)
+: std::invalid_argument ("SA-POP Duplicate condition ID.")
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Constructor with condition id info for exception message.
+DuplicateCond::DuplicateCond (CondID cond_id)
+: std::invalid_argument (create_msg (cond_id))
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+DuplicateCond::~DuplicateCond (void) throw ()
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create exception message string.
+std::string DuplicateCond::create_msg (CondID )
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ return "Temp";
+};
+
+
+
+// Default constructor.
+InvalidCond::InvalidCond (void)
+: std::invalid_argument ("SA-POP Invalid condition ID.")
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Constructor with condition id info for exception message.
+InvalidCond::InvalidCond (CondID cond_id)
+: std::invalid_argument (create_msg (cond_id))
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+InvalidCond::~InvalidCond (void) throw ()
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create exception message string.
+std::string InvalidCond::create_msg (CondID )
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ return "Temp";
+};
+
+
+
+// Default constructor.
+Uninitialized::Uninitialized (void)
+: std::logic_error ("SA-POP Unitialized exception.")
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Constructor with exception message.
+Uninitialized::Uninitialized (std::string msg)
+: std::logic_error (msg)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+Uninitialized::~Uninitialized (void) throw ()
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
diff --git a/SA_POP/SA_POP_Exceptions.h b/SA_POP/SA_POP_Exceptions.h
new file mode 100644
index 00000000000..6bc69e8f978
--- /dev/null
+++ b/SA_POP/SA_POP_Exceptions.h
@@ -0,0 +1,157 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_POP_Exceptions.h
+ *
+ * This file contains the class definitions for SA-POP exceptions.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_EXCEPTIONS_H_
+#define SA_POP_EXCEPTIONS_H_
+
+#include <stdexcept>
+#include <string>
+#include "SA_POP_Types.h"
+
+namespace SA_POP {
+
+ /**
+ * @class InvalidTask
+ *
+ * @brief Class for invalid task id argument exceptions.
+ */
+ class InvalidTask : public std::invalid_argument {
+ public:
+ /// Default constructor.
+ InvalidTask (void);
+
+ /// Constructor with task id info for exception message.
+ /**
+ * @param task_id Invalid task id.
+ */
+ InvalidTask (TaskID task_id);
+
+ /// Destructor.
+ virtual ~InvalidTask (void) throw ();
+
+ /// Create exception message string.
+ /**
+ * @param task_id Invalid task id.
+ *
+ * @return Exception message string.
+ */
+ std::string create_msg (TaskID task_id);
+ };
+
+ /**
+ * @class DuplicateTask
+ *
+ * @brief Class for duplicate task id argument exceptions.
+ */
+ class DuplicateTask : public std::invalid_argument {
+ public:
+ /// Default constructor.
+ DuplicateTask (void);
+
+ /// Constructor with task id info for exception message.
+ /**
+ * @param task_id Duplicate task id.
+ */
+ DuplicateTask (TaskID task_id);
+
+ /// Destructor.
+ virtual ~DuplicateTask (void) throw ();
+
+ /// Create exception message string.
+ /**
+ * @param task_id Duplicate task id.
+ *
+ * @return Exception message string.
+ */
+ std::string create_msg (TaskID task_id);
+ };
+
+ /**
+ * @class DuplicateCond
+ *
+ * @brief Class for duplicate condition id argument exceptions.
+ */
+ class DuplicateCond : public std::invalid_argument {
+ public:
+ /// Default constructor.
+ DuplicateCond (void);
+
+ /// Constructor with condition id info for exception message.
+ /**
+ * @param cond_id Duplicate condition id.
+ */
+ DuplicateCond (CondID cond_id);
+
+ /// Destructor.
+ virtual ~DuplicateCond (void) throw ();
+
+ /// Create exception message string.
+ /**
+ * @param cond_id Duplicate condition id.
+ *
+ * @return Exception message string.
+ */
+ std::string create_msg (CondID cond_id);
+ };
+
+ /**
+ * @class InvalidCond
+ *
+ * @brief Class for invalid condition id argument exceptions.
+ */
+ class InvalidCond : public std::invalid_argument {
+ public:
+ /// Default constructor.
+ InvalidCond (void);
+
+ /// Constructor with condition id info for exception message.
+ /**
+ * @param cond_id Invalid condition id.
+ */
+ InvalidCond (CondID cond_id);
+
+ /// Destructor.
+ virtual ~InvalidCond (void) throw ();
+
+ /// Create exception message string.
+ /**
+ * @param cond_id Duplicate condition id.
+ *
+ * @return Exception message string.
+ */
+ std::string create_msg (CondID cond_id);
+ };
+
+ /**
+ * @class Uninitialized
+ *
+ * @brief Class for exceptions an object being used before being initialized.
+ */
+ class Uninitialized : public std::logic_error {
+ public:
+ /// Default constructor.
+ Uninitialized (void);
+
+ /// Constructor with exception message.
+ /**
+ * @param msg Exception message.
+ */
+ Uninitialized (std::string msg);
+
+ /// Destructor.
+ virtual ~Uninitialized (void) throw ();
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_EXCEPTIONS_H_ */
diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h
new file mode 100644
index 00000000000..28fd9adb2e0
--- /dev/null
+++ b/SA_POP/SA_POP_Types.h
@@ -0,0 +1,428 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_POP_Types.h
+ *
+ * This file contains the definitions of types used throughout SA-POP.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_TYPES_H_
+#define SA_POP_TYPES_H_
+
+#include <string>
+#include <set>
+#include <list>
+#include <map>
+
+#if defined (SA_POP_HAS_ACE)
+#include "ace/Log_Msg.h"
+#include "ace/Log_Priority.h"
+#endif /* SA_POP_HAS_ACE */
+
+#define SA_POP_DEBUG_NORMAL 5
+#define SA_POP_DEBUG_HIGH 10
+
+#if defined (SA_POP_HAS_ACE)
+#define SA_POP_DEBUG(x,y) \
+if (x > 0) \
+ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("SA-POP: %s\n"), y));
+#define SA_POP_DEBUG_STR(x,y) \
+if (x > 0) \
+ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("SA-POP: %s\n"), y.c_str ()));
+
+#else /* SA_POP_HAS_ACE not defined */
+#include <iostream>
+#define SA_POP_DEBUG(x,y) \
+if (x > 0) \
+ std::cout << "SA-POP: " << y << std::endl;
+#define SA_POP_DEBUG_STR(x,y) \
+if (x > 0) \
+ std::cout << "SA-POP: " << y << std::endl;
+#endif /* SA_POP_HAS_ACE */
+
+
+namespace SA_POP {
+
+ /// Type of a node id (tasks and conditions).
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef int NodeID;
+
+ /// Type of a condition id.
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef NodeID CondID;
+
+ /// Type of a condition value.
+ typedef bool CondValue;
+
+ /// Type of a condition kind/type.
+ enum CondKind {ENVIRON, SYSTEM, DATA};
+
+ /// Type of a condition.
+ struct Condition {
+ 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 == s); };
+ bool operator< (const Condition &s) const { return this->id < s.id; };
+ };
+
+ /// Type of a task ID.
+ /// (must be > 0 and unique across all tasks *and* conditions).
+ typedef NodeID TaskID;
+
+ /// Type of a task type ID.
+ typedef std::string TaskTypeID;
+
+ /// NULL task ID (for unknown/uninitialized tasks).
+ const TaskID NULL_TASK_ID = 0;
+
+ /// NULL condition ID (for unknown/uninitialized conditions).
+ const CondID NULL_COND_ID = 0;
+
+ /// Type of a port id.
+ typedef std::string PortID;
+
+ /// Type of an expected utility calculation (basetype for others).
+ /// (N.B. this must be a double or float to handle [0,1] range probabilities
+ /// and multiplication factors).
+ typedef double EUCalc;
+
+ /// Type of a condition utility.
+ typedef EUCalc Utility;
+
+ /// Type of a probability.
+ typedef EUCalc Probability;
+
+ /// Type of a (precondition or effect) link weight.
+ typedef EUCalc LinkWeight;
+
+ /// Type of a task cost.
+ typedef EUCalc TaskCost;
+
+ /// Type of a multiplicative factor (e.g. attenuation factor).
+ typedef EUCalc MultFactor;
+
+ /// Type of a precondition link.
+ typedef std::pair<CondID, TaskID> PrecondLink;
+
+ /// Type of an effect link.
+ typedef std::pair<TaskID, CondID> EffectLink;
+
+ /// Type of a pair of ports for a link.
+ typedef std::pair<PortID, PortID> LinkPorts;
+
+ /// Type of a list of tasks.
+ typedef std::list<TaskID> TaskList;
+
+ /// Type of a set of goal conditions with associated utilities.
+ typedef std::map<CondID, Utility> GoalMap;
+
+ /// Type of a set of tasks with associated expected utilities.
+ typedef std::map<TaskID, Utility> TaskEUMap;
+
+ /// Type of a set of conditions (condition & value).
+ typedef std::set<Condition> CondSet;
+
+ /// Type of a set of task ids.
+ typedef std::set<TaskID> TaskSet;
+
+
+ /// Type of a task instance id.
+ /// (must be unique across all task instances).
+ typedef int TaskInstID;
+
+ /// Goal task instance ID (for task instance placeholders in open goals).
+ const TaskInstID GOAL_TASK_INST_ID = -1;
+
+ /// Null task instance ID (for unknown/uninitialized task instances).
+ const TaskInstID NULL_TASK_INST_ID = -2;
+
+ /// Type of a task implementation id.
+ /// (must be unique across all task implementations).
+ typedef std::string TaskImplID;
+
+ /// Null task implementation ID (for unknown/uninitialized task implementations).
+ const TaskImplID NULL_TASK_IMPL_ID = "NULL_TASK_IMPL_ID";
+
+ /// Type of a task implementation parameter id/name.
+ typedef std::string ImplParamID;
+
+ /// Type of a task implementation parameter kind/type.
+ typedef std::string ImplParamKind;
+
+ /// Type of a task implementation parameter value.
+ typedef std::string ImplParamValue;
+
+ /// Type of an implementation parameter.
+ struct ImplParam {
+ ImplParamID id;
+ ImplParamKind kind;
+ ImplParamValue value;
+ bool operator== (const ImplParam &s) const { return this->id == s.id; };
+ bool operator!= (const ImplParam &s) const { return !(*this == s); };
+ bool operator< (const ImplParam &s) const { return this->id < s.id; };
+ };
+
+ /// Type of a resource id.
+ /// (must be unique across all resources).
+ typedef std::string ResourceID;
+
+ const ResourceID NULL_RESOURCE_ID = "NULL_RESOURCE_ID";
+
+ /// Type of a resource capacity or utilization value.
+ /// (must be >= 0.)
+ typedef int ResourceValue;
+
+ /// Type of a resource kind/type.
+ enum ResourceKind {UNARY, DISCRETE, RESERVOIR};
+
+ /// Type of a resource.
+ struct Resource {
+ ResourceID id;
+ ResourceValue capacity;
+ ResourceKind kind;
+ bool operator== (const Resource &s) const { return this->id == s.id; };
+ bool operator!= (const Resource &s) const { return !(*this == s); };
+ bool operator< (const Resource &s) const { return this->id < s.id; };
+ };
+
+ /// Type of a time (Seconds since Jan. 1, 1970).
+ /// (must be >= 0, or = NULL_TIME.)
+ typedef long TimeValue;
+
+ /// NULL time (for unknown or unconstrained times).
+ #define NULL_TIME -1
+
+ /// Time Window (e.g. start or end window for a task instance or plan).
+ typedef std::pair<SA_POP::TimeValue, SA_POP::TimeValue> TimeWindow;
+
+ /// Type of a command id, indicating when command was issued.
+ /// (indicates planning step, decision point within step, and
+ /// number of command within decision point and step.)
+ struct CommandID {
+ int step;
+ int decision_pt;
+ int seq_num;
+ bool operator== (CommandID &s) const { return (this->step == s.step && this->decision_pt == s.decision_pt && this->seq_num == s.seq_num); };
+ bool operator!= (CommandID &s) const { return !(*this == s); };
+ bool operator< (CommandID &s) const
+ {
+ if (this->step == s.step) {
+ if (this->decision_pt == s.decision_pt)
+ return this->seq_num < s.seq_num;
+ return this->decision_pt < s.decision_pt;
+ }
+ return this->step < s.step;
+ };
+ };
+
+ /// Type of a causal link.
+ /// ("first" task instance achieves "cond" for "second" task instance.)
+ struct CausalLink {
+ TaskInstID first;
+ TaskInstID second;
+ Condition cond;
+ bool operator== (const CausalLink &s) const { return (this->first == s.first && this->second == s.second && this->cond == s.cond); };
+ bool operator!= (const CausalLink &s) const { return !(*this == s); };
+ bool operator< (const CausalLink &s) const
+ {
+ if (this->first == s.first) {
+ if (this->second == s.second)
+ return this->cond < cond;
+ return this->second < s.second;
+ }
+ return this->first < s.first;
+ };
+ };
+
+ // Type of a set of causal links.
+ typedef std::set<CausalLink> CLSet;
+
+ /// Type of a causal link threat.
+ /// ("threat" task instance threatens "clink" causal link)
+ struct CLThreat {
+ CausalLink clink;
+ TaskInstID threat;
+ bool operator== (const CLThreat &s) const { return (this->clink == s.clink && this->threat == s.threat); };
+ bool operator!= (const CLThreat &s) const { return !(*this == s); };
+ bool operator< (const CLThreat &s) const
+ {
+ if (this->clink == s.clink)
+ return this->threat < s.threat;
+ return this->clink < s.clink;
+ };
+ };
+
+ /// Type of a precedence relation.
+ enum PrecedenceRelation {UNRANKED, BEFORE, AFTER, SIMUL,
+ BEFORE_SIMUL, AFTER_SIMUL};
+
+ /// Type of a set of task implementation ids.
+ typedef std::set<TaskImplID> TaskImplSet;
+
+ /// Type of a list of task implementation ids.
+ typedef std::list<TaskImplID> TaskImplList;
+
+ /// Type of a set of task instance ids.
+ typedef std::set<TaskInstID> TaskInstSet;
+
+ /// Type of a set of task implementation parameters and associated values.
+ typedef std::set<ImplParam> ImplParamSet;
+
+ /// Type of a set of task instance ids.
+ typedef std::set<TaskInstID> TaskInstSet;
+
+ /// Type of a set of task instances mapped to task implementations.
+ typedef std::map <TaskInstID, TaskImplID> InstToImplMap;
+
+ /// Type of a set of resources and associated utilization.
+ typedef std::map<ResourceID, ResourceValue> ResourceMap;
+
+ /// Type of a set of resources (map from id to resource).
+ typedef std::map<ResourceID, Resource> Resources;
+
+ /// Type of Criticality as a pair of the Resource it is in and the value.
+ typedef std::pair<ResourceID,double> Criticality;
+
+ /// Type of a set of conditions (condition & value).
+ typedef std::set<Condition> CondSet;
+
+ /// Type of a set of open conditions, each associated with task instances
+ /// for which it is a precondition.
+ typedef std::multimap<Condition, TaskInstID> OpenCondMap;
+
+ /// Type of a set of causal link threats.
+ typedef std::set<CLThreat> CLThreatSet;
+
+ /// Type of a data connection in a plan.
+ struct PlanConnection {
+ TaskInstID first_task_inst;
+ TaskInstID second_task_inst;
+ PortID first_port;
+ PortID second_port;
+ CondID cond;
+ bool operator== (const PlanConnection &s) const { return (this->first_task_inst == s.first_task_inst && this->second_task_inst == s.second_task_inst && this->first_port == s.first_port && this->second_port == s.second_port && this->cond == s.cond); };
+ bool operator!= (const PlanConnection &s) const { return !(*this == s); };
+ bool operator< (const PlanConnection &s) const
+ {
+ if (this->first_task_inst == s.first_task_inst) {
+ if (this->second_task_inst == s.second_task_inst) {
+ if (this->first_port == s.first_port) {
+ if (this->second_port == s.second_port)
+ return this->cond < s.cond;
+ return this->second_port < s.second_port;
+ }
+ return this->first_port < s.first_port;
+ }
+ return this->second_task_inst < s.second_task_inst;
+ }
+ return this->first_task_inst < s.first_task_inst;
+ };
+ };
+
+ /// Type of a set of plan connections.
+ typedef std::set<PlanConnection> PlanConnSet;
+
+ /// Type of an instance in a plan.
+ struct PlanTaskInst {
+ // Unique ID of this task instance.
+ TaskInstID inst_id;
+
+ // Human-readable name (for debugging, not identification).
+ std::string name;
+
+ // Task ID of this instance.
+ TaskID task_id;
+
+ // Task type ID of this instance.
+ TaskTypeID type_id;
+
+ // ID of suggested implementation.
+ TaskImplID suggested_impl;
+
+ // Derived start window.
+ TimeWindow start_window;
+
+ // Derived end window.
+ TimeWindow end_window;
+
+ bool operator== (const PlanTaskInst &s) const { return (this->inst_id == s.inst_id); };
+ bool operator!= (const PlanTaskInst &s) const { return !(*this == s); };
+ bool operator< (const PlanTaskInst &s) const
+ {
+ return this->inst_id < s.inst_id;
+ };
+ };
+
+ /// Type of a set of plan instances.
+ typedef std::set<PlanTaskInst> PlanInstSet;
+
+ /// Type of a generic ordering link.
+ typedef std::pair<TaskInstID, TaskInstID> OrderLink;
+
+ /// Type of a scheduling link.
+ typedef OrderLink SchedLink;
+
+ /// Type of a set of scheduling links.
+ typedef std::set<SchedLink> SchedLinkSet;
+
+ // Type of a threat link.
+ typedef OrderLink ThreatLink;
+
+ /// Type of a set of threat links.
+ typedef std::set<ThreatLink> ThreatLinkSet;
+
+ /// Type of a goal ID.
+ typedef std::string GoalID;
+
+ /// Type of a plan ID.
+ typedef GoalID PlanID;
+
+ /// Type of a plan generated by SA-POP (output of a WorkingPlan object).
+ struct Plan {
+ // Unique ID of plan (from goal).
+ PlanID plan_id;
+
+ // Human-readable name of plan (used for debugging, not identification).
+ std::string name;
+
+ // Task instances in plan.
+ PlanInstSet task_insts;
+
+ // Data connections in plan.
+ PlanConnSet connections;
+
+ // Causal links (non-data) in plan.
+ CLSet causal_links;
+
+ // Scheduling links (added to prevent resource conflicts) in plan.
+ SchedLinkSet sched_links;
+
+ // Threat links (added to prevent causal link threats) in plan.
+ ThreatLinkSet threat_links;
+
+ // Expected start window.
+ TimeWindow start_window;
+
+ // Expected end window.
+ TimeWindow end_window;
+
+ bool operator== (const Plan &s) const { return (this->task_insts == s.task_insts && this->connections == s.connections); };
+ bool operator!= (const Plan &s) const { return !(*this == s); };
+ bool operator< (const Plan &s) const
+ {
+ if (this->task_insts == s.task_insts)
+ return this->connections < s.connections;
+ return this->task_insts < s.task_insts;
+ };
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_TYPES_H_ */
diff --git a/SA_POP/SA_PlanCommands.cpp b/SA_POP/SA_PlanCommands.cpp
new file mode 100644
index 00000000000..8fcb46a84a5
--- /dev/null
+++ b/SA_POP/SA_PlanCommands.cpp
@@ -0,0 +1,816 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_PlanCommands.cpp
+ *
+ * This file contains the implementation of the concrete classes,
+ * which implement PlanCommand.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "SA_PlanCommands.h"
+#include "SA_WorkingPlan.h"
+#include "SA_PlanStrategy.h"
+#include <string>
+#include <stdlib.h>
+
+using namespace SA_POP;
+
+// Constructor.
+SA_AdjustMinTimesCmd::SA_AdjustMinTimesCmd (SA_WorkingPlan *working_plan)
+: working_plan_ (working_plan)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+SA_AdjustMinTimesCmd::~SA_AdjustMinTimesCmd (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_AdjustMinTimesCmd::clone (void)
+{
+ return new SA_AdjustMinTimesCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_AdjustMinTimesCmd::execute_next (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+// this->working_plan_->execute (this);
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+ return this->working_plan_->execute (this);
+};
+
+// Undo this command.
+void SA_AdjustMinTimesCmd::undo (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ this->working_plan_->undo (this);
+};
+
+// Get log text for most recent execution of command.
+std::string SA_AdjustMinTimesCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Adjusting Schedule Minimum Times (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ log_str += "): [NOT HANDLING FULL SCHEDULING YET]";
+
+ return log_str;
+};
+
+// Set the task instance and window adjustment.
+void SA_AdjustMinTimesCmd::set_times (TaskInstID task_inst, TimeValue start_min,
+TimeValue end_min)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ TimeWindow start_old = this->working_plan_->get_start_window(task_inst);
+ TimeWindow end_old = this->working_plan_->get_end_window(task_inst);
+ this->task_inst_=task_inst;
+ this->old_start_min = start_old.second;
+ this->old_end_min = end_old.second;
+ this->new_start_min = start_min;
+ this->new_end_min = end_min;
+};
+
+
+
+// Constructor.
+SA_AdjustMaxTimesCmd::SA_AdjustMaxTimesCmd (SA_WorkingPlan *working_plan)
+: working_plan_ (working_plan)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+SA_AdjustMaxTimesCmd::~SA_AdjustMaxTimesCmd (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_AdjustMaxTimesCmd::clone (void)
+{
+ return new SA_AdjustMaxTimesCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_AdjustMaxTimesCmd::execute_next (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+// this->working_plan_->execute (this);
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+ return this->working_plan_->execute (this);
+};
+
+// Undo this command.
+void SA_AdjustMaxTimesCmd::undo (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ this->working_plan_->undo (this);
+};
+
+// Get log text for most recent execution of command.
+std::string SA_AdjustMaxTimesCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Adjusting Schedule Maximum Times (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ log_str += "): [NOT HANDLING FULL SCHEDULING YET]";
+
+ return log_str;
+};
+
+// Set the task instance and window adjustment.
+void SA_AdjustMaxTimesCmd::set_times (TaskInstID task_inst, TimeValue start_max,
+TimeValue end_max)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ TimeWindow start_old = this->working_plan_->get_start_window(task_inst);
+ TimeWindow end_old = this->working_plan_->get_end_window(task_inst);
+ this->task_inst_=task_inst;
+ this->old_start_max = start_old.second;
+ this->old_end_max = end_old.second;
+ this->new_start_max = start_max;
+ this->new_end_max = end_max;
+ // std::cout<<"setting max times "<<start_max<<" "<<end_max<<std::endl;
+};
+
+
+
+// Constructor.
+SA_AddTaskCmd::SA_AddTaskCmd (SA_WorkingPlan *working_plan)
+: working_plan_ (working_plan),
+last_task_ (SA_POP::NULL_TASK_ID),
+last_task_inst_ (SA_POP::NULL_TASK_INST_ID),
+num_tries_ (0)
+{
+ this->tasks_.clear ();
+ this->cond_.id = SA_POP::NULL_COND_ID;
+ this->task_insts_.clear ();
+ this->used_task_insts_.clear();
+};
+
+// Destructor.
+SA_AddTaskCmd::~SA_AddTaskCmd (void)
+{
+ // Nothing to do.
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_AddTaskCmd::clone (void)
+{
+ return new SA_AddTaskCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_AddTaskCmd::execute_next (void)
+{
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+
+ this->undo();
+ if (this->tasks_.empty ())
+ return false;
+ this->working_plan_->execute (this);
+ this->num_tries_++;
+ return true;
+};
+
+// Undo this command.
+void SA_AddTaskCmd::undo (void)
+{
+ if (this->last_task_ == SA_POP::NULL_TASK_ID)
+ return;
+
+ this->working_plan_->undo (this);
+
+ if (this->tasks_.empty ()) {
+ this->task_insts_.clear ();
+ this->cond_.id = SA_POP::NULL_COND_ID;
+ this->last_task_ = SA_POP::NULL_TASK_ID;
+ }
+};
+
+// Get log text for most recent execution of command.
+std::string SA_AddTaskCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Adding Task (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ log_str += "): ";
+ TaskList::iterator task_iter = this->tasks_.begin ();
+ if (task_iter == this->tasks_.end ())
+ log_str += "[NO TASKS TO ADD]";
+ else
+ log_str += itoa (*task_iter, buffer, 10);
+
+ return log_str;
+};
+
+// Set (ordered) list of tasks to add (one per execution) to the plan.
+void SA_AddTaskCmd::set_tasks (const TaskList &tasks)
+{
+ if (!this->tasks_.empty ())
+ throw "SA_POP::SA_AddTaskCmd::set_tasks (): called while current task list is not empty.";
+
+ if (this->last_task_ != SA_POP::NULL_TASK_ID)
+ throw "SA_POP::SA_AddTaskCmd::set_tasks (): called before last task was undone.";
+
+ this->tasks_ = tasks;
+};
+
+// Set causal link info to add to the plan with task.
+void SA_AddTaskCmd::set_causal_info (Condition cond, TaskInstSet task_insts)
+{
+ if (!this->task_insts_.empty ())
+ throw "SA_POP::SA_AddTaskCmd::set_causal_info (): called while current task instance set is not empty.";
+
+ if (this->cond_.id != SA_POP::NULL_COND_ID)
+ throw "SA_POP::SA_AddTaskCmd::set_causal_info (): called while current condition is already set.";
+
+ this->cond_ = cond;
+ this->task_insts_ = task_insts;
+};
+
+// Get ID of last task added to the plan by this command.
+TaskID SA_AddTaskCmd::get_task (void)
+{
+ return this->last_task_;
+};
+
+// Get ID of instance of last task added to the plan by this command.
+TaskInstID SA_AddTaskCmd::get_task_inst (void)
+{
+ return this->last_task_inst_;
+};
+
+/// Check if the instance id used by the task of this command already exists.
+bool SA_AddTaskCmd::inst_exists (void)
+{
+ return !this->used_task_insts_.empty();
+}
+// Constructor.
+SA_AssocTaskImplCmd::SA_AssocTaskImplCmd (SA_WorkingPlan *working_plan)
+: working_plan_ (working_plan),
+task_inst_ (SA_POP::NULL_TASK_INST_ID),
+last_impl_ (SA_POP::NULL_TASK_IMPL_ID),
+num_tries_ (0),
+min_adj_cmd(working_plan),
+max_adj_cmd(working_plan)
+{
+ this->causal_insertions.clear();
+ this->simul_insertions.clear();
+ this->impls_.clear ();
+};
+
+// Destructor.
+SA_AssocTaskImplCmd::~SA_AssocTaskImplCmd (void)
+{
+ // Nothing to do.
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_AssocTaskImplCmd::clone (void)
+{
+ return new SA_AssocTaskImplCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_AssocTaskImplCmd::execute_next (void)
+{
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+
+ this->undo();
+ if (this->impls_.empty ())
+ return false;
+
+ this->num_tries_++;
+ return this->working_plan_->execute (this);
+ //return true;
+};
+
+// Undo this command.
+void SA_AssocTaskImplCmd::undo (void)
+{
+ if (this->last_impl_ == SA_POP::NULL_TASK_IMPL_ID)
+ return;
+
+ this->working_plan_->undo (this);
+ this->last_impl_ = SA_POP::NULL_TASK_IMPL_ID;
+
+ if (this->impls_.empty ())
+ this->task_inst_ = SA_POP::NULL_TASK_INST_ID;
+};
+
+// Get log text for most recent execution of command.
+std::string SA_AssocTaskImplCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Associating Task(Instance)->Implementation (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ log_str += "): ";
+ log_str += itoa (this->working_plan_->get_task_from_inst (this->task_inst_),
+ buffer, 10);
+ log_str += "(";
+ log_str += itoa (this->task_inst_, buffer, 10);
+ log_str += ")->";
+ TaskImplList::iterator impl_iter = this->impls_.begin ();
+ if (impl_iter == this->impls_.end ())
+ log_str += "[NO IMPLEMENTATIONS TO ASSOCIATE]";
+ else
+ log_str += *impl_iter;
+
+ return log_str;
+};
+
+// Set the task->implementation associations.
+void SA_AssocTaskImplCmd::set_assoc (TaskInstID task_inst,
+ TaskImplList impl_list)
+{
+ if (!this->impls_.empty ())
+ throw "SA_POP::SA_AssocTaskImplCmd::set_assoc (): called while current task implementation list is not empty.";
+
+ if (this->last_impl_ != SA_POP::NULL_TASK_IMPL_ID)
+ throw "SA_POP::SA_AssocTaskImplCmd::set_assoc (): called before last execution was undone.";
+
+ this->impls_ = impl_list;
+ this->task_inst_ = task_inst;
+};
+
+// Get ID of instance of this command.
+TaskInstID SA_AssocTaskImplCmd::get_task_inst (void)
+{
+ return this->task_inst_;
+};
+
+
+// Constructor.
+SA_AddOpenCondsCmd::SA_AddOpenCondsCmd (SA_PlanStrategy *plan_strat)
+: plan_strat_ (plan_strat),
+task_inst_ (SA_POP::NULL_TASK_INST_ID),
+has_executed_ (false)
+{
+ this->conds_.clear ();
+};
+
+// Destructor.
+SA_AddOpenCondsCmd::~SA_AddOpenCondsCmd (void)
+{
+ // Nothing to do.
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_AddOpenCondsCmd::clone (void)
+{
+ return new SA_AddOpenCondsCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_AddOpenCondsCmd::execute_next (void)
+{
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+
+ if (this->conds_.empty ())
+ return false;
+
+ if (this->task_inst_ == SA_POP::NULL_TASK_INST_ID)
+ throw "SA_POP::SA_AddOpenCondsCmd::execute_next (): called without task instance set.";
+
+ this->undo();
+ this->plan_strat_->execute (this);
+ this->has_executed_ = true;
+ return true;
+};
+
+// Undo this command.
+void SA_AddOpenCondsCmd::undo (void)
+{
+ if (!this->has_executed_ || this->conds_.empty ())
+ return;
+
+ this->plan_strat_->undo (this);
+ this->task_inst_ = SA_POP::NULL_TASK_INST_ID;
+ this->conds_.clear ();
+};
+
+// Get log text for most recent execution of command.
+std::string SA_AddOpenCondsCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Adding Open Conditions (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ log_str += "):";
+ for (CondSet::iterator cond_iter = this->conds_.begin ();
+ cond_iter != this->conds_.end (); cond_iter++)
+ {
+ log_str += " ";
+ log_str += itoa ((*cond_iter).id, buffer, 10);
+ log_str += " = ";
+ if ((*cond_iter).value)
+ log_str += "TRUE;";
+ else
+ log_str += "FALSE;";
+ }
+
+ return log_str;
+};
+
+// Set the open conditions to add.
+void SA_AddOpenCondsCmd::set_conds (const CondSet &conds)
+{
+ if (!this->conds_.empty ())
+ throw "SA_POP::SA_AddOpenCondsCmd::set_conds (): called while current condition set is not empty.";
+
+ this->conds_ = conds;
+};
+
+// Set the task instance for which these are preconditions.
+void SA_AddOpenCondsCmd::set_task_inst (TaskInstID task_inst)
+{
+ if (this->task_inst_ != SA_POP::NULL_TASK_INST_ID)
+ throw "SA_POP::SA_AddOpenCondsCmd::set_conds (): called before last command was undone.";
+
+ this->task_inst_ = task_inst;
+};
+
+
+
+// Constructor.
+SA_RemoveOpenCondsCmd::SA_RemoveOpenCondsCmd (SA_PlanStrategy *plan_strat)
+: plan_strat_ (plan_strat)
+{
+ this->conds_.clear ();
+ this->removed_.clear ();
+};
+
+// Destructor.
+SA_RemoveOpenCondsCmd::~SA_RemoveOpenCondsCmd (void)
+{
+ // Nothing to do.
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_RemoveOpenCondsCmd::clone (void)
+{
+ return new SA_RemoveOpenCondsCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_RemoveOpenCondsCmd::execute_next (void)
+{
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+
+ if (this->conds_.empty ())
+ return false;
+
+ this->undo();
+ this->plan_strat_->execute (this);
+ return true;
+};
+
+// Undo this command.
+void SA_RemoveOpenCondsCmd::undo (void)
+{
+ if (this->removed_.empty ())
+ return;
+
+ this->plan_strat_->undo (this);
+ this->removed_.clear ();
+ this->conds_.clear ();
+};
+
+// Get log text for most recent execution of command.
+std::string SA_RemoveOpenCondsCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Removing Open Conditions (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ log_str += "):";
+ for (CondSet::iterator cond_iter = this->conds_.begin ();
+ cond_iter != this->conds_.end (); cond_iter++)
+ {
+ log_str += " ";
+ log_str += itoa ((*cond_iter).id, buffer, 10);
+ log_str += " = ";
+ if ((*cond_iter).value)
+ log_str += "TRUE;";
+ else
+ log_str += "FALSE;";
+ }
+
+ return log_str;
+};
+
+// Set the open conditions to remove.
+void SA_RemoveOpenCondsCmd::set_conds (const CondSet &conds)
+{
+ if (!this->conds_.empty ())
+ throw "SA_POP::SA_RemoveOpenCondsCmd::set_conds (): called while current condition set is not empty.";
+
+ if (!this->removed_.empty ())
+ throw "SA_POP::SA_RemoveOpenCondsCmd::set_conds (): called before last execution undone.";
+
+ this->conds_ = conds;
+};
+
+
+
+// Constructor.
+SA_AddOpenThreatsCmd::SA_AddOpenThreatsCmd (SA_PlanStrategy *plan_strat)
+: plan_strat_ (plan_strat)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+SA_AddOpenThreatsCmd::~SA_AddOpenThreatsCmd (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_AddOpenThreatsCmd::clone (void)
+{
+ return new SA_AddOpenThreatsCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_AddOpenThreatsCmd::execute_next (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+// this->plan_strat_->execute (this);
+ return false;
+};
+
+// Undo this command.
+void SA_AddOpenThreatsCmd::undo (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// this->plan_strat_->undo (this);
+};
+
+// Get log text for most recent execution of command.
+std::string SA_AddOpenThreatsCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Adding Open Threats (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ log_str += "): [NOT HANDLING THREATS YET]";
+
+ return log_str;
+};
+
+// Set the open threats to add.
+void SA_AddOpenThreatsCmd::set_threats (const CLThreatSet &)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+
+
+// Constructor.
+SA_RemoveOpenThreatsCmd::SA_RemoveOpenThreatsCmd (SA_PlanStrategy *plan_strat)
+: plan_strat_ (plan_strat)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+SA_RemoveOpenThreatsCmd::~SA_RemoveOpenThreatsCmd (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_RemoveOpenThreatsCmd::clone (void)
+{
+ return new SA_RemoveOpenThreatsCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_RemoveOpenThreatsCmd::execute_next (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+// this->plan_strat_->execute (this);
+ return false;
+};
+
+// Undo this command.
+void SA_RemoveOpenThreatsCmd::undo (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// this->plan_strat_->undo (this);
+};
+
+// Get log text for most recent execution of command.
+std::string SA_RemoveOpenThreatsCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Removing Open Threats (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ log_str += "): [NOT HANDLING THREATS YET]";
+
+ return log_str;
+};
+
+// Set the open threats to remove.
+void SA_RemoveOpenThreatsCmd::set_threats (const CLThreatSet &)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+
+
+// Constructor.
+SA_ResolveCLThreatCmd::SA_ResolveCLThreatCmd (SA_WorkingPlan *working_plan)
+: working_plan_ (working_plan)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+SA_ResolveCLThreatCmd::~SA_ResolveCLThreatCmd (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_ResolveCLThreatCmd::clone (void)
+{
+ return new SA_ResolveCLThreatCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_ResolveCLThreatCmd::execute_next (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+// this->working_plan_->execute (this);
+ return false;
+};
+
+// Undo this command.
+void SA_ResolveCLThreatCmd::undo (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+// this->working_plan_->undo (this);
+};
+
+// Get log text for most recent execution of command.
+std::string SA_ResolveCLThreatCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Resolving Open Threat (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ log_str += "): [NOT HANDLING THREATS YET]";
+
+ return log_str;
+};
+
+// Set the causal link threat to resolve.
+void SA_ResolveCLThreatCmd::set_threat (CLThreat &)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+
+
+// Constructor.
+SA_ResolveSchedOrderCmd::SA_ResolveSchedOrderCmd (SA_WorkingPlan *working_plan)
+: working_plan_ (working_plan)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Destructor.
+SA_ResolveSchedOrderCmd::~SA_ResolveSchedOrderCmd (void)
+{
+ this->adj_max_times_cmd_=NULL;
+ this->adj_min_times_cmd_=NULL;
+};
+
+// Create a deep copy of this command.
+PlanCommand *SA_ResolveSchedOrderCmd::clone (void)
+{
+ return new SA_ResolveSchedOrderCmd (*this);
+};
+
+// Execute next option for this command.
+bool SA_ResolveSchedOrderCmd::execute_next (void)
+{
+ SA_POP_DEBUG_STR (SA_POP_DEBUG_NORMAL, this->get_log_text ());
+ this->working_plan_->add_sched_link(this->first,this->second);
+ return this->working_plan_->execute (this);
+};
+
+// Undo this command.
+void SA_ResolveSchedOrderCmd::undo (void)
+{
+ this->working_plan_->remove_sched_link(this->first,this->second);
+ this->working_plan_->undo (this);
+};
+
+// Get log text for most recent execution of command.
+std::string SA_ResolveSchedOrderCmd::get_log_text (void)
+{
+ std::string log_str = "";
+ log_str += "Resolving Schedule Ordering (CommandID ";
+ char buffer[64];
+ log_str += itoa (this->get_id().step, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().decision_pt, buffer, 10);
+ log_str += ".";
+ log_str += itoa (this->get_id().seq_num, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ log_str += "): [NOT HANDLING FULL SCHEDULING YET]";
+
+ return log_str;
+};
+
+// Set the task instances to order.
+void SA_ResolveSchedOrderCmd::set_task_insts (TaskInstID task_inst_a, TaskInstID task_inst_b)
+{
+ this->first = task_inst_a;
+ this->second = task_inst_b;
+};
+
+/// Get the affected task instances.
+TaskInstSet SA_ResolveSchedOrderCmd::get_affected_insts ()
+{
+ TaskInstSet affected_insts;
+ affected_insts.insert(this->first);
+ affected_insts.insert(this->second);
+ for(ResolveSchedOrderCmdList::iterator iter=this->cmds_.begin();iter!=this->cmds_.end();iter++)
+ {
+ TaskInstSet temp=(*iter)->get_affected_insts();
+ for(TaskInstSet::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
+ {
+ if(*iter2!=this->first && *iter2!=this->second) affected_insts.insert(*iter2);
+ }
+ }
+ return affected_insts;
+};
+
+
diff --git a/SA_POP/SA_PlanCommands.h b/SA_POP/SA_PlanCommands.h
new file mode 100644
index 00000000000..adb6be44cfa
--- /dev/null
+++ b/SA_POP/SA_PlanCommands.h
@@ -0,0 +1,732 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_PlanCommands.h
+ *
+ * This file contains the definition of the concrete classes,
+ * which implement PlanCommand.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SA_PLAN_COMMANDS_H_
+#define SA_POP_SA_PLAN_COMMANDS_H_
+
+#include <list>
+
+#include "SA_POP_Types.h"
+#include "PlanCommands.h"
+
+namespace SA_POP {
+
+ // Forward declarations.
+ class SA_WorkingPlan;
+ class SA_PlanStrategy;
+ /**
+ * @class SA_AdjustMinTimesCmd
+ *
+ * @brief AdjustMinTimesCmd concrete class for the encapsulation of a
+ * command to adjust the start-min and end-min times of a task
+ * instance in the plan.
+ */
+ class SA_AdjustMinTimesCmd : public AdjustMinTimesCmd {
+ public:
+ /// SA_WorkingPlan needs access to private data to execute this command.
+ friend class SA_WorkingPlan;
+
+ /// Constructor.
+ /**
+ * @param working_plan WorkingPlan object associated with this command.
+ */
+ SA_AdjustMinTimesCmd (SA_WorkingPlan *working_plan);
+
+ /// Destructor.
+ virtual ~SA_AdjustMinTimesCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the task instance and window adjustment.
+ /**
+ * @param task_inst The task instance for which to adjust to the window.
+ *
+ * @param start_min The new start-min time.
+ *
+ * @param end_min The new end-min time.
+ */
+ virtual void set_times (TaskInstID task_inst, TimeValue start_min,
+ TimeValue end_min);
+
+ protected:
+ /// WorkingPlan object that this command works on.
+ SA_WorkingPlan *working_plan_;
+
+ //Task Instance Id for which the min times are being adjusted
+ TaskInstID task_inst_;
+
+ //Time values associated with this command
+ TimeValue new_start_min,new_end_min,old_start_min,old_end_min;
+
+ // Type of a list of AdjustMinTimesCmd
+ typedef std::list<SA_AdjustMinTimesCmd*> MinTimesAdjustList;
+
+ // A list of all the minimum times changes due to this command
+ MinTimesAdjustList min_adjust_cmds;
+
+ // A set of all the task instances taht are removed from the unranked set
+ TaskInstSet ranked;
+ };
+
+ /**
+ * @class SA_AdjustMaxTimesCmd
+ *
+ * @brief AdjustMaxTimesCmd concrete class for the encapsulation of a
+ * command to adjust the start-max and end-max times of a task
+ * instance in the plan.
+ */
+ class SA_AdjustMaxTimesCmd : public AdjustMaxTimesCmd {
+ public:
+ /// SA_WorkingPlan needs access to private data to execute this command.
+ friend class SA_WorkingPlan;
+
+ /// Constructor.
+ /**
+ * @param working_plan WorkingPlan object associated with this command.
+ */
+ SA_AdjustMaxTimesCmd (SA_WorkingPlan *working_plan);
+
+ /// Destructor.
+ virtual ~SA_AdjustMaxTimesCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the task instance and window adjustment.
+ /**
+ * @param task_inst The task instance for which to adjust to the window.
+ *
+ * @param start_max The new start-max time.
+ *
+ * @param end_max The new end-max time.
+ */
+ virtual void set_times (TaskInstID task_inst, TimeValue start_max,
+ TimeValue end_max);
+
+ protected:
+ /// WorkingPlan object that this command works on.
+ SA_WorkingPlan *working_plan_;
+
+ //Task Instance Id for which the max times are being adjusted
+ TaskInstID task_inst_;
+
+ //Time values associated with this command
+ TimeValue new_start_max,new_end_max,old_start_max,old_end_max;
+
+ // Type of a list of AdjustMaxTimesCmd
+ typedef std::list<SA_AdjustMaxTimesCmd*> MaxTimesAdjustList;
+
+ // A list of all the maximum times changes due to this command
+ MaxTimesAdjustList max_adjust_cmds;
+
+ // A set of all the task instances taht are removed from the unranked set
+ TaskInstSet ranked;
+ };
+
+ /**
+ * @class SA_AddTaskCmd
+ *
+ * @brief AddTaskCmd concrete class for the encapsulation of a command to add
+ * a task to the current plan.
+ */
+ class SA_AddTaskCmd : public AddTaskCmd {
+ public:
+ /// SA_WorkingPlan needs access to private data to execute this command.
+ friend class SA_WorkingPlan;
+
+ /// Constructor.
+ /**
+ * @param working_plan WorkingPlan object associated with this command.
+ */
+ SA_AddTaskCmd (SA_WorkingPlan *working_plan);
+
+ /// Destructor.
+ virtual ~SA_AddTaskCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set (ordered) list of tasks to add (one per execution) to the plan.
+ /**
+ * @param tasks Ordered list of tasks.
+ */
+ virtual void set_tasks (const TaskList &tasks);
+
+ /// Set causal link info to add to the plan with task.
+ /**
+ * @param cond Condition this task satisifies.
+ *
+ * @param task_insts Set of task instances that this task satisifes
+ * the given precondition.
+ */
+ virtual void set_causal_info (Condition cond, TaskInstSet task_insts);
+
+ /// Get ID of last task added to the plan by this command.
+ /**
+ * @return ID of last task added to the plan by this command.
+ */
+ virtual TaskID get_task (void);
+
+ /// Get ID of instance of last task added to the plan by this command.
+ /**
+ * @return ID of instance of last task added to the plan by this command.
+ */
+ virtual TaskInstID get_task_inst (void);
+
+ /// Check if the instance id used by the task of this command already exists.
+ /**
+ * @return True if this command is using an already existing instance id.
+ */
+ virtual bool inst_exists (void);
+
+ protected:
+ /// WorkingPlan object that this command works on.
+ SA_WorkingPlan *working_plan_;
+
+ /// Ordered list of tasks to try adding to the plan.
+ TaskList tasks_;
+
+ /// Open condition satisfied by these tasks.
+ Condition cond_;
+
+ /// Task instances requiring the open condition satisfied by these tasks.
+ TaskInstSet task_insts_;
+
+ /// Task instances of the task at the front of the tasks_ list.
+ TaskInstSet used_task_insts_;
+
+ /// Last task tried.
+ TaskID last_task_;
+
+ /// Instance of last task tried.
+ TaskInstID last_task_inst_;
+
+ /// Number of tasks tried.
+ size_t num_tries_;
+
+ /// Causal Links added by this command
+ CLSet added_links_;
+
+ };
+
+ /**
+ * @class SA_AssocTaskImplCmd
+ *
+ * @brief AssocTaskImplCmd concrete class for the encapsulation of a command
+ * to associate an implementation with a task instance in the plan.
+ */
+ class SA_AssocTaskImplCmd : public AssocTaskImplCmd {
+ public:
+ /// SA_WorkingPlan needs access to private data to execute this command.
+ friend class SA_WorkingPlan;
+
+ /// Constructor.
+ /**
+ * @param working_plan WorkingPlan object associated with this command.
+ */
+ SA_AssocTaskImplCmd (SA_WorkingPlan *working_plan);
+
+ /// Destructor.
+ virtual ~SA_AssocTaskImplCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the task->implementation associate.
+ /**
+ * @param task_inst The task instance.
+ *
+ * @param impl_list The task implementations to try for this instance.
+ */
+ virtual void set_assoc (TaskInstID task_inst, TaskImplList impl_list);
+
+ /// Get ID of instance of this command.
+ /**
+ * @return ID of instance of this command.
+ */
+ virtual TaskInstID get_task_inst (void);
+
+ protected:
+ /// WorkingPlan object that this command works on.
+ SA_WorkingPlan *working_plan_;
+
+ /// Ordered list of task implementations to try.
+ TaskImplList impls_;
+
+ /// Task instance with which to associate an implementation.
+ TaskInstID task_inst_;
+
+ /// Last task implementation tried.
+ TaskImplID last_impl_;
+
+ /// Number of task implementations tried.
+ size_t num_tries_;
+
+ // The min and max time adjusttments made for the selected
+ // task implementation and the task instance associated with it
+ SA_AdjustMinTimesCmd min_adj_cmd;
+ SA_AdjustMaxTimesCmd max_adj_cmd;
+
+ // The changes made in the precedence set due to the selection of this task instance
+ // are recorded in these sets.
+ std::set< std::pair<TaskInstID,TaskInstID> > causal_insertions;
+ std::set< std::pair<TaskInstID,TaskInstID> > simul_insertions;
+ };
+
+ /**
+ * @class SA_AddOpenCondsCmd
+ *
+ * @brief AddOpenCondsCmd concrete class for the encapsulation of a command
+ * to add open conditions to the current planning strategy.
+ */
+ class SA_AddOpenCondsCmd : public AddOpenCondsCmd {
+ public:
+ /// SA_PlanStrategy needs access to private data to execute this command.
+ friend class SA_PlanStrategy;
+
+ /// Constructor.
+ /**
+ * @param plan_strat PlanStrategy object associated with this command.
+ */
+ SA_AddOpenCondsCmd (SA_PlanStrategy *plan_strat);
+
+ /// Destructor.
+ virtual ~SA_AddOpenCondsCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the open conditions to add.
+ /**
+ * @param conds Set of open conditions to add.
+ */
+ virtual void set_conds (const CondSet &conds);
+
+ /// Set the task instance for which these are preconditions.
+ /**
+ * @param task_inst Task instance for which these are preconditions.
+ */
+ virtual void set_task_inst (TaskInstID task_inst);
+
+ protected:
+ /// PlanStrategy object that this command works on.
+ SA_PlanStrategy *plan_strat_;
+
+ /// Set of conditions to add to open conditions.
+ CondSet conds_;
+
+ /// Task instance for which these are preconditions.
+ TaskInstID task_inst_;
+
+ /// Flag for whether this has been executed.
+ bool has_executed_;
+ };
+
+ /**
+ * @class SA_RemoveOpenCondsCmd
+ *
+ * @brief RemoveOpenCondsCmd concrete class for the encapsulation of a
+ * command to remove open conditions from the current planning
+ * strategy.
+ */
+ class SA_RemoveOpenCondsCmd : public RemoveOpenCondsCmd {
+ public:
+ /// SA_PlanStrategy needs access to private data to execute this command.
+ friend class SA_PlanStrategy;
+
+ /// Constructor.
+ /**
+ * @param plan_strat PlanStrategy object associated with this command.
+ */
+ SA_RemoveOpenCondsCmd (SA_PlanStrategy *plan_strat);
+
+ /// Destructor.
+ virtual ~SA_RemoveOpenCondsCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the open conditions to remove.
+ /**
+ * @param conds Set of open conditions to remove.
+ */
+ virtual void set_conds (const CondSet &conds);
+
+ protected:
+ /// PlanStrategy object that this command works on.
+ SA_PlanStrategy *plan_strat_;
+
+ /// Set of conditions to remove from open conditions.
+ CondSet conds_;
+
+ /// Map from removed conditions to (removed) task instances.
+ OpenCondMap removed_;
+ };
+
+ /**
+ * @class SA_AddOpenThreatsCmd
+ *
+ * @brief AddOpenThreatsCmd concrete class for the encapsulation of a command
+ * to add open causal link threats to the current planning strategy.
+ */
+ class SA_AddOpenThreatsCmd : public AddOpenThreatsCmd {
+ public:
+ /// SA_PlanStrategy needs access to private data to execute this command.
+ friend class SA_PlanStrategy;
+
+ /// Constructor.
+ /**
+ * @param plan_strat PlanStrategy object associated with this command.
+ */
+ SA_AddOpenThreatsCmd (SA_PlanStrategy *plan_strat);
+
+ /// Destructor.
+ virtual ~SA_AddOpenThreatsCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the open threats to add.
+ /**
+ * @param conds Set of open threats to add.
+ */
+ virtual void set_threats (const CLThreatSet &threats);
+
+ protected:
+ /// PlanStrategy object that this command works on.
+ SA_PlanStrategy *plan_strat_;
+
+ };
+
+ /**
+ * @class SA_RemoveOpenThreatsCmd
+ *
+ * @brief RemoveOpenThreatsCmd concrete class for the encapsulation of a
+ * command to remove open causal link threats from the current
+ * planning strategy.
+ */
+ class SA_RemoveOpenThreatsCmd : public RemoveOpenThreatsCmd {
+ public:
+ /// SA_PlanStrategy needs access to private data to execute this command.
+ friend class SA_PlanStrategy;
+
+ /// Constructor.
+ /**
+ * @param plan_strat PlanStrategy object associated with this command.
+ */
+ SA_RemoveOpenThreatsCmd (SA_PlanStrategy *plan_strat);
+
+ /// Destructor.
+ virtual ~SA_RemoveOpenThreatsCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the open threats to remove.
+ /**
+ * @param conds Set of open threats to remove.
+ */
+ virtual void set_threats (const CLThreatSet &threats);
+
+ protected:
+ /// PlanStrategy object that this command works on.
+ SA_PlanStrategy *plan_strat_;
+
+ };
+
+ /**
+ * @class SA_ResolveCLThreatCmd
+ *
+ * @brief ResolveCLThreatCmd concrete class for the encapsulation of a
+ * command to resolve a causal link threat in the plan.
+ */
+ class SA_ResolveCLThreatCmd : public ResolveCLThreatCmd {
+ public:
+ /// SA_WorkingPlan needs access to private data to execute this command.
+ friend class SA_WorkingPlan;
+
+ /// Constructor.
+ /**
+ * @param working_plan WorkingPlan object associated with this command.
+ */
+ SA_ResolveCLThreatCmd (SA_WorkingPlan *working_plan);
+
+ /// Destructor.
+ virtual ~SA_ResolveCLThreatCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the causal link threat to resolve.
+ /**
+ * @param threat The causal link threat to resolve.
+ */
+ virtual void set_threat (CLThreat &threat);
+
+ protected:
+ /// WorkingPlan object that this command works on.
+ SA_WorkingPlan *working_plan_;
+
+ };
+
+ /**
+ * @class SA_ResolveSchedOrderCmd
+ *
+ * @brief ResolveSchedOrderCmd concrete class for the encapsulation of a
+ * command to add a non-causal-link ordering constraint (promotion
+ * or demotion) between two task instances in the plan.
+ */
+ class SA_ResolveSchedOrderCmd : public ResolveSchedOrderCmd {
+ public:
+ /// SA_WorkingPlan needs access to private data to execute this command.
+ friend class SA_WorkingPlan;
+
+ /// Constructor.
+ /**
+ * @param working_plan WorkingPlan object associated with this command.
+ */
+ SA_ResolveSchedOrderCmd (SA_WorkingPlan *working_plan);
+
+ /// Destructor.
+ virtual ~SA_ResolveSchedOrderCmd (void);
+
+ /// Create a deep copy of this command.
+ /**
+ * @return A deep copy of this command.
+ */
+ virtual PlanCommand *clone (void);
+
+ /// Execute next option for this command.
+ /**
+ * @return True if there was an option executed for this command, or
+ * false if no options remain.
+ */
+ virtual bool execute_next (void);
+
+ /// Undo this command.
+ virtual void undo (void);
+
+ /// Get log text for most recent execution of command.
+ /**
+ * @return Log text for most recent execution of command.
+ */
+ virtual std::string get_log_text (void);
+
+ /// Set the task instances to order.
+ /**
+ * @param task_inst_a One task instance.
+ *
+ * @param task_inst_b The other task instance.
+ */
+ virtual void set_task_insts (TaskInstID task_inst_a,
+ TaskInstID task_inst_b);
+ /// Get the affected task instances.
+ /**
+ * @return A set of the affected task instances.
+ */
+ virtual TaskInstSet get_affected_insts ();
+
+ // A Type of a list of ResolveSchedOrderCmd pointers
+ typedef std::list<SA_ResolveSchedOrderCmd* > ResolveSchedOrderCmdList;
+ protected:
+ /// WorkingPlan object that this command works on.
+ SA_WorkingPlan *working_plan_;
+
+ // The first task instance is scheduled before the second one
+ TaskInstID first,second;
+
+ // The min and the max times changed due to this command
+ SA_AdjustMinTimesCmd *adj_min_times_cmd_;
+ SA_AdjustMaxTimesCmd *adj_max_times_cmd_;
+
+ // A list of all the scheduling orderings introduced by this command
+ ResolveSchedOrderCmdList cmds_;
+ };
+
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_SA_PLAN_COMMANDS_H_ */
diff --git a/SA_POP/SA_PlanHeuristics.cpp b/SA_POP/SA_PlanHeuristics.cpp
new file mode 100644
index 00000000000..115690ad6bd
--- /dev/null
+++ b/SA_POP/SA_PlanHeuristics.cpp
@@ -0,0 +1,125 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_PlanHeuristics.cpp
+ *
+ * This file contains the implementations of concrete classes,
+ * which implement plan heuristic strategies.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "SA_PlanHeuristics.h"
+#include "Planner.h"
+
+using namespace SA_POP;
+
+// Constructor.
+SA_CondStrategy::SA_CondStrategy (SA_POP::Planner *planner)
+: CondStrategy (planner)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+SA_CondStrategy::~SA_CondStrategy (void)
+{
+ // Nothing to do.
+};
+
+// Choose the next open condition to satisfy.
+Condition SA_CondStrategy::choose_cond (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;
+ }
+
+ // If no data conditions, just return first condition.
+ return open_conds.begin ()->first;
+};
+
+
+
+// Constructor.
+SA_TaskStrategy::SA_TaskStrategy (SA_POP::Planner *planner)
+: TaskStrategy (planner)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+SA_TaskStrategy::~SA_TaskStrategy (void)
+{
+ // Nothing to do.
+};
+
+// Choose the (ordering of) task(s) to satisfy an open condition.
+TaskList SA_TaskStrategy::choose_task (Condition open_cond)
+{
+ TaskSet tasks = this->planner_->get_satisfying_tasks (open_cond);
+
+ // Add tasks to map with EU (to sort).
+ std::map<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));
+ }
+
+ // Add tasks to list in reverse order of map (highest EU first).
+ TaskList task_list;
+ task_list.clear ();
+ for (std::map<EUCalc, TaskID>::reverse_iterator iter = task_map.rbegin ();
+ iter != task_map.rend (); iter++)
+ {
+ task_list.push_back (iter->second);
+ }
+ return task_list;
+};
+
+
+
+// Constructor.
+SA_ImplStrategy::SA_ImplStrategy (SA_POP::Planner *planner)
+: ImplStrategy (planner)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+SA_ImplStrategy::~SA_ImplStrategy (void)
+{
+ // Nothing to do.
+};
+
+// Choose the (ordering of) task implementation(s) for a task instance.
+TaskImplList SA_ImplStrategy::choose_impl (TaskInstID task_inst)
+{
+ TaskID task = this->planner_->get_task_from_inst (task_inst);
+ TaskImplSet impls = this->planner_->get_all_impls (task);
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // Order by resource impact score.
+
+ TaskImplList impl_list;
+ impl_list.clear ();
+ for (TaskImplSet::iterator iter = impls.begin ();
+ iter != impls.end (); iter++)
+ {
+ impl_list.push_back (*iter);
+ }
+
+ return impl_list;
+};
diff --git a/SA_POP/SA_PlanHeuristics.h b/SA_POP/SA_PlanHeuristics.h
new file mode 100644
index 00000000000..ab4a859d982
--- /dev/null
+++ b/SA_POP/SA_PlanHeuristics.h
@@ -0,0 +1,107 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_PlanHeuristics.h
+ *
+ * This file contains the definitions of concrete classes,
+ * which implement plan heuristic strategies.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SA_PLAN_HEURISTICS_H_
+#define SA_POP_SA_PLAN_HEURISTICS_H_
+
+#include "SA_POP_Types.h"
+#include "PlanHeuristics.h"
+
+namespace SA_POP {
+
+ /**
+ * @class SA_CondStrategy
+ *
+ * @brief CondStrategy concrete class for a PlanHeuristic that
+ * chooses an open condition in the plan to satisfy next.
+ */
+ class SA_CondStrategy : public CondStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ SA_CondStrategy (SA_POP::Planner *planner);
+
+ /// Destructor.
+ virtual ~SA_CondStrategy (void);
+
+ /// Choose the next open condition to satisfy.
+ /**
+ * @param open_conds Open conditions in the plan.
+ *
+ * @return Next open condition to satisfy.
+ */
+ virtual Condition choose_cond (const OpenCondMap &open_conds);
+ };
+
+ /**
+ * @class SA_TaskStrategy
+ *
+ * @brief TaskStrategy concrete class for a PlanHeuristic that
+ * chooses an ordering of tasks for the choice to satisfy an
+ * open condition.
+ */
+ class SA_TaskStrategy : public TaskStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ SA_TaskStrategy (SA_POP::Planner *planner);
+
+ /// Destructor.
+ virtual ~SA_TaskStrategy (void);
+
+ /// Choose the (ordering of) task(s) to satisfy an open condition.
+ /**
+ * @param open_cond Open condition to satisfy.
+ *
+ * @return Sorted list of tasks that satisfy given condition.
+ */
+ virtual TaskList choose_task (Condition open_cond);
+ };
+
+ /**
+ * @class SA_ImplStrategy
+ *
+ * @brief ImplStrategy concrete class for a PlanHeuristic that
+ * chooses an ordering of implementations to try for a given
+ * task instance.
+ */
+ class SA_ImplStrategy : public ImplStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ SA_ImplStrategy (SA_POP::Planner *planner);
+
+ /// Destructor.
+ virtual ~SA_ImplStrategy (void);
+
+ /// Choose the (ordering of) task implementation(s) for a task instance.
+ /**
+ * @param task_inst Task instance for which to choose implementations.
+ *
+ * @return Ordered list of implementations for the given task instance.
+ */
+ virtual TaskImplList choose_impl (TaskInstID task_inst);
+ };
+
+
+}; /* SA_POP namespace */
+
+
+#endif /* SA_POP_SA_PLAN_HEURISTICS_H_ */
diff --git a/SA_POP/SA_PlanStrategy.cpp b/SA_POP/SA_PlanStrategy.cpp
new file mode 100644
index 00000000000..4a32e79a21a
--- /dev/null
+++ b/SA_POP/SA_PlanStrategy.cpp
@@ -0,0 +1,474 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_PlanStrategy.cpp
+ *
+ * This file contains the implementation of the SA_PlanStrategy concrete class,
+ * which implements a PlanStrategy for use with spreading activation networks
+ * and precedence graphs.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <set>
+#include "SA_POP_Types.h"
+#include "SA_PlanStrategy.h"
+#include "Planner.h"
+#include "PlanHeuristics.h"
+#include "PlanCommands.h"
+
+using namespace SA_POP;
+
+// Constructor.
+SA_PlanStrategy::SA_PlanStrategy (SA_POP::Planner *planner,
+ CondStrategy *cond_choice, TaskStrategy *task_choice,
+ ImplStrategy *impl_choice)
+: PlanStrategy (planner),
+has_cmds_ (false),
+cur_task_ (SA_POP::NULL_TASK_ID),
+cur_task_inst_ (SA_POP::NULL_TASK_ID),
+cur_step_ (0),
+cur_decision_pt_ (SA_POP::SA_PlanStrategy::TASK_DECISION),
+cur_seq_num_ (1),
+cond_choice_ (cond_choice),
+task_choice_ (task_choice),
+impl_choice_ (impl_choice),
+add_conds_cmd_ (0),
+rmv_conds_cmd_ (0),
+add_threats_cmd_ (0),
+rmv_threats_cmd_ (0),
+add_task_cmd_ (0),
+assoc_impl_cmd_ (0),
+resolve_threat_cmd_ (0)
+{
+ this->add_conds_cmd_ = new SA_AddOpenCondsCmd (this);
+ this->rmv_conds_cmd_ = new SA_RemoveOpenCondsCmd (this);
+ this->add_threats_cmd_ = new SA_AddOpenThreatsCmd (this);
+ this->rmv_threats_cmd_ = new SA_RemoveOpenThreatsCmd (this);
+ this->open_conds_.clear ();
+ this->open_threats_.clear ();
+};
+
+// Destructor.
+SA_PlanStrategy::~SA_PlanStrategy (void)
+{
+ // Delete heuristic strategies.
+ delete this->cond_choice_;
+ delete this->task_choice_;
+ delete this->impl_choice_;
+};
+
+// Set command prototypes to use in planning.
+void SA_PlanStrategy::set_commands (AddTaskCmd *add_task_cmd,
+ AssocTaskImplCmd *assoc_impl_cmd,
+ ResolveCLThreatCmd *resolve_threat_cmd)
+{
+ this->has_cmds_ = true;
+
+ if (add_task_cmd)
+ this->add_task_cmd_ = add_task_cmd;
+ else if (this->add_task_cmd_ == 0)
+ this->has_cmds_ = false;
+
+ if (assoc_impl_cmd)
+ this->assoc_impl_cmd_ = assoc_impl_cmd;
+ else if (this->assoc_impl_cmd_ == 0)
+ this->has_cmds_ = false;
+
+ if (resolve_threat_cmd)
+ this->resolve_threat_cmd_ = resolve_threat_cmd;
+ else if (this->resolve_threat_cmd_ == 0)
+ this->has_cmds_ = false;
+};
+
+// Set goals.
+void SA_PlanStrategy::set_goals (GoalMap goals)
+{
+ for (SA_POP::GoalMap::iterator iter = goals.begin ();
+ iter != goals.end (); iter++)
+ {
+ Condition cond;
+ cond.id = iter->first;
+ if (iter->second > 0)
+ cond.value = true;
+ else
+ cond.value = false;
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // Get type of condition.
+ cond.kind = SA_POP::SYSTEM;
+
+ this->open_conds_.insert (std::make_pair (cond, SA_POP::GOAL_TASK_INST_ID));
+ }
+};
+
+// Get command ID to use for next command.
+CommandID SA_PlanStrategy::get_next_cmd_id (void)
+{
+ CommandID temp;
+ temp.step = this->cur_step_;
+ temp.decision_pt = this->cur_decision_pt_;
+ temp.seq_num = this->cur_seq_num_;
+
+ this->cur_seq_num_++;
+ return temp;
+};
+
+// Recursively satisfy all open conditions (including recursive
+// scheduling constraint satisfaction through call back).
+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();
+
+ // Increment step counter.
+ this->cur_step_++;
+
+ // Set decision point and reset sequence number for commands.
+ this->cur_decision_pt_ = SA_PlanStrategy::TASK_DECISION;
+ this->cur_seq_num_ = 1;
+
+ // Variable for preconditions of current task.
+ CondSet preconds;
+
+ // Choose an open condition to satisfy.
+ Condition open_cond = this->cond_choice_->choose_cond (this->open_conds_);
+
+ // Choose task to satisfy open condition (actually an ordered list of
+ // tasks to try), passing command to planner to be executed next.
+ AddTaskCmd *add_task_cmd = this->satisfy_cond (open_cond);
+
+ // Try tasks until one yields a complete plan or all have been tried.
+ while (this->planner_->try_next (add_task_cmd->get_id ())) {
+ // Get current task and task instance.
+ this->cur_task_ = add_task_cmd->get_task ();
+ this->cur_task_inst_ = add_task_cmd->get_task_inst ();
+ // Remove open condition.
+ CommandID rmv_cond_cmd_id = this->rmv_open_cond (open_cond);
+
+ // Add preconditions of this task of we didn't reuse the task instance.
+ CommandID add_preconds_cmd_id;
+ if(!add_task_cmd->inst_exists())
+ {
+ preconds = this->planner_->get_unsat_preconds (this->cur_task_);
+ add_preconds_cmd_id =
+ this->add_open_conds (preconds, this->cur_task_inst_);
+ }
+ // Set decision point and reset sequence number for commands.
+ this->cur_decision_pt_ = SA_PlanStrategy::THREAT_DECISION;
+ this->cur_seq_num_ = 1;
+
+ // Add causal link threats to open threats.
+ bool are_threats = !this->planner_->get_all_threats ().empty ();
+ CommandID add_threats_cmd_id;
+ if (are_threats)
+ add_threats_cmd_id =
+ this->add_open_threats (this->planner_->get_all_threats ());
+
+ // Try to satisfy threats and continue recursive planning.
+ if (this->satisfy_open_threats ())
+ return true;
+
+ SA_POP_DEBUG(SA_POP_DEBUG_NORMAL, "Backtracking from task addition...");
+ // Undo addition of causal link threats from this task.
+ if (are_threats)
+ this->planner_->undo_command (add_threats_cmd_id);
+ std::cout<<" the task instance being deleted is "<<add_task_cmd->get_task_inst()<<std::endl;
+ // Undo addition of preconditions from this task if we didn't reuse the task instance.
+ if(!add_task_cmd->inst_exists())
+ this->planner_->undo_command (add_preconds_cmd_id);
+
+ // Undo removal of open condition.
+ this->planner_->undo_command (rmv_cond_cmd_id);
+
+ }
+
+ SA_POP_DEBUG (SA_POP_DEBUG_NORMAL, "Backtracking to previous step...");
+ // Undo addition of task.
+ this->planner_->undo_command (add_task_cmd->get_id ());
+
+ // Decrement step.
+ this->cur_step_--;
+
+ // No task could satisfy open condition, so return failure.
+ return false;
+};
+
+// Get a PlanCommand prototype for adding open conditions,
+// which works on this strategy.
+AddOpenCondsCmd *SA_PlanStrategy::get_AddOpenCondsCmd (void)
+{
+ return static_cast<AddOpenCondsCmd *> (this->add_conds_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for removing open conditions,
+// which works on this strategy.
+RemoveOpenCondsCmd *SA_PlanStrategy::get_RemoveOpenCondsCmd (void)
+{
+ return static_cast<RemoveOpenCondsCmd *> (this->rmv_conds_cmd_->clone ());
+};
+
+// Get an command prototype for adding causal link threats, which works on
+// this strategy.
+AddOpenThreatsCmd *SA_PlanStrategy::get_AddOpenThreatsCmd (void)
+{
+ return static_cast<AddOpenThreatsCmd *> (this->add_threats_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for removing causal link threats,
+// which works on this strategy.
+RemoveOpenThreatsCmd *SA_PlanStrategy::get_RemoveOpenThreatsCmd (void)
+{
+ return static_cast<RemoveOpenThreatsCmd *> (this->rmv_threats_cmd_->clone ());
+};
+
+// Execute a command to add open conditions to planning.
+void SA_PlanStrategy::execute (SA_AddOpenCondsCmd *cmd)
+{
+ for (CondSet::iterator iter = cmd->conds_.begin ();
+ iter != cmd->conds_.end (); iter++)
+ {
+ this->open_conds_.insert (std::make_pair (*iter, cmd->task_inst_));
+ }
+};
+
+// Undo a command to add open conditions to planning.
+void SA_PlanStrategy::undo (SA_AddOpenCondsCmd *cmd)
+{
+ // Remove open conditions mapped to the specified task instance.
+ std::cout<<"removing open conds mapped to "<<cmd->task_inst_<<std::endl;
+ for (CondSet::iterator cond_iter = cmd->conds_.begin ();
+ cond_iter != cmd->conds_.end (); cond_iter++)
+ {
+ std::cout<<"checking for "<<cond_iter->id<<std::endl;
+ for (OpenCondMap::iterator open_iter =
+ this->open_conds_.lower_bound (*cond_iter);
+ open_iter != this->open_conds_.upper_bound (*cond_iter);)
+ {
+ OpenCondMap::iterator prev_iter = open_iter;
+ open_iter++;
+ if (prev_iter->second == cmd->task_inst_)
+ {
+ std::cout<<"in planstrat erasing from open_conds_ "<<prev_iter->first.id<<" to "<<prev_iter->second<<std::endl;
+ this->open_conds_.erase (prev_iter);
+ }
+ }
+ }
+};
+
+// Execute a command to remove open conditions from planning.
+void SA_PlanStrategy::execute (SA_RemoveOpenCondsCmd *cmd)
+{
+ // Remove open conditions, keeping track of removed cond->inst mapping.
+ for (CondSet::iterator cond_iter = cmd->conds_.begin ();
+ cond_iter != cmd->conds_.end (); cond_iter++)
+ {
+ for (OpenCondMap::iterator open_iter =
+ this->open_conds_.lower_bound (*cond_iter);
+ open_iter != this->open_conds_.upper_bound (*cond_iter); )
+ {
+ cmd->removed_.insert (std::make_pair
+ (open_iter->first, open_iter->second));
+ OpenCondMap::iterator prev_iter = open_iter;
+ open_iter++;
+ this->open_conds_.erase (prev_iter);
+ }
+ }
+};
+
+// Undo a command to remove open conditions from planning.
+void SA_PlanStrategy::undo (SA_RemoveOpenCondsCmd *cmd)
+{
+ // Insert removed open condition to task instance mapping.
+ for (OpenCondMap::iterator open_iter = cmd->removed_.begin ();
+ open_iter != cmd->removed_.end (); open_iter++)
+ {
+ std::cout<<"in planstrat undo adding "<<open_iter->first.id<<" to "<<open_iter->second<<std::endl;
+ this->open_conds_.insert (std::make_pair
+ (open_iter->first, open_iter->second));
+ }
+};
+
+// Execute a command to add causal link threats to planning.
+void SA_PlanStrategy::execute (SA_AddOpenThreatsCmd *)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Undo a command to add causal link threats to planning.
+void SA_PlanStrategy::undo (SA_AddOpenThreatsCmd *)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Execute a command to remove causal link threats from planning.
+void SA_PlanStrategy::execute (SA_RemoveOpenThreatsCmd *)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Undo a command to remove causal link threats from planning.
+void SA_PlanStrategy::undo (SA_RemoveOpenThreatsCmd *)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Recursively satisfy all open causal link threats and continue planning.
+bool SA_PlanStrategy::satisfy_open_threats (void)
+{
+ if (this->open_threats_.empty ()) {
+ // Set decision point and reset sequence number for commands.
+ this->cur_decision_pt_ = SA_PlanStrategy::IMPL_DECISION;
+ this->cur_seq_num_ = 1;
+
+ // Choose a task implementation.
+ AssocTaskImplCmd *assoc_impl_cmd =
+ static_cast<AssocTaskImplCmd *> (this->assoc_impl_cmd_->clone ());
+ TaskImplList impl_list;
+ if(!this->planner_->inst_exists(this->cur_task_inst_)) impl_list = this->impl_choice_->choose_impl (this->cur_task_inst_);
+ else impl_list.push_back(this->planner_->get_impl_id(this->cur_task_inst_));
+ assoc_impl_cmd->set_id (this->get_next_cmd_id ());
+ assoc_impl_cmd->set_assoc (this->cur_task_inst_, impl_list);
+ this->planner_->add_command (assoc_impl_cmd);
+
+ // Try task implementations until one yields a complete plan or all have
+ // been tried.
+ while (this->planner_->try_next (assoc_impl_cmd->get_id ())) {
+ // Get the task instance.
+ this->cur_task_inst_ = assoc_impl_cmd->get_task_inst ();
+ // Set decision point and reset sequence number for commands.
+ this->cur_decision_pt_ = SA_PlanStrategy::SCHEDULE_DECISION;
+ this->cur_seq_num_ = 1;
+
+ // Try to schedule and recursively continue planning.
+ if (this->planner_->recurse_sched (this->cur_task_inst_))
+ return true;
+ }
+
+ // No task implementation worked so return failure.
+ return false;
+ }
+
+ // Choose an open threat to satisfy and remove from open threats.
+ CLThreat threat = *this->open_threats_.begin ();
+ CommandID rmv_threat_cmd_id = this->rmv_open_threat (threat);
+
+ // Create threat resolution command and add to planner.
+ ResolveCLThreatCmd *resolve_threat_cmd =
+ static_cast<ResolveCLThreatCmd *> (this->resolve_threat_cmd_->clone ());
+ resolve_threat_cmd->set_id (this->get_next_cmd_id ());
+ resolve_threat_cmd->set_threat (threat);
+ this->planner_->add_command (resolve_threat_cmd);
+
+ // Try threat resolutions until one yields a complete plan or all have been
+ // tried.
+ while (this->planner_->try_next (resolve_threat_cmd->get_id ())) {
+ if (this->satisfy_open_threats ())
+ return true;
+ }
+
+ // Undo threat resolution.
+ this->planner_->undo_command (resolve_threat_cmd->get_id ());
+
+ // Undo removal of open threat.
+ this->planner_->undo_command (rmv_threat_cmd_id);
+
+ // No threat resolution was successful so return failure.
+ return false;
+};
+
+// Satisfy an open condition with an appropriate task.
+AddTaskCmd *SA_PlanStrategy::satisfy_cond (Condition open_cond)
+{
+ // Get add task command.
+ AddTaskCmd *add_task_cmd =
+ static_cast<AddTaskCmd *> (this->add_task_cmd_->clone ());
+ TaskList task_list = this->task_choice_->choose_task (open_cond);
+ add_task_cmd->set_id (this->get_next_cmd_id ());
+ add_task_cmd->set_tasks (task_list);
+
+ // Get task instances requiring this open condition, and set in command.
+ TaskInstSet inst_set;
+ inst_set.clear ();
+ 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);
+ }
+ add_task_cmd->set_causal_info (open_cond, inst_set);
+
+ // Add command to planner to be executed next.
+ this->planner_->add_command (add_task_cmd);
+
+ // Return pointer to command.
+ return add_task_cmd;
+};
+
+// Add open conditions.
+CommandID SA_PlanStrategy::add_open_conds (const CondSet &open_conds,
+ TaskInstID task_inst)
+{
+ // Get command to add open conditions for task instance.
+ AddOpenCondsCmd *add_conds_cmd =
+ static_cast<AddOpenCondsCmd *> (this->add_conds_cmd_->clone ());
+ add_conds_cmd->set_conds (open_conds);
+ add_conds_cmd->set_task_inst (task_inst);
+ CommandID cmd_id = this->get_next_cmd_id ();
+ add_conds_cmd->set_id (cmd_id);
+
+ // Execute command immediately and return command id.
+ this->planner_->execute_command (add_conds_cmd);
+ return cmd_id;
+};
+
+// Remove open condition.
+CommandID SA_PlanStrategy::rmv_open_cond (Condition open_cond)
+{
+ // Get commmand to remove open conditions.
+ RemoveOpenCondsCmd *rmv_conds_cmd =
+ static_cast<RemoveOpenCondsCmd *> (this->rmv_conds_cmd_->clone ());
+ CondSet conds;
+ conds.insert (open_cond);
+ rmv_conds_cmd->set_conds (conds);
+ CommandID cmd_id = this->get_next_cmd_id ();
+ rmv_conds_cmd->set_id (cmd_id);
+
+ // Execute command immediately and return command id.
+ this->planner_->execute_command (rmv_conds_cmd);
+ return cmd_id;
+};
+
+// Add open causal link threats.
+CommandID SA_PlanStrategy::add_open_threats (const CLThreatSet &threats)
+{
+ // Get commmand to add open threats.
+ AddOpenThreatsCmd *add_threats_cmd =
+ static_cast<AddOpenThreatsCmd *> (this->add_threats_cmd_->clone ());
+ add_threats_cmd->set_threats (threats);
+ CommandID cmd_id = this->get_next_cmd_id ();
+ add_threats_cmd->set_id (cmd_id);
+
+ // Execute command immediately and return command id.
+ this->planner_->execute_command (add_threats_cmd);
+ return cmd_id;
+};
+
+// Remove open causal link threat.
+CommandID SA_PlanStrategy::rmv_open_threat (CLThreat threat)
+{
+ // Get commmand to remove open threats.
+ RemoveOpenThreatsCmd *rmv_threats_cmd =
+ static_cast<RemoveOpenThreatsCmd *> (this->rmv_threats_cmd_->clone ());
+ CLThreatSet threats;
+ threats.insert (threat);
+ rmv_threats_cmd->set_threats (threats);
+ CommandID cmd_id = this->get_next_cmd_id ();
+ rmv_threats_cmd->set_id (cmd_id);
+
+ // Execute command immediately and return command id.
+ this->planner_->execute_command (rmv_threats_cmd);
+ return cmd_id;
+};
diff --git a/SA_POP/SA_PlanStrategy.h b/SA_POP/SA_PlanStrategy.h
new file mode 100644
index 00000000000..61969a7ae8f
--- /dev/null
+++ b/SA_POP/SA_PlanStrategy.h
@@ -0,0 +1,337 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_PlanStrategy.h
+ *
+ * This file contains the definition of the SA_PlanStrategy concrete class,
+ * which implements a PlanStrategy for use with spreading activation networks
+ * and precedence graphs.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SA_PLAN_STRATEGY_H_
+#define SA_POP_SA_PLAN_STRATEGY_H_
+
+#include <set>
+#include "SA_POP_Types.h"
+#include "PlanStrategy.h"
+#include "PlanHeuristics.h"
+#include "PlanCommands.h"
+#include "SA_PlanCommands.h"
+
+namespace SA_POP {
+
+ /**
+ * @class SA_PlanStrategy
+ *
+ * @brief PlanStrategy concrete class for the high-level
+ * planning/scheduling algorithm for use with spreading activation
+ * networks and precedence graphs.
+ */
+ class SA_PlanStrategy : public PlanStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ *
+ * @param cond_choice Strategy for choosing open condition to satisfy.
+ *
+ * @param task_choice Strategy for choosing/ordering tasks to satisfy
+ * an open condition.
+ *
+ * @param impl_choice Strategy for choosing an implementation of a task.
+ */
+ SA_PlanStrategy (SA_POP::Planner *planner, CondStrategy *cond_choice,
+ TaskStrategy *task_choice, ImplStrategy *impl_choice);
+
+ /// Destructor.
+ virtual ~SA_PlanStrategy (void);
+
+ /// Set command prototypes to use in planning.
+ /**
+ * @param assoc_impl_cmd Prototype of command for associating an
+ * implementation with a task instance in the plan.
+ *
+ * @param add_task_cmd Prototype of command for adding a task to the plan.
+ *
+ * @param resolve_threat_cmd Prototype of command for resolving causal
+ * link threats.
+ */
+ virtual void set_commands (AddTaskCmd *add_task_cmd,
+ AssocTaskImplCmd *assoc_impl_cmd,
+ ResolveCLThreatCmd *resolve_threat_cmd);
+
+
+
+ // ************************************************************************
+ // Planning methods.
+ // ************************************************************************
+
+ /// Set goals.
+ /**
+ * @param goals Set of goals and associated utilities.
+ */
+ virtual void set_goals (GoalMap goals);
+
+ /// Get command ID to use for next command.
+ /**
+ * @return Command ID to use for next command.
+ */
+ virtual CommandID get_next_cmd_id (void);
+
+ /// Recursively satisfy all open conditions (including recursive
+ /// scheduling constraint satisfaction through call back).
+ /**
+ * @return True if all open conditions were satisfied, false otherwise.
+ */
+ virtual bool satisfy_open_conds (void);
+
+
+ // ************************************************************************
+ // Methods for obtaining prototypes of commands that work on this strategy.
+ // ************************************************************************
+
+ /// Get a PlanCommand prototype for adding open conditions,
+ /// which works on this strategy.
+ /**
+ * @return An AddOpenCondsCmd prototype for this strategy.
+ */
+ virtual AddOpenCondsCmd *get_AddOpenCondsCmd (void);
+
+ /// Get a PlanCommand prototype for removing open conditions,
+ /// which works on this strategy.
+ /**
+ * @return A RemoveOpenCondsCmd prototype for this strategy.
+ */
+ virtual RemoveOpenCondsCmd *get_RemoveOpenCondsCmd (void);
+
+ /// Get an command prototype for adding causal link threats, which works on
+ /// this strategy.
+ /**
+ * @return An AddOpenThreatsCmd prototype for this strategy.
+ */
+ virtual AddOpenThreatsCmd *get_AddOpenThreatsCmd (void);
+
+ /// Get a PlanCommand prototype for removing causal link threats,
+ /// which works on this strategy.
+ /**
+ * @return A RemoveOpenThreatsCmd prototype for this strategy.
+ */
+ virtual RemoveOpenThreatsCmd *get_RemoveOpenThreatsCmd (void);
+
+
+
+ // ************************************************************************
+ // Methods for executing and undoing commands.
+ // ************************************************************************
+
+ /// Execute a command to add open conditions to planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void execute (SA_AddOpenCondsCmd *cmd);
+
+ /// Undo a command to add open conditions to planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_AddOpenCondsCmd *cmd);
+
+ /// Execute a command to remove open conditions from planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void execute (SA_RemoveOpenCondsCmd *cmd);
+
+ /// Undo a command to remove open conditions from planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_RemoveOpenCondsCmd *cmd);
+
+ /// Execute a command to add causal link threats to planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void execute (SA_AddOpenThreatsCmd *cmd);
+
+ /// Undo a command to add causal link threats to planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_AddOpenThreatsCmd *cmd);
+
+ /// Execute a command to remove causal link threats from planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void execute (SA_RemoveOpenThreatsCmd *cmd);
+
+ /// Undo a command to remove causal link threats from planning.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_RemoveOpenThreatsCmd *cmd);
+
+ protected:
+ // ************************************************************************
+ // State information.
+ // ************************************************************************
+
+ /// Flag for whether command prototypes have been set.
+ bool has_cmds_;
+
+ /// Set of open conditions with associated task instances that require
+ /// them as preconditions.
+ OpenCondMap open_conds_;
+
+ /// Set of open causal link threats.
+ CLThreatSet open_threats_;
+
+ /// ID of current task being tried (to satisfy an open condition).
+ TaskID cur_task_;
+
+ /// ID of instance of current task being tried.
+ TaskInstID cur_task_inst_;
+
+ /// Current step number.
+ int cur_step_;
+
+ /// Current decision point.
+ int cur_decision_pt_;
+
+ /// Current sequence number for commands in this decision point.
+ int cur_seq_num_;
+
+
+
+ // ************************************************************************
+ // Decision point numbers.
+ // ************************************************************************
+
+ /// Task choice is first decision point.
+ static const int TASK_DECISION = 1;
+
+ /// Causal link threat handling is second decision point.
+ static const int THREAT_DECISION = 2;
+
+ /// Task implementation choice is third decision point.
+ static const int IMPL_DECISION = 3;
+
+ /// Scheduling is fourth decision point.
+ static const int SCHEDULE_DECISION = 3;
+
+
+
+ // ************************************************************************
+ // Decision point heuristic strategies.
+ // ************************************************************************
+
+ /// Strategy for choosing open condition to satisfy.
+ CondStrategy *cond_choice_;
+
+ /// Strategy for choosing tasks to satisfy an open condition.
+ TaskStrategy *task_choice_;
+
+ /// Strategy for choosing task implementation.
+ ImplStrategy *impl_choice_;
+
+
+
+ // ************************************************************************
+ // Prototypes of commands that work on this object.
+ // ************************************************************************
+
+ /// PlanCommand prototype to add open conditions.
+ SA_AddOpenCondsCmd *add_conds_cmd_;
+
+ /// PlanCommand prototype to remove open conditions.
+ SA_RemoveOpenCondsCmd *rmv_conds_cmd_;
+
+ /// PlanCommand prototype to add open causal link threats.
+ SA_AddOpenThreatsCmd *add_threats_cmd_;
+
+ /// PlanCommand prototype to remove open causal link threats.
+ SA_RemoveOpenThreatsCmd *rmv_threats_cmd_;
+
+
+
+ // ************************************************************************
+ // Prototypes of commands that work on other objects.
+ // ************************************************************************
+
+ /// PlanCommand prototype for adding a task to the plan.
+ AddTaskCmd *add_task_cmd_;
+
+ /// PlanCommand prototype for associating an implementation with a
+ /// task instance in the plan.
+ AssocTaskImplCmd *assoc_impl_cmd_;
+
+ /// PlanCommand prototype for resolving a causal link threat in the
+ /// plan (with promotion or demotion).
+ ResolveCLThreatCmd *resolve_threat_cmd_;
+
+
+
+ // ************************************************************************
+ // Internal helper methods.
+ // ************************************************************************
+
+ /// Recursively satisfy all open causal link threats and continue planning.
+ /**
+ * @return True if planning succeeded, false otherwise.
+ */
+ virtual bool satisfy_open_threats (void);
+
+ /// Satisfy an open condition with an appropriate task.
+ /**
+ * @param open_cond Open condition to be satisfied.
+ *
+ * @return Pointer to command passed to planner.
+ */
+ virtual AddTaskCmd *satisfy_cond (Condition open_cond);
+
+ /// Add open conditions.
+ /**
+ * @param open_conds Set of open conditions to add.
+ *
+ * @param task_inst The task instance for which these are preconditions.
+ *
+ * @return ID of command passed to planner to add open conditions.
+ */
+ virtual CommandID add_open_conds (const CondSet &open_conds,
+ TaskInstID task_inst);
+
+ /// Remove open condition.
+ /**
+ * @param open_cond Open condition to remove.
+ *
+ * @return ID of command passed to planner to remove open condition.
+ */
+ virtual CommandID rmv_open_cond (Condition open_cond);
+
+ /// Add open causal link threats.
+ /**
+ * @param threats Set of open causal link threats to add.
+ *
+ * @return ID of command passed to planner to add open threats.
+ */
+ virtual CommandID add_open_threats (const CLThreatSet &threats);
+
+ /// Remove open causal link threat.
+ /**
+ * @param threat Open causal link threat to remove.
+ *
+ * @return ID of command passed to planner to remove open threat.
+ */
+ virtual CommandID rmv_open_threat (CLThreat threat);
+
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_SA_PLAN_STRATEGY_H_ */
diff --git a/SA_POP/SA_SchedStrategy.cpp b/SA_POP/SA_SchedStrategy.cpp
new file mode 100644
index 00000000000..16a4c7ea309
--- /dev/null
+++ b/SA_POP/SA_SchedStrategy.cpp
@@ -0,0 +1,814 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_SchedStrategy.cpp
+ *
+ * This file contains the SA_SchedStrategy concrete class implementation, which
+ * implements a SchedStrategy for the high-level scheduling algorithm.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "SA_SchedStrategy.h"
+#include "Planner.h"
+#include <list>
+#include <set>
+using namespace SA_POP;
+
+// Constructor.
+SA_SchedStrategy::SA_SchedStrategy (SA_POP::Planner *planner)
+: SchedStrategy (planner),
+cur_decision_pt_ (SA_POP::SA_SchedStrategy::SCHEDULE_DECISION),
+cur_seq_num_ (1),
+resolve_sched_cmd_ (0),
+adj_min_times_cmd_ (0),
+adj_max_times_cmd_ (0)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+SA_SchedStrategy::~SA_SchedStrategy (void)
+{
+ // Nothing to do.
+};
+
+// Set command prototypes to use in scheduling.
+void SA_SchedStrategy::set_commands (ResolveSchedOrderCmd *resolve_sched_cmd,
+ AdjustMinTimesCmd *adj_min_times_cmd,
+ AdjustMaxTimesCmd *adj_max_times_cmd)
+{
+ this->has_cmds_ = true;
+
+ if (resolve_sched_cmd)
+ this->resolve_sched_cmd_ = resolve_sched_cmd;
+ else if (this->resolve_sched_cmd_ == 0)
+ this->has_cmds_ = false;
+
+ if (adj_min_times_cmd)
+ this->adj_min_times_cmd_ = adj_min_times_cmd;
+ else if (this->adj_min_times_cmd_ == 0)
+ this->has_cmds_ = false;
+
+ if (adj_max_times_cmd)
+ this->adj_max_times_cmd_ = adj_max_times_cmd;
+ else if (this->adj_max_times_cmd_ == 0)
+ this->has_cmds_ = false;
+};
+// Get command ID to use for next command.
+CommandID SA_SchedStrategy::get_next_cmd_id (void)
+{
+ CommandID temp;
+ temp.step = this->planner_->cur_command_id().step;
+ temp.decision_pt = this->cur_decision_pt_;
+ temp.seq_num = this->cur_seq_num_;
+
+ this->cur_seq_num_++;
+ return temp;
+};
+
+// Recursively satisfy all scheduling constraints (and continue
+// satisfaction of open conditions by recursive call back to planning).
+bool SA_SchedStrategy::satisfy_sched (TaskInstID task_inst)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ //return this->planner_->recurse_plan ();
+ // Adjust schedule.
+ double THRESHOLD_CRIT = 0.8;
+ // Get the current command id to backtrack to.
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ this->cur_seq_num_=1;
+ // Do the energy propogation for this task instance
+ // This function automatically does this for the task instances before and after it.
+ if(!this->energy_prop(task_inst))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ // Do the balance propogation related to time windows for this task instance
+ // and those unranked with respect to it
+ if(!this->time_balance_prop(task_inst))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ const TaskInstSet *unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ for(TaskInstSet::const_iterator iter = unranked->begin();iter!=unranked->end();iter++)
+ {
+ if(!this->time_balance_prop(*iter))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ // Do the balance propogation related to precedence graph links for this task instance
+ // and those unranked with respect to it
+ // if(!this->prec_balance_prop(task_inst))
+ // {
+ // this->planner_->undo_through(cur_cmd_id);
+ // return false;
+ // }
+ // unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ //for(TaskInstSet::const_iterator iter = unranked->begin();iter!=unranked->end();iter++)
+ //{
+ // if(!this->prec_balance_prop(*iter))
+ // {
+ // this->planner_->undo_through(cur_cmd_id);
+ // return false;
+ // }
+ //}
+
+ // Recalculate all the levels
+ TaskInstSet all = this->planner_->get_all_insts();
+ for(TaskInstSet::iterator iter=all.begin();iter!=all.end();iter++)
+ this->calculate_levels(*iter);
+
+ // start the search
+ if(!search(THRESHOLD_CRIT))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ return this->planner_->recurse_plan ();
+};
+
+// Satisfy fully instantiated plan.
+bool SA_SchedStrategy::satisfy_full_sched ()
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ //return true;
+ // Adjust schedule.
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ this->cur_seq_num_=1;
+ if(!search(0))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ return true;
+};
+/// Calculate the min and max levels for the consumer of a task instance
+void SA_SchedStrategy::calculate_levels(TaskInstID task_inst)
+{
+ const TaskInstSet *unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ TimeWindow end_win = this->planner_->get_end_window(task_inst);
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ // Calculate the levels for all the resources this task instance uses
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+// Sum of the resource usages of all the consumers that have to occur before the consumer of this task instance
+ ResourceValue Q=this->planner_->get_capacity(rm_iter->first);
+ // The max and min levels at the consumer
+ ResourceValue cons_min=Q,cons_max=Q;
+ for(TaskInstSet::const_iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ // get the resourse usage by the task instance in the unranked set
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ // Check whether it uses the resource that we are calculating the level for
+ if(temp_rm_iter==temp_rm.end()) continue;
+ TimeWindow temp_start = this->planner_->get_start_window(*iter);
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ //The consumer of *iter can be executed before and its producer after the consumer of task_inst
+ if(start_win.second==NULL_TIME || temp_start.first<start_win.second)
+ {
+ std::cout<<"The consumer of "<<*iter<<" can be executed before and its producer after the consumer of "<<task_inst<<std::endl;
+ cons_min-=temp_rm_iter->second;
+ }
+ // The consumer of *iter has to executed before the consumer of task_inst
+ if(temp_start.second!=NULL_TIME && temp_start.second<start_win.first)
+ {
+ std::cout<<"THe consumer of "<<*iter<<" has to executed before the consumer of "<<task_inst<<std::endl;
+ cons_max-=temp_rm_iter->second;
+ }
+ }
+ LevelMap temp;
+ MinimumLevels::iterator iter1=this->min_cons_levels_.find(rm_iter->first);
+ // Insert dummy levels if this is a new task instance
+ if(iter1==this->min_cons_levels_.end())
+ {
+ this->min_cons_levels_.insert(std::make_pair(rm_iter->first,temp));
+ this->max_cons_levels_.insert(std::make_pair(rm_iter->first,temp));
+ }
+ ResourceValue simul_level=0;
+ const TaskInstSet *simul = this->planner_->get_prec_insts(task_inst,SIMUL);
+ // Calculate the usage of all the task instances simultaneous to this one
+ for(TaskInstSet::const_iterator iter2 = simul->begin();iter2!=simul->end();iter2++)
+ {
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter2));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+// std::cout<<"calculating for "<<task_inst<<" adding "<<temp_rm_iter->second<<" for task inst "<<*iter2<<std::endl;
+ simul_level+=temp_rm_iter->second;
+ }
+ this->min_cons_levels_.find(rm_iter->first)->second.insert(std::make_pair(task_inst,-1));
+ this->max_cons_levels_.find(rm_iter->first)->second.insert(std::make_pair(task_inst,-1));
+ cons_min-=rm_iter->second;
+ // erase any previous levels and add the new one.
+ this->min_cons_levels_.find(rm_iter->first)->second.erase(this->min_cons_levels_.find(rm_iter->first)->second.find(task_inst));
+ this->max_cons_levels_.find(rm_iter->first)->second.erase(this->max_cons_levels_.find(rm_iter->first)->second.find(task_inst));
+ this->min_cons_levels_.find(rm_iter->first)->second.insert(std::make_pair(task_inst,cons_min-simul_level));
+ this->max_cons_levels_.find(rm_iter->first)->second.insert(std::make_pair(task_inst,cons_max));
+ }
+}
+/// Get the Criticality of the consumer of a task instance
+Criticality SA_SchedStrategy::crit(TaskInstID task_inst)
+{
+ double INF_CRIT = 0.2;
+ const TaskInstSet *unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ Criticality max_crit=std::make_pair(NULL_RESOURCE_ID,0);
+ if(start_win.second==NULL_TIME)
+ {
+ ResourceMap::iterator rm_iter = rm.begin();
+ for(;rm_iter!=rm.end();rm_iter++)
+ {
+ ResourceValue lack = this->min_cons_levels_.find(rm_iter->first)->second.find(task_inst)->second;
+ if(lack<0) break;
+ }
+ // If this doesn't lack, then its not critical.
+ if(rm_iter==rm.end()) return max_crit;
+ else return std::make_pair(rm.begin()->first,INF_CRIT);
+ }
+ // Calculate the criticality and return the maximum criticality.
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ ResourceValue lack = this->min_cons_levels_.find(rm_iter->first)->second.find(task_inst)->second;
+ if(lack>0) continue;
+ ResourceValue Q = this->planner_->get_capacity(rm_iter->first);
+ double crit_value = (0-lack)/(Q*(start_win.second-start_win.first+1));
+ if(max_crit.second<crit_value) max_crit=std::make_pair(rm_iter->first,crit_value);
+ }
+ return max_crit;
+}
+///Get the commitment of an ordering
+double SA_SchedStrategy::commit(TaskInstID first_task_inst, TaskInstID second_task_inst)
+{
+ double INF_COMMIT = 0.2;
+ TimeValue first_min,first_max,second_min,second_max;
+ TimeWindow first_end_win = this->planner_->get_end_window(first_task_inst);
+ TimeWindow second_start_win = this->planner_->get_start_window(second_task_inst);
+ first_min=first_end_win.first;
+ first_max=first_end_win.second;
+ second_min=second_start_win.first;
+ second_max=second_start_win.second;
+ if(first_max==NULL_TIME || second_max==NULL_TIME) return INF_COMMIT;
+ // Calculate the commitment
+ double A,B,C_min,C_max,delta_min,delta_max;
+ if(first_min>second_min) delta_min=1;
+ else delta_min=0;
+ if(first_max>second_max) delta_max=1;
+ else delta_max=0;
+ A = (second_max-second_min+1)*(first_max-first_min+1);
+ B = (first_max-second_min+1)*(first_max-second_min+1)/2;
+ C_min = (first_min-second_min)*(first_min-second_min)/2;
+ C_max = (first_max-second_max)*(first_max-second_max)/2;
+ return (B-delta_min*C_min-delta_max*C_max)/A;
+}
+/// Perform the search till the ctiricality goes below a certain value
+bool SA_SchedStrategy::search(double min_crit)
+{
+ TaskInstSet all = this->planner_->get_all_insts();
+ // Task Instances at maximum criticality
+ TaskInstSet maxcritical;
+ Criticality max_crit;
+ max_crit = std::make_pair(NULL_RESOURCE_ID,0);
+ TaskInstID task_inst=NULL_TASK_INST_ID;
+ for(TaskInstSet::iterator iter=all.begin();iter!=all.end();iter++)
+ {
+ Criticality crit_cons = this->crit(*iter);
+ std::cout<<"Criticality of "<<*iter<<" consumer: "<<crit_cons.second<<std::endl;
+ if(crit_cons.second>=max_crit.second)
+ {
+ max_crit=crit_cons;
+ maxcritical.insert(*iter);
+ }
+ }
+ if(max_crit.second<=min_crit) return true;
+ for(TaskInstSet::iterator iter=maxcritical.begin(); iter!=maxcritical.end(); iter++)
+ {
+ task_inst=*iter;
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ const TaskInstSet *unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ std::set<std::pair<double,TaskInstID> > probables;
+ // get all the probable task instances that can be ordered before this task instance
+ for(TaskInstSet::const_iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ if(temp_end.first!=NULL_TIME && (start_win.second==NULL_TIME || temp_end.first<start_win.second))
+ {
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(max_crit.first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ double rel_crit=this->commit(*iter,task_inst)/(double)temp_rm_iter->second;
+ if(rel_crit!=0) probables.insert(std::make_pair(rel_crit,*iter));
+ }
+ }
+ for(std::set<std::pair<double,TaskInstID> >::iterator iter=probables.begin();iter!=probables.end();iter++)
+ {
+ ResolveSchedOrderCmd *sched_cmd = static_cast<ResolveSchedOrderCmd *> (this->resolve_sched_cmd_->clone ());
+ sched_cmd->set_id(this->get_next_cmd_id());
+ sched_cmd->set_task_insts(iter->second,task_inst);
+ this->planner_->add_command(sched_cmd);
+ if(this->planner_->try_next(sched_cmd->get_id()))
+ {
+ TaskInstSet affected_insts = sched_cmd->get_affected_insts();
+ for(TaskInstSet::iterator iter2=affected_insts.begin();iter2!=affected_insts.end();iter2++)
+ {
+ this->calculate_levels(*iter2);
+ }
+ if(search(min_crit)) return true;
+ }
+ this->planner_->undo_command(sched_cmd->get_id());
+ }
+ }
+ return false;
+}
+
+///Precedence Link Based Balance Constraint Propogation 5.3.3 (labourie paper)
+bool SA_SchedStrategy::prec_balance_prop (TaskInstID task_inst)
+{
+ std::cout<<"Doing Precedence balance prop for "<<task_inst<<std::endl;
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ const TaskInstSet *unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ // Iterate over all resources that this task instance uses
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ //Sum of the resource usages of all the consumers that have to occur before the consumer of this task instance
+ ResourceValue level_before=this->planner_->get_capacity(rm_iter->first);
+ TaskInstSet producers_unranked;
+ for(TaskInstSet::const_iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ TimeWindow temp_start = this->planner_->get_start_window(*iter);
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ if(temp_start.second!=NULL_TIME && temp_start.second<start_win.first)
+ {
+ std::cout<<"The consumer of "<<*iter<<" has to executed before"<<std::endl;
+ if(temp_end.first!=NULL_TIME && (start_win.second==NULL_TIME || temp_end.first<start_win.second)) producers_unranked.insert(*iter);
+ //The consumer has to be executed before this task instance
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ level_before-=temp_rm_iter->second;
+ }
+ }
+ if(level_before<0)
+ {
+ ResourceValue production=0;
+ for(TaskInstSet::const_iterator iter=producers_unranked.begin();iter!=producers_unranked.end();iter++)
+ {
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ for(TaskInstSet::const_iterator iter2=producers_unranked.begin();iter2!=producers_unranked.end();iter2++)
+ {
+ if(*iter2==*iter) continue;
+ TimeWindow temp_end2 = this->planner_->get_end_window(*iter2);
+ if(temp_end.second==NULL_TIME || temp_end2.first<temp_end.second)
+ production+=this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter2)).find(rm_iter->first)->second;
+ }
+ if(production+level_before<0)
+ {
+ ResolveSchedOrderCmd *sched_cmd = static_cast<ResolveSchedOrderCmd *> (this->resolve_sched_cmd_->clone ());
+ sched_cmd->set_id(this->get_next_cmd_id());
+ sched_cmd->set_task_insts(*iter,task_inst);
+ this->planner_->add_command(sched_cmd);
+ if(!this->planner_->try_next(sched_cmd->get_id()))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ }
+
+ }
+ }
+ return true;
+}
+///Time Based Balance Constraint Propogation 5.3.3 (labourie paper)
+bool SA_SchedStrategy::time_balance_prop (TaskInstID task_inst)
+{
+ std::cout<<"Doing time balance prop for "<<task_inst<<std::endl;
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ const TaskInstSet *unranked = this->planner_->get_prec_insts(task_inst,UNRANKED);
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ TimeWindow end_win = this->planner_->get_end_window(task_inst);
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ // Iterate over all resources used by this task instance
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ //Sum of the resource usages of all the consumers that have to occur before the consumer of this task instance
+ ResourceValue level_before=this->planner_->get_capacity(rm_iter->first);
+ //All the producers that can occur before this task instance
+ std::list<TaskInstID> producers_unranked;
+ for(TaskInstSet::const_iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ TimeWindow temp_start = this->planner_->get_start_window(*iter);
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ if(temp_start.second!=NULL_TIME && temp_start.second<start_win.first)
+ {
+ std::cout<<"THe consumer of "<<*iter<<" has to executed before"<<std::endl;
+ //The consumer has to be executed before this task instance
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ level_before-=temp_rm_iter->second;
+ if(temp_end.first!=NULL_TIME && (start_win.second==NULL_TIME || temp_end.first<start_win.second))
+ {
+ // This task instance can be pushed before the task instance
+ std::cout<<"Task inst "<<*iter<<" can cause trouble"<<std::endl;
+ if(producers_unranked.empty())
+ producers_unranked.push_front(*iter);
+ else
+ {
+ std::list<TaskInstID>::iterator iter2=producers_unranked.begin();
+ for(;iter2!=producers_unranked.end();iter2++)
+ {
+ TimeWindow temp2_end = this->planner_->get_end_window(*iter2);
+ if(temp2_end.first>temp_end.first) break;
+ }
+ producers_unranked.insert(iter2,*iter);
+ }
+ }
+ else continue;
+ }
+ }
+ std::cout<<"The producers_unranked list is: "<<std::endl;
+ for(std::list<TaskInstID>::iterator iter2=producers_unranked.begin();iter2!=producers_unranked.end();iter2++)
+ {
+ std::cout<<*iter2<<" ";
+ }
+
+ if(level_before<0)
+ {
+ std::cout<<"The level_before is negative"<<std::endl;
+ ResourceValue level_prod=0;
+ std::list<TaskInstID>::iterator iter2=producers_unranked.begin();
+ for(;iter2!=producers_unranked.end();iter2++)
+ {
+ TimeWindow temp2_end = this->planner_->get_end_window(*iter2);
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter2));
+ level_prod+=temp_rm.find(rm_iter->first)->second;
+ if(level_prod>=0-level_before) break;
+ }
+ if(iter2==producers_unranked.end()) return false;
+ TimeWindow temp2_end = this->planner_->get_end_window(*iter2);
+ std::cout<<"greater than "<<*iter2<<std::endl;
+ if(temp2_end.first>start_win.first)
+ {
+ AdjustMinTimesCmd *adj_min_times_cmd = static_cast<AdjustMinTimesCmd *> (this->adj_min_times_cmd_->clone ());
+ adj_min_times_cmd->set_id(this->get_next_cmd_id());
+ adj_min_times_cmd->set_times(task_inst,temp2_end.first,temp2_end.first+this->planner_->get_duration(task_inst));
+ this->planner_->add_command(adj_min_times_cmd);
+ if(!this->planner_->try_next(adj_min_times_cmd->get_id()))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ }
+ }
+ // Do the same as above for the producer of this task. This is more likely to give results
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ //Sum of the resource usages of all the consumers that have to occur before the producer of this task instance but there produces doesn't
+ ResourceValue level_before=this->planner_->get_capacity(rm_iter->first)-rm_iter->second;
+ const TaskInstSet *simul = this->planner_->get_prec_insts(task_inst,SIMUL);
+ for(TaskInstSet::const_iterator iter=simul->begin();iter!=simul->end();iter++)
+ {
+ std::cout<<"calculating for "<<*iter<<std::endl;
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ //This task instance doesn't use this resource
+ if(temp_rm_iter==temp_rm.end()) continue;
+ level_before-=temp_rm_iter->second;
+ }
+ //All the producers that can occur before this task instance
+ std::list<TaskInstID> producers_unranked;
+ for(TaskInstSet::const_iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ std::cout<<"checking out "<<*iter<<std::endl;
+ TimeWindow temp_start = this->planner_->get_start_window(*iter);
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ if(end_win.first==NULL_TIME ||(temp_start.second!=NULL_TIME && temp_start.second<end_win.first))
+ {
+ //The consumer has to be executed before this task instance
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ //This task instance doesn't use this resource
+ if(temp_rm_iter==temp_rm.end()) continue;
+ level_before-=temp_rm_iter->second;
+ if(temp_end.first!=NULL_TIME && (end_win.second==NULL_TIME || temp_end.first<end_win.second))
+ {
+ if(producers_unranked.empty())
+ producers_unranked.push_front(*iter);
+ else
+ {
+ std::list<TaskInstID>::iterator iter2=producers_unranked.begin();
+ for(;iter2!=producers_unranked.end();iter2++)
+ {
+ TimeWindow temp2_end = this->planner_->get_end_window(*iter2);
+ if(temp2_end.first>temp_end.first) break;
+ }
+ producers_unranked.insert(iter2,*iter);
+ }
+ }
+ else continue;
+ }
+ }
+ if(level_before<0)
+ {
+ ResourceValue level_prod=0;
+ std::list<TaskInstID>::iterator iter2=producers_unranked.begin();
+ for(;iter2!=producers_unranked.end();iter2++)
+ {
+ TimeWindow temp2_end = this->planner_->get_end_window(*iter2);
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter2));
+ level_prod+=temp_rm.find(rm_iter->first)->second;
+ if(level_prod>=0-level_before) break;
+ }
+ if(iter2==producers_unranked.end()) return false;
+ TimeWindow temp2_end = this->planner_->get_end_window(*iter2);
+ if(end_win.first!=NULL_TIME && temp2_end.first>end_win.first)
+ {
+ AdjustMinTimesCmd *adj_min_times_cmd = static_cast<AdjustMinTimesCmd *> (this->adj_min_times_cmd_->clone ());
+ adj_min_times_cmd->set_id(this->get_next_cmd_id());
+ adj_min_times_cmd->set_times(task_inst,temp2_end.first-this->planner_->get_duration(task_inst),temp2_end.first);
+ this->planner_->add_command(adj_min_times_cmd);
+ if(!this->planner_->try_next(adj_min_times_cmd->get_id()))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+//Do the energy precedence calculations for this taskinstance.
+//If nothing changes go to the orderings after this and perform the calculations
+//otherwise, repeat these for this task instance till the windows stop changing and stop in this branch.
+bool SA_SchedStrategy::energy_prop (TaskInstID task_inst)
+{
+ std::cout<<"Doing energy precedence calculations for "<<task_inst<<std::endl;
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ AdjustMinTimesCmd *adj_min_times_cmd = static_cast<AdjustMinTimesCmd *> (this->adj_min_times_cmd_->clone ());
+ AdjustMaxTimesCmd *adj_max_times_cmd = static_cast<AdjustMaxTimesCmd *> (this->adj_max_times_cmd_->clone ());
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ TimeWindow end_win = this->planner_->get_end_window(task_inst);
+ TimeValue min_start = start_win.first;
+ TimeValue max_end = end_win.second;
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ bool min_times_changed=false,max_times_changed=false;
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ //Based on all task instances before task_inst
+ ResourceValue Q = this->planner_->get_capacity(rm_iter->first);
+ std::cout<<"The capacity of resource:"<<rm_iter->first<<" is "<<Q<<std::endl;
+ double first_before=-1,first_after=-1,second_before=0,second_after=0;
+ const TaskInstSet *before = this->planner_->get_prec_insts(task_inst,BEFORE);
+ const TaskInstSet *after = this->planner_->get_prec_insts(task_inst,AFTER);
+ if(!before->empty())
+ {
+ for(TaskInstSet::const_iterator iter = before->begin();iter!=before->end();iter++)
+ {
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ second_before += this->planner_->get_duration(*iter) * (temp_rm_iter->second) / Q;
+ TimeWindow temp_start = this->planner_->get_start_window(*iter);
+ if(first_before==-1 || first_before>temp_start.first) first_before = temp_start.first;
+ }
+ if(first_before!=-1 && min_start<first_before+second_before) min_start=first_before+second_before;
+ }
+ //Based on all task instances after task_inst
+ if(!after->empty() && end_win.second!=NULL_TIME)
+ {
+ for(TaskInstSet::const_iterator iter = after->begin();iter!=after->end();iter++)
+ {
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ TimeValue temp_dur = this->planner_->get_duration(*iter);
+ ResourceValue temp_rval = temp_rm_iter->second;
+ second_after += (double)temp_dur * (double)temp_rval / Q;
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ if(temp_end.second==NULL_TIME)
+ {
+ max_end=end_win.second;
+ break;
+ }
+ if(first_after==-1 || first_after<temp_end.second) first_after = temp_end.second;
+ }
+ if(first_after!=-1 && max_end>first_after-second_after) max_end=first_after-second_after;
+ }
+ std::cout<<"After calculations for resource "<<rm_iter->first<<" start_min="<<min_start<<" and end_max="<<max_end<<std::endl;
+ }
+ if(min_start!=start_win.first)
+ {
+ min_times_changed=true;
+ adj_min_times_cmd->set_times(task_inst,min_start,min_start+this->planner_->get_duration(task_inst));
+ adj_min_times_cmd->set_id(this->get_next_cmd_id());
+ this->planner_->add_command (adj_min_times_cmd);
+ if(!this->planner_->try_next(adj_min_times_cmd->get_id())) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ if(max_end!=end_win.second)
+ {
+ max_times_changed=true;
+ adj_max_times_cmd->set_times(task_inst,max_end-this->planner_->get_duration(task_inst),max_end);
+ adj_max_times_cmd->set_id(this->get_next_cmd_id());
+ this->planner_->add_command (adj_max_times_cmd);
+ if(!this->planner_->try_next(adj_max_times_cmd->get_id())) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ if(min_times_changed || max_times_changed)
+ {
+ //Since the time windows have changed, some unranked task instances have gone to before or after.
+ //Thus, we need to do the energy precedence calculations for this task instance again.
+ //Also we have to do the energy precedence calculations for the affected task instances.
+ if(!this->energy_prop(task_inst)) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ // Propogate the energy precedence constraint calculations to before and after tasks
+ // in only one direction
+ //TaskInstSet aft = this->planner_->after_orderings(task_inst);
+ //TaskInstSet bef = this->planner_->before_orderings(task_inst);
+ const TaskInstSet *aft = this->planner_->get_prec_insts(task_inst,AFTER);
+ const TaskInstSet *bef = this->planner_->get_prec_insts(task_inst,BEFORE);
+
+ for(TaskInstSet::const_iterator iter = aft->begin();iter!=aft->end();iter++)
+ {
+ if(!this->energy_prop_after(*iter))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+
+ for(TaskInstSet::const_iterator iter = bef->begin();iter!=bef->end();iter++)
+ {
+ if(!this->energy_prop_before(*iter))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ return true;
+}
+/// Do the uni directional energy precedence propogation in the after direction
+bool SA_SchedStrategy::energy_prop_after (TaskInstID task_inst)
+{
+ std::cout<<"Doing energy precedence after calculations for "<<task_inst<<std::endl;
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ AdjustMinTimesCmd *adj_min_times_cmd = static_cast<AdjustMinTimesCmd *> (this->adj_min_times_cmd_->clone ());
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ TimeWindow end_win = this->planner_->get_end_window(task_inst);
+ TimeValue min_start = start_win.first;
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ bool min_times_changed=false;
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ //Based on all task instances before task_inst
+ ResourceValue Q = this->planner_->get_capacity(rm_iter->first);
+ std::cout<<"The capacity of resource:"<<rm_iter->first<<" is "<<Q<<std::endl;
+ double first_before=-1,second_before=0;
+ const TaskInstSet *before = this->planner_->get_prec_insts(task_inst,BEFORE);
+ if(!before->empty())
+ {
+ for(TaskInstSet::const_iterator iter = before->begin();iter!=before->end();iter++)
+ {
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ second_before += this->planner_->get_duration(*iter) * (temp_rm_iter->second) / Q;
+ TimeWindow temp_start = this->planner_->get_start_window(*iter);
+ if(first_before==-1 || first_before>temp_start.first) first_before = temp_start.first;
+ }
+ if(first_before!=-1 && min_start<first_before+second_before) min_start=first_before+second_before;
+ }
+ std::cout<<"After after calculations for resource "<<rm_iter->first<<" start_min="<<min_start<<std::endl;
+ }
+ if(min_start!=start_win.first)
+ {
+ min_times_changed=true;
+ adj_min_times_cmd->set_times(task_inst,min_start,min_start+this->planner_->get_duration(task_inst));
+ adj_min_times_cmd->set_id(this->get_next_cmd_id());
+ this->planner_->add_command (adj_min_times_cmd);
+ if(!this->planner_->try_next(adj_min_times_cmd->get_id())) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ if(min_times_changed)
+ {
+ //Since the time windows have changed, some unranked task instances have gone to before or after.
+ //Thus, we need to do the energy precedence calculations for this task instance again.
+ //Also we have to do the energy precedence calculations for the affected task instances.
+ if(!this->energy_prop_after(task_inst)) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ //TaskInstSet aft = this->planner_->after_orderings(task_inst);
+ //TaskInstSet bef = this->planner_->before_orderings(task_inst);
+ const TaskInstSet *aft = this->planner_->get_prec_insts(task_inst,AFTER);
+
+ for(TaskInstSet::const_iterator iter = aft->begin();iter!=aft->end();iter++)
+ {
+ if(!this->energy_prop_after(*iter))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ return true;
+}
+/// Do the uni directional energy precedence propogation in the after direction
+bool SA_SchedStrategy::energy_prop_before (TaskInstID task_inst)
+{
+ std::cout<<"Doing before energy precedence calculations for "<<task_inst<<std::endl;
+ CommandID cur_cmd_id = this->planner_->cur_command_id();
+ AdjustMaxTimesCmd *adj_max_times_cmd = static_cast<AdjustMaxTimesCmd *> (this->adj_max_times_cmd_->clone ());
+ TimeWindow start_win = this->planner_->get_start_window(task_inst);
+ TimeWindow end_win = this->planner_->get_end_window(task_inst);
+ TimeValue min_start = start_win.first;
+ TimeValue max_end = end_win.second;
+ ResourceMap rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(task_inst));
+ bool max_times_changed=false;
+ for(ResourceMap::iterator rm_iter = rm.begin();rm_iter!=rm.end();rm_iter++)
+ {
+ //Based on all task instances before task_inst
+ ResourceValue Q = this->planner_->get_capacity(rm_iter->first);
+ std::cout<<"The capacity of resource:"<<rm_iter->first<<" is "<<Q<<std::endl;
+ double first_after=-1,second_after=0;
+ const TaskInstSet *after = this->planner_->get_prec_insts(task_inst,AFTER);
+ if(!after->empty() && end_win.second!=NULL_TIME)
+ {
+ for(TaskInstSet::const_iterator iter = after->begin();iter!=after->end();iter++)
+ {
+ ResourceMap temp_rm = this->planner_->get_all_resources(this->planner_->get_task_impl_from_inst(*iter));
+ ResourceMap::iterator temp_rm_iter = temp_rm.find(rm_iter->first);
+ if(temp_rm_iter==temp_rm.end()) continue;
+ TimeValue temp_dur = this->planner_->get_duration(*iter);
+ ResourceValue temp_rval = temp_rm_iter->second;
+ second_after += (double)temp_dur * (double)temp_rval / Q;
+ TimeWindow temp_end = this->planner_->get_end_window(*iter);
+ if(temp_end.second==NULL_TIME)
+ {
+ max_end=end_win.second;
+ break;
+ }
+ if(first_after==-1 || first_after<temp_end.second) first_after = temp_end.second;
+ }
+ if(first_after!=-1 && max_end>first_after-second_after) max_end=first_after-second_after;
+ }
+ std::cout<<"After before calculations for resource "<<rm_iter->first<<" and end_max="<<max_end<<std::endl;
+ }
+ if(max_end!=end_win.second)
+ {
+ max_times_changed=true;
+ adj_max_times_cmd->set_times(task_inst,max_end-this->planner_->get_duration(task_inst),max_end);
+ adj_max_times_cmd->set_id(this->get_next_cmd_id());
+ this->planner_->add_command (adj_max_times_cmd);
+ if(!this->planner_->try_next(adj_max_times_cmd->get_id())) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ if(max_times_changed)
+ {
+ //Since the time windows have changed, some unranked task instances have gone to before or after.
+ //Thus, we need to do the energy precedence calculations for this task instance again.
+ //Also we have to do the energy precedence calculations for the affected task instances.
+ if(!this->energy_prop_before(task_inst)) {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ //TaskInstSet bef = this->planner_->before_orderings(task_inst);
+ const TaskInstSet *bef = this->planner_->get_prec_insts(task_inst,BEFORE);
+
+ for(TaskInstSet::const_iterator iter = bef->begin();iter!=bef->end();iter++)
+ {
+ if(!this->energy_prop_before(*iter))
+ {
+ this->planner_->undo_through(cur_cmd_id);
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/SA_POP/SA_SchedStrategy.h b/SA_POP/SA_SchedStrategy.h
new file mode 100644
index 00000000000..88a1fda8326
--- /dev/null
+++ b/SA_POP/SA_SchedStrategy.h
@@ -0,0 +1,189 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_SchedStrategy.h
+ *
+ * This file contains the SA_SchedStrategy concrete class definition, which
+ * implements a SchedStrategy for the high-level scheduling algorithm.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SA_SCHED_STRATEGY_H_
+#define SA_POP_SA_SCHED_STRATEGY_H_
+
+#include<map>
+#include "SA_POP_Types.h"
+#include "SchedStrategy.h"
+#include "PlanCommands.h"
+
+namespace SA_POP {
+
+ /**
+ * @class SA_SchedStrategy
+ *
+ * @brief Concrete class of SchedStrategy for the high-level scheduling
+ * algorithm.
+ */
+ class SA_SchedStrategy : public SchedStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ SA_SchedStrategy (SA_POP::Planner *planner);
+
+ /// Destructor.
+ virtual ~SA_SchedStrategy (void);
+
+ /// Set command prototypes to use in scheduling.
+ /**
+ * @param resolve_sched_cmd Prototype of command for resolving a
+ * scheduling conflict between two task
+ * instances in the plan.
+ *
+ * @param adj_min_times_cmd Prototype of command for adjusting the
+ * min times of a task instance in the plan.
+ *
+ * @param adj_max_times_cmd Prototype of command for adjusting the
+ * max times of a task instance in the plan.
+ */
+ virtual void set_commands (ResolveSchedOrderCmd *resolve_sched_cmd,
+ AdjustMinTimesCmd *adj_min_times_cmd,
+ AdjustMaxTimesCmd *adj_max_times_cmd);
+
+
+ /// Get command ID to use for next command.
+ /**
+ * @return Command ID to use for next command.
+ */
+ virtual CommandID get_next_cmd_id (void);
+
+ /// Recursively satisfy all scheduling constraints (and continue
+ /// satisfaction of open conditions by recursive call back to planning).
+ /**
+ * @param task_inst Current task instance being tried in the plan.
+ *
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool satisfy_sched (TaskInstID task_inst);
+
+ /// Satisfy fully instantiated plan.
+ /**
+ * @param task_inst Current task instance being tried in the plan.
+ *
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool satisfy_full_sched ();
+
+ ///Energy Constraint Propogation
+ /**
+ * @param task_inst Current task instance being tried in the plan
+ *
+ * @return True if the energy constraint propogation is successfull
+ */
+ virtual bool energy_prop (TaskInstID task_inst);
+ ///Energy Constraint Propogation Helper functions
+ /**
+ * @param task_inst Current task instance being tried in the plan
+ *
+ * @return True if the energy constraint propogation is successfull
+ */
+ virtual bool energy_prop_after (TaskInstID task_inst);
+ ///Energy Constraint Propogation Helper functions
+ /**
+ * @param task_inst Current task instance being tried in the plan
+ *
+ * @return True if the energy constraint propogation is successfull
+ */
+ virtual bool energy_prop_before (TaskInstID task_inst);
+ ///Time Based Balance Constraint Propogation 5.3.3 (labourie paper)
+ /**
+ * @param task_inst Current task instance being tried in the plan
+ *
+ * @return True if the balance constraint propogation is successfull
+ */
+ virtual bool time_balance_prop (TaskInstID task_inst);
+ ///Precedence Link Based Balance Constraint Propogation 5.3.4 (labourie paper)
+ /**
+ * @param task_inst Current task instance being tried in the plan
+ *
+ * @return True if the balance constraint propogation is successfull
+ */
+ virtual bool prec_balance_prop (TaskInstID task_inst);
+ ///Commitment of an ordering
+ /**
+ * @param first_task_inst The task_instance scheduled before the second one.
+ *
+ * @param second_task_inst The task instance schedules after the first one.
+ *
+ * @return The value of the commitment of this order.
+ */
+ virtual double commit(TaskInstID first_task_inst, TaskInstID second_task_inst);
+ ///Criticality of the consumer of a task instance
+ /**
+ * @param task_inst The task instance.
+ *
+ * @return The value of the criticality of the task instance.
+ */
+ virtual Criticality crit(TaskInstID task_inst);
+ /// Calculate the min and max levels
+ virtual void calculate_levels(TaskInstID task_inst);
+ /// Perform the search till the ctiricality goes below a certain value
+ /**
+ * @param min_crit The threshold criticality value
+ *
+ * @return True if it succeds
+ */
+ virtual bool search(double min_crit);
+ protected:
+
+ /// Flag for whether command prototypes have been set.
+ bool has_cmds_;
+
+ /// Current decision point.
+ int cur_decision_pt_;
+
+ /// Current sequence number for commands in this decision point.
+ int cur_seq_num_;
+
+ /// Type of a map from task instance to its level
+ typedef std::map<TaskInstID,ResourceValue> LevelMap;
+ /// Type of a map from the Resource ID to the minimum levels
+ typedef std::map<ResourceID,LevelMap> MinimumLevels;
+ /// Type of a map from the Resource ID to the maximum levels
+ typedef std::map<ResourceID,LevelMap> MaximumLevels;
+
+ MinimumLevels min_cons_levels_;
+ MaximumLevels max_cons_levels_;
+ // ************************************************************************
+ // Decision point numbers.
+ // ************************************************************************
+
+ /// Scheduling is fourth decision point.
+ static const int SCHEDULE_DECISION = 3;
+
+ // ************************************************************************
+ // Prototypes of commands that work on other objects.
+ // ************************************************************************
+
+ /// PlanCommand prototype for resolving a scheduling conflict (i.e.
+ /// non-causal-link ordering constraint (with promotion or demotion)
+ /// between two task instances in the plan.
+ ResolveSchedOrderCmd *resolve_sched_cmd_;
+
+ /// PlanCommand prototype for adjusting the min times of a
+ /// task instance in the plan.
+ AdjustMinTimesCmd *adj_min_times_cmd_;
+
+ /// PlanCommand prototype for adjusting the max times of a
+ /// task instance in the plan.
+ AdjustMaxTimesCmd *adj_max_times_cmd_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_SA_SCHED_STRATEGY_H_ */
diff --git a/SA_POP/SA_WorkingPlan.cpp b/SA_POP/SA_WorkingPlan.cpp
new file mode 100644
index 00000000000..33090f0961f
--- /dev/null
+++ b/SA_POP/SA_WorkingPlan.cpp
@@ -0,0 +1,1447 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_WorkingPlan.cpp
+ *
+ * This file contains the implementation of the SA_WorkingPlan concrete class,
+ * which implements a WorkingPlan that uses precedence graphs for scheduling.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "SA_WorkingPlan.h"
+#include "Planner.h"
+#include "PlanCommands.h"
+#include "SA_PlanCommands.h"
+
+
+using namespace SA_POP;
+
+// Constructor.
+SA_WorkingPlan::SA_WorkingPlan (SA_POP::Planner *planner)
+: WorkingPlan (planner),
+has_cmds_ (false),
+next_inst_id_ (1),
+add_task_cmd_ (0),
+assoc_impl_cmd_ (0),
+resolve_threat_cmd_ (0),
+resolve_sched_cmd_ (0),
+adj_min_times_cmd_ (0),
+adj_max_times_cmd_ (0),
+add_threats_cmd_ (0)
+{
+ this->task_insts_.clear ();
+ this->task_impls_.clear ();
+ this->causal_links_.clear ();
+
+ // Clear plan.
+ this->plan_.causal_links.clear ();
+ this->plan_.connections.clear ();
+ this->plan_.sched_links.clear ();
+ this->plan_.task_insts.clear ();
+ this->plan_.threat_links.clear ();
+
+ this->add_task_cmd_ = new SA_AddTaskCmd (this);
+ this->assoc_impl_cmd_ = new SA_AssocTaskImplCmd (this);
+ this->resolve_threat_cmd_ = new SA_ResolveCLThreatCmd (this);
+ this->resolve_sched_cmd_ = new SA_ResolveSchedOrderCmd (this);
+ this->adj_min_times_cmd_ = new SA_AdjustMinTimesCmd (this);
+ this->adj_max_times_cmd_ = new SA_AdjustMaxTimesCmd (this);
+
+ PrecedenceSet temp;
+ this->precedence_graph_.insert(std::make_pair(BEFORE,temp));
+ this->precedence_graph_.insert(std::make_pair(AFTER,temp));
+ this->precedence_graph_.insert(std::make_pair(SIMUL,temp));
+ this->precedence_graph_.insert(std::make_pair(UNRANKED,temp));
+
+ ////////////////////TEMPORARY///////////TEMPORARY/////////////////
+///For SPACE
+//this->durations.insert(std::make_pair(1,2));
+//this->durations.insert(std::make_pair(2,5));
+//this->durations.insert(std::make_pair(3,2));
+//this->durations.insert(std::make_pair(4,10));
+//this->durations.insert(std::make_pair(5,1));
+//this->durations.insert(std::make_pair(6,4));
+//
+//this->init_start.insert(std::make_pair(1,(TimeWindow)std::make_pair(22,28)));
+//this->init_end.insert(std::make_pair(1,(TimeWindow)std::make_pair(24,30)));
+//this->init_start.insert(std::make_pair(2,(TimeWindow)std::make_pair(17,23)));
+//this->init_end.insert(std::make_pair(2,(TimeWindow)std::make_pair(22,28)));
+//this->init_start.insert(std::make_pair(3,(TimeWindow)std::make_pair(15,21)));
+//this->init_end.insert(std::make_pair(3,(TimeWindow)std::make_pair(17,23)));
+//this->init_start.insert(std::make_pair(4,(TimeWindow)std::make_pair(5,19)));
+//this->init_end.insert(std::make_pair(4,(TimeWindow)std::make_pair(15,21)));
+//this->init_start.insert(std::make_pair(5,(TimeWindow)std::make_pair(0,18)));
+//this->init_end.insert(std::make_pair(5,(TimeWindow)std::make_pair(1,19)));
+//this->init_start.insert(std::make_pair(6,(TimeWindow)std::make_pair(0,9)));
+//this->init_end.insert(std::make_pair(6,(TimeWindow)std::make_pair(4,13)));
+///For sched_test1
+//this->durations.insert(std::make_pair(1,10));
+//this->durations.insert(std::make_pair(2,2));
+//this->durations.insert(std::make_pair(3,8));
+//this->durations.insert(std::make_pair(4,8));
+//this->durations.insert(std::make_pair(5,10));
+//this->durations.insert(std::make_pair(7,15));
+//this->durations.insert(std::make_pair(6,10));
+//
+//this->init_start.insert(std::make_pair(1,(TimeWindow)std::make_pair(10,30)));
+//this->init_end.insert(std::make_pair(1,(TimeWindow)std::make_pair(20,40)));
+//this->init_start.insert(std::make_pair(2,(TimeWindow)std::make_pair(8,28)));
+//this->init_end.insert(std::make_pair(2,(TimeWindow)std::make_pair(10,30)));
+//this->init_start.insert(std::make_pair(3,(TimeWindow)std::make_pair(0,20)));
+//this->init_end.insert(std::make_pair(3,(TimeWindow)std::make_pair(8,28)));
+//this->init_start.insert(std::make_pair(4,(TimeWindow)std::make_pair(0,20)));
+//this->init_end.insert(std::make_pair(4,(TimeWindow)std::make_pair(8,28)));
+//this->init_start.insert(std::make_pair(5,(TimeWindow)std::make_pair(0,20)));
+//this->init_end.insert(std::make_pair(5,(TimeWindow)std::make_pair(10,30)));
+//this->init_start.insert(std::make_pair(7,(TimeWindow)std::make_pair(10,NULL_TIME)));
+//this->init_end.insert(std::make_pair(7,(TimeWindow)std::make_pair(25,NULL_TIME)));
+//this->init_start.insert(std::make_pair(6,(TimeWindow)std::make_pair(25,NULL_TIME)));
+//this->init_end.insert(std::make_pair(6,(TimeWindow)std::make_pair(35,NULL_TIME)));
+//this->init_start.insert(std::make_pair(1,(TimeWindow)std::make_pair(10,NULL_TIME)));
+//this->init_end.insert(std::make_pair(1,(TimeWindow)std::make_pair(20,NULL_TIME)));
+//this->init_start.insert(std::make_pair(2,(TimeWindow)std::make_pair(8,NULL_TIME)));
+//this->init_end.insert(std::make_pair(2,(TimeWindow)std::make_pair(10,NULL_TIME)));
+//this->init_start.insert(std::make_pair(3,(TimeWindow)std::make_pair(0,NULL_TIME)));
+//this->init_end.insert(std::make_pair(3,(TimeWindow)std::make_pair(8,NULL_TIME)));
+//this->init_start.insert(std::make_pair(4,(TimeWindow)std::make_pair(0,NULL_TIME)));
+//this->init_end.insert(std::make_pair(4,(TimeWindow)std::make_pair(8,NULL_TIME)));
+//this->init_start.insert(std::make_pair(5,(TimeWindow)std::make_pair(0,NULL_TIME)));
+//this->init_end.insert(std::make_pair(5,(TimeWindow)std::make_pair(10,NULL_TIME)));
+
+/////For sched_test4
+//this->durations.insert(std::make_pair(1,10));
+//this->durations.insert(std::make_pair(2,5));
+//this->durations.insert(std::make_pair(3,5));
+//this->durations.insert(std::make_pair(4,5));
+//
+//this->init_start.insert(std::make_pair(1,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(1,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_start.insert(std::make_pair(2,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(2,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_start.insert(std::make_pair(3,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(3,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_start.insert(std::make_pair(4,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(4,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+
+/////For sched_test5
+//this->durations.insert(std::make_pair(1,0));
+//this->durations.insert(std::make_pair(2,0));
+//this->durations.insert(std::make_pair(3,0));
+//this->durations.insert(std::make_pair(4,10));
+//
+//this->init_start.insert(std::make_pair(1,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(1,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_start.insert(std::make_pair(2,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(2,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_start.insert(std::make_pair(3,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(3,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_start.insert(std::make_pair(4,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+//this->init_end.insert(std::make_pair(4,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+
+///For sched_main_test
+//this->durations.insert(std::make_pair(1,0));
+//this->durations.insert(std::make_pair(2,0));
+//this->durations.insert(std::make_pair(3,0));
+//this->durations.insert(std::make_pair(4,0));
+//this->durations.insert(std::make_pair(5,0));
+//this->durations.insert(std::make_pair(6,0));
+//this->durations.insert(std::make_pair(7,0));
+//this->durations.insert(std::make_pair(8,0));
+//this->durations.insert(std::make_pair(9,1));
+//this->durations.insert(std::make_pair(10,0));
+//this->durations.insert(std::make_pair(11,0));
+//this->durations.insert(std::make_pair(12,0));
+//this->durations.insert(std::make_pair(13,0));
+//this->durations.insert(std::make_pair(14,0));
+//this->durations.insert(std::make_pair(15,0));
+//this->durations.insert(std::make_pair(16,0));
+//this->durations.insert(std::make_pair(17,0));
+
+this->init_start.insert(std::make_pair(1,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(1,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(2,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(2,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(3,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(3,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(4,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(4,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(5,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(5,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(6,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(6,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(7,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(7,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(8,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(8,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(9,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(9,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(10,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(10,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(11,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(11,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(12,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(12,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(13,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(13,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(14,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(14,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(15,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(15,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(16,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(16,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(17,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(17,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(17,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(17,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(18,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(18,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(19,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(19,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(20,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(20,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(21,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(21,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(22,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(22,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(23,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(23,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(24,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(24,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(25,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(25,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(26,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(26,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(27,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(27,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(28,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(28,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(29,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(29,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(30,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(30,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(31,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(31,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_start.insert(std::make_pair(32,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+this->init_end.insert(std::make_pair(32,(TimeWindow)std::make_pair(NULL_TIME,NULL_TIME)));
+};
+
+// Destructor.
+SA_WorkingPlan::~SA_WorkingPlan (void)
+{
+ // Nothing to do.
+};
+
+// Set command prototypes to use.
+void SA_WorkingPlan::set_commands (AddOpenThreatsCmd *add_threats_cmd)
+{
+ if (add_threats_cmd == 0)
+ return;
+
+ this->add_threats_cmd_ = add_threats_cmd;
+ this->has_cmds_ = true;
+};
+
+// Helper function to create next instance id.
+TaskInstID SA_WorkingPlan::get_next_inst_id (void)
+{
+ TaskInstID inst_id = this->next_inst_id_;
+ this->next_inst_id_++;
+ return inst_id;
+};
+
+// Get current plan.
+const Plan& SA_WorkingPlan::get_plan (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // Should track whether plan has changed rather than regenerating every time.
+
+ // Clear plan.
+ this->plan_.causal_links.clear ();
+ this->plan_.connections.clear ();
+ this->plan_.sched_links.clear ();
+ this->plan_.task_insts.clear ();
+ this->plan_.threat_links.clear ();
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Need absolute windows from goal)
+ // Set time windows.
+ this->plan_.start_window = std::make_pair (0, 0);
+ this->plan_.end_window = std::make_pair (0, 0);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Need goal structure to set plan ID & name)
+ // Set plan ID and name from goal.
+ this->plan_.plan_id = "1";
+ this->plan_.name = this->plan_.plan_id;
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Add task instances to plan.
+ for (SA_WorkingPlan::InstToTaskMap::iterator iter =
+ this->task_insts_.begin ();
+ iter != this->task_insts_.end (); iter++)
+ {
+ // Creat task instance and set instance and task IDs from task instance map.
+ PlanTaskInst inst;
+ inst.inst_id = iter->first;
+ inst.task_id = iter->second;
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Need to add separate Type to task nodes instead of using name.)
+ // Set instance type.
+ inst.type_id = this->planner_->get_task_name (inst.task_id);
+ // Give instance a name.
+ char buffer[64];
+ inst.name = "Task_Instance_";
+ inst.name += itoa (inst.inst_id, buffer, 10);
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set start and end windows for this instance.
+ SA_WorkingPlan::InstToWinMap::iterator win_iter;
+ win_iter = this->start_window_map_.find (inst.inst_id);
+ if (win_iter != this->start_window_map_.end ())
+ inst.start_window = win_iter->second;
+ else
+ throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find start window for task instance.";
+ win_iter = this->end_window_map_.find (inst.inst_id);
+ if (win_iter != this->end_window_map_.end ())
+ inst.end_window = win_iter->second;
+ else
+ throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find end window for task instance.";
+
+ // Set suggested implementation for this instance.
+ InstToImplMap::iterator impl_iter;
+ impl_iter = this->task_impls_.find (inst.inst_id);
+ if (impl_iter != this->task_impls_.end ())
+ inst.suggested_impl = impl_iter->second;
+ else
+ throw "SA_POP::SA_WorkingPlan::get_plan (): Unable to find implementation from task instance.";
+
+ // Add instance to plan.
+ this->plan_.task_insts.insert (inst);
+ }
+
+ // Add scheduling links.
+ for (SA_WorkingPlan::SchedulingLinks::iterator sched_iter =
+ this->sched_links_.begin ();
+ sched_iter != this->sched_links_.end (); sched_iter++)
+ {
+ this->plan_.sched_links.insert (std::make_pair (
+ sched_iter->first, sched_iter->second));
+ }
+
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Need to include threat links.)
+ // Add threat links.
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+
+ // Add plan data connections and causal links.
+ for (SA_WorkingPlan::CondToCLinksMap::iterator cl_iter =
+ this->causal_links_.begin ();
+ cl_iter != this->causal_links_.end (); cl_iter++)
+ {
+ // If this is the placeholder goal task instance, don't add connection.
+ if (cl_iter->second.second == SA_POP::GOAL_TASK_INST_ID)
+ continue;
+
+ // If this condition is a data condition, add data connection to plan.
+ if (cl_iter->first.kind == SA_POP::DATA) {
+ PlanConnection plan_conn;
+
+ // Set condition.
+ plan_conn.cond = cl_iter->first.id;
+
+ // Set task instances.
+ plan_conn.first_task_inst = cl_iter->second.first;
+ plan_conn.second_task_inst = cl_iter->second.second;
+
+ // Get task ids from instances.
+ SA_WorkingPlan::InstToTaskMap::iterator inst_task_iter;
+
+ inst_task_iter = this->task_insts_.find (cl_iter->second.first);
+ if (inst_task_iter == this->task_insts_.end ())
+ throw "SA_POP::SA_WorkingPlan::get_plan (): couldn't find task id for task instance to get port for plan connection.";
+ TaskID first_task = inst_task_iter->second;
+
+ inst_task_iter = this->task_insts_.find (cl_iter->second.second);
+ if (inst_task_iter == this->task_insts_.end ())
+ throw "SA_POP::SA_WorkingPlan::get_plan (): couldn't find task id for task instance to get port for plan connection.";
+ TaskID second_task = inst_task_iter->second;
+
+ // Get ports.
+ LinkPorts ports = this->planner_->get_clink_ports
+ (first_task, cl_iter->first.id, second_task);
+ plan_conn.first_port = ports.first;
+ plan_conn.second_port = ports.second;
+
+ this->plan_.connections.insert (plan_conn);
+ } else { // This is a non-data condition so add causal link to plan.
+ this->plan_.causal_links.insert (cl_iter->second);
+ }
+ }
+
+ return this->plan_;
+};
+
+// Get set of task instances for a precedence relation to a task instance.
+const TaskInstSet *SA_WorkingPlan::get_prec_set (TaskInstID task_inst, PrecedenceRelation prec_rel)
+{
+ PrecedenceGraph::iterator piter = this->precedence_graph_.find(prec_rel);
+ PrecedenceSet::iterator titer = piter->second.find(task_inst);
+ return &(titer->second);
+};
+
+// Get task id of a task instance.
+TaskID SA_WorkingPlan::get_task_from_inst (TaskInstID inst_id)
+{
+ SA_WorkingPlan::InstToTaskMap::iterator iter =
+ this->task_insts_.find (inst_id);
+ if (iter == this->task_insts_.end ())
+ throw "SA_POP::SA_WorkingPlan::get_task_from_inst (): requested instance id does not exist.";
+
+ return iter->second;
+};
+
+/// Get task implementation id of a task instance.
+TaskImplID SA_WorkingPlan::get_task_impl_from_inst(TaskInstID inst_id)
+{
+ return this->task_impls_.find(inst_id)->second;
+}
+
+// Get all current causal link threats.
+CLThreatSet SA_WorkingPlan::get_all_threats (void)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ CLThreatSet temp;
+ temp.clear ();
+ return temp;
+};
+
+//Get all the causal and data links TO the task instance
+CLSet SA_WorkingPlan::get_before(TaskInstID task_inst)
+{
+ CLSet ret;
+ for(CondToCLinksMap::iterator iter = this->causal_links_.begin();iter!=this->causal_links_.end();iter++)
+ if(iter->second.second == task_inst) ret.insert(iter->second);
+ return ret;
+}
+//Get all the causal and data links FROM the task instance
+CLSet SA_WorkingPlan::get_after(TaskInstID task_inst)
+{
+ CLSet ret;
+ for(CondToCLinksMap::iterator iter = this->causal_links_.begin();iter!=this->causal_links_.end();iter++)
+ if(iter->second.second != GOAL_TASK_INST_ID && iter->second.second != NULL_TASK_INST_ID && iter->second.first == task_inst) ret.insert(iter->second);
+ return ret;
+}
+
+/// Get the Causal and Scheduling orderings to this task instance
+TaskInstSet SA_WorkingPlan::before_orderings (TaskInstID inst_id)
+{
+ CLSet before_links = this->get_before(inst_id);
+ TaskInstSet ret;
+ for(CLSet::iterator iter=before_links.begin();iter!=before_links.end();iter++)
+ {
+ if(iter->cond.kind!=DATA) ret.insert(iter->first);
+ }
+ for(SchedulingLinks::iterator iter=sched_links_.begin();iter!=sched_links_.end();iter++)
+ if(iter->second==inst_id) ret.insert(iter->first);
+ return ret;
+}
+/// Get the Causal and Scheduling orderings from this task instance
+TaskInstSet SA_WorkingPlan::after_orderings (TaskInstID inst_id)
+{
+ CLSet after_links = this->get_after(inst_id);
+ TaskInstSet ret;
+ for(CLSet::iterator iter=after_links.begin();iter!=after_links.end();iter++)
+ if(iter->cond.kind!=DATA) ret.insert(iter->second);
+ for(SchedulingLinks::iterator iter=sched_links_.begin();iter!=sched_links_.end();iter++)
+ if(iter->first==inst_id) ret.insert(iter->second);
+ return ret;
+}
+/// Get a PlanCommand prototype for adding a task to the plan.
+AddTaskCmd *SA_WorkingPlan::get_AddTaskCmd (void)
+{
+ return static_cast<AddTaskCmd *> (this->add_task_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for associating an implementation with a
+// task instance in the plan.
+AssocTaskImplCmd *SA_WorkingPlan::get_AssocTaskImplCmd (void)
+{
+ return static_cast<AssocTaskImplCmd *> (this->assoc_impl_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for resolving a causal link threat in the
+// plan (with promotion or demotion).
+ResolveCLThreatCmd *SA_WorkingPlan::get_ResolveCLThreatCmd (void)
+{
+ return static_cast<ResolveCLThreatCmd *> (this->resolve_threat_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for resolving a scheduling conflict (i.e.
+// non-causal-link ordering constraint (with promotion or demotion)
+// between two task instances in the plan.
+ResolveSchedOrderCmd *SA_WorkingPlan::get_ResolveSchedOrderCmd (void)
+{
+ return static_cast<ResolveSchedOrderCmd *> (this->resolve_sched_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for adjusting the minimum times of a
+// task instance in the plan.
+AdjustMinTimesCmd *SA_WorkingPlan::get_AdjustMinTimesCmd (void)
+{
+ return static_cast<AdjustMinTimesCmd *> (this->adj_min_times_cmd_->clone ());
+};
+
+// Get a PlanCommand prototype for adjusting the maximum times of a
+// task instance in the plan.
+AdjustMaxTimesCmd *SA_WorkingPlan::get_AdjustMaxTimesCmd (void)
+{
+ return static_cast<AdjustMaxTimesCmd *> (this->adj_max_times_cmd_->clone ());
+};
+
+void SA_WorkingPlan::execute (SA_AddTaskCmd *cmd)
+{
+ // Get task ID, condition, and instance ID.
+ TaskID task = cmd->tasks_.front ();
+ Condition cond = cmd->cond_;
+ TaskInstID task_inst;
+ if(cmd->last_task_ != task)
+ {
+ // The task instance is reused.
+ for(InstToTaskMap::iterator iter = this->task_insts_.begin(); iter!=this->task_insts_.end();iter++)
+ if(iter->second==cmd->tasks_.front())
+ cmd->used_task_insts_.insert(iter->first);
+ }
+ if(cmd->used_task_insts_.empty())
+ {
+ task_inst = this->get_next_inst_id ();
+ // Add task instance.
+ this->task_insts_.insert (std::make_pair (task_inst, task));
+ // Remove task from command and update last task and instance.
+ cmd->tasks_.pop_front ();
+ }
+ else
+ {
+ // Reuse the task instance
+ task_inst = *cmd->used_task_insts_.begin();
+ this->reused_insts.insert(task_inst);
+ }
+ // Create causal links for each task instance depending on the condition.
+ for (TaskInstSet::iterator inst_iter = cmd->task_insts_.begin ();
+ inst_iter != cmd->task_insts_.end (); inst_iter++)
+ {
+ CausalLink clink;
+ clink.cond = cond;
+ clink.first = task_inst;
+ clink.second = *inst_iter;
+ CondToCLinksMap::iterator links_iter;
+ for (links_iter = this->causal_links_.lower_bound (cond);links_iter != this->causal_links_.upper_bound (cond);links_iter++)
+ if(links_iter->second == clink)
+ break;
+ if(links_iter==this->causal_links_.upper_bound(cond))
+ {
+ this->causal_links_.insert (std::make_pair (cond, clink));
+ cmd->added_links_.insert(clink);
+ }
+ }
+ cmd->last_task_ = task;
+ cmd->last_task_inst_ = task_inst;
+};
+
+void SA_WorkingPlan::undo (SA_AddTaskCmd *cmd)
+{
+ if(cmd->used_task_insts_.empty())
+ {
+ // Remove task instance.
+ this->task_insts_.erase (this->task_insts_.find(cmd->last_task_inst_));
+ }
+ else {
+ // Remove the task instance from the set of reusable task instances
+ cmd->used_task_insts_.erase(cmd->used_task_insts_.begin());
+ this->reused_insts.erase(this->reused_insts.find(cmd->last_task_inst_));
+ }
+ // Remove causal links.
+ for (SA_WorkingPlan::CondToCLinksMap::iterator cl_iter =
+ this->causal_links_.lower_bound (cmd->cond_);
+ cl_iter != this->causal_links_.upper_bound (cmd->cond_);)
+ {
+ SA_WorkingPlan::CondToCLinksMap::iterator prev_iter = cl_iter;
+ cl_iter++;
+ if (cmd->task_insts_.find (prev_iter->second.second) != cmd->task_insts_.end ())
+ {
+ for(CLSet::iterator iter = cmd->added_links_.begin();iter!=cmd->added_links_.end();iter++)
+ {
+ if(prev_iter->second == *iter)
+ {
+ this->causal_links_.erase (prev_iter);
+ cmd->added_links_.erase(iter);
+ break;
+ }
+ }
+ }
+ }
+};
+
+// Execute a command to associate an implementation with a
+// task instance in the plan.
+bool SA_WorkingPlan::execute (SA_AssocTaskImplCmd *cmd)
+{
+ // Associate task instance with first implementation in list from command.
+ if(this->reused_insts.find(cmd->task_inst_)==this->reused_insts.end())
+ {
+ this->task_impls_.insert (std::make_pair(cmd->task_inst_, cmd->impls_.front ()));
+ this->durations.insert(std::make_pair(cmd->task_inst_, this->planner_->get_impl(cmd->impls_.front())->get_duration()));
+ }
+ // Update last implementation to this one and remove it from command.
+ cmd->last_impl_ = cmd->impls_.front ();
+ cmd->impls_.pop_front ();
+ // Update the precedence graph
+ return this->init_prec_insert(cmd->task_inst_,cmd);
+};
+
+// Undo a command to associate an implementation with a
+// task instance in the plan.
+void SA_WorkingPlan::undo (SA_AssocTaskImplCmd *cmd)
+{
+ // Undo the time window adjustments and the precedence graph updations.
+ this->undo(&cmd->max_adj_cmd);
+ this->undo(&cmd->min_adj_cmd);
+ this->prec_erase(cmd->task_inst_,cmd);
+ cmd->causal_insertions.clear();
+ cmd->simul_insertions.clear();
+ if(this->reused_insts.find(cmd->task_inst_)==this->reused_insts.end())
+ {
+ this->durations.erase(this->durations.find(cmd->task_inst_));
+ this->task_impls_.erase (cmd->task_inst_);
+ }
+};
+
+// Execute a command to resolve a causal link threat in the
+// plan (with promotion or demotion).
+void SA_WorkingPlan::execute (SA_ResolveCLThreatCmd *)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Undo a command to resolve a causal link threat in the
+// plan (with promotion or demotion).
+void SA_WorkingPlan::undo (SA_ResolveCLThreatCmd *)
+{
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+};
+
+// Execute a command to resolve a scheduling conflict (i.e.
+// non-causal-link ordering constraint with promotion or demotion)
+// between two task instances in the plan.
+bool SA_WorkingPlan::execute (SA_ResolveSchedOrderCmd *cmd)
+{
+ std::cout<<"Scheduling "<<cmd->first<<" before "<<cmd->second<<std::endl;
+ TaskInstID first_task_inst = cmd->first;
+ TaskInstID second_task_inst = cmd->second;
+ TimeWindow first_start,second_start;
+ TimeWindow first_end,second_end;
+ first_start = this->get_start_window(first_task_inst);
+ first_end = this->get_end_window(first_task_inst);
+ second_start = this->get_start_window(second_task_inst);
+ second_end = this->get_end_window(second_task_inst);
+
+ if(second_start.second!= NULL_TIME && (first_end.second==NULL_TIME || second_start.second<first_end.second))
+ {
+ // There is a need to adjust the max times
+ cmd->adj_max_times_cmd_ = static_cast<SA_AdjustMaxTimesCmd *> (this->get_AdjustMaxTimesCmd());
+ cmd->adj_max_times_cmd_->set_times(first_task_inst,second_start.second-this->get_duration(first_task_inst),second_start.second);
+ if(!this->execute(cmd->adj_max_times_cmd_))
+ return false;
+ }
+ else cmd->adj_max_times_cmd_=NULL;
+ if(first_end.first!= NULL_TIME && second_start.first<first_end.first)
+ {
+ // There is a need to adjust the min times
+ cmd->adj_min_times_cmd_ = static_cast<SA_AdjustMinTimesCmd *> (this->get_AdjustMinTimesCmd());
+ cmd->adj_min_times_cmd_->set_times(second_task_inst,first_end.first,first_end.first+this->get_duration(second_task_inst));
+ if(!this->execute(cmd->adj_min_times_cmd_))
+ return false;
+ }
+ else cmd->adj_min_times_cmd_=NULL;
+
+ PrecedenceSet *before = &this->precedence_graph_.find(BEFORE)->second;
+ PrecedenceSet *after = &this->precedence_graph_.find(AFTER)->second;
+ PrecedenceSet *simul = &this->precedence_graph_.find(SIMUL)->second;
+ PrecedenceSet *unranked = &this->precedence_graph_.find(UNRANKED)->second;
+
+ before->find(second_task_inst)->second.insert(first_task_inst);
+ after->find(first_task_inst)->second.insert(second_task_inst);
+ unranked->find(first_task_inst)->second.erase(unranked->find(first_task_inst)->second.find(second_task_inst));
+ unranked->find(second_task_inst)->second.erase(unranked->find(second_task_inst)->second.find(first_task_inst));
+
+ TaskInstSet after_second = this->after_orderings(second_task_inst);
+ for(TaskInstSet::iterator iter=simul->find(second_task_inst)->second.begin();iter!=simul->find(second_task_inst)->second.end();iter++)
+ after_second.insert(*iter);
+ TaskInstSet before_first = this->before_orderings(first_task_inst);
+ for(TaskInstSet::iterator iter=simul->find(first_task_inst)->second.begin();iter!=simul->find(first_task_inst)->second.end();iter++)
+ before_first.insert(*iter);
+ // All the task instances after and simultaneous to the second task instance should
+ // be after all the task instances before and simultaneous to the first task instance
+ for(TaskInstSet::iterator iter=after_second.begin();iter!=after_second.end();iter++)
+ {
+ if(before->find(*iter)->second.find(first_task_inst)==before->find(*iter)->second.end())
+ {
+ SA_ResolveSchedOrderCmd *temp = static_cast<SA_ResolveSchedOrderCmd *> (this->get_ResolveSchedOrderCmd());
+ temp->set_task_insts(first_task_inst,*iter);
+ cmd->cmds_.push_back(temp);
+ if(!this->execute(temp)) return false;
+ }
+ }
+ // All the task instances before and simultaneous to the first task instance should
+ // be before all the task instances after and simultaneous to the second task instance
+ for(TaskInstSet::iterator iter=before_first.begin();iter!=before_first.end();iter++)
+ {
+ if(after->find(*iter)->second.find(second_task_inst)==after->find(*iter)->second.end())
+ {
+ SA_ResolveSchedOrderCmd *temp = static_cast<SA_ResolveSchedOrderCmd *> (this->get_ResolveSchedOrderCmd());
+ temp->set_task_insts(*iter,second_task_inst);
+ cmd->cmds_.push_back(temp);
+ if(!this->execute(temp)) return false;
+ }
+ }
+ return true;
+};
+
+// Undo a command to resolve a scheduling conflict (i.e.
+// non-causal-link ordering constraint with promotion or demotion)
+// between two task instances in the plan.
+void SA_WorkingPlan::undo (SA_ResolveSchedOrderCmd *cmd)
+{
+ for(std::list<SA_ResolveSchedOrderCmd*>::reverse_iterator iter=cmd->cmds_.rbegin();iter!=cmd->cmds_.rend();iter++)
+ this->undo(*iter);
+
+ TaskInstID first_task_inst = cmd->first;
+ TaskInstID second_task_inst = cmd->second;
+
+ PrecedenceSet *before = &this->precedence_graph_.find(BEFORE)->second;
+ PrecedenceSet *after = &this->precedence_graph_.find(AFTER)->second;
+ PrecedenceSet *unranked = &this->precedence_graph_.find(UNRANKED)->second;
+
+ before->find(second_task_inst)->second.erase(before->find(second_task_inst)->second.find(first_task_inst));
+ after->find(first_task_inst)->second.erase(after->find(first_task_inst)->second.find(second_task_inst));
+ unranked->find(first_task_inst)->second.insert(second_task_inst);
+ unranked->find(second_task_inst)->second.insert(first_task_inst);
+ if(cmd->adj_max_times_cmd_ != NULL) {
+ this->undo(cmd->adj_max_times_cmd_);
+ }
+ if(cmd->adj_min_times_cmd_ != NULL)this->undo(cmd->adj_min_times_cmd_);
+};
+
+// Execute a command to adjust the minimum times of a
+// task instance in the plan.
+bool SA_WorkingPlan::execute (SA_AdjustMinTimesCmd *cmd)
+{
+ std::cout<<"adjusting min time for "<<cmd->task_inst_<<std::endl;
+ TimeWindow *start_win = &this->start_window_map_.find(cmd->task_inst_)->second;
+ TimeWindow *end_win = &this->end_window_map_.find(cmd->task_inst_)->second;
+ // If this adjustment violated and time constraints, return false.
+ if(start_win->second!=NULL_TIME &&(cmd->new_end_min==NULL_TIME || cmd->new_end_min>end_win->second || cmd->new_start_min>start_win->second))
+ return false;
+ // Set the new time window
+ start_win->first = cmd->new_start_min;
+ end_win->first = cmd->new_end_min;
+
+ TimeWindow ts = this->get_start_window(cmd->task_inst_);
+ TimeWindow es = this->get_end_window(cmd->task_inst_);
+ CLSet after_links = this->get_after(cmd->task_inst_);
+ if(after_links.empty()) std::cout<<"after links is empty"<<std::endl;
+ TaskInstSet causal,sched,data;
+ for(CLSet::iterator iter=after_links.begin();iter!=after_links.end();iter++)
+ { if(iter->cond.kind!=DATA) causal.insert(iter->second);
+ else data.insert(iter->second);
+ }
+ for(SchedulingLinks::iterator iter=sched_links_.begin();iter!=sched_links_.end();iter++)
+ if(iter->first==cmd->task_inst_) sched.insert(iter->second);
+
+ // Propagate this time window change to all the task instances ordered after this task instance
+ for(TaskInstSet::iterator iter=causal.begin();iter!=causal.end();iter++)
+ {
+ TimeWindow temp_start = this->get_start_window(*iter);
+ TimeWindow temp_end = this->get_end_window(*iter);
+ if(end_win->first>temp_start.first)
+ {
+ std::cout<<"adjusting time for causal "<<*iter<<std::endl;
+ SA_AdjustMinTimesCmd* temp = static_cast<SA_AdjustMinTimesCmd *> (this->get_AdjustMinTimesCmd());
+ TimeValue dur = this->durations.find(*iter)->second;
+ if(dur!=0) temp->set_times(*iter,end_win->first,end_win->first+this->durations.find(*iter)->second);
+ else temp->set_times(*iter,end_win->first,temp_end.first);
+ cmd->min_adjust_cmds.push_back(temp);
+ }
+ }
+ if(sched.empty()) std::cout<<"sched is empty"<<std::endl;
+ for(TaskInstSet::iterator iter=sched.begin();iter!=sched.end();iter++)
+ {
+ TimeWindow temp_start = this->get_start_window(*iter);
+ TimeWindow temp_end = this->get_end_window(*iter);
+ if(end_win->first>temp_start.first)
+ {
+ SA_AdjustMinTimesCmd* temp = static_cast<SA_AdjustMinTimesCmd *> (this->get_AdjustMinTimesCmd());
+ TimeValue dur = this->durations.find(*iter)->second;
+ if(dur!=0) temp->set_times(*iter,end_win->first,end_win->first+this->durations.find(*iter)->second);
+ else temp->set_times(*iter,end_win->first,temp_end.first);
+ cmd->min_adjust_cmds.push_back(temp);
+ }
+ }
+ // Do the same change for the task instances simultaneous to this one
+ for(TaskInstSet::iterator iter=data.begin();iter!=data.end();iter++)
+ {
+ TimeWindow temp_start = this->get_start_window(*iter);
+ if(start_win->first>temp_start.first)
+ {
+ std::cout<<"adjusting time for data "<<*iter<<std::endl;
+ SA_AdjustMinTimesCmd* temp = static_cast<SA_AdjustMinTimesCmd *> (this->get_AdjustMinTimesCmd());
+ temp->set_times(*iter,start_win->first,end_win->first);
+ cmd->min_adjust_cmds.push_back(temp);
+ }
+ }
+
+ for(SA_AdjustMinTimesCmd::MinTimesAdjustList::iterator iter=cmd->min_adjust_cmds.begin();iter!=cmd->min_adjust_cmds.end();iter++)
+ {
+ if(!this->execute(*iter)) return false;
+ }
+ std::cout<<"the task inst is "<<cmd->task_inst_<<std::endl;
+ // Check to see whether any task instance should be removed from the unranked set due to this time window change
+ TaskInstSet *unranked = &this->precedence_graph_.find(UNRANKED)->second.find(cmd->task_inst_)->second;
+ for(TaskInstSet::iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ TimeWindow temp_end = this->get_end_window(*iter);
+ if(temp_end.second!=NULL_TIME && temp_end.second<start_win->first)
+ {
+ this->precedence_graph_.find(BEFORE)->second.find(cmd->task_inst_)->second.insert(*iter);
+ this->precedence_graph_.find(AFTER)->second.find(*iter)->second.insert(cmd->task_inst_);
+ this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second.erase(this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second.find(*iter));
+ cmd->ranked.insert(*iter);
+ }
+ }
+ for(TaskInstSet::iterator iter=cmd->ranked.begin();iter!=cmd->ranked.end();iter++)
+ {
+ unranked->erase(unranked->find(*iter));
+ }
+ std::cout<<"min times of "<<cmd->task_inst_<<" : "<<cmd->new_start_min<<" "<<cmd->new_end_min<<std::endl;
+ return true;
+};
+
+// Undo a command to adjust the minimum times of a
+// task instance in the plan.
+void SA_WorkingPlan::undo (SA_AdjustMinTimesCmd *cmd)
+{
+ TimeWindow *start_win = &this->get_start_window(cmd->task_inst_);
+ TimeWindow *end_win = &this->get_end_window(cmd->task_inst_);
+
+ if(start_win->first==cmd->old_start_min && end_win->first==cmd->old_end_min) return;
+ // Undo all the removal of the tasks from the unranked set
+ TaskInstSet *unranked1 = &this->precedence_graph_.find(UNRANKED)->second.find(cmd->task_inst_)->second;
+ TaskInstSet *before = &this->precedence_graph_.find(BEFORE)->second.find(cmd->task_inst_)->second;
+ for(TaskInstSet::iterator iter=cmd->ranked.begin();iter!=cmd->ranked.end();iter++)
+ {
+ TaskInstSet *unranked2 = &this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second;
+ TaskInstSet *after = &this->precedence_graph_.find(AFTER)->second.find(*iter)->second;
+ unranked1->insert(*iter);
+ unranked2->insert(cmd->task_inst_);
+ before->erase(before->find(*iter));
+ after->erase(after->find(cmd->task_inst_));
+ }
+
+ // Undo all the time window changes caused by this command
+ for(SA_AdjustMinTimesCmd::MinTimesAdjustList::reverse_iterator iter=cmd->min_adjust_cmds.rbegin();iter!=cmd->min_adjust_cmds.rend();iter++)
+ {
+ this->undo(*iter);
+ }
+ // Reset the time window to the old one
+ start_win->first=cmd->old_start_min;
+ end_win->first=cmd->old_end_min;
+
+ return;
+};
+
+// Execute a command to adjust the maximum times of a
+// task instance in the plan.
+bool SA_WorkingPlan::execute (SA_AdjustMaxTimesCmd *cmd)
+{
+ std::cout<<"adjusting max time for "<<cmd->task_inst_<<std::endl;
+ TimeWindow *start_win = &this->start_window_map_.find(cmd->task_inst_)->second;
+ TimeWindow *end_win = &this->end_window_map_.find(cmd->task_inst_)->second;
+ std::cout<<"for "<<cmd->task_inst_<<" "<<cmd->new_end_max<<" "<<end_win->first<<" "<<cmd->new_start_max<<" "<<start_win->first<<std::endl;
+ // If this adjustment violated and time constraints, return false.
+ if((end_win->first==NULL_TIME && cmd->new_end_max!= NULL_TIME) || cmd->new_end_max<end_win->first || cmd->new_start_max<start_win->first) return false;
+ // Set the new time window
+ start_win->second = cmd->new_start_max;
+ end_win->second = cmd->new_end_max;
+ CLSet before_links = this->get_before(cmd->task_inst_);
+ TaskInstSet causal,sched,data;
+ for(CLSet::iterator iter=before_links.begin();iter!=before_links.end();iter++)
+ { if(iter->cond.kind!=DATA) causal.insert(iter->first);
+ else data.insert(iter->first);
+ }
+ for(SchedulingLinks::iterator iter=sched_links_.begin();iter!=sched_links_.end();iter++)
+ if(iter->second==cmd->task_inst_) sched.insert(iter->first);
+
+ // Propagate this time window change to all the task instances ordered before this task instance
+ for(TaskInstSet::iterator iter=causal.begin();iter!=causal.end();iter++)
+ {
+ TimeWindow temp_end = this->get_end_window(*iter);
+ if(temp_end.second==NULL_TIME || (temp_end.second!=NULL_TIME && start_win->second<temp_end.second))
+ {
+ SA_AdjustMaxTimesCmd* temp = static_cast<SA_AdjustMaxTimesCmd *> (this->get_AdjustMaxTimesCmd());
+ temp->set_times(*iter,start_win->second-this->durations.find(*iter)->second,start_win->second);
+ cmd->max_adjust_cmds.push_back(temp);
+ }
+ }
+
+ for(TaskInstSet::iterator iter=sched.begin();iter!=sched.end();iter++)
+ {
+ TimeWindow temp_end = this->get_end_window(*iter);
+ if(temp_end.second==NULL_TIME || (temp_end.second!=NULL_TIME && start_win->second<temp_end.second))
+ {
+ SA_AdjustMaxTimesCmd* temp = static_cast<SA_AdjustMaxTimesCmd *> (this->get_AdjustMaxTimesCmd());
+ temp->set_times(*iter,start_win->second-this->durations.find(*iter)->second,start_win->second);
+ cmd->max_adjust_cmds.push_back(temp);
+ }
+ }
+
+ // Do the same change for the task instances simultaneous to this one
+ for(TaskInstSet::iterator iter=data.begin();iter!=data.end();iter++)
+ {
+ TimeWindow temp_end = this->get_end_window(*iter);
+ if(temp_end.second==NULL_TIME || (temp_end.second!=NULL_TIME && end_win->second<temp_end.second))
+ {
+ SA_AdjustMaxTimesCmd* temp = static_cast<SA_AdjustMaxTimesCmd *> (this->get_AdjustMaxTimesCmd());
+ temp->set_times(*iter,start_win->second,end_win->second);
+ cmd->max_adjust_cmds.push_back(temp);
+ }
+ }
+ for(SA_AdjustMaxTimesCmd::MaxTimesAdjustList::iterator iter=cmd->max_adjust_cmds.begin();iter!=cmd->max_adjust_cmds.end();iter++)
+ {
+ if(!this->execute(*iter)) return false;
+ }
+ // Check to see whether any task instance should be removed from the unranked set due to this time window change
+ TaskInstSet *unranked = &this->precedence_graph_.find(UNRANKED)->second.find(cmd->task_inst_)->second;
+ for(TaskInstSet::iterator iter=unranked->begin();iter!=unranked->end();iter++)
+ {
+ TimeWindow temp_start = this->get_start_window(*iter);
+ if(temp_start.first>end_win->second)
+ {
+ this->precedence_graph_.find(AFTER)->second.find(cmd->task_inst_)->second.insert(*iter);
+ this->precedence_graph_.find(BEFORE)->second.find(*iter)->second.insert(cmd->task_inst_);
+ this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second.erase(this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second.find(*iter));
+ cmd->ranked.insert(*iter);
+ }
+ }
+ for(TaskInstSet::iterator iter=cmd->ranked.begin();iter!=cmd->ranked.end();iter++)
+ {
+ unranked->erase(unranked->find(*iter));
+ }
+ std::cout<<"max times for "<<cmd->task_inst_<<" : "<<cmd->new_start_max<<" "<<cmd->new_end_max<<std::endl;
+ return true;
+};
+
+// Undo a command to adjust the maximum times of a
+// task instance in the plan.
+void SA_WorkingPlan::undo (SA_AdjustMaxTimesCmd *cmd)
+{
+ std::cout<<"task inst is "<<cmd->task_inst_<<std::endl;
+ TimeWindow *start_win = &this->get_start_window(cmd->task_inst_);
+ TimeWindow *end_win = &this->get_end_window(cmd->task_inst_);
+ if(start_win->second==cmd->old_start_max && end_win->second==cmd->old_end_max) return;
+ // Undo all the removal of the tasks from the unranked set
+ TaskInstSet *unranked1 = &this->precedence_graph_.find(UNRANKED)->second.find(cmd->task_inst_)->second;
+ TaskInstSet *after = &this->precedence_graph_.find(AFTER)->second.find(cmd->task_inst_)->second;
+ for(TaskInstSet::iterator iter=cmd->ranked.begin();iter!=cmd->ranked.end();iter++)
+ {
+ TaskInstSet *unranked2 = &this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second;
+ TaskInstSet *before = &this->precedence_graph_.find(BEFORE)->second.find(*iter)->second;
+ unranked1->insert(*iter);
+ unranked2->insert(cmd->task_inst_);
+ after->erase(after->find(*iter));
+ before->erase(before->find(cmd->task_inst_));
+ }
+
+ // Undo all the time window changes caused by this command
+ for(SA_AdjustMaxTimesCmd::MaxTimesAdjustList::reverse_iterator iter=cmd->max_adjust_cmds.rbegin();iter!=cmd->max_adjust_cmds.rend();iter++)
+ {
+ this->undo(*iter);
+ }
+
+ // Reset the time window to the old one
+ start_win->second=cmd->old_start_max;
+ end_win->second=cmd->old_end_max;
+
+ return;
+};
+// Get the start window of the task instance. If one doesn't exist, then assign it one.
+TimeWindow SA_WorkingPlan::get_start_window(TaskInstID task_inst)
+{
+ InstToWinMap::iterator iter = this->start_window_map_.find(task_inst);
+ if(iter==this->start_window_map_.end()) {
+ // The window doesn't exist
+ // The default start window.
+ TimeWindow temp_start = std::make_pair(0,NULL_TIME);
+ TimeWindow temp_end;
+ if(this->durations.find(task_inst)->second!=0)
+ {
+ // The default end window for non data tasks.
+ temp_end = std::make_pair(this->durations.find(task_inst)->second,NULL_TIME);
+ }
+ else
+ {
+ // The default end window for data tasks.
+ temp_end = std::make_pair(NULL_TIME,NULL_TIME);
+ }
+ this->start_window_map_.insert(std::make_pair(task_inst,temp_start));
+ this->end_window_map_.insert(std::make_pair(task_inst,temp_end));
+ }
+ return this->start_window_map_.find(task_inst)->second;
+};
+
+TimeWindow SA_WorkingPlan::get_end_window(TaskInstID task_inst)
+{
+ InstToWinMap::iterator iter = this->end_window_map_.find(task_inst);
+ if(iter==this->end_window_map_.end()) {
+ // The window doesn't exist
+ // The default start window.
+ TimeWindow temp_start = std::make_pair(0,NULL_TIME);
+ TimeWindow temp_end;
+ if(this->durations.find(task_inst)->second!=0)
+ {
+ // The default end window for non data tasks.
+ temp_end = std::make_pair(this->durations.find(task_inst)->second,NULL_TIME);
+ }
+ else
+ {
+ // The default end window for data tasks.
+ temp_end = std::make_pair(NULL_TIME,NULL_TIME);
+ }
+ this->start_window_map_.insert(std::make_pair(task_inst,temp_start));
+ this->end_window_map_.insert(std::make_pair(task_inst,temp_end));
+ }
+ return this->end_window_map_.find(task_inst)->second;
+};
+
+//Get the duration of a task instance
+TimeValue SA_WorkingPlan::get_duration(TaskInstID task_inst)
+{
+ return this->durations.find(task_inst)->second;
+};
+
+/// Adds the sched order to the sched_links_ map by putting the first task instance before the second
+void SA_WorkingPlan::add_sched_link(TaskInstID first_task_inst, TaskInstID second_task_inst)
+{
+ this->sched_links_.insert(std::make_pair(first_task_inst,second_task_inst));
+}
+/// Removes the sched order from the sched_links_ map
+void SA_WorkingPlan::remove_sched_link(TaskInstID first_task_inst, TaskInstID second_task_inst)
+{
+ for(SchedulingLinks::iterator iter=this->sched_links_.begin();iter!=this->sched_links_.end();iter++)
+ {
+ if(iter->first==first_task_inst && iter->second==second_task_inst)
+ {
+ this->sched_links_.erase(iter);
+ break;
+ }
+ }
+}
+// Update the precedence graph by inserting the task instance.
+bool SA_WorkingPlan::init_prec_insert(TaskInstID task_inst, SA_AssocTaskImplCmd *cmd)
+{
+ TaskInstSet temp;
+ this->precedence_graph_.find(BEFORE)->second.insert(std::make_pair(task_inst,temp));
+ this->precedence_graph_.find(AFTER)->second.insert(std::make_pair(task_inst,temp));
+ this->precedence_graph_.find(UNRANKED)->second.insert(std::make_pair(task_inst,temp));
+ this->precedence_graph_.find(SIMUL)->second.insert(std::make_pair(task_inst,temp));
+
+ TimeWindow win_start = this->init_start.find(task_inst)->second;
+ TimeWindow win_end = this->init_end.find(task_inst)->second;
+ TimeWindow start_win = this->get_start_window(task_inst);
+ TimeWindow end_win = this->get_end_window(task_inst);
+ std::cout<<"for "<<task_inst<<win_start.first<<" "<<win_start.second<<" "<<win_end.first<<" "<<win_end.second<<std::endl;
+ std::cout<<"for "<<task_inst<<start_win.first<<" "<<start_win.second<<" "<<end_win.first<<" "<<end_win.second<<std::endl;
+ if(win_start.first!=NULL_TIME)
+ {
+ // An initial time constraint is set on the minimum times
+ if(win_start.second!=NULL_TIME)
+ {
+ // An initial time constraint is set on the maximum times
+ cmd->min_adj_cmd.set_times(task_inst,win_start.first,win_end.first);
+ cmd->max_adj_cmd.set_times(task_inst,win_start.second,win_end.second);
+ if(!this->execute(&cmd->min_adj_cmd))
+ {
+ this->undo(&cmd->min_adj_cmd);
+ return false;
+ }
+ if(!this->execute(&cmd->max_adj_cmd))
+ {
+ this->undo(&cmd->max_adj_cmd);
+ this->undo(&cmd->min_adj_cmd);
+ return false;
+ }
+ }
+ else
+ {
+ // No initial time constraint is set on the maximum times
+ cmd->min_adj_cmd.set_times(task_inst,win_start.first,win_end.first);
+ if(!this->execute(&cmd->min_adj_cmd))
+ {
+ this->undo(&cmd->min_adj_cmd);
+ return false;
+ }
+ }
+ }
+ else
+ {
+ // No initial time constraint is set on the minimum times
+ if(win_start.second!=NULL_TIME)
+ {
+ // An initial time constraint is set on the maximum times
+ cmd->max_adj_cmd.set_times(task_inst,win_start.second,win_end.second);
+ if(!this->execute(&cmd->max_adj_cmd))
+ {
+ this->undo(&cmd->min_adj_cmd);
+ return false;
+ }
+ }
+ else
+ {
+ // No initial time constraint.
+ cmd->min_adj_cmd.set_times(task_inst,start_win.first,end_win.first);
+ cmd->max_adj_cmd.set_times(task_inst,start_win.second,end_win.second);
+ std::cout<<"for "<<task_inst<<" "<<start_win.first<<" "<<start_win.second<<" "<<end_win.first<<" "<<end_win.second<<std::endl;
+ if(!this->execute(&cmd->min_adj_cmd))
+ {
+ this->undo(&cmd->min_adj_cmd);
+ return false;
+ }
+ //if(!this->execute(&cmd->max_adj_cmd))
+ //{
+ // this->undo(&cmd->max_adj_cmd);
+ // this->undo(&cmd->min_adj_cmd);
+ // return false;
+ //}
+ }
+ }
+ start_win = this->get_start_window(task_inst);
+ end_win = this->get_end_window(task_inst);
+ TaskInstSet *before,*after,*simul,*unranked;
+ before = &this->precedence_graph_.find(BEFORE)->second.find(task_inst)->second;
+ after = &this->precedence_graph_.find(AFTER)->second.find(task_inst)->second;
+ unranked = &this->precedence_graph_.find(UNRANKED)->second.find(task_inst)->second;
+ simul = &this->precedence_graph_.find(SIMUL)->second.find(task_inst)->second;
+ // If this task instance is not reused, insert all the task instances in it unranked set.
+ if(unranked->empty())
+ {
+ for(PrecedenceSet::iterator iter=this->precedence_graph_.find(BEFORE)->second.begin();iter!=this->precedence_graph_.find(BEFORE)->second.end();iter++)
+ {
+ if(iter->first!=task_inst)
+ {
+ std::cout<<"inserting "<<iter->first<<" in unranked of "<<task_inst<<std::endl;
+ unranked->insert(iter->first);
+ }
+ }
+ if(unranked->empty()) return true;
+ }
+ CLSet after_links = this->get_after(task_inst);
+
+ TaskInstSet causal,data;
+ for(CLSet::iterator iter=after_links.begin();iter!=after_links.end();iter++)
+ {
+ if(iter->second==GOAL_TASK_INST_ID || iter->second==NULL_TASK_INST_ID) continue;
+ if(iter->cond.kind!=DATA) causal.insert(iter->second);
+ else data.insert(iter->second);
+ }
+
+ for(TaskInstSet::iterator iter=causal.begin();iter!=causal.end();iter++)
+ {
+ TaskInstSet *iter_after = &this->precedence_graph_.find(AFTER)->second.find(*iter)->second;
+ TaskInstSet *iter_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter)->second;
+ TaskInstSet *iter_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second;
+ TaskInstSet *iter_simul = &this->precedence_graph_.find(SIMUL)->second.find(*iter)->second;
+ if(after->find(*iter)!=after->end()) continue;
+ std::cout<<"inserting "<<*iter<<" in after set of "<<task_inst<<std::endl;
+ TaskInstSet temp = *before;
+ temp.insert(task_inst);
+ for(TaskInstSet::iterator iter2=simul->begin();iter2!=simul->end();iter2++)
+ temp.insert(*iter2);
+ for(TaskInstSet::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
+ {
+ TaskInstSet *iter2_before,*iter2_after,*iter2_simul,*iter2_unranked;
+ iter2_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter2)->second;
+ iter2_after = &this->precedence_graph_.find(AFTER)->second.find(*iter2)->second;
+ iter2_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter2)->second;
+ iter2_simul = &this->precedence_graph_.find(SIMUL)->second.find(*iter2)->second;
+ for(TaskInstSet::iterator iter1=iter_after->begin();iter1!=iter_after->end();iter1++)
+ {
+ std::cout<<*iter1<<" is after "<<*iter<<" so it is after "<<*iter2<<std::endl;
+ TaskInstSet *iter1_before,*iter1_unranked;
+ iter1_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_before->find(*iter2)!=iter1_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter1));
+ iter1_before->insert(*iter2);
+ iter2_after->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ for(TaskInstSet::iterator iter1=iter_simul->begin();iter1!=iter_simul->end();iter1++)
+ {
+ std::cout<<*iter1<<" is siml to "<<*iter<<" so it is after "<<*iter2<<std::endl;
+ TaskInstSet *iter1_before,*iter1_unranked;
+ iter1_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_before->find(*iter2)!=iter1_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter1));
+ iter1_before->insert(*iter2);
+ iter2_after->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ if(iter_before->find(*iter2)!=iter_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter));
+ iter_before->insert(*iter2);
+ iter2_after->insert(*iter);
+ if(iter_unranked->find(*iter2)!=iter_unranked->end()) iter_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter));
+ }
+ }
+ for(TaskInstSet::iterator iter=data.begin();iter!=data.end();iter++)
+ {
+ TaskInstSet *iter_after = &this->precedence_graph_.find(AFTER)->second.find(*iter)->second;
+ TaskInstSet *iter_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter)->second;
+ TaskInstSet *iter_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second;
+ TaskInstSet *iter_simul = &this->precedence_graph_.find(SIMUL)->second.find(*iter)->second;
+ if(simul->find(*iter)!=simul->end()) continue;
+ std::cout<<"inserting "<<*iter<<" in simul set of "<<task_inst<<std::endl;
+ TaskInstSet temp = *before;
+ for(TaskInstSet::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
+ {
+ std::cout<<"iter2 is "<<*iter2<<std::endl;
+ TaskInstSet *iter2_before,*iter2_after,*iter2_simul,*iter2_unranked;
+ iter2_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter2)->second;
+ iter2_after = &this->precedence_graph_.find(AFTER)->second.find(*iter2)->second;
+ iter2_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter2)->second;
+ iter2_simul = &this->precedence_graph_.find(SIMUL)->second.find(*iter2)->second;
+ for(TaskInstSet::iterator iter1=iter_after->begin();iter1!=iter_after->end();iter1++)
+ {
+ std::cout<<*iter1<<" is after "<<*iter<<" so it is after "<<*iter2<<std::endl;
+ TaskInstSet *iter1_before,*iter1_unranked;
+ iter1_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_before->find(*iter2)!=iter1_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter1));
+ iter1_before->insert(*iter2);
+ iter2_after->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ for(TaskInstSet::iterator iter1=iter_simul->begin();iter1!=iter_simul->end();iter1++)
+ {
+ std::cout<<*iter1<<" is simul to "<<*iter<<" so it is after "<<*iter2<<std::endl;
+ TaskInstSet *iter1_before,*iter1_unranked;
+ iter1_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_before->find(*iter2)!=iter1_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter1));
+ iter1_before->insert(*iter2);
+ iter2_after->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ if(iter_before->find(*iter2)!=iter_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter));
+ iter_before->insert(*iter2);
+ iter2_after->insert(*iter);
+ if(iter_unranked->find(*iter2)!=iter_unranked->end()) iter_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter));
+ }
+ temp = *simul;
+ temp.insert(task_inst);
+ for(TaskInstSet::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
+ {
+ TaskInstSet *iter2_before,*iter2_after,*iter2_simul,*iter2_unranked;
+ iter2_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter2)->second;
+ iter2_after = &this->precedence_graph_.find(AFTER)->second.find(*iter2)->second;
+ iter2_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter2)->second;
+ iter2_simul = &this->precedence_graph_.find(SIMUL)->second.find(*iter2)->second;
+ for(TaskInstSet::iterator iter1=iter_after->begin();iter1!=iter_after->end();iter1++)
+ {
+ std::cout<<*iter1<<" is after "<<*iter<<" so it is after "<<*iter2<<std::endl;
+ TaskInstSet *iter1_before,*iter1_unranked;
+ iter1_before = &this->precedence_graph_.find(BEFORE)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_before->find(*iter2)!=iter1_before->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter2,*iter1));
+ iter1_before->insert(*iter2);
+ iter2_after->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ for(TaskInstSet::iterator iter1=iter_simul->begin();iter1!=iter_simul->end();iter1++)
+ {
+ std::cout<<*iter1<<" is simul "<<*iter<<" so it is simul "<<*iter2<<std::endl;
+ TaskInstSet *iter1_simul,*iter1_unranked;
+ iter1_simul = &this->precedence_graph_.find(SIMUL)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_simul->find(*iter2)!=iter1_simul->end()) continue;
+ else
+ {
+ cmd->simul_insertions.insert(std::make_pair(*iter2,*iter1));
+ }
+ iter1_simul->insert(*iter2);
+ iter2_simul->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ for(TaskInstSet::iterator iter1=iter_before->begin();iter1!=iter_before->end();iter1++)
+ {
+ std::cout<<*iter1<<" is before "<<*iter<<" so it is before "<<*iter2<<std::endl;
+ TaskInstSet *iter1_after,*iter1_unranked;
+ iter1_after = &this->precedence_graph_.find(AFTER)->second.find(*iter1)->second;
+ iter1_unranked = &this->precedence_graph_.find(UNRANKED)->second.find(*iter1)->second;
+ if(iter1_after->find(*iter2)!=iter1_after->end()) continue;
+ else cmd->causal_insertions.insert(std::make_pair(*iter1,*iter2));
+ iter1_after->insert(*iter2);
+ iter2_before->insert(*iter1);
+ if(iter1_unranked->find(*iter2)!=iter1_unranked->end()) iter1_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter1)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter1));
+ }
+ if(iter_simul->find(*iter2)!=iter_simul->end()) continue;
+ else cmd->simul_insertions.insert(std::make_pair(*iter2,*iter));
+ iter2_simul->insert(*iter);
+ iter_simul->insert(*iter2);
+ if(iter_unranked->find(*iter2)!=iter_unranked->end()) iter_unranked->erase(*iter2);
+ if(iter2_unranked->find(*iter)!=iter2_unranked->end()) iter2_unranked->erase(iter2_unranked->find(*iter));
+ }
+ }
+ std::cout<<"for "<<task_inst<<" start window: "<<start_win.first<<"-"<<start_win.second<<" and end window "<<end_win.first<<"-"<<end_win.second<<std::endl;
+ for(TaskInstSet::iterator iter = unranked->begin();iter!=unranked->end();iter++)
+ {
+ TimeWindow temp_start = this->get_start_window(*iter);
+ TimeWindow temp_end = this->get_end_window(*iter);
+ std::cout<<"checking "<<*iter<<" in all with start window: "<<temp_start.first<<"-"<<temp_start.second<<" and end window "<<temp_end.first<<"-"<<temp_end.second<<std::endl;
+ if(end_win.second!=NULL_TIME && temp_start.first>end_win.second)
+ {
+ after->insert(*iter);
+ this->precedence_graph_.find(BEFORE)->second.find(*iter)->second.insert(task_inst);
+ }
+ else if(temp_end.second!=NULL_TIME && temp_end.second<start_win.first)
+ {
+ before->insert(*iter);
+ this->precedence_graph_.find(AFTER)->second.find(*iter)->second.insert(task_inst);
+ }
+ else
+ {
+ this->precedence_graph_.find(UNRANKED)->second.find(*iter)->second.insert(task_inst);
+ }
+ }
+ this->print_prec();
+ for(InstToWinMap::iterator iter=this->start_window_map_.begin();iter!=this->start_window_map_.end();iter++)
+ {
+ std::cout<<"The start window for "<<iter->first<<" is "<<iter->second.first<<" - "<<iter->second.second<<std::endl;
+ }
+ for(InstToWinMap::iterator iter=this->end_window_map_.begin();iter!=this->end_window_map_.end();iter++)
+ {
+ std::cout<<"The end window for "<<iter->first<<" is "<<iter->second.first<<" - "<<iter->second.second<<std::endl;
+ }
+ return true;
+};
+
+// Print the precedence graph
+void SA_WorkingPlan::print_prec()
+{
+ std::cout<<"BEFORE : "<<BEFORE<<", AFTER : "<<AFTER<<", SIMUL : "<<SIMUL<<", UNRANKED : "<<UNRANKED<<std::endl;
+ for(PrecedenceGraph::iterator iter1 = this->precedence_graph_.begin(); iter1 != this->precedence_graph_.end(); iter1++)
+ {
+ std::cout<<"The precedence set "<<iter1->first<<": "<<std::endl;
+ for(PrecedenceSet::iterator iter2 = iter1->second.begin(); iter2 != iter1->second.end(); iter2++)
+ {
+ std::cout<<"The task inst set of "<<iter2->first<<" is ";
+ for(TaskInstSet::iterator iter3 = iter2->second.begin(); iter3 != iter2->second.end(); iter3++)
+ {
+ std::cout<<*iter3<<",";
+ }
+ std::cout<<std::endl;
+ }
+ }
+};
+
+// Undo all the updation to the precedence graph due to the chosen task instance
+void SA_WorkingPlan::prec_erase(TaskInstID task_inst, SA_AssocTaskImplCmd *cmd)
+{
+PrecedenceSet *before = &this->precedence_graph_.find(BEFORE)->second;
+PrecedenceSet *simul = &this->precedence_graph_.find(SIMUL)->second;
+PrecedenceSet *after = &this->precedence_graph_.find(AFTER)->second;
+PrecedenceSet *unranked = &this->precedence_graph_.find(UNRANKED)->second;
+ for(std::set< std::pair<TaskInstID,TaskInstID> >::iterator iter = cmd->causal_insertions.begin();iter!=cmd->causal_insertions.end();iter++)
+ {
+ // iter->second has been inserted in the after set of iter->first
+ std::cout<<"removing "<<iter->second<<" from after of "<<iter->first<<std::endl;
+ before->find(iter->second)->second.erase(iter->first);
+ after->find(iter->first)->second.erase(iter->second);
+ unranked->find(iter->first)->second.insert(iter->second);
+ unranked->find(iter->second)->second.insert(iter->first);
+ }
+ for(std::set< std::pair<TaskInstID,TaskInstID> >::iterator iter = cmd->simul_insertions.begin();iter!=cmd->simul_insertions.end();iter++)
+ {
+ // iter->second has been inserted in the simul set of iter->first
+ std::cout<<"removing "<<iter->second<<" from simul of "<<iter->first<<std::endl;
+ simul->find(iter->second)->second.erase(iter->first);
+ simul->find(iter->first)->second.erase(iter->second);
+ unranked->find(iter->first)->second.insert(iter->second);
+ unranked->find(iter->second)->second.insert(iter->first);
+ }
+ //if(before->find(task_inst)->second.empty() && after->find(task_inst)->second.empty() && simul->find(task_inst)->second.empty())
+ //{
+ // CondToCLinksMap::iterator iter;
+ // for(iter = this->causal_links_.begin();iter!=this->causal_links_.end();iter++)
+ // if(iter->second.second == GOAL_TASK_INST_ID && iter->second.first == task_inst) break;
+ // if(iter==this->causal_links_.end() || cmd->impls_.size()!=0)
+ // {
+ std::cout<<this->reused_insts.size()<<std::endl;
+ if(this->reused_insts.find(task_inst)==this->reused_insts.end())
+ {
+ before->erase(before->find(task_inst));
+ after->erase(after->find(task_inst));
+ simul->erase(simul->find(task_inst));
+ unranked->erase(unranked->find(task_inst));
+ this->start_window_map_.erase(this->start_window_map_.find(task_inst));
+ this->end_window_map_.erase(this->end_window_map_.find(task_inst));
+ for(PrecedenceSet::iterator iter1 = unranked->begin();iter1!=unranked->end();iter1++)
+ iter1->second.erase(task_inst);
+ }
+// }
+ //std::cout<<"after erasing the precedence graph is "<<std::endl;
+ //this->print_prec();
+};
+/// Get all the task instances
+TaskInstSet SA_WorkingPlan::get_all_insts()
+{
+ TaskInstSet all;
+ for(PrecedenceSet::iterator iter=this->precedence_graph_.find(BEFORE)->second.begin();iter!=this->precedence_graph_.find(BEFORE)->second.end();iter++)
+ {
+ all.insert(iter->first);
+ }
+ return all;
+}
+/// Check if the instance id already exists and is being reused.
+bool SA_WorkingPlan::inst_exists (TaskInstID task_inst)
+{
+ if(this->task_impls_.find(task_inst)!=this->task_impls_.end()) return true;
+ else return false;
+}
+
+/// Get task implementation for a task instance.
+TaskImplID SA_WorkingPlan::get_impl_id (TaskInstID task_inst)
+{
+ return this->task_impls_.find(task_inst)->second;
+}
+
diff --git a/SA_POP/SA_WorkingPlan.h b/SA_POP/SA_WorkingPlan.h
new file mode 100644
index 00000000000..e9944e5fea0
--- /dev/null
+++ b/SA_POP/SA_WorkingPlan.h
@@ -0,0 +1,451 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SA_WorkingPlan.h
+ *
+ * This file contains the definition of the SA_WorkingPlan concrete class,
+ * which implements a WorkingPlan that uses precedence graphs for scheduling.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SA_WORKING_PLAN_H_
+#define SA_POP_SA_WORKING_PLAN_H_
+
+#include <map>
+#include "SA_POP_Types.h"
+#include "WorkingPlan.h"
+#include "PlanCommands.h"
+#include "SA_PlanCommands.h"
+
+
+namespace SA_POP {
+
+ /**
+ * @class SA_WorkingPlan
+ *
+ * @brief WorkingPlan concrete class for encapsulation of a plan that uses
+ * precedence graphs for scheduling.
+ */
+ class SA_WorkingPlan : public WorkingPlan {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ SA_WorkingPlan (SA_POP::Planner *planner);
+
+ /// Destructor.
+ virtual ~SA_WorkingPlan (void);
+
+ /// Set command prototypes to use.
+ /**
+ * @param add_threats_cmd Prototype of command for adding open causal
+ * link threats to be handled.
+ */
+ virtual void set_commands (AddOpenThreatsCmd *add_threats_cmd);
+
+ /// Get current plan.
+ /**
+ * @return Reference to current plan.
+ */
+ virtual const Plan& get_plan (void);
+
+ /// Get set of task instances for a precedence relation to a task instance.
+ /**
+ * @param task_inst Task instance for which to get precedence set.
+ *
+ * @param prec_rel Precedence relation.
+ *
+ * @return Set of task instances for given precedence relation to given
+ * task instance.
+ */
+ virtual const TaskInstSet *get_prec_set (TaskInstID task_inst,
+ PrecedenceRelation prec_rel);
+
+ /// Get task id of a task instance.
+ /**
+ * @param inst_id The task instance id.
+ *
+ * @return The task id of this task instance.
+ */
+ virtual TaskID get_task_from_inst (TaskInstID inst_id);
+
+ /// Get task implementation id of a task instance.
+ /**
+ * @param inst_id The task instance id.
+ *
+ * @return The task implementation id of this task instance.
+ */
+ virtual TaskImplID get_task_impl_from_inst (TaskInstID inst_id);
+
+ /// Get all current causal link threats.
+ /**
+ * @return Set of all current causal link threats.
+ */
+ virtual CLThreatSet get_all_threats (void);
+
+ //Get the Start Window for a task instance
+ /**
+ * @param task_inst The task instance of which the start window is returned
+ *
+ * @return The start window for the task instance
+ */
+ virtual TimeWindow get_start_window(TaskInstID task_inst);
+
+ //Get the End Window for a task instance
+ /**
+ * @param task_inst The task instance of which the end window is returned
+ *
+ * @return The end window for the task instance
+ */
+ virtual TimeWindow get_end_window(TaskInstID task_inst);
+
+ //Get the duration of a task instance
+ /**
+ * @param task_inst The task instance of which the duration is returned
+ *
+ * @return The duration of the task instance
+ */
+ virtual TimeValue get_duration(TaskInstID task_inst);
+
+ //Get all the causal and data links TO the task instance
+ /**
+ * @param task_inst All causal and data links to this task instance have to be returned
+ *
+ * @return All causal and data links to this task instance
+ */
+ virtual CLSet get_before(TaskInstID task_inst);
+ //Get all the causal and data links FROM the task instance
+ /**
+ * @param task_inst All causal and data links from this task instance have to be returned
+ *
+ * @return All causal and data links from this task instance
+ */
+ virtual CLSet get_after(TaskInstID task_inst);
+
+ /// Get the Causal and Scheduling orderings to this task instance
+ /**
+ * @param inst_id The task instance to which all orderings are required
+ */
+ virtual TaskInstSet before_orderings (TaskInstID inst_id);
+
+ /// Get the Causal and Scheduling orderings from this task instance
+ /**
+ * @param inst_id The task instance from which all orderings are required
+ */
+ virtual TaskInstSet after_orderings (TaskInstID inst_id);
+
+ /// Adds the sched order to the sched_links_ map by putting the first task instance before the second
+ /**
+ * @param first_task_inst The task instance before the second one
+ *
+ * @param second_task_inst The task instance after the first one
+ */
+ virtual void add_sched_link(TaskInstID first_task_inst, TaskInstID second_task_inst);
+ /// Removes the sched order from the sched_links_ map
+ /**
+ * @param first_task_inst The task instance before the second one
+ *
+ * @param second_task_inst The task instance after the first one
+ */
+ virtual void remove_sched_link(TaskInstID first_task_inst, TaskInstID second_task_inst);
+
+ /// Get all the task instances
+ virtual TaskInstSet get_all_insts();
+
+ /// Check if the instance id already exists and is being reused.
+ /**
+ * @param task_inst The task instance being checked
+ *
+ * @return True If this task instance already exists.
+ */
+ virtual bool inst_exists (TaskInstID task_inst);
+
+ /// Get task implementation for a task instance.
+ /**
+ * @param task_inst The task instance.
+ *
+ * @return The task implementation id.
+ */
+ virtual TaskImplID get_impl_id (TaskInstID task_inst);
+
+ // ************************************************************************
+ // Methods for obtaining prototypes of commands that work on this object.
+ // ************************************************************************
+
+ /// Get a PlanCommand prototype for adding a task to the plan.
+ /**
+ * @return An AddTaskCmd prototype for this WorkingPlan.
+ */
+ virtual AddTaskCmd *get_AddTaskCmd (void);
+
+ /// Get a PlanCommand prototype for associating an implementation with a
+ /// task instance in the plan.
+ /**
+ * @return An AssocTaskImplCmd prototype for this WorkingPlan.
+ */
+ virtual AssocTaskImplCmd *get_AssocTaskImplCmd (void);
+
+ /// Get a PlanCommand prototype for resolving a causal link threat in the
+ /// plan (with promotion or demotion).
+ /**
+ * @return An ResolveCLThreatCmd prototype for this WorkingPlan.
+ */
+ virtual ResolveCLThreatCmd *get_ResolveCLThreatCmd (void);
+
+ /// Get a PlanCommand prototype for resolving a scheduling conflict (i.e.
+ /// non-causal-link ordering constraint (with promotion or demotion)
+ /// between two task instances in the plan.
+ /**
+ * @return An ResolveSchedOrderCmd prototype for this WorkingPlan.
+ */
+ virtual ResolveSchedOrderCmd *get_ResolveSchedOrderCmd (void);
+
+ /// Get a PlanCommand prototype for adjusting the minimum times of a
+ /// task instance in the plan.
+ /**
+ * @return An AdjustStartWindowCmd prototype for this WorkingPlan.
+ */
+ virtual AdjustMinTimesCmd *get_AdjustMinTimesCmd (void);
+
+ /// Get a PlanCommand prototype for adjusting the max times of a
+ /// task instance in the plan.
+ /**
+ * @return An AdjustEndWindowCmd prototype for this WorkingPlan.
+ */
+ virtual AdjustMaxTimesCmd *get_AdjustMaxTimesCmd (void);
+
+
+
+ // ************************************************************************
+ // Methods for executing and undoing commands.
+ // ************************************************************************
+
+ /// Execute a command to add a task to the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void execute (SA_AddTaskCmd *cmd);
+
+ /// Undo a command to add a task to the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_AddTaskCmd *cmd);
+
+ /// Execute a command to associate an implementation with a
+ /// task instance in the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual bool execute (SA_AssocTaskImplCmd *cmd);
+
+ /// Undo a command to associate an implementation with a
+ /// task instance in the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_AssocTaskImplCmd *cmd);
+
+ /// Execute a command to resolve a causal link threat in the
+ /// plan (with promotion or demotion).
+ /**
+ * @param cmd Command object.
+ */
+ virtual void execute (SA_ResolveCLThreatCmd *cmd);
+
+ /// Undo a command to resolve a causal link threat in the
+ /// plan (with promotion or demotion).
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_ResolveCLThreatCmd *cmd);
+
+ /// Execute a command to resolve a scheduling conflict (i.e.
+ /// non-causal-link ordering constraint with promotion or demotion)
+ /// between two task instances in the plan.
+ /**
+ * @param cmd Command object.
+ *
+ * @return Returns true if the new scheduling order is without any violations
+ */
+ virtual bool execute (SA_ResolveSchedOrderCmd *cmd);
+
+ /// Undo a command to resolve a scheduling conflict (i.e.
+ /// non-causal-link ordering constraint with promotion or demotion)
+ /// between two task instances in the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_ResolveSchedOrderCmd *cmd);
+
+ /// Execute a command to adjust the minimum times of a
+ /// task instance in the plan.
+ /**
+ * @param cmd Command object.
+ *
+ * @return Returns true if the adjustment succeeded without any violations
+ */
+ virtual bool execute (SA_AdjustMinTimesCmd *cmd);
+
+ /// Undo a command to adjust the minimum times of a
+ /// task instance in the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_AdjustMinTimesCmd *cmd);
+
+ /// Execute a command to adjust the maximum times of a
+ /// task instance in the plan.
+ /**
+ * @param cmd Command object.
+ *
+ * @return Returns true if the adjustment succeeded without any violations
+ */
+ virtual bool execute (SA_AdjustMaxTimesCmd *cmd);
+
+ /// Undo a command to adjust the maximum times of a
+ /// task instance in the plan.
+ /**
+ * @param cmd Command object.
+ */
+ virtual void undo (SA_AdjustMaxTimesCmd *cmd);
+
+ protected:
+ // ************************************************************************
+ // State information.
+ // ************************************************************************
+
+ /// Flag for whether command prototypes have been set.
+ bool has_cmds_;
+
+ /// Task instance ID to use for next instance created.
+ TaskInstID next_inst_id_;
+
+ typedef std::map <TaskInstID, TaskID> InstToTaskMap;
+ /// Task instances in plan (mapping to task id).
+ InstToTaskMap task_insts_;
+
+ /// Implementations of task instances in plan (mapping from task instance).
+ InstToImplMap task_impls_;
+
+ // Type of a map from conditions to causal links.
+ typedef std::multimap <Condition, CausalLink> CondToCLinksMap;
+
+ /// Causal links in plan (mapping from conditions to all causal links
+ /// containing that condition).
+ CondToCLinksMap causal_links_;
+
+ /// Current plan (generated upon request).
+ Plan plan_;
+
+ /// Helper function to create next instance id.
+ virtual TaskInstID get_next_inst_id (void);
+
+ /// Type of particular Task Implementation mapped to a Task Implementation Set.
+ /// This is a particular Precedence set. Like Before, After etc.
+ typedef std::map <TaskInstID, TaskInstSet> PrecedenceSet;
+
+ /// Type of a Precedence Relation mapped to a Precedence Set.
+ /// This gives the whole Precedence Graph
+ typedef std::map <PrecedenceRelation, PrecedenceSet> PrecedenceGraph;
+
+ /// PrecedenceGraph
+ PrecedenceGraph precedence_graph_;
+
+ /// Type of an ordering imposed during Scheduling.
+ /// First task instance is ordered before the second.
+ typedef std::multimap <TaskInstID, TaskInstID> SchedulingLinks;
+
+ /// Map of the imposed orderings
+ SchedulingLinks sched_links_;
+
+ /// Map from task instances to the time windows
+ typedef std::map <TaskInstID, TimeWindow> InstToWinMap;
+ typedef std::map <TaskInstID, TimeWindow> InstToWinMap;
+
+ /// InstToWinMap and InstToWinMap
+ InstToWinMap start_window_map_;
+ InstToWinMap end_window_map_;
+
+ /// Type of a map of task instances and the durations
+ typedef std::map <TaskInstID, TimeValue> DurationMap;
+
+ DurationMap durations;
+
+ // The initial start and end windows. There has to be something
+ // in this for every task instance be it {NULL_TIME,NULL_TIME}
+ InstToWinMap init_start;
+ InstToWinMap init_end;
+
+ // The set of reused task instances
+ std::multiset<TaskInstID> reused_insts;
+ /// Insert initially task by task in the precedence graph
+ /**
+ * @param task_inst The task instance to insert into the precedence graph
+ *
+ * @param cmd The task Command executing this
+ *
+ * @return True if this can be successfully added into the precedence graph
+ */
+ virtual bool init_prec_insert(TaskInstID task_inst, SA_AssocTaskImplCmd *cmd);
+
+/// prints the precedence graph
+ virtual void print_prec(void);
+
+ /// Erases a task instance from the precedence graph
+ /**
+ * @param task_instance The task instance to be erased
+ *
+ * @param cmd The task Command executing this
+ *
+ */
+ virtual void prec_erase(TaskInstID task_inst, SA_AssocTaskImplCmd *cmd);
+
+
+ // ************************************************************************
+ // Prototypes of commands that work on this object.
+ // ************************************************************************
+
+ /// PlanCommand prototype for adding a task to the plan.
+ SA_AddTaskCmd *add_task_cmd_;
+
+ /// PlanCommand prototype for associating an implementation with a
+ /// task instance in the plan.
+ SA_AssocTaskImplCmd *assoc_impl_cmd_;
+
+ /// PlanCommand prototype for resolving a causal link threat in the
+ /// plan (with promotion or demotion).
+ SA_ResolveCLThreatCmd *resolve_threat_cmd_;
+
+ /// PlanCommand prototype for resolving a scheduling conflict (i.e.
+ /// non-causal-link ordering constraint (with promotion or demotion)
+ /// between two task instances in the plan.
+ SA_ResolveSchedOrderCmd *resolve_sched_cmd_;
+
+ /// PlanCommand prototype for adjusting the minimum times of a
+ /// task instance in the plan.
+ SA_AdjustMinTimesCmd *adj_min_times_cmd_;
+
+ /// PlanCommand prototype for adjusting the maximum times of a
+ /// task instance in the plan.
+ SA_AdjustMaxTimesCmd *adj_max_times_cmd_;
+
+
+
+ // ************************************************************************
+ // Prototypes of commands that work on other objects.
+ // ************************************************************************
+
+ /// PlanCommand prototype for adding open causal link threats to be
+ /// handled.
+ AddOpenThreatsCmd *add_threats_cmd_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_SA_WORKING_PLAN_H_ */
diff --git a/SA_POP/SPACE.san.xml b/SA_POP/SPACE.san.xml
new file mode 100644
index 00000000000..1f512f0b569
--- /dev/null
+++ b/SA_POP/SPACE.san.xml
@@ -0,0 +1,357 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SANet:network
+ xmlns:SANet="http://www.vanderbilt.edu/SANet"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.vanderbilt.edu/SANet SANet_Network.xsd"
+ xmlns="http://www.vanderbilt.edu/SANet">
+
+ <defaultAttenFactor />
+ <defaultTaskCost />
+ <defaultCondUtil />
+ <defaultCondProbTrue />
+ <linkThresh />
+
+
+ <taskNode>
+ <nodeID>2221</nodeID>
+ <name>Gizmo1</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2222</nodeID>
+ <name>Gizmo2</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2223</nodeID>
+ <name>Gizmo3</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2231</nodeID>
+ <name>Filter_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2232</nodeID>
+ <name>Filter_G2_G3</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2233</nodeID>
+ <name>Compression_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2234</nodeID>
+ <name>Compression_G2_G3</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2235</nodeID>
+ <name>Comm_Ex_G1</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2236</nodeID>
+ <name>Comm_Ex_G2_G3</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2237</nodeID>
+ <name>Exec</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2241</nodeID>
+ <name>Ground_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2242</nodeID>
+ <name>Ground_G2_G3</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+
+
+
+
+ <condNode>
+ <nodeID>1121</nodeID>
+ <name>Gizmo1_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1122</nodeID>
+ <name>Gizmo2_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1123</nodeID>
+ <name>Gizmo3_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1131</nodeID>
+ <name>G1_Filter_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1132</nodeID>
+ <name>G2_G3_Filter_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1133</nodeID>
+ <name>G1_Comp_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1134</nodeID>
+ <name>G2_G3_Comp_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1135</nodeID>
+ <name>G1_Comm_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1136</nodeID>
+ <name>G2_G3_Comm_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1137</nodeID>
+ <name>Exec_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1141</nodeID>
+ <name>G1_Data_Recvd</name>
+ <probTrue>0</probTrue>
+ <utility>10</utility>
+ <kind />
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1142</nodeID>
+ <name>G2_G3_Data_Recvd</name>
+ <probTrue>0</probTrue>
+ <utility>10</utility>
+ <kind />
+ <attenFactor />
+ </condNode>
+
+
+
+
+ <precondLink>
+ <condID>1121</condID>
+ <taskID>2231</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1122</condID>
+ <taskID>2232</taskID>
+ <portID>recv_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1123</condID>
+ <taskID>2232</taskID>
+ <portID>recv_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1131</condID>
+ <taskID>2233</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1132</condID>
+ <taskID>2234</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1133</condID>
+ <taskID>2235</taskID>
+ <portID>science_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1134</condID>
+ <taskID>2236</taskID>
+ <portID>science_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1137</condID>
+ <taskID>2235</taskID>
+ <portID>recv_command</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1137</condID>
+ <taskID>2236</taskID>
+ <portID>recv_command</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1135</condID>
+ <taskID>2241</taskID>
+ <portID>recv_transmission</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1136</condID>
+ <taskID>2242</taskID>
+ <portID>recv_transmission</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+
+
+
+
+ <effectLink>
+ <taskID>2221</taskID>
+ <condID>1121</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2222</taskID>
+ <condID>1122</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2223</taskID>
+ <condID>1123</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2231</taskID>
+ <condID>1131</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2232</taskID>
+ <condID>1132</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2233</taskID>
+ <condID>1133</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2234</taskID>
+ <condID>1134</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2235</taskID>
+ <condID>1135</condID>
+ <portID>transmit_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2236</taskID>
+ <condID>1136</condID>
+ <portID>transmit_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2237</taskID>
+ <condID>1137</condID>
+ <portID>send_command</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2241</taskID>
+ <condID>1141</condID>
+ <portID>NONE</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2242</taskID>
+ <condID>1142</condID>
+ <portID>NONE</portID>
+ <weight>1.0</weight>
+ </effectLink>
+
+</SANet:network> \ No newline at end of file
diff --git a/SA_POP/SPACE.tm.xml b/SA_POP/SPACE.tm.xml
new file mode 100644
index 00000000000..96cded96543
--- /dev/null
+++ b/SA_POP/SPACE.tm.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SA-POP:taskMap
+ xmlns:SA-POP="http://www.vanderbilt.edu/SA-POP"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.vanderbilt.edu/SA-POP Task_Map.xsd"
+ xmlns="http://www.vanderbilt.edu/SA-POP">
+
+
+
+ <taskImpl>
+ <implID>IDL:SPACE/Ground_Station:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Compression_Component:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Comm_Component:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Backup_Gizmo_High:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Backup_Gizmo_Low:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+ <taskImpl>
+ <implID>IDL:SPACE/Primary_Gizmo:1.0</implID>
+ <param>
+ <paramID></paramID>
+ <kind></kind>
+ <value></value>
+ </param>
+ </taskImpl>
+
+
+
+ <resource>
+ <resourceID>Memory</resourceID>
+ <kind>DISCRETE</kind>
+ <capacity>512</capacity>
+ </resource>
+ <resource>
+ <resourceID>CPU</resourceID>
+ <kind>DISCRETE</kind>
+ <capacity />
+ </resource>
+
+
+ <taskToImpl>
+ <taskID>2241</taskID>
+ <implID>IDL:SPACE/Ground_Station:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2242</taskID>
+ <implID>IDL:SPACE/Ground_Station:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2237</taskID>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2231</taskID>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2232</taskID>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2233</taskID>
+ <implID>IDL:SPACE/Compression_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2234</taskID>
+ <implID>IDL:SPACE/Compression_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2235</taskID>
+ <implID>IDL:SPACE/Comm_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2236</taskID>
+ <implID>IDL:SPACE/Comm_Component:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2223</taskID>
+ <implID>IDL:SPACE/Backup_Gizmo_High:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2222</taskID>
+ <implID>IDL:SPACE/Backup_Gizmo_Low:1.0</implID>
+ <duration />
+ </taskToImpl>
+ <taskToImpl>
+ <taskID>2221</taskID>
+ <implID>IDL:SPACE/Primary_Gizmo:1.0</implID>
+ <duration />
+ </taskToImpl>
+
+
+
+
+ <implToResource>
+ <implID>IDL:SPACE/Ground_Station:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Exec_Component:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Compression_Component:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Comm_Component:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Backup_Gizmo_High:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Backup_Gizmo_Low:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+ <implToResource>
+ <implID>IDL:SPACE/Primary_Gizmo:1.0</implID>
+ <resourceID>CPU</resourceID>
+ <utilization>5</utilization>
+ </implToResource>
+
+</SA-POP:taskMap> \ No newline at end of file
diff --git a/SA_POP/SPACE_Goal1.san.xml b/SA_POP/SPACE_Goal1.san.xml
new file mode 100644
index 00000000000..6f1a8865b84
--- /dev/null
+++ b/SA_POP/SPACE_Goal1.san.xml
@@ -0,0 +1,357 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SANet:network
+ xmlns:SANet="http://www.vanderbilt.edu/SANet"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.vanderbilt.edu/SANet SANet_Network.xsd"
+ xmlns="http://www.vanderbilt.edu/SANet">
+
+ <defaultAttenFactor />
+ <defaultTaskCost />
+ <defaultCondUtil />
+ <defaultCondProbTrue />
+ <linkThresh />
+
+
+ <taskNode>
+ <nodeID>2221</nodeID>
+ <name>Gizmo1</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2222</nodeID>
+ <name>Gizmo2</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2223</nodeID>
+ <name>Gizmo3</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2231</nodeID>
+ <name>Filter_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2232</nodeID>
+ <name>Filter_G2_G3</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2233</nodeID>
+ <name>Compression_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2234</nodeID>
+ <name>Compression_G2_G3</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2235</nodeID>
+ <name>Comm_Ex_G1</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2236</nodeID>
+ <name>Comm_Ex_G2_G3</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2237</nodeID>
+ <name>Exec</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2241</nodeID>
+ <name>Ground_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2242</nodeID>
+ <name>Ground_G2_G3</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+
+
+
+
+ <condNode>
+ <nodeID>1121</nodeID>
+ <name>Gizmo1_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1122</nodeID>
+ <name>Gizmo2_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1123</nodeID>
+ <name>Gizmo3_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1131</nodeID>
+ <name>G1_Filter_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1132</nodeID>
+ <name>G2_G3_Filter_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1133</nodeID>
+ <name>G1_Comp_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1134</nodeID>
+ <name>G2_G3_Comp_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1135</nodeID>
+ <name>G1_Comm_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1136</nodeID>
+ <name>G2_G3_Comm_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1137</nodeID>
+ <name>Exec_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1141</nodeID>
+ <name>G1_Data_Recvd</name>
+ <probTrue>0</probTrue>
+ <utility>10</utility>
+ <kind />
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1142</nodeID>
+ <name>G2_G3_Data_Recvd</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind />
+ <attenFactor />
+ </condNode>
+
+
+
+
+ <precondLink>
+ <condID>1121</condID>
+ <taskID>2231</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1122</condID>
+ <taskID>2232</taskID>
+ <portID>recv_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1123</condID>
+ <taskID>2232</taskID>
+ <portID>recv_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1131</condID>
+ <taskID>2233</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1132</condID>
+ <taskID>2234</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1133</condID>
+ <taskID>2235</taskID>
+ <portID>science_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1134</condID>
+ <taskID>2236</taskID>
+ <portID>science_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1137</condID>
+ <taskID>2235</taskID>
+ <portID>recv_command</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1137</condID>
+ <taskID>2236</taskID>
+ <portID>recv_command</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1135</condID>
+ <taskID>2241</taskID>
+ <portID>recv_transmission</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1136</condID>
+ <taskID>2242</taskID>
+ <portID>recv_transmission</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+
+
+
+
+ <effectLink>
+ <taskID>2221</taskID>
+ <condID>1121</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2222</taskID>
+ <condID>1122</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2223</taskID>
+ <condID>1123</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2231</taskID>
+ <condID>1131</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2232</taskID>
+ <condID>1132</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2233</taskID>
+ <condID>1133</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2234</taskID>
+ <condID>1134</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2235</taskID>
+ <condID>1135</condID>
+ <portID>transmit_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2236</taskID>
+ <condID>1136</condID>
+ <portID>transmit_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2237</taskID>
+ <condID>1137</condID>
+ <portID>send_command</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2241</taskID>
+ <condID>1141</condID>
+ <portID>NONE</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2242</taskID>
+ <condID>1142</condID>
+ <portID>NONE</portID>
+ <weight>1.0</weight>
+ </effectLink>
+
+</SANet:network> \ No newline at end of file
diff --git a/SA_POP/SPACE_Goal2.san.xml b/SA_POP/SPACE_Goal2.san.xml
new file mode 100644
index 00000000000..e91b6e2df99
--- /dev/null
+++ b/SA_POP/SPACE_Goal2.san.xml
@@ -0,0 +1,357 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SANet:network
+ xmlns:SANet="http://www.vanderbilt.edu/SANet"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.vanderbilt.edu/SANet SANet_Network.xsd"
+ xmlns="http://www.vanderbilt.edu/SANet">
+
+ <defaultAttenFactor />
+ <defaultTaskCost />
+ <defaultCondUtil />
+ <defaultCondProbTrue />
+ <linkThresh />
+
+
+ <taskNode>
+ <nodeID>2221</nodeID>
+ <name>Gizmo1</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2222</nodeID>
+ <name>Gizmo2</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2223</nodeID>
+ <name>Gizmo3</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2231</nodeID>
+ <name>Filter_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2232</nodeID>
+ <name>Filter_G2_G3</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2233</nodeID>
+ <name>Compression_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2234</nodeID>
+ <name>Compression_G2_G3</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2235</nodeID>
+ <name>Comm_Ex_G1</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2236</nodeID>
+ <name>Comm_Ex_G2_G3</name>
+ <priorProb>0.25</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2237</nodeID>
+ <name>Exec</name>
+ <priorProb>1.0</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2241</nodeID>
+ <name>Ground_G1</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+ <taskNode>
+ <nodeID>2242</nodeID>
+ <name>Ground_G2_G3</name>
+ <priorProb>0.5</priorProb>
+ <attenFactor />
+ <cost />
+ </taskNode>
+
+
+
+
+ <condNode>
+ <nodeID>1121</nodeID>
+ <name>Gizmo1_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1122</nodeID>
+ <name>Gizmo2_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1123</nodeID>
+ <name>Gizmo3_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1131</nodeID>
+ <name>G1_Filter_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1132</nodeID>
+ <name>G2_G3_Filter_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1133</nodeID>
+ <name>G1_Comp_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1134</nodeID>
+ <name>G2_G3_Comp_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1135</nodeID>
+ <name>G1_Comm_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1136</nodeID>
+ <name>G2_G3_Comm_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1137</nodeID>
+ <name>Exec_Data</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind>DATA</kind>
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1141</nodeID>
+ <name>G1_Data_Recvd</name>
+ <probTrue>0</probTrue>
+ <utility>0</utility>
+ <kind />
+ <attenFactor />
+ </condNode>
+ <condNode>
+ <nodeID>1142</nodeID>
+ <name>G2_G3_Data_Recvd</name>
+ <probTrue>0</probTrue>
+ <utility>10</utility>
+ <kind />
+ <attenFactor />
+ </condNode>
+
+
+
+
+ <precondLink>
+ <condID>1121</condID>
+ <taskID>2231</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1122</condID>
+ <taskID>2232</taskID>
+ <portID>recv_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1123</condID>
+ <taskID>2232</taskID>
+ <portID>recv_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1131</condID>
+ <taskID>2233</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1132</condID>
+ <taskID>2234</taskID>
+ <portID>recv_data</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1133</condID>
+ <taskID>2235</taskID>
+ <portID>science_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1134</condID>
+ <taskID>2236</taskID>
+ <portID>science_data</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1137</condID>
+ <taskID>2235</taskID>
+ <portID>recv_command</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1137</condID>
+ <taskID>2236</taskID>
+ <portID>recv_command</portID>
+ <trueProb>0.5</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1135</condID>
+ <taskID>2241</taskID>
+ <portID>recv_transmission</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+ <precondLink>
+ <condID>1136</condID>
+ <taskID>2242</taskID>
+ <portID>recv_transmission</portID>
+ <trueProb>1.0</trueProb>
+ <falseProb>0</falseProb>
+ </precondLink>
+
+
+
+
+ <effectLink>
+ <taskID>2221</taskID>
+ <condID>1121</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2222</taskID>
+ <condID>1122</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2223</taskID>
+ <condID>1123</condID>
+ <portID>observation_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2231</taskID>
+ <condID>1131</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2232</taskID>
+ <condID>1132</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2233</taskID>
+ <condID>1133</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2234</taskID>
+ <condID>1134</condID>
+ <portID>send_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2235</taskID>
+ <condID>1135</condID>
+ <portID>transmit_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2236</taskID>
+ <condID>1136</condID>
+ <portID>transmit_data</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2237</taskID>
+ <condID>1137</condID>
+ <portID>send_command</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2241</taskID>
+ <condID>1141</condID>
+ <portID>NONE</portID>
+ <weight>1.0</weight>
+ </effectLink>
+ <effectLink>
+ <taskID>2242</taskID>
+ <condID>1142</condID>
+ <portID>NONE</portID>
+ <weight>1.0</weight>
+ </effectLink>
+
+</SANet:network> \ No newline at end of file
diff --git a/SA_POP/SchedStrategy.h b/SA_POP/SchedStrategy.h
new file mode 100644
index 00000000000..962be086889
--- /dev/null
+++ b/SA_POP/SchedStrategy.h
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file SchedStrategy.h
+ *
+ * This file contains the SchedStrategy abstract base class definition for
+ * the high-level scheduling algorithm.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_SCHED_STRATEGY_H_
+#define SA_POP_SCHED_STRATEGY_H_
+
+#include "SA_POP_Types.h"
+
+namespace SA_POP {
+
+ // Forward declaration of Planner.
+ class Planner;
+
+ /**
+ * @class SchedStrategy
+ *
+ * @brief Abstract base class for the high-level scheduling algorithm.
+ */
+ class SchedStrategy {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ SchedStrategy (SA_POP::Planner *planner)
+ : planner_ (planner) { };
+
+ /// Destructor.
+ virtual ~SchedStrategy (void) { };
+
+ /// Recursively satisfy all scheduling constraints (and continue
+ /// satisfaction of open conditions by recursive call back to planning).
+ /**
+ * @param task_inst Current task instance being tried in the plan.
+ *
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool satisfy_sched (TaskInstID task_inst) = 0;
+
+ /// Satisfy fully instantiated plan.
+ /**
+ * @param task_inst Current task instance being tried in the plan.
+ *
+ * @return True if fully satisfied plan found, false otherwise.
+ */
+ virtual bool satisfy_full_sched () = 0;
+
+ protected:
+ /// Pointer to Planner object.
+ SA_POP::Planner *planner_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_SCHED_STRATEGY_H_ */
diff --git a/SA_POP/TaskImpl.cpp b/SA_POP/TaskImpl.cpp
new file mode 100644
index 00000000000..cdc72f878c2
--- /dev/null
+++ b/SA_POP/TaskImpl.cpp
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file TaskImpl.cpp
+ *
+ * This file contains the TaskImpl class implementation for the encapsulation
+ * of a task implementation's details.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "TaskImpl.h"
+
+using namespace SA_POP;
+
+// Constructor.
+TaskImpl::TaskImpl (TaskImplID id, const ImplParamSet &params)
+: id_ (id),
+ params_ (params),
+ duration_ (NULL_TIME)
+
+{
+ this->resources_.clear ();
+};
+
+// Destructor.
+TaskImpl::~TaskImpl (void)
+{
+ // Nothing to do.
+};
+
+// Set duration.
+void TaskImpl::set_duration (TimeValue duration)
+{
+ this->duration_ = duration;
+};
+// Get duration.
+TimeValue TaskImpl::get_duration (void)
+{
+ return this->duration_;
+};
+
+// Add resource utilization.
+void TaskImpl::add_resource (ResourceID id, ResourceValue value)
+{
+ this->resources_.insert (std::make_pair (id, value));
+};
+
+// Get task implementation id.
+TaskImplID TaskImpl::get_id (void)
+{
+ return this->id_;
+};
+
+// Get task implementation parameters.
+ImplParamSet TaskImpl::get_params (void)
+{
+ return this->params_;
+};
+
+// Get utilization of a resource.
+ResourceValue TaskImpl::get_resource_usage (ResourceID resource_id)
+{
+ ResourceMap::iterator iter = this->resources_.find (resource_id);
+ if (iter == this->resources_.end ())
+ return 0;
+
+ return iter->second;
+};
+
+// Get all resources with utilization.
+const ResourceMap& TaskImpl::get_all_resources ()
+{
+ return this->resources_;
+};
+
diff --git a/SA_POP/TaskImpl.h b/SA_POP/TaskImpl.h
new file mode 100644
index 00000000000..aac61ef3d94
--- /dev/null
+++ b/SA_POP/TaskImpl.h
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file TaskImpl.h
+ *
+ * This file contains the TaskImpl class definition for the encapsulation
+ * of a task implementation's details.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_TASK_IMPL_H_
+#define SA_POP_TASK_IMPL_H_
+
+#include "SA_POP_Types.h"
+
+namespace SA_POP {
+
+ /**
+ * @class TaskImpl
+ *
+ * @brief Encapsulation of a task implementation's details.
+ */
+ class TaskImpl {
+ public:
+ /// Constructor.
+ /**
+ * @param id Unique ID of this task implementation.
+ *
+ * @param params Implementation parameters (ID, kind, and value).
+ */
+ TaskImpl (TaskImplID id, const ImplParamSet &params);
+
+ /// Destructor.
+ virtual ~TaskImpl (void);
+
+ /// Set duration.
+ /**
+ * @param duration Duration of implementation.
+ */
+ virtual void set_duration (TimeValue duration);
+ /// Get duration.
+ /**
+ * @return Duration of implementation.
+ */
+ virtual TimeValue get_duration (void);
+
+ /// Add resource utilization.
+ /**
+ * @param id Resource id.
+ *
+ * @param value Resource utilization value.
+ */
+ virtual void add_resource (ResourceID id, ResourceValue value);
+
+ /// Get task implementation id.
+ /**
+ * @return Unique ID of this this task implementation.
+ */
+ virtual TaskImplID get_id (void);
+
+ /// Get task implementation parameters.
+ /**
+ * @return Set of parameters for this implementation.
+ */
+ virtual ImplParamSet get_params (void);
+
+ /// Get utilization of a resource.
+ /**
+ * @param resource_id The resource id.
+ *
+ * @return The quantity of resource used.
+ */
+ virtual ResourceValue get_resource_usage (ResourceID resource_id);
+
+ /// Get all resources with utilization.
+ /**
+ * @return The set of all resources used (with associated usage values).
+ */
+ virtual const ResourceMap& get_all_resources ();
+
+ protected:
+ /// Unique ID of the task implementation.
+ TaskImplID id_;
+
+ /// Set of parameters.
+ ImplParamSet params_;
+
+ /// Duration.
+ TimeValue duration_;
+
+ /// Map from resource IDs to resource utilization.
+ ResourceMap resources_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_TASK_IMPL_H_ */
diff --git a/SA_POP/TaskMap.cpp b/SA_POP/TaskMap.cpp
new file mode 100644
index 00000000000..96bfde39989
--- /dev/null
+++ b/SA_POP/TaskMap.cpp
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file TaskMap.cpp
+ *
+ * This file contains the TaskMap class implementation for objects that provide
+ * the mapping from tasks to parameterized components, resource capacities, and
+ * resource usage for parameterized components.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include <set>
+#include <map>
+#include "SA_POP_Types.h"
+#include "TaskMap.h"
+#include "TaskImpl.h"
+
+using namespace SA_POP;
+
+// Constructor.
+TaskMap::TaskMap (void)
+{
+ this->task_impls_.clear ();
+ this->task_to_impls_.clear ();
+ this->resources_.clear ();
+};
+
+// Destructor.
+TaskMap::~TaskMap (void)
+{
+ // Delete task implementations.
+ for (TaskMap::ImplIDObjMap::iterator iter = this->task_impls_.begin ();
+ iter != this->task_impls_.end (); iter++)
+ {
+ delete iter->second;
+ }
+};
+
+// Add a resource.
+void TaskMap::add_resource (Resource resource)
+{
+ this->resources_.insert (std::make_pair (resource.id, resource));
+};
+
+// Add an implementation.
+void TaskMap::add_task_impl (TaskImpl *task_impl)
+{
+ this->task_impls_.insert (std::make_pair (task_impl->get_id (), task_impl));
+};
+
+// Associate a task with a task implementation.
+void TaskMap::assoc_task_with_impl (TaskID task_id, TaskImplID task_impl_id,
+ TimeValue duration)
+{
+ this->task_to_impls_.insert (std::make_pair (task_id, task_impl_id));
+ ImplIDObjMap::iterator iter = this->task_impls_.find (task_impl_id);
+ if (iter == this->task_impls_.end ())
+ throw "SA_POP::TaskMap::assoc_task_with_impl (): Unknown implementation ID.";
+ iter->second->set_duration (duration);
+};
+
+// Associate a task implementation with its utilization of a resource.
+void TaskMap::assoc_impl_with_resource (TaskImplID impl_id,
+ ResourceID resource_id, ResourceValue resource_usage)
+{
+ ImplIDObjMap::iterator iter = this->task_impls_.find (impl_id);
+ if (iter == this->task_impls_.end ())
+ throw "SA_POP::TaskMap::assoc_impl_with_resource (): Unknown implementation ID.";
+ iter->second->add_resource (resource_id, resource_usage);
+};
+
+// Get all implementations of a task.
+TaskImplSet TaskMap::get_all_impls (TaskID task_id)
+{
+ TaskImplSet temp;
+ temp.clear ();
+ for (TaskMap::TaskToImplMap::iterator iter =
+ this->task_to_impls_.lower_bound (task_id);
+ iter != this->task_to_impls_.upper_bound (task_id); iter++)
+ {
+ temp.insert (iter->second);
+ }
+ return temp;
+};
+
+// Get task implementation.
+TaskImpl *TaskMap::get_impl (TaskImplID impl_id)
+{
+ ImplIDObjMap::iterator iter = this->task_impls_.find (impl_id);
+ if (iter == this->task_impls_.end ())
+ throw "SA_POP::TaskMap::get_impl (): Unknown implementation ID.";
+ return iter->second;
+};
+
+// Get utilization info of a task implementation for a resource.
+ResourceValue TaskMap::get_resource_usage (TaskImplID impl_id,
+ ResourceID resource_id)
+{
+ ImplIDObjMap::iterator iter = this->task_impls_.find (impl_id);
+ if (iter == this->task_impls_.end ())
+ throw "SA_POP::TaskMap::get_resource_usage (): Unknown implementation ID.";
+ return iter->second->get_resource_usage (resource_id);
+};
+
+// Get all resources used by a task implementation.
+ResourceMap TaskMap::get_all_resources (TaskImplID impl_id)
+{
+ ImplIDObjMap::iterator iter = this->task_impls_.find (impl_id);
+ if (iter == this->task_impls_.end ())
+ throw "SA_POP::TaskMap::get_all_resources (): Unknown implementation ID.";
+ return iter->second->get_all_resources ();
+};
+
+/// Get the capacity of a resource.
+ResourceValue TaskMap::get_capacity (ResourceID res_id)
+{
+ return this->resources_.find(res_id)->second.capacity;
+}
diff --git a/SA_POP/TaskMap.h b/SA_POP/TaskMap.h
new file mode 100644
index 00000000000..807f9759de3
--- /dev/null
+++ b/SA_POP/TaskMap.h
@@ -0,0 +1,147 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file TaskMap.h
+ *
+ * This file contains the TaskMap class definition for objects that provide
+ * the mapping from tasks to parameterized components, resource capacities, and
+ * resource usage for parameterized components.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_TASK_MAP_H_
+#define SA_POP_TASK_MAP_H_
+
+#include <set>
+#include <map>
+#include "SA_POP_Types.h"
+#include "TaskImpl.h"
+
+namespace SA_POP {
+
+
+ /**
+ * @class TaskMap
+ *
+ * @brief Object that provides the mapping from tasks to parameterized
+ * components, resource capacities, and resource usage for
+ * parameterized components.
+ */
+ class TaskMap {
+ public:
+ /// Constructor.
+ TaskMap (void);
+
+ /// Destructor.
+ virtual ~TaskMap (void);
+
+
+
+ // ************************************************************************
+ // TaskMap construction methods.
+ // ************************************************************************
+
+ /// Add a resource.
+ /**
+ * @param resource The resource info.
+ */
+ virtual void add_resource (Resource resource);
+
+ /// Add an implementation.
+ /**
+ * @param task_impl The task implementation info.
+ */
+ virtual void add_task_impl (TaskImpl *task_impl);
+
+ /// Associate a task with a task implementation.
+ /**
+ * @param task_id ID of the task.
+ *
+ * @param task_impl_id ID of the task implementation.
+ *
+ * @param duration The duration of the task implementation for this task.
+ */
+ virtual void assoc_task_with_impl (TaskID task_id, TaskImplID task_impl_id,
+ TimeValue duration);
+
+ /// Associate a task implementation with its utilization of a resource.
+ /**
+ * @param impl_id ID of the task implementation.
+ *
+ * @param resource_id ID of the associated resource.
+ *
+ * @param resource_usage The quantity of resource used.
+ */
+ virtual void assoc_impl_with_resource (TaskImplID impl_id,
+ ResourceID resource_id, ResourceValue resource_usage);
+
+
+
+ // ************************************************************************
+ // Implementation and resource accessor methods.
+ // ************************************************************************
+
+ /// Get all implementations of a task.
+ /**
+ * @param task_id The task id.
+ *
+ * @return The set of all implementations (ids) for the given task.
+ */
+ virtual TaskImplSet get_all_impls (TaskID task_id);
+
+ /// Get task implementation.
+ /**
+ * @param impl_id The task implementation id.
+ *
+ * @return Reference to the task implementation.
+ */
+ virtual TaskImpl *get_impl (TaskImplID impl_id);
+
+ /// Get utilization info of a task implementation for a resource.
+ /**
+ * @param impl_id The task implementation id.
+ *
+ * @param resource_id The resource id.
+ *
+ * @return The quantity of resource used.
+ */
+ virtual ResourceValue get_resource_usage (TaskImplID impl_id,
+ ResourceID resource_id);
+
+ /// Get all resources used by a task implementation.
+ /**
+ * @param impl_id The task implementation id.
+ *
+ * @return The set of all resources used (with associated usage values).
+ */
+ virtual ResourceMap get_all_resources (TaskImplID impl_id);
+
+ /// Get the capacity of a resource.
+ /**
+ * @param res_id The resource id whose capacity that we want to get.
+ *
+ * @return The capacity of the resource
+ */
+ virtual ResourceValue get_capacity (ResourceID res_id);
+
+ protected:
+ /// Map from task implementation IDs to objects.
+ typedef std::map <TaskImplID, TaskImpl *> ImplIDObjMap;
+ ImplIDObjMap task_impls_;
+
+ /// Map from tasks to task implementations.
+ typedef std::multimap <TaskID, TaskImplID> TaskToImplMap;
+ TaskToImplMap task_to_impls_;
+
+ /// Set of resources and associated capacity.
+ Resources resources_;
+
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_TASK_MAP_H_ */
diff --git a/SA_POP/TaskMapFileIn.cpp b/SA_POP/TaskMapFileIn.cpp
new file mode 100644
index 00000000000..076dab26587
--- /dev/null
+++ b/SA_POP/TaskMapFileIn.cpp
@@ -0,0 +1,173 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file TaskMapFileIn.cpp
+ *
+ * This file contains the TaskMapFileIn class implementation for the input adapter
+ * that initializes a TaskMap object using an XML TaskMap file.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#include "SA_POP_Types.h"
+#include "TaskMapFileIn.h"
+#include "Builder.h"
+#include "Utils/XML_Helper.h"
+#include "XML_TaskMap.hpp"
+
+using namespace SA_POP;
+
+// Constructor.
+TaskMapFileIn::TaskMapFileIn (void)
+{
+ // Nothing to do.
+};
+
+// Destructor.
+TaskMapFileIn::~TaskMapFileIn (void)
+{
+ // Nothing to do.
+};
+
+// Build task map from XML file.
+void TaskMapFileIn::build_task_map (std::string filename, Builder *builder)
+{
+ CIAO::Config_Handlers::XML_Helper helper;
+ if (!helper.is_initialized ())
+ throw "SA_POP::TaskMapFileIn::build_task_map (): Could not initialize XML_Helper";
+
+ // Parse file with Xerces.
+ XERCES_CPP_NAMESPACE::DOMDocument *dom =
+#if defined (SA_POP_HAS_CIAO)
+ helper.create_dom (filename.c_str ());
+#else
+ helper.create_dom (filename.c_str (), "");
+#endif /* SA_POP_HAS_CIAO */
+ if (!dom)
+ throw "SA_POP::TaskMapFileIn::build_task_map (): Could not create Xerces DOMDocument from file";
+
+ SA_POP::XML::TaskMap xml_tm = SA_POP::XML::taskMap (dom);
+
+ // Get task implementations.
+ for (SA_POP::XML::TaskMap::taskImpl_iterator impl_iter =
+ xml_tm.begin_taskImpl ();
+ impl_iter != xml_tm.end_taskImpl (); impl_iter++)
+ {
+ // Get implementation ID.
+ char implID[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (implID, (*impl_iter).implID ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get implementation parameters.
+ ImplParamSet params;
+ params.clear ();
+ for (SA_POP::XML::TaskImpl::param_iterator param_iter =
+ (*impl_iter).begin_param ();
+ param_iter != (*impl_iter).end_param (); param_iter++)
+ {
+ // Get parameter ID.
+ char paramID[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (paramID, (*param_iter).paramID ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get parameter kind.
+ char kind[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (kind, (*param_iter).kind ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get parameter value.
+ char value[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (value, (*param_iter).value ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Add parameter to implementation parameter set.
+ ImplParam param;
+ param.id = paramID;
+ param.kind = kind;
+ param.value = value;
+ params.insert (param);
+ }
+
+ // Add task implementation.
+ TaskImpl *impl = new TaskImpl (implID, params);
+ builder->add_task_impl (impl);
+ }
+
+ // Get resources.
+ for (SA_POP::XML::TaskMap::resource_iterator res_iter =
+ xml_tm.begin_resource ();
+ res_iter != xml_tm.end_resource (); res_iter++)
+ {
+ // Get resource ID.
+ char resourceID[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (resourceID, (*res_iter).resourceID ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get resource kind.
+ SA_POP::ResourceKind kind;
+ if ((*res_iter).kind () == SA_POP::XML::ResourceKind::DISCRETE)
+ kind = SA_POP::DISCRETE;
+ else if ((*res_iter).kind () == SA_POP::XML::ResourceKind::RESERVOIR)
+ kind = SA_POP::RESERVOIR;
+ else if ((*res_iter).kind () == SA_POP::XML::ResourceKind::UNARY)
+ kind = SA_POP::UNARY;
+ else
+ kind = SA_POP::DISCRETE;
+
+ // Get resource capacity.
+ ResourceValue capacity = (*res_iter).capacity ();
+
+ // Add resource.
+ Resource resource;
+ resource.id = resourceID;
+ resource.kind = kind;
+ resource.capacity = capacity;
+
+ builder->add_resource (resource);
+ }
+
+ // Get task to implementation associations.
+ for (SA_POP::XML::TaskMap::taskToImpl_iterator tassoci_iter =
+ xml_tm.begin_taskToImpl ();
+ tassoci_iter != xml_tm.end_taskToImpl (); tassoci_iter++)
+ {
+ // Get task ID.
+ TaskID taskID = (*tassoci_iter).taskID ();
+
+ // Get impl ID.
+ char implID[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (implID, (*tassoci_iter).implID ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get duration.
+ TimeValue duration = (*tassoci_iter).duration ();
+
+ // Add association.
+ builder->assoc_task_with_impl (taskID, implID, duration);
+ }
+
+ // Get task implementation to resource associations.
+ for (SA_POP::XML::TaskMap::implToResource_iterator iassocr_iter =
+ xml_tm.begin_implToResource ();
+ iassocr_iter != xml_tm.end_implToResource (); iassocr_iter++)
+ {
+ // Get impl ID.
+ char implID[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (implID, (*iassocr_iter).implID ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get resource ID.
+ char resourceID[SA_POP::TaskMapFileIn::STR_BUF_SIZE];
+ wcstombs (resourceID, (*iassocr_iter).resourceID ().c_str (),
+ SA_POP::TaskMapFileIn::STR_BUF_SIZE);
+
+ // Get duration.
+ ResourceValue utilization = (*iassocr_iter).utilization ();
+
+ // Add association.
+ builder->assoc_impl_with_resource (implID, resourceID, utilization);
+ }
+};
diff --git a/SA_POP/TaskMapFileIn.h b/SA_POP/TaskMapFileIn.h
new file mode 100644
index 00000000000..4b962f20955
--- /dev/null
+++ b/SA_POP/TaskMapFileIn.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file TaskMapFileIn.h
+ *
+ * This file contains the TaskMapFileIn class definition for the input adapter
+ * that initializes a TaskMap object using an XML TaskMap file.
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_TASK_MAP_FILE_IN_H_
+#define SA_POP_TASK_MAP_FILE_IN_H_
+
+#include "SA_POP_Types.h"
+#include "Builder.h"
+
+
+namespace SA_POP {
+
+ /**
+ * @class TaskMapFileIn
+ *
+ * @brief Input adapter that initializes a TaskMap object using an XML
+ * TaskMap file.
+ */
+ class TaskMapFileIn {
+ public:
+ /// Constructor.
+ TaskMapFileIn (void);
+
+ /// Destructor.
+ virtual ~TaskMapFileIn (void);
+
+ /// Buffer size for string conversion.
+ static const size_t STR_BUF_SIZE = 129;
+
+ /// Build task map from XML file.
+ /**
+ * @param filename Name of XML task map file.
+ *
+ * @param builder SA-POP builder to use in building task map.
+ */
+ virtual void build_task_map (std::string filename, Builder *builder);
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_TASK_MAP_FILE_IN_H_ */
diff --git a/SA_POP/WorkingPlan.h b/SA_POP/WorkingPlan.h
new file mode 100644
index 00000000000..48fe05a0540
--- /dev/null
+++ b/SA_POP/WorkingPlan.h
@@ -0,0 +1,192 @@
+// -*- C++ -*-
+// $Id$
+
+//=============================================================================
+/**
+ * @file WorkingPlan.h
+ *
+ * This file contains the WorkingPlan abstract base class definition for the
+ * encapsulation of a plan (partial or complete).
+ *
+ * @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SA_POP_WORKING_PLAN_H_
+#define SA_POP_WORKING_PLAN_H_
+
+#include "SA_POP_Types.h"
+#include "PlanCommands.h"
+
+namespace SA_POP {
+
+ // Forward declaration of Planner.
+ class Planner;
+
+ /**
+ * @class WorkingPlan
+ *
+ * @brief Abstract base class for the encapsulation of a plan (partial or
+ * complete).
+ */
+ class WorkingPlan {
+ public:
+ /// Constructor.
+ /**
+ * @param planner Planner object to use.
+ */
+ WorkingPlan (SA_POP::Planner *planner)
+ : planner_ (planner) { };
+
+ /// Destructor.
+ virtual ~WorkingPlan (void) { };
+
+ /// Get current plan.
+ /**
+ * @return Reference to current plan.
+ */
+ virtual const Plan& get_plan (void) = 0;
+
+ /// Get set of task instances for a precedence relation to a task instance.
+ /**
+ * @param task_inst Task instance for which to get precedence set.
+ *
+ * @param prec_rel Precedence relation.
+ *
+ * @return Set of task instances for given precedence relation to given
+ * task instance.
+ */
+ virtual const TaskInstSet *get_prec_set (TaskInstID task_inst,
+ PrecedenceRelation prec_rel) = 0;
+
+ /// Get task id of a task instance.
+ /**
+ * @param inst_id The task instance id.
+ *
+ * @return The task id of this task instance.
+ */
+ virtual TaskID get_task_from_inst (TaskInstID inst_id) = 0;
+
+ /// Get task implementation id of a task instance.
+ /**
+ * @param inst_id The task instance id.
+ *
+ * @return The task implementation id of this task instance.
+ */
+ virtual TaskImplID get_task_impl_from_inst (TaskInstID inst_id) = 0;
+
+ /// Get all current causal link threats.
+ /**
+ * @return Set of all current causal link threats.
+ */
+ virtual CLThreatSet get_all_threats (void) = 0;
+
+ //Get the Start Window for a task instance
+ /**
+ * @param task_inst The task instance of which the start window is returned
+ *
+ * @return The start window for the task instance
+ */
+ virtual TimeWindow get_start_window(TaskInstID task_inst) = 0;
+
+ //Get the End Window for a task instance
+ /**
+ * @param task_inst The task instance of which the end window is returned
+ *
+ * @return The end window for the task instance
+ */
+ virtual TimeWindow get_end_window(TaskInstID task_inst) = 0;
+
+ //Get the duration of a task instance
+ /**
+ * @param task_inst The task instance of which the duration is returned
+ *
+ * @return The duration of the task instance
+ */
+ virtual TimeValue get_duration(TaskInstID task_inst) = 0;
+
+ /// Get the Causal and Scheduling orderings to this task instance
+ /**
+ * @param inst_id The task instance to which all orderings are required
+ */
+ virtual TaskInstSet before_orderings (TaskInstID inst_id) = 0;
+
+ /// Get the Causal and Scheduling orderings from this task instance
+ /**
+ * @param inst_id The task instance from which all orderings are required
+ */
+ virtual TaskInstSet after_orderings (TaskInstID inst_id) = 0;
+
+ /// Get all the task instances
+ virtual TaskInstSet get_all_insts() = 0;
+
+ /// Check if the instance id already exists and is being reused.
+ /**
+ * @param task_inst The task instance being checked
+ *
+ * @return True If this task instance already exists.
+ */
+ virtual bool inst_exists (TaskInstID task_inst) = 0;
+
+ /// Get task implementation for a task instance.
+ /**
+ * @param task_inst The task instance.
+ *
+ * @return The task implementation id.
+ */
+ virtual TaskImplID get_impl_id (TaskInstID task_inst) = 0;
+
+ // ************************************************************************
+ // Methods for obtaining prototypes of commands that work on this object.
+ // ************************************************************************
+
+ /// Get a PlanCommand prototype for adding a task to the plan.
+ /**
+ * @return An AddTaskCmd prototype for this WorkingPlan.
+ */
+ virtual AddTaskCmd *get_AddTaskCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for associating an implementation with a
+ /// task instance in the plan.
+ /**
+ * @return An AssocTaskImplCmd prototype for this WorkingPlan.
+ */
+ virtual AssocTaskImplCmd *get_AssocTaskImplCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for resolving a causal link threat in the
+ /// plan (with promotion or demotion).
+ /**
+ * @return An ResolveCLThreatCmd prototype for this WorkingPlan.
+ */
+ virtual ResolveCLThreatCmd *get_ResolveCLThreatCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for resolving a scheduling (i.e.
+ /// non-causal-link ordering constraint (with promotion or demotion)
+ /// between two task instances in the plan.
+ /**
+ * @return An ResolveSchedOrderCmd prototype for this WorkingPlan.
+ */
+ virtual ResolveSchedOrderCmd *get_ResolveSchedOrderCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for adjusting the minimum times of a
+ /// task instance in the plan.
+ /**
+ * @return An AdjustStartWindowCmd prototype for this WorkingPlan.
+ */
+ virtual AdjustMinTimesCmd *get_AdjustMinTimesCmd (void) = 0;
+
+ /// Get a PlanCommand prototype for adjusting the max times of a
+ /// task instance in the plan.
+ /**
+ * @return An AdjustEndWindowCmd prototype for this WorkingPlan.
+ */
+ virtual AdjustMaxTimesCmd *get_AdjustMaxTimesCmd (void) = 0;
+
+ protected:
+ /// Pointer to Planner object.
+ SA_POP::Planner *planner_;
+ };
+
+}; /* SA_POP namespace */
+
+#endif /* SA_POP_WORKING_PLAN_H_ */
diff --git a/SA_POP/XML_TaskMap.cpp b/SA_POP/XML_TaskMap.cpp
new file mode 100644
index 00000000000..a8e00344203
--- /dev/null
+++ b/SA_POP/XML_TaskMap.cpp
@@ -0,0 +1,3259 @@
+#include "XML_TaskMap.hpp"
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ // TaskID
+ //
+
+ TaskID::
+ TaskID (::XMLSchema::int_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ TaskID::
+ TaskID (::SA_POP::XML::TaskID const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::TaskID& TaskID::
+ operator= (::SA_POP::XML::TaskID const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // TaskImplID
+ //
+
+ TaskImplID::
+ TaskImplID (::XMLSchema::string< wchar_t > const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ TaskImplID::
+ TaskImplID (::SA_POP::XML::TaskImplID const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::TaskImplID& TaskImplID::
+ operator= (::SA_POP::XML::TaskImplID const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // ResourceID
+ //
+
+ ResourceID::
+ ResourceID (::XMLSchema::string< wchar_t > const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ ResourceID::
+ ResourceID (::SA_POP::XML::ResourceID const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::ResourceID& ResourceID::
+ operator= (::SA_POP::XML::ResourceID const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // ResourceKind
+ //
+
+ ResourceKind::Value ResourceKind::
+ integral () const
+ {
+ return v_;
+ }
+
+ bool
+ operator== (::SA_POP::XML::ResourceKind const& a, ::SA_POP::XML::ResourceKind const& b)
+ {
+ return a.v_ == b.v_;
+ }
+
+ bool
+ operator!= (::SA_POP::XML::ResourceKind const& a, ::SA_POP::XML::ResourceKind const& b)
+ {
+ return a.v_ != b.v_;
+ }
+
+ ResourceKind::
+ ResourceKind (ResourceKind::Value v)
+ : v_ (v)
+ {
+ }
+
+ // ResourceValue
+ //
+
+ ResourceValue::
+ ResourceValue (::XMLSchema::int_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ ResourceValue::
+ ResourceValue (::SA_POP::XML::ResourceValue const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::ResourceValue& ResourceValue::
+ operator= (::SA_POP::XML::ResourceValue const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // ImplParamID
+ //
+
+ ImplParamID::
+ ImplParamID (::XMLSchema::string< wchar_t > const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ ImplParamID::
+ ImplParamID (::SA_POP::XML::ImplParamID const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::ImplParamID& ImplParamID::
+ operator= (::SA_POP::XML::ImplParamID const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // ImplParamKind
+ //
+
+ ImplParamKind::
+ ImplParamKind (::XMLSchema::string< wchar_t > const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ ImplParamKind::
+ ImplParamKind (::SA_POP::XML::ImplParamKind const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::ImplParamKind& ImplParamKind::
+ operator= (::SA_POP::XML::ImplParamKind const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // ImplParamValue
+ //
+
+ ImplParamValue::
+ ImplParamValue (::XMLSchema::string< wchar_t > const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ ImplParamValue::
+ ImplParamValue (::SA_POP::XML::ImplParamValue const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::ImplParamValue& ImplParamValue::
+ operator= (::SA_POP::XML::ImplParamValue const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // TimeValue
+ //
+
+ TimeValue::
+ TimeValue (::XMLSchema::int_ const& b__)
+ :
+ Base__ (b__),
+ regulator__ ()
+ {
+ }
+
+ TimeValue::
+ TimeValue (::SA_POP::XML::TimeValue const& s)
+ :
+ Base__ (s),
+ regulator__ ()
+ {
+ }
+
+ ::SA_POP::XML::TimeValue& TimeValue::
+ operator= (::SA_POP::XML::TimeValue const& s)
+ {
+ static_cast< Base__& > (*this) = static_cast< Base__ const& > (s);
+
+ return *this;
+ }
+
+
+
+ // Resource
+ //
+
+ Resource::
+ Resource (::SA_POP::XML::ResourceID const& resourceID__,
+ ::SA_POP::XML::ResourceKind const& kind__,
+ ::SA_POP::XML::ResourceValue const& capacity__)
+ :
+ ::XSCRT::Type (),
+ resourceID_ (new ::SA_POP::XML::ResourceID (resourceID__)),
+ kind_ (new ::SA_POP::XML::ResourceKind (kind__)),
+ capacity_ (new ::SA_POP::XML::ResourceValue (capacity__)),
+ regulator__ ()
+ {
+ resourceID_->container (this);
+ kind_->container (this);
+ capacity_->container (this);
+ }
+
+ Resource::
+ Resource (::SA_POP::XML::Resource const& s)
+ :
+ ::XSCRT::Type (),
+ resourceID_ (new ::SA_POP::XML::ResourceID (*s.resourceID_)),
+ kind_ (new ::SA_POP::XML::ResourceKind (*s.kind_)),
+ capacity_ (new ::SA_POP::XML::ResourceValue (*s.capacity_)),
+ regulator__ ()
+ {
+ resourceID_->container (this);
+ kind_->container (this);
+ capacity_->container (this);
+ }
+
+ ::SA_POP::XML::Resource& Resource::
+ operator= (::SA_POP::XML::Resource const& s)
+ {
+ resourceID (s.resourceID ());
+
+ kind (s.kind ());
+
+ capacity (s.capacity ());
+
+ return *this;
+ }
+
+
+ // Resource
+ //
+ ::SA_POP::XML::ResourceID const& Resource::
+ resourceID () const
+ {
+ return *resourceID_;
+ }
+
+ void Resource::
+ resourceID (::SA_POP::XML::ResourceID const& e)
+ {
+ *resourceID_ = e;
+ }
+
+ // Resource
+ //
+ ::SA_POP::XML::ResourceKind const& Resource::
+ kind () const
+ {
+ return *kind_;
+ }
+
+ void Resource::
+ kind (::SA_POP::XML::ResourceKind const& e)
+ {
+ *kind_ = e;
+ }
+
+ // Resource
+ //
+ ::SA_POP::XML::ResourceValue const& Resource::
+ capacity () const
+ {
+ return *capacity_;
+ }
+
+ void Resource::
+ capacity (::SA_POP::XML::ResourceValue const& e)
+ {
+ *capacity_ = e;
+ }
+
+
+ // ImplParam
+ //
+
+ ImplParam::
+ ImplParam (::SA_POP::XML::ImplParamID const& paramID__,
+ ::SA_POP::XML::ImplParamKind const& kind__,
+ ::SA_POP::XML::ImplParamValue const& value__)
+ :
+ ::XSCRT::Type (),
+ paramID_ (new ::SA_POP::XML::ImplParamID (paramID__)),
+ kind_ (new ::SA_POP::XML::ImplParamKind (kind__)),
+ value_ (new ::SA_POP::XML::ImplParamValue (value__)),
+ regulator__ ()
+ {
+ paramID_->container (this);
+ kind_->container (this);
+ value_->container (this);
+ }
+
+ ImplParam::
+ ImplParam (::SA_POP::XML::ImplParam const& s)
+ :
+ ::XSCRT::Type (),
+ paramID_ (new ::SA_POP::XML::ImplParamID (*s.paramID_)),
+ kind_ (new ::SA_POP::XML::ImplParamKind (*s.kind_)),
+ value_ (new ::SA_POP::XML::ImplParamValue (*s.value_)),
+ regulator__ ()
+ {
+ paramID_->container (this);
+ kind_->container (this);
+ value_->container (this);
+ }
+
+ ::SA_POP::XML::ImplParam& ImplParam::
+ operator= (::SA_POP::XML::ImplParam const& s)
+ {
+ paramID (s.paramID ());
+
+ kind (s.kind ());
+
+ value (s.value ());
+
+ return *this;
+ }
+
+
+ // ImplParam
+ //
+ ::SA_POP::XML::ImplParamID const& ImplParam::
+ paramID () const
+ {
+ return *paramID_;
+ }
+
+ void ImplParam::
+ paramID (::SA_POP::XML::ImplParamID const& e)
+ {
+ *paramID_ = e;
+ }
+
+ // ImplParam
+ //
+ ::SA_POP::XML::ImplParamKind const& ImplParam::
+ kind () const
+ {
+ return *kind_;
+ }
+
+ void ImplParam::
+ kind (::SA_POP::XML::ImplParamKind const& e)
+ {
+ *kind_ = e;
+ }
+
+ // ImplParam
+ //
+ ::SA_POP::XML::ImplParamValue const& ImplParam::
+ value () const
+ {
+ return *value_;
+ }
+
+ void ImplParam::
+ value (::SA_POP::XML::ImplParamValue const& e)
+ {
+ *value_ = e;
+ }
+
+
+ // TaskImpl
+ //
+
+ TaskImpl::
+ TaskImpl (::SA_POP::XML::TaskImplID const& implID__)
+ :
+ ::XSCRT::Type (),
+ implID_ (new ::SA_POP::XML::TaskImplID (implID__)),
+ regulator__ ()
+ {
+ implID_->container (this);
+ }
+
+ TaskImpl::
+ TaskImpl (::SA_POP::XML::TaskImpl const& s)
+ :
+ ::XSCRT::Type (),
+ implID_ (new ::SA_POP::XML::TaskImplID (*s.implID_)),
+ regulator__ ()
+ {
+ implID_->container (this);
+ {
+ for (param_const_iterator i (s.param_.begin ());i != s.param_.end ();++i) add_param (*i);
+ }
+ }
+
+ ::SA_POP::XML::TaskImpl& TaskImpl::
+ operator= (::SA_POP::XML::TaskImpl const& s)
+ {
+ implID (s.implID ());
+
+ param_.clear ();
+ {
+ for (param_const_iterator i (s.param_.begin ());i != s.param_.end ();++i) add_param (*i);
+ }
+
+ return *this;
+ }
+
+
+ // TaskImpl
+ //
+ ::SA_POP::XML::TaskImplID const& TaskImpl::
+ implID () const
+ {
+ return *implID_;
+ }
+
+ void TaskImpl::
+ implID (::SA_POP::XML::TaskImplID const& e)
+ {
+ *implID_ = e;
+ }
+
+ // TaskImpl
+ //
+ TaskImpl::param_iterator TaskImpl::
+ begin_param ()
+ {
+ return param_.begin ();
+ }
+
+ TaskImpl::param_iterator TaskImpl::
+ end_param ()
+ {
+ return param_.end ();
+ }
+
+ TaskImpl::param_const_iterator TaskImpl::
+ begin_param () const
+ {
+ return param_.begin ();
+ }
+
+ TaskImpl::param_const_iterator TaskImpl::
+ end_param () const
+ {
+ return param_.end ();
+ }
+
+ void TaskImpl::
+ add_param (::SA_POP::XML::ImplParam const& e)
+ {
+ param_.push_back (e);
+ }
+
+ size_t TaskImpl::
+ count_param(void) const
+ {
+ return param_.size ();
+ }
+
+
+ // TaskToImpl
+ //
+
+ TaskToImpl::
+ TaskToImpl (::SA_POP::XML::TaskID const& taskID__,
+ ::SA_POP::XML::TaskImplID const& implID__,
+ ::SA_POP::XML::TimeValue const& duration__)
+ :
+ ::XSCRT::Type (),
+ taskID_ (new ::SA_POP::XML::TaskID (taskID__)),
+ implID_ (new ::SA_POP::XML::TaskImplID (implID__)),
+ duration_ (new ::SA_POP::XML::TimeValue (duration__)),
+ regulator__ ()
+ {
+ taskID_->container (this);
+ implID_->container (this);
+ duration_->container (this);
+ }
+
+ TaskToImpl::
+ TaskToImpl (::SA_POP::XML::TaskToImpl const& s)
+ :
+ ::XSCRT::Type (),
+ taskID_ (new ::SA_POP::XML::TaskID (*s.taskID_)),
+ implID_ (new ::SA_POP::XML::TaskImplID (*s.implID_)),
+ duration_ (new ::SA_POP::XML::TimeValue (*s.duration_)),
+ regulator__ ()
+ {
+ taskID_->container (this);
+ implID_->container (this);
+ duration_->container (this);
+ }
+
+ ::SA_POP::XML::TaskToImpl& TaskToImpl::
+ operator= (::SA_POP::XML::TaskToImpl const& s)
+ {
+ taskID (s.taskID ());
+
+ implID (s.implID ());
+
+ duration (s.duration ());
+
+ return *this;
+ }
+
+
+ // TaskToImpl
+ //
+ ::SA_POP::XML::TaskID const& TaskToImpl::
+ taskID () const
+ {
+ return *taskID_;
+ }
+
+ void TaskToImpl::
+ taskID (::SA_POP::XML::TaskID const& e)
+ {
+ *taskID_ = e;
+ }
+
+ // TaskToImpl
+ //
+ ::SA_POP::XML::TaskImplID const& TaskToImpl::
+ implID () const
+ {
+ return *implID_;
+ }
+
+ void TaskToImpl::
+ implID (::SA_POP::XML::TaskImplID const& e)
+ {
+ *implID_ = e;
+ }
+
+ // TaskToImpl
+ //
+ ::SA_POP::XML::TimeValue const& TaskToImpl::
+ duration () const
+ {
+ return *duration_;
+ }
+
+ void TaskToImpl::
+ duration (::SA_POP::XML::TimeValue const& e)
+ {
+ *duration_ = e;
+ }
+
+
+ // ImplToResource
+ //
+
+ ImplToResource::
+ ImplToResource (::SA_POP::XML::TaskImplID const& implID__,
+ ::SA_POP::XML::ResourceID const& resourceID__,
+ ::SA_POP::XML::ResourceValue const& utilization__)
+ :
+ ::XSCRT::Type (),
+ implID_ (new ::SA_POP::XML::TaskImplID (implID__)),
+ resourceID_ (new ::SA_POP::XML::ResourceID (resourceID__)),
+ utilization_ (new ::SA_POP::XML::ResourceValue (utilization__)),
+ regulator__ ()
+ {
+ implID_->container (this);
+ resourceID_->container (this);
+ utilization_->container (this);
+ }
+
+ ImplToResource::
+ ImplToResource (::SA_POP::XML::ImplToResource const& s)
+ :
+ ::XSCRT::Type (),
+ implID_ (new ::SA_POP::XML::TaskImplID (*s.implID_)),
+ resourceID_ (new ::SA_POP::XML::ResourceID (*s.resourceID_)),
+ utilization_ (new ::SA_POP::XML::ResourceValue (*s.utilization_)),
+ regulator__ ()
+ {
+ implID_->container (this);
+ resourceID_->container (this);
+ utilization_->container (this);
+ }
+
+ ::SA_POP::XML::ImplToResource& ImplToResource::
+ operator= (::SA_POP::XML::ImplToResource const& s)
+ {
+ implID (s.implID ());
+
+ resourceID (s.resourceID ());
+
+ utilization (s.utilization ());
+
+ return *this;
+ }
+
+
+ // ImplToResource
+ //
+ ::SA_POP::XML::TaskImplID const& ImplToResource::
+ implID () const
+ {
+ return *implID_;
+ }
+
+ void ImplToResource::
+ implID (::SA_POP::XML::TaskImplID const& e)
+ {
+ *implID_ = e;
+ }
+
+ // ImplToResource
+ //
+ ::SA_POP::XML::ResourceID const& ImplToResource::
+ resourceID () const
+ {
+ return *resourceID_;
+ }
+
+ void ImplToResource::
+ resourceID (::SA_POP::XML::ResourceID const& e)
+ {
+ *resourceID_ = e;
+ }
+
+ // ImplToResource
+ //
+ ::SA_POP::XML::ResourceValue const& ImplToResource::
+ utilization () const
+ {
+ return *utilization_;
+ }
+
+ void ImplToResource::
+ utilization (::SA_POP::XML::ResourceValue const& e)
+ {
+ *utilization_ = e;
+ }
+
+
+ // TaskMap
+ //
+
+ TaskMap::
+ TaskMap ()
+ :
+ ::XSCRT::Type (),
+ regulator__ ()
+ {
+ }
+
+ TaskMap::
+ TaskMap (::SA_POP::XML::TaskMap const& s)
+ :
+ ::XSCRT::Type (),
+ regulator__ ()
+ {
+ {
+ for (taskImpl_const_iterator i (s.taskImpl_.begin ());i != s.taskImpl_.end ();++i) add_taskImpl (*i);
+ }
+
+ {
+ for (resource_const_iterator i (s.resource_.begin ());i != s.resource_.end ();++i) add_resource (*i);
+ }
+
+ {
+ for (taskToImpl_const_iterator i (s.taskToImpl_.begin ());i != s.taskToImpl_.end ();++i) add_taskToImpl (*i);
+ }
+
+ {
+ for (implToResource_const_iterator i (s.implToResource_.begin ());i != s.implToResource_.end ();++i) add_implToResource (*i);
+ }
+ }
+
+ ::SA_POP::XML::TaskMap& TaskMap::
+ operator= (::SA_POP::XML::TaskMap const& s)
+ {
+ taskImpl_.clear ();
+ {
+ for (taskImpl_const_iterator i (s.taskImpl_.begin ());i != s.taskImpl_.end ();++i) add_taskImpl (*i);
+ }
+
+ resource_.clear ();
+ {
+ for (resource_const_iterator i (s.resource_.begin ());i != s.resource_.end ();++i) add_resource (*i);
+ }
+
+ taskToImpl_.clear ();
+ {
+ for (taskToImpl_const_iterator i (s.taskToImpl_.begin ());i != s.taskToImpl_.end ();++i) add_taskToImpl (*i);
+ }
+
+ implToResource_.clear ();
+ {
+ for (implToResource_const_iterator i (s.implToResource_.begin ());i != s.implToResource_.end ();++i) add_implToResource (*i);
+ }
+
+ return *this;
+ }
+
+
+ // TaskMap
+ //
+ TaskMap::taskImpl_iterator TaskMap::
+ begin_taskImpl ()
+ {
+ return taskImpl_.begin ();
+ }
+
+ TaskMap::taskImpl_iterator TaskMap::
+ end_taskImpl ()
+ {
+ return taskImpl_.end ();
+ }
+
+ TaskMap::taskImpl_const_iterator TaskMap::
+ begin_taskImpl () const
+ {
+ return taskImpl_.begin ();
+ }
+
+ TaskMap::taskImpl_const_iterator TaskMap::
+ end_taskImpl () const
+ {
+ return taskImpl_.end ();
+ }
+
+ void TaskMap::
+ add_taskImpl (::SA_POP::XML::TaskImpl const& e)
+ {
+ taskImpl_.push_back (e);
+ }
+
+ size_t TaskMap::
+ count_taskImpl(void) const
+ {
+ return taskImpl_.size ();
+ }
+
+ // TaskMap
+ //
+ TaskMap::resource_iterator TaskMap::
+ begin_resource ()
+ {
+ return resource_.begin ();
+ }
+
+ TaskMap::resource_iterator TaskMap::
+ end_resource ()
+ {
+ return resource_.end ();
+ }
+
+ TaskMap::resource_const_iterator TaskMap::
+ begin_resource () const
+ {
+ return resource_.begin ();
+ }
+
+ TaskMap::resource_const_iterator TaskMap::
+ end_resource () const
+ {
+ return resource_.end ();
+ }
+
+ void TaskMap::
+ add_resource (::SA_POP::XML::Resource const& e)
+ {
+ resource_.push_back (e);
+ }
+
+ size_t TaskMap::
+ count_resource(void) const
+ {
+ return resource_.size ();
+ }
+
+ // TaskMap
+ //
+ TaskMap::taskToImpl_iterator TaskMap::
+ begin_taskToImpl ()
+ {
+ return taskToImpl_.begin ();
+ }
+
+ TaskMap::taskToImpl_iterator TaskMap::
+ end_taskToImpl ()
+ {
+ return taskToImpl_.end ();
+ }
+
+ TaskMap::taskToImpl_const_iterator TaskMap::
+ begin_taskToImpl () const
+ {
+ return taskToImpl_.begin ();
+ }
+
+ TaskMap::taskToImpl_const_iterator TaskMap::
+ end_taskToImpl () const
+ {
+ return taskToImpl_.end ();
+ }
+
+ void TaskMap::
+ add_taskToImpl (::SA_POP::XML::TaskToImpl const& e)
+ {
+ taskToImpl_.push_back (e);
+ }
+
+ size_t TaskMap::
+ count_taskToImpl(void) const
+ {
+ return taskToImpl_.size ();
+ }
+
+ // TaskMap
+ //
+ TaskMap::implToResource_iterator TaskMap::
+ begin_implToResource ()
+ {
+ return implToResource_.begin ();
+ }
+
+ TaskMap::implToResource_iterator TaskMap::
+ end_implToResource ()
+ {
+ return implToResource_.end ();
+ }
+
+ TaskMap::implToResource_const_iterator TaskMap::
+ begin_implToResource () const
+ {
+ return implToResource_.begin ();
+ }
+
+ TaskMap::implToResource_const_iterator TaskMap::
+ end_implToResource () const
+ {
+ return implToResource_.end ();
+ }
+
+ void TaskMap::
+ add_implToResource (::SA_POP::XML::ImplToResource const& e)
+ {
+ implToResource_.push_back (e);
+ }
+
+ size_t TaskMap::
+ count_implToResource(void) const
+ {
+ return implToResource_.size ();
+ }
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ // TaskID
+ //
+
+ TaskID::
+ TaskID (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ TaskID::
+ TaskID (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // TaskImplID
+ //
+
+ TaskImplID::
+ TaskImplID (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ TaskImplID::
+ TaskImplID (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // ResourceID
+ //
+
+ ResourceID::
+ ResourceID (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ ResourceID::
+ ResourceID (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // ResourceKind
+ //
+
+ ResourceKind::
+ ResourceKind (::XSCRT::XML::Element< wchar_t > const& e)
+ : ::XSCRT::Type (e)
+ {
+ ::std::basic_string< wchar_t > v (e.value ());
+
+ if (v == L"UNARY") v_ = UNARY_l;
+ else if (v == L"DISCRETE") v_ = DISCRETE_l;
+ else if (v == L"RESERVOIR") v_ = RESERVOIR_l;
+ else
+ {
+ }
+ }
+
+ ResourceKind::
+ ResourceKind (::XSCRT::XML::Attribute< wchar_t > const& a)
+ : ::XSCRT::Type (a)
+ {
+ ::std::basic_string< wchar_t > v (a.value ());
+
+ if (v == L"UNARY") v_ = UNARY_l;
+ else if (v == L"DISCRETE") v_ = DISCRETE_l;
+ else if (v == L"RESERVOIR") v_ = RESERVOIR_l;
+ else
+ {
+ }
+ }
+
+ ResourceKind const ResourceKind::UNARY (ResourceKind::UNARY_l);
+ ResourceKind const ResourceKind::DISCRETE (ResourceKind::DISCRETE_l);
+ ResourceKind const ResourceKind::RESERVOIR (ResourceKind::RESERVOIR_l);
+
+ // ResourceValue
+ //
+
+ ResourceValue::
+ ResourceValue (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ ResourceValue::
+ ResourceValue (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // ImplParamID
+ //
+
+ ImplParamID::
+ ImplParamID (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ ImplParamID::
+ ImplParamID (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // ImplParamKind
+ //
+
+ ImplParamKind::
+ ImplParamKind (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ ImplParamKind::
+ ImplParamKind (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // ImplParamValue
+ //
+
+ ImplParamValue::
+ ImplParamValue (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ ImplParamValue::
+ ImplParamValue (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // TimeValue
+ //
+
+ TimeValue::
+ TimeValue (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+ }
+
+ TimeValue::
+ TimeValue (::XSCRT::XML::Attribute< wchar_t > const& a)
+ :
+ Base__ (a),
+ regulator__ ()
+ {
+ }
+
+ // Resource
+ //
+
+ Resource::
+ Resource (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"resourceID")
+ {
+ resourceID_ = ::std::auto_ptr< ::SA_POP::XML::ResourceID > (new ::SA_POP::XML::ResourceID (e));
+ resourceID_->container (this);
+ }
+
+ else if (n == L"kind")
+ {
+ kind_ = ::std::auto_ptr< ::SA_POP::XML::ResourceKind > (new ::SA_POP::XML::ResourceKind (e));
+ kind_->container (this);
+ }
+
+ else if (n == L"capacity")
+ {
+ capacity_ = ::std::auto_ptr< ::SA_POP::XML::ResourceValue > (new ::SA_POP::XML::ResourceValue (e));
+ capacity_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // ImplParam
+ //
+
+ ImplParam::
+ ImplParam (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"paramID")
+ {
+ paramID_ = ::std::auto_ptr< ::SA_POP::XML::ImplParamID > (new ::SA_POP::XML::ImplParamID (e));
+ paramID_->container (this);
+ }
+
+ else if (n == L"kind")
+ {
+ kind_ = ::std::auto_ptr< ::SA_POP::XML::ImplParamKind > (new ::SA_POP::XML::ImplParamKind (e));
+ kind_->container (this);
+ }
+
+ else if (n == L"value")
+ {
+ value_ = ::std::auto_ptr< ::SA_POP::XML::ImplParamValue > (new ::SA_POP::XML::ImplParamValue (e));
+ value_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // TaskImpl
+ //
+
+ TaskImpl::
+ TaskImpl (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"implID")
+ {
+ implID_ = ::std::auto_ptr< ::SA_POP::XML::TaskImplID > (new ::SA_POP::XML::TaskImplID (e));
+ implID_->container (this);
+ }
+
+ else if (n == L"param")
+ {
+ ::SA_POP::XML::ImplParam t (e);
+ add_param (t);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // TaskToImpl
+ //
+
+ TaskToImpl::
+ TaskToImpl (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"taskID")
+ {
+ taskID_ = ::std::auto_ptr< ::SA_POP::XML::TaskID > (new ::SA_POP::XML::TaskID (e));
+ taskID_->container (this);
+ }
+
+ else if (n == L"implID")
+ {
+ implID_ = ::std::auto_ptr< ::SA_POP::XML::TaskImplID > (new ::SA_POP::XML::TaskImplID (e));
+ implID_->container (this);
+ }
+
+ else if (n == L"duration")
+ {
+ duration_ = ::std::auto_ptr< ::SA_POP::XML::TimeValue > (new ::SA_POP::XML::TimeValue (e));
+ duration_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // ImplToResource
+ //
+
+ ImplToResource::
+ ImplToResource (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"implID")
+ {
+ implID_ = ::std::auto_ptr< ::SA_POP::XML::TaskImplID > (new ::SA_POP::XML::TaskImplID (e));
+ implID_->container (this);
+ }
+
+ else if (n == L"resourceID")
+ {
+ resourceID_ = ::std::auto_ptr< ::SA_POP::XML::ResourceID > (new ::SA_POP::XML::ResourceID (e));
+ resourceID_->container (this);
+ }
+
+ else if (n == L"utilization")
+ {
+ utilization_ = ::std::auto_ptr< ::SA_POP::XML::ResourceValue > (new ::SA_POP::XML::ResourceValue (e));
+ utilization_->container (this);
+ }
+
+ else
+ {
+ }
+ }
+ }
+
+ // TaskMap
+ //
+
+ TaskMap::
+ TaskMap (::XSCRT::XML::Element< wchar_t > const& e)
+ :Base__ (e), regulator__ ()
+ {
+
+ ::XSCRT::Parser< wchar_t > p (e);
+
+ while (p.more_elements ())
+ {
+ ::XSCRT::XML::Element< wchar_t > e (p.next_element ());
+ ::std::basic_string< wchar_t > n (::XSCRT::XML::uq_name (e.name ()));
+
+ if (n == L"taskImpl")
+ {
+ ::SA_POP::XML::TaskImpl t (e);
+ add_taskImpl (t);
+ }
+
+ else if (n == L"resource")
+ {
+ ::SA_POP::XML::Resource t (e);
+ add_resource (t);
+ }
+
+ else if (n == L"taskToImpl")
+ {
+ ::SA_POP::XML::TaskToImpl t (e);
+ add_taskToImpl (t);
+ }
+
+ else if (n == L"implToResource")
+ {
+ ::SA_POP::XML::ImplToResource t (e);
+ add_implToResource (t);
+ }
+
+ else
+ {
+ }
+ }
+ }
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ ::SA_POP::XML::TaskMap
+ taskMap (xercesc::DOMDocument const* d)
+ {
+ ::XSCRT::XML::Element< wchar_t > e (d->getDocumentElement ());
+ if (e.name () == L"taskMap")
+ {
+ ::SA_POP::XML::TaskMap r (e);
+ return r;
+ }
+
+ else
+ {
+ throw 1;
+ }
+ }
+ }
+}
+
+#include "XMLSchema/TypeInfo.hpp"
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ namespace
+ {
+ ::XMLSchema::TypeInfoInitializer < wchar_t > XMLSchemaTypeInfoInitializer_ (::XSCRT::extended_type_info_map ());
+
+ struct TaskIDTypeInfoInitializer
+ {
+ TaskIDTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskID));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::int_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskIDTypeInfoInitializer TaskIDTypeInfoInitializer_;
+
+ struct TaskImplIDTypeInfoInitializer
+ {
+ TaskImplIDTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskImplID));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::string< wchar_t >));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskImplIDTypeInfoInitializer TaskImplIDTypeInfoInitializer_;
+
+ struct ResourceIDTypeInfoInitializer
+ {
+ ResourceIDTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ResourceID));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::string< wchar_t >));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ResourceIDTypeInfoInitializer ResourceIDTypeInfoInitializer_;
+
+ struct ResourceKindTypeInfoInitializer
+ {
+ ResourceKindTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ResourceKind));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ResourceKindTypeInfoInitializer ResourceKindTypeInfoInitializer_;
+
+ struct ResourceValueTypeInfoInitializer
+ {
+ ResourceValueTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ResourceValue));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::int_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ResourceValueTypeInfoInitializer ResourceValueTypeInfoInitializer_;
+
+ struct ImplParamIDTypeInfoInitializer
+ {
+ ImplParamIDTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ImplParamID));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::string< wchar_t >));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ImplParamIDTypeInfoInitializer ImplParamIDTypeInfoInitializer_;
+
+ struct ImplParamKindTypeInfoInitializer
+ {
+ ImplParamKindTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ImplParamKind));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::string< wchar_t >));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ImplParamKindTypeInfoInitializer ImplParamKindTypeInfoInitializer_;
+
+ struct ImplParamValueTypeInfoInitializer
+ {
+ ImplParamValueTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ImplParamValue));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::string< wchar_t >));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ImplParamValueTypeInfoInitializer ImplParamValueTypeInfoInitializer_;
+
+ struct TimeValueTypeInfoInitializer
+ {
+ TimeValueTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TimeValue));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XMLSchema::int_));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TimeValueTypeInfoInitializer TimeValueTypeInfoInitializer_;
+
+ struct ResourceTypeInfoInitializer
+ {
+ ResourceTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (Resource));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ResourceTypeInfoInitializer ResourceTypeInfoInitializer_;
+
+ struct ImplParamTypeInfoInitializer
+ {
+ ImplParamTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ImplParam));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ImplParamTypeInfoInitializer ImplParamTypeInfoInitializer_;
+
+ struct TaskImplTypeInfoInitializer
+ {
+ TaskImplTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskImpl));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskImplTypeInfoInitializer TaskImplTypeInfoInitializer_;
+
+ struct TaskToImplTypeInfoInitializer
+ {
+ TaskToImplTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskToImpl));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskToImplTypeInfoInitializer TaskToImplTypeInfoInitializer_;
+
+ struct ImplToResourceTypeInfoInitializer
+ {
+ ImplToResourceTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (ImplToResource));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ ImplToResourceTypeInfoInitializer ImplToResourceTypeInfoInitializer_;
+
+ struct TaskMapTypeInfoInitializer
+ {
+ TaskMapTypeInfoInitializer ()
+ {
+ ::XSCRT::TypeId id (typeid (TaskMap));
+ ::XSCRT::ExtendedTypeInfo nf (id);
+
+ nf.add_base (::XSCRT::ExtendedTypeInfo::Access::public_, false, typeid (::XSCRT::Type));
+ ::XSCRT::extended_type_info_map ().insert (::std::make_pair (id, nf));
+ }
+ };
+
+ TaskMapTypeInfoInitializer TaskMapTypeInfoInitializer_;
+ }
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ namespace Traversal
+ {
+ // TaskID
+ //
+ //
+
+ void TaskID::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TaskID::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TaskID::
+ pre (Type&)
+ {
+ }
+
+ void TaskID::
+ pre (Type const&)
+ {
+ }
+
+ void TaskID::
+ post (Type&)
+ {
+ }
+
+ void TaskID::
+ post (Type const&)
+ {
+ }
+
+ // TaskImplID
+ //
+ //
+
+ void TaskImplID::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TaskImplID::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TaskImplID::
+ pre (Type&)
+ {
+ }
+
+ void TaskImplID::
+ pre (Type const&)
+ {
+ }
+
+ void TaskImplID::
+ post (Type&)
+ {
+ }
+
+ void TaskImplID::
+ post (Type const&)
+ {
+ }
+
+ // ResourceID
+ //
+ //
+
+ void ResourceID::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ResourceID::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ResourceID::
+ pre (Type&)
+ {
+ }
+
+ void ResourceID::
+ pre (Type const&)
+ {
+ }
+
+ void ResourceID::
+ post (Type&)
+ {
+ }
+
+ void ResourceID::
+ post (Type const&)
+ {
+ }
+
+ // ResourceValue
+ //
+ //
+
+ void ResourceValue::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ResourceValue::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ResourceValue::
+ pre (Type&)
+ {
+ }
+
+ void ResourceValue::
+ pre (Type const&)
+ {
+ }
+
+ void ResourceValue::
+ post (Type&)
+ {
+ }
+
+ void ResourceValue::
+ post (Type const&)
+ {
+ }
+
+ // ImplParamID
+ //
+ //
+
+ void ImplParamID::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ImplParamID::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ImplParamID::
+ pre (Type&)
+ {
+ }
+
+ void ImplParamID::
+ pre (Type const&)
+ {
+ }
+
+ void ImplParamID::
+ post (Type&)
+ {
+ }
+
+ void ImplParamID::
+ post (Type const&)
+ {
+ }
+
+ // ImplParamKind
+ //
+ //
+
+ void ImplParamKind::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ImplParamKind::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ImplParamKind::
+ pre (Type&)
+ {
+ }
+
+ void ImplParamKind::
+ pre (Type const&)
+ {
+ }
+
+ void ImplParamKind::
+ post (Type&)
+ {
+ }
+
+ void ImplParamKind::
+ post (Type const&)
+ {
+ }
+
+ // ImplParamValue
+ //
+ //
+
+ void ImplParamValue::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ImplParamValue::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void ImplParamValue::
+ pre (Type&)
+ {
+ }
+
+ void ImplParamValue::
+ pre (Type const&)
+ {
+ }
+
+ void ImplParamValue::
+ post (Type&)
+ {
+ }
+
+ void ImplParamValue::
+ post (Type const&)
+ {
+ }
+
+ // TimeValue
+ //
+ //
+
+ void TimeValue::
+ traverse (Type& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TimeValue::
+ traverse (Type const& o)
+ {
+ pre (o);
+ post (o);
+ }
+
+ void TimeValue::
+ pre (Type&)
+ {
+ }
+
+ void TimeValue::
+ pre (Type const&)
+ {
+ }
+
+ void TimeValue::
+ post (Type&)
+ {
+ }
+
+ void TimeValue::
+ post (Type const&)
+ {
+ }
+
+ // Resource
+ //
+ //
+
+ void Resource::
+ traverse (Type& o)
+ {
+ pre (o);
+ resourceID (o);
+ kind (o);
+ capacity (o);
+ post (o);
+ }
+
+ void Resource::
+ traverse (Type const& o)
+ {
+ pre (o);
+ resourceID (o);
+ kind (o);
+ capacity (o);
+ post (o);
+ }
+
+ void Resource::
+ pre (Type&)
+ {
+ }
+
+ void Resource::
+ pre (Type const&)
+ {
+ }
+
+ void Resource::
+ resourceID (Type& o)
+ {
+ dispatch (o.resourceID ());
+ }
+
+ void Resource::
+ resourceID (Type const& o)
+ {
+ dispatch (o.resourceID ());
+ }
+
+ void Resource::
+ kind (Type& o)
+ {
+ dispatch (o.kind ());
+ }
+
+ void Resource::
+ kind (Type const& o)
+ {
+ dispatch (o.kind ());
+ }
+
+ void Resource::
+ capacity (Type& o)
+ {
+ dispatch (o.capacity ());
+ }
+
+ void Resource::
+ capacity (Type const& o)
+ {
+ dispatch (o.capacity ());
+ }
+
+ void Resource::
+ post (Type&)
+ {
+ }
+
+ void Resource::
+ post (Type const&)
+ {
+ }
+
+ // ImplParam
+ //
+ //
+
+ void ImplParam::
+ traverse (Type& o)
+ {
+ pre (o);
+ paramID (o);
+ kind (o);
+ value (o);
+ post (o);
+ }
+
+ void ImplParam::
+ traverse (Type const& o)
+ {
+ pre (o);
+ paramID (o);
+ kind (o);
+ value (o);
+ post (o);
+ }
+
+ void ImplParam::
+ pre (Type&)
+ {
+ }
+
+ void ImplParam::
+ pre (Type const&)
+ {
+ }
+
+ void ImplParam::
+ paramID (Type& o)
+ {
+ dispatch (o.paramID ());
+ }
+
+ void ImplParam::
+ paramID (Type const& o)
+ {
+ dispatch (o.paramID ());
+ }
+
+ void ImplParam::
+ kind (Type& o)
+ {
+ dispatch (o.kind ());
+ }
+
+ void ImplParam::
+ kind (Type const& o)
+ {
+ dispatch (o.kind ());
+ }
+
+ void ImplParam::
+ value (Type& o)
+ {
+ dispatch (o.value ());
+ }
+
+ void ImplParam::
+ value (Type const& o)
+ {
+ dispatch (o.value ());
+ }
+
+ void ImplParam::
+ post (Type&)
+ {
+ }
+
+ void ImplParam::
+ post (Type const&)
+ {
+ }
+
+ // TaskImpl
+ //
+ //
+
+ void TaskImpl::
+ traverse (Type& o)
+ {
+ pre (o);
+ implID (o);
+ param (o);
+ post (o);
+ }
+
+ void TaskImpl::
+ traverse (Type const& o)
+ {
+ pre (o);
+ implID (o);
+ param (o);
+ post (o);
+ }
+
+ void TaskImpl::
+ pre (Type&)
+ {
+ }
+
+ void TaskImpl::
+ pre (Type const&)
+ {
+ }
+
+ void TaskImpl::
+ implID (Type& o)
+ {
+ dispatch (o.implID ());
+ }
+
+ void TaskImpl::
+ implID (Type const& o)
+ {
+ dispatch (o.implID ());
+ }
+
+ void TaskImpl::
+ param (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskImpl::Type::param_iterator b (o.begin_param()), e (o.end_param());
+
+ if (b != e)
+ {
+ param_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) param_next (o);
+ }
+
+ param_post (o);
+ }
+ }
+
+ void TaskImpl::
+ param (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskImpl::Type::param_const_iterator b (o.begin_param()), e (o.end_param());
+
+ if (b != e)
+ {
+ param_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) param_next (o);
+ }
+
+ param_post (o);
+ }
+ }
+
+ void TaskImpl::
+ param_pre (Type&)
+ {
+ }
+
+ void TaskImpl::
+ param_pre (Type const&)
+ {
+ }
+
+ void TaskImpl::
+ param_next (Type&)
+ {
+ }
+
+ void TaskImpl::
+ param_next (Type const&)
+ {
+ }
+
+ void TaskImpl::
+ param_post (Type&)
+ {
+ }
+
+ void TaskImpl::
+ param_post (Type const&)
+ {
+ }
+
+ void TaskImpl::
+ post (Type&)
+ {
+ }
+
+ void TaskImpl::
+ post (Type const&)
+ {
+ }
+
+ // TaskToImpl
+ //
+ //
+
+ void TaskToImpl::
+ traverse (Type& o)
+ {
+ pre (o);
+ taskID (o);
+ implID (o);
+ duration (o);
+ post (o);
+ }
+
+ void TaskToImpl::
+ traverse (Type const& o)
+ {
+ pre (o);
+ taskID (o);
+ implID (o);
+ duration (o);
+ post (o);
+ }
+
+ void TaskToImpl::
+ pre (Type&)
+ {
+ }
+
+ void TaskToImpl::
+ pre (Type const&)
+ {
+ }
+
+ void TaskToImpl::
+ taskID (Type& o)
+ {
+ dispatch (o.taskID ());
+ }
+
+ void TaskToImpl::
+ taskID (Type const& o)
+ {
+ dispatch (o.taskID ());
+ }
+
+ void TaskToImpl::
+ implID (Type& o)
+ {
+ dispatch (o.implID ());
+ }
+
+ void TaskToImpl::
+ implID (Type const& o)
+ {
+ dispatch (o.implID ());
+ }
+
+ void TaskToImpl::
+ duration (Type& o)
+ {
+ dispatch (o.duration ());
+ }
+
+ void TaskToImpl::
+ duration (Type const& o)
+ {
+ dispatch (o.duration ());
+ }
+
+ void TaskToImpl::
+ post (Type&)
+ {
+ }
+
+ void TaskToImpl::
+ post (Type const&)
+ {
+ }
+
+ // ImplToResource
+ //
+ //
+
+ void ImplToResource::
+ traverse (Type& o)
+ {
+ pre (o);
+ implID (o);
+ resourceID (o);
+ utilization (o);
+ post (o);
+ }
+
+ void ImplToResource::
+ traverse (Type const& o)
+ {
+ pre (o);
+ implID (o);
+ resourceID (o);
+ utilization (o);
+ post (o);
+ }
+
+ void ImplToResource::
+ pre (Type&)
+ {
+ }
+
+ void ImplToResource::
+ pre (Type const&)
+ {
+ }
+
+ void ImplToResource::
+ implID (Type& o)
+ {
+ dispatch (o.implID ());
+ }
+
+ void ImplToResource::
+ implID (Type const& o)
+ {
+ dispatch (o.implID ());
+ }
+
+ void ImplToResource::
+ resourceID (Type& o)
+ {
+ dispatch (o.resourceID ());
+ }
+
+ void ImplToResource::
+ resourceID (Type const& o)
+ {
+ dispatch (o.resourceID ());
+ }
+
+ void ImplToResource::
+ utilization (Type& o)
+ {
+ dispatch (o.utilization ());
+ }
+
+ void ImplToResource::
+ utilization (Type const& o)
+ {
+ dispatch (o.utilization ());
+ }
+
+ void ImplToResource::
+ post (Type&)
+ {
+ }
+
+ void ImplToResource::
+ post (Type const&)
+ {
+ }
+
+ // TaskMap
+ //
+ //
+
+ void TaskMap::
+ traverse (Type& o)
+ {
+ pre (o);
+ taskImpl (o);
+ resource (o);
+ taskToImpl (o);
+ implToResource (o);
+ post (o);
+ }
+
+ void TaskMap::
+ traverse (Type const& o)
+ {
+ pre (o);
+ taskImpl (o);
+ resource (o);
+ taskToImpl (o);
+ implToResource (o);
+ post (o);
+ }
+
+ void TaskMap::
+ pre (Type&)
+ {
+ }
+
+ void TaskMap::
+ pre (Type const&)
+ {
+ }
+
+ void TaskMap::
+ taskImpl (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::taskImpl_iterator b (o.begin_taskImpl()), e (o.end_taskImpl());
+
+ if (b != e)
+ {
+ taskImpl_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) taskImpl_next (o);
+ }
+
+ taskImpl_post (o);
+ }
+ }
+
+ void TaskMap::
+ taskImpl (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::taskImpl_const_iterator b (o.begin_taskImpl()), e (o.end_taskImpl());
+
+ if (b != e)
+ {
+ taskImpl_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) taskImpl_next (o);
+ }
+
+ taskImpl_post (o);
+ }
+ }
+
+ void TaskMap::
+ taskImpl_pre (Type&)
+ {
+ }
+
+ void TaskMap::
+ taskImpl_pre (Type const&)
+ {
+ }
+
+ void TaskMap::
+ taskImpl_next (Type&)
+ {
+ }
+
+ void TaskMap::
+ taskImpl_next (Type const&)
+ {
+ }
+
+ void TaskMap::
+ taskImpl_post (Type&)
+ {
+ }
+
+ void TaskMap::
+ taskImpl_post (Type const&)
+ {
+ }
+
+ void TaskMap::
+ resource (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::resource_iterator b (o.begin_resource()), e (o.end_resource());
+
+ if (b != e)
+ {
+ resource_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) resource_next (o);
+ }
+
+ resource_post (o);
+ }
+ }
+
+ void TaskMap::
+ resource (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::resource_const_iterator b (o.begin_resource()), e (o.end_resource());
+
+ if (b != e)
+ {
+ resource_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) resource_next (o);
+ }
+
+ resource_post (o);
+ }
+ }
+
+ void TaskMap::
+ resource_pre (Type&)
+ {
+ }
+
+ void TaskMap::
+ resource_pre (Type const&)
+ {
+ }
+
+ void TaskMap::
+ resource_next (Type&)
+ {
+ }
+
+ void TaskMap::
+ resource_next (Type const&)
+ {
+ }
+
+ void TaskMap::
+ resource_post (Type&)
+ {
+ }
+
+ void TaskMap::
+ resource_post (Type const&)
+ {
+ }
+
+ void TaskMap::
+ taskToImpl (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::taskToImpl_iterator b (o.begin_taskToImpl()), e (o.end_taskToImpl());
+
+ if (b != e)
+ {
+ taskToImpl_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) taskToImpl_next (o);
+ }
+
+ taskToImpl_post (o);
+ }
+ }
+
+ void TaskMap::
+ taskToImpl (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::taskToImpl_const_iterator b (o.begin_taskToImpl()), e (o.end_taskToImpl());
+
+ if (b != e)
+ {
+ taskToImpl_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) taskToImpl_next (o);
+ }
+
+ taskToImpl_post (o);
+ }
+ }
+
+ void TaskMap::
+ taskToImpl_pre (Type&)
+ {
+ }
+
+ void TaskMap::
+ taskToImpl_pre (Type const&)
+ {
+ }
+
+ void TaskMap::
+ taskToImpl_next (Type&)
+ {
+ }
+
+ void TaskMap::
+ taskToImpl_next (Type const&)
+ {
+ }
+
+ void TaskMap::
+ taskToImpl_post (Type&)
+ {
+ }
+
+ void TaskMap::
+ taskToImpl_post (Type const&)
+ {
+ }
+
+ void TaskMap::
+ implToResource (Type& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::implToResource_iterator b (o.begin_implToResource()), e (o.end_implToResource());
+
+ if (b != e)
+ {
+ implToResource_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) implToResource_next (o);
+ }
+
+ implToResource_post (o);
+ }
+ }
+
+ void TaskMap::
+ implToResource (Type const& o)
+ {
+ // VC6 anathema strikes again
+ //
+ TaskMap::Type::implToResource_const_iterator b (o.begin_implToResource()), e (o.end_implToResource());
+
+ if (b != e)
+ {
+ implToResource_pre (o);
+ for (; b != e;)
+ {
+ dispatch (*b);
+ if (++b != e) implToResource_next (o);
+ }
+
+ implToResource_post (o);
+ }
+ }
+
+ void TaskMap::
+ implToResource_pre (Type&)
+ {
+ }
+
+ void TaskMap::
+ implToResource_pre (Type const&)
+ {
+ }
+
+ void TaskMap::
+ implToResource_next (Type&)
+ {
+ }
+
+ void TaskMap::
+ implToResource_next (Type const&)
+ {
+ }
+
+ void TaskMap::
+ implToResource_post (Type&)
+ {
+ }
+
+ void TaskMap::
+ implToResource_post (Type const&)
+ {
+ }
+
+ void TaskMap::
+ post (Type&)
+ {
+ }
+
+ void TaskMap::
+ post (Type const&)
+ {
+ }
+ }
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ namespace Writer
+ {
+ // TaskID
+ //
+ //
+
+ TaskID::
+ TaskID (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskID::
+ TaskID ()
+ {
+ }
+
+ void TaskID::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >::traverse (o);
+ Traversal::TaskID::traverse (o);
+ }
+
+ // TaskImplID
+ //
+ //
+
+ TaskImplID::
+ TaskImplID (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskImplID::
+ TaskImplID ()
+ {
+ }
+
+ void TaskImplID::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >::traverse (o);
+ Traversal::TaskImplID::traverse (o);
+ }
+
+ // ResourceID
+ //
+ //
+
+ ResourceID::
+ ResourceID (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ResourceID::
+ ResourceID ()
+ {
+ }
+
+ void ResourceID::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >::traverse (o);
+ Traversal::ResourceID::traverse (o);
+ }
+
+ // ResourceKind
+ //
+ //
+
+ ResourceKind::
+ ResourceKind (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ResourceKind::
+ ResourceKind ()
+ {
+ }
+
+ void ResourceKind::
+ traverse (Type const& o)
+ {
+ ::std::basic_string< wchar_t > s;
+
+ if (o == ::SA_POP::XML::ResourceKind::UNARY) s = L"UNARY";
+ else if (o == ::SA_POP::XML::ResourceKind::DISCRETE) s = L"DISCRETE";
+ else if (o == ::SA_POP::XML::ResourceKind::RESERVOIR) s = L"RESERVOIR";
+ else
+ {
+ }
+
+ if (::XSCRT::XML::Attribute< wchar_t >* a = attr_ ())
+ {
+ a->value (s);
+ }
+
+ else
+ {
+ top_().value (s);
+ }
+ }
+
+ // ResourceValue
+ //
+ //
+
+ ResourceValue::
+ ResourceValue (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ResourceValue::
+ ResourceValue ()
+ {
+ }
+
+ void ResourceValue::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >::traverse (o);
+ Traversal::ResourceValue::traverse (o);
+ }
+
+ // ImplParamID
+ //
+ //
+
+ ImplParamID::
+ ImplParamID (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ImplParamID::
+ ImplParamID ()
+ {
+ }
+
+ void ImplParamID::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >::traverse (o);
+ Traversal::ImplParamID::traverse (o);
+ }
+
+ // ImplParamKind
+ //
+ //
+
+ ImplParamKind::
+ ImplParamKind (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ImplParamKind::
+ ImplParamKind ()
+ {
+ }
+
+ void ImplParamKind::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >::traverse (o);
+ Traversal::ImplParamKind::traverse (o);
+ }
+
+ // ImplParamValue
+ //
+ //
+
+ ImplParamValue::
+ ImplParamValue (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ImplParamValue::
+ ImplParamValue ()
+ {
+ }
+
+ void ImplParamValue::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >::traverse (o);
+ Traversal::ImplParamValue::traverse (o);
+ }
+
+ // TimeValue
+ //
+ //
+
+ TimeValue::
+ TimeValue (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TimeValue::
+ TimeValue ()
+ {
+ }
+
+ void TimeValue::
+ traverse (Type const& o)
+ {
+ ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >::traverse (o);
+ Traversal::TimeValue::traverse (o);
+ }
+
+ // Resource
+ //
+ //
+
+ Resource::
+ Resource (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ Resource::
+ Resource ()
+ {
+ }
+
+ void Resource::
+ traverse (Type const& o)
+ {
+ Traversal::Resource::traverse (o);
+ }
+
+ void Resource::
+ resourceID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"resourceID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::Resource::resourceID (o);
+ pop_ ();
+ }
+
+ void Resource::
+ kind (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"kind", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::Resource::kind (o);
+ pop_ ();
+ }
+
+ void Resource::
+ capacity (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"capacity", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::Resource::capacity (o);
+ pop_ ();
+ }
+
+ // ImplParam
+ //
+ //
+
+ ImplParam::
+ ImplParam (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ImplParam::
+ ImplParam ()
+ {
+ }
+
+ void ImplParam::
+ traverse (Type const& o)
+ {
+ Traversal::ImplParam::traverse (o);
+ }
+
+ void ImplParam::
+ paramID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"paramID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::ImplParam::paramID (o);
+ pop_ ();
+ }
+
+ void ImplParam::
+ kind (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"kind", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::ImplParam::kind (o);
+ pop_ ();
+ }
+
+ void ImplParam::
+ value (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"value", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::ImplParam::value (o);
+ pop_ ();
+ }
+
+ // TaskImpl
+ //
+ //
+
+ TaskImpl::
+ TaskImpl (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskImpl::
+ TaskImpl ()
+ {
+ }
+
+ void TaskImpl::
+ traverse (Type const& o)
+ {
+ Traversal::TaskImpl::traverse (o);
+ }
+
+ void TaskImpl::
+ implID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"implID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::TaskImpl::implID (o);
+ pop_ ();
+ }
+
+ void TaskImpl::
+ param_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"param", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ }
+
+ void TaskImpl::
+ param_next (Type const& o)
+ {
+ param_post (o);
+ param_pre (o);
+ }
+
+ void TaskImpl::
+ param_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ // TaskToImpl
+ //
+ //
+
+ TaskToImpl::
+ TaskToImpl (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskToImpl::
+ TaskToImpl ()
+ {
+ }
+
+ void TaskToImpl::
+ traverse (Type const& o)
+ {
+ Traversal::TaskToImpl::traverse (o);
+ }
+
+ void TaskToImpl::
+ taskID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"taskID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::TaskToImpl::taskID (o);
+ pop_ ();
+ }
+
+ void TaskToImpl::
+ implID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"implID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::TaskToImpl::implID (o);
+ pop_ ();
+ }
+
+ void TaskToImpl::
+ duration (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"duration", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::TaskToImpl::duration (o);
+ pop_ ();
+ }
+
+ // ImplToResource
+ //
+ //
+
+ ImplToResource::
+ ImplToResource (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ ImplToResource::
+ ImplToResource ()
+ {
+ }
+
+ void ImplToResource::
+ traverse (Type const& o)
+ {
+ Traversal::ImplToResource::traverse (o);
+ }
+
+ void ImplToResource::
+ implID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"implID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::ImplToResource::implID (o);
+ pop_ ();
+ }
+
+ void ImplToResource::
+ resourceID (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"resourceID", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::ImplToResource::resourceID (o);
+ pop_ ();
+ }
+
+ void ImplToResource::
+ utilization (Type const& o)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"utilization", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ Traversal::ImplToResource::utilization (o);
+ pop_ ();
+ }
+
+ // TaskMap
+ //
+ //
+
+ TaskMap::
+ TaskMap (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+
+ TaskMap::
+ TaskMap ()
+ {
+ }
+
+ void TaskMap::
+ traverse (Type const& o)
+ {
+ Traversal::TaskMap::traverse (o);
+ }
+
+ void TaskMap::
+ taskImpl_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"taskImpl", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ }
+
+ void TaskMap::
+ taskImpl_next (Type const& o)
+ {
+ taskImpl_post (o);
+ taskImpl_pre (o);
+ }
+
+ void TaskMap::
+ taskImpl_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ void TaskMap::
+ resource_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"resource", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ }
+
+ void TaskMap::
+ resource_next (Type const& o)
+ {
+ resource_post (o);
+ resource_pre (o);
+ }
+
+ void TaskMap::
+ resource_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ void TaskMap::
+ taskToImpl_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"taskToImpl", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ }
+
+ void TaskMap::
+ taskToImpl_next (Type const& o)
+ {
+ taskToImpl_post (o);
+ taskToImpl_pre (o);
+ }
+
+ void TaskMap::
+ taskToImpl_post (Type const&)
+ {
+ pop_ ();
+ }
+
+ void TaskMap::
+ implToResource_pre (Type const&)
+ {
+ push_ (::XSCRT::XML::Element< wchar_t > (L"implToResource", L"http://www.vanderbilt.edu/SA-POP", top_ ()));
+ }
+
+ void TaskMap::
+ implToResource_next (Type const& o)
+ {
+ implToResource_post (o);
+ implToResource_pre (o);
+ }
+
+ void TaskMap::
+ implToResource_post (Type const&)
+ {
+ pop_ ();
+ }
+ }
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ void
+ taskMap (::SA_POP::XML::TaskMap const& s, xercesc::DOMDocument* d)
+ {
+ ::XSCRT::XML::Element< wchar_t > e (d->getDocumentElement ());
+ if (e.name () != L"taskMap")
+ {
+ throw 1;
+ }
+
+ struct W : virtual ::SA_POP::XML::Writer::TaskMap,
+ virtual ::SA_POP::XML::Writer::TaskImpl,
+ virtual ::SA_POP::XML::Writer::TaskImplID,
+ virtual ::SA_POP::XML::Writer::ImplParam,
+ virtual ::SA_POP::XML::Writer::ImplParamID,
+ virtual ::SA_POP::XML::Writer::ImplParamKind,
+ virtual ::SA_POP::XML::Writer::ImplParamValue,
+ virtual ::SA_POP::XML::Writer::Resource,
+ virtual ::SA_POP::XML::Writer::ResourceID,
+ virtual ::SA_POP::XML::Writer::ResourceKind,
+ virtual ::SA_POP::XML::Writer::ResourceValue,
+ virtual ::SA_POP::XML::Writer::TaskToImpl,
+ virtual ::SA_POP::XML::Writer::TaskID,
+ virtual ::SA_POP::XML::Writer::TimeValue,
+ virtual ::SA_POP::XML::Writer::ImplToResource,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ W (::XSCRT::XML::Element< wchar_t >& e)
+ : ::XSCRT::Writer< wchar_t > (e)
+ {
+ }
+ };
+
+ W w (e);
+ w.dispatch (s);
+ }
+ }
+}
+
diff --git a/SA_POP/XML_TaskMap.hpp b/SA_POP/XML_TaskMap.hpp
new file mode 100644
index 00000000000..b972fd9e848
--- /dev/null
+++ b/SA_POP/XML_TaskMap.hpp
@@ -0,0 +1,1703 @@
+#ifndef XML_TASKMAP_HPP
+#define XML_TASKMAP_HPP
+
+// Forward declarations.
+//
+namespace SA_POP
+{
+ namespace XML
+ {
+ class TaskID;
+ class TaskImplID;
+ class ResourceID;
+ class ResourceKind;
+ class ResourceValue;
+ class ImplParamID;
+ class ImplParamKind;
+ class ImplParamValue;
+ class TimeValue;
+ class Resource;
+ class ImplParam;
+ class TaskImpl;
+ class TaskToImpl;
+ class ImplToResource;
+ class TaskMap;
+ }
+}
+
+#include <memory>
+#include <list>
+#include "XMLSchema/Types.hpp"
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ class TaskID : public ::XMLSchema::int_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::int_ Base__;
+
+ public:
+ TaskID (::XMLSchema::int_ const& b__);
+
+ TaskID (::XSCRT::XML::Element< wchar_t > const&);
+ TaskID (::XSCRT::XML::Attribute< wchar_t > const&);
+ TaskID (TaskID const& s);
+
+ TaskID&
+ operator= (TaskID const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class TaskImplID : public ::XMLSchema::string< wchar_t >
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::string< wchar_t > Base__;
+
+ public:
+ TaskImplID (::XMLSchema::string< wchar_t > const& b__);
+
+ TaskImplID (::XSCRT::XML::Element< wchar_t > const&);
+ TaskImplID (::XSCRT::XML::Attribute< wchar_t > const&);
+ TaskImplID (TaskImplID const& s);
+
+ TaskImplID&
+ operator= (TaskImplID const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class ResourceID : public ::XMLSchema::string< wchar_t >
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::string< wchar_t > Base__;
+
+ public:
+ ResourceID (::XMLSchema::string< wchar_t > const& b__);
+
+ ResourceID (::XSCRT::XML::Element< wchar_t > const&);
+ ResourceID (::XSCRT::XML::Attribute< wchar_t > const&);
+ ResourceID (ResourceID const& s);
+
+ ResourceID&
+ operator= (ResourceID const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class ResourceKind : public ::XSCRT::Type
+ {
+ public:
+ ResourceKind (::XSCRT::XML::Element< wchar_t > const&);
+ ResourceKind (::XSCRT::XML::Attribute< wchar_t > const&);
+
+ static ResourceKind const UNARY;
+ static ResourceKind const DISCRETE;
+ static ResourceKind const RESERVOIR;
+
+ enum Value
+ {
+ UNARY_l,DISCRETE_l,RESERVOIR_l,
+ };
+
+
+ Value
+ integral () const;
+
+ friend bool
+ operator== (ResourceKind const& a, ResourceKind const& b);
+
+ friend bool
+ operator!= (ResourceKind const& a, ResourceKind const& b);
+
+ private:
+ ResourceKind (Value v);
+
+ Value v_;
+ };
+
+ bool operator== (ResourceKind const &a, ResourceKind const &b);
+
+ bool operator!= (ResourceKind const &a, ResourceKind const &b);
+
+
+ class ResourceValue : public ::XMLSchema::int_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::int_ Base__;
+
+ public:
+ ResourceValue (::XMLSchema::int_ const& b__);
+
+ ResourceValue (::XSCRT::XML::Element< wchar_t > const&);
+ ResourceValue (::XSCRT::XML::Attribute< wchar_t > const&);
+ ResourceValue (ResourceValue const& s);
+
+ ResourceValue&
+ operator= (ResourceValue const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class ImplParamID : public ::XMLSchema::string< wchar_t >
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::string< wchar_t > Base__;
+
+ public:
+ ImplParamID (::XMLSchema::string< wchar_t > const& b__);
+
+ ImplParamID (::XSCRT::XML::Element< wchar_t > const&);
+ ImplParamID (::XSCRT::XML::Attribute< wchar_t > const&);
+ ImplParamID (ImplParamID const& s);
+
+ ImplParamID&
+ operator= (ImplParamID const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class ImplParamKind : public ::XMLSchema::string< wchar_t >
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::string< wchar_t > Base__;
+
+ public:
+ ImplParamKind (::XMLSchema::string< wchar_t > const& b__);
+
+ ImplParamKind (::XSCRT::XML::Element< wchar_t > const&);
+ ImplParamKind (::XSCRT::XML::Attribute< wchar_t > const&);
+ ImplParamKind (ImplParamKind const& s);
+
+ ImplParamKind&
+ operator= (ImplParamKind const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class ImplParamValue : public ::XMLSchema::string< wchar_t >
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::string< wchar_t > Base__;
+
+ public:
+ ImplParamValue (::XMLSchema::string< wchar_t > const& b__);
+
+ ImplParamValue (::XSCRT::XML::Element< wchar_t > const&);
+ ImplParamValue (::XSCRT::XML::Attribute< wchar_t > const&);
+ ImplParamValue (ImplParamValue const& s);
+
+ ImplParamValue&
+ operator= (ImplParamValue const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class TimeValue : public ::XMLSchema::int_
+ {
+ //@@ VC6 anathema
+ typedef ::XMLSchema::int_ Base__;
+
+ public:
+ TimeValue (::XMLSchema::int_ const& b__);
+
+ TimeValue (::XSCRT::XML::Element< wchar_t > const&);
+ TimeValue (::XSCRT::XML::Attribute< wchar_t > const&);
+ TimeValue (TimeValue const& s);
+
+ TimeValue&
+ operator= (TimeValue const& s);
+
+ private:
+ char regulator__;
+ };
+
+ class Resource : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // resourceID
+ //
+ public:
+ ::SA_POP::XML::ResourceID const& resourceID () const;
+ void resourceID (::SA_POP::XML::ResourceID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ResourceID > resourceID_;
+
+ // kind
+ //
+ public:
+ ::SA_POP::XML::ResourceKind const& kind () const;
+ void kind (::SA_POP::XML::ResourceKind const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ResourceKind > kind_;
+
+ // capacity
+ //
+ public:
+ ::SA_POP::XML::ResourceValue const& capacity () const;
+ void capacity (::SA_POP::XML::ResourceValue const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ResourceValue > capacity_;
+
+ public:
+ Resource (::SA_POP::XML::ResourceID const& resourceID__,
+ ::SA_POP::XML::ResourceKind const& kind__,
+ ::SA_POP::XML::ResourceValue const& capacity__);
+
+ Resource (::XSCRT::XML::Element< wchar_t > const&);
+ Resource (Resource const& s);
+
+ Resource&
+ operator= (Resource const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class ImplParam : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // paramID
+ //
+ public:
+ ::SA_POP::XML::ImplParamID const& paramID () const;
+ void paramID (::SA_POP::XML::ImplParamID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ImplParamID > paramID_;
+
+ // kind
+ //
+ public:
+ ::SA_POP::XML::ImplParamKind const& kind () const;
+ void kind (::SA_POP::XML::ImplParamKind const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ImplParamKind > kind_;
+
+ // value
+ //
+ public:
+ ::SA_POP::XML::ImplParamValue const& value () const;
+ void value (::SA_POP::XML::ImplParamValue const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ImplParamValue > value_;
+
+ public:
+ ImplParam (::SA_POP::XML::ImplParamID const& paramID__,
+ ::SA_POP::XML::ImplParamKind const& kind__,
+ ::SA_POP::XML::ImplParamValue const& value__);
+
+ ImplParam (::XSCRT::XML::Element< wchar_t > const&);
+ ImplParam (ImplParam const& s);
+
+ ImplParam&
+ operator= (ImplParam const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class TaskImpl : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // implID
+ //
+ public:
+ ::SA_POP::XML::TaskImplID const& implID () const;
+ void implID (::SA_POP::XML::TaskImplID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::TaskImplID > implID_;
+
+ // param
+ //
+ public:
+ typedef ::std::list< ::SA_POP::XML::ImplParam >::iterator param_iterator;
+ typedef ::std::list< ::SA_POP::XML::ImplParam >::const_iterator param_const_iterator;
+ param_iterator begin_param ();
+ param_iterator end_param ();
+ param_const_iterator begin_param () const;
+ param_const_iterator end_param () const;
+ void add_param (::SA_POP::XML::ImplParam const& );
+ size_t count_param (void) const;
+
+ protected:
+ ::std::list< ::SA_POP::XML::ImplParam > param_;
+
+ public:
+ TaskImpl (::SA_POP::XML::TaskImplID const& implID__);
+
+ TaskImpl (::XSCRT::XML::Element< wchar_t > const&);
+ TaskImpl (TaskImpl const& s);
+
+ TaskImpl&
+ operator= (TaskImpl const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class TaskToImpl : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // taskID
+ //
+ public:
+ ::SA_POP::XML::TaskID const& taskID () const;
+ void taskID (::SA_POP::XML::TaskID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::TaskID > taskID_;
+
+ // implID
+ //
+ public:
+ ::SA_POP::XML::TaskImplID const& implID () const;
+ void implID (::SA_POP::XML::TaskImplID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::TaskImplID > implID_;
+
+ // duration
+ //
+ public:
+ ::SA_POP::XML::TimeValue const& duration () const;
+ void duration (::SA_POP::XML::TimeValue const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::TimeValue > duration_;
+
+ public:
+ TaskToImpl (::SA_POP::XML::TaskID const& taskID__,
+ ::SA_POP::XML::TaskImplID const& implID__,
+ ::SA_POP::XML::TimeValue const& duration__);
+
+ TaskToImpl (::XSCRT::XML::Element< wchar_t > const&);
+ TaskToImpl (TaskToImpl const& s);
+
+ TaskToImpl&
+ operator= (TaskToImpl const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class ImplToResource : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // implID
+ //
+ public:
+ ::SA_POP::XML::TaskImplID const& implID () const;
+ void implID (::SA_POP::XML::TaskImplID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::TaskImplID > implID_;
+
+ // resourceID
+ //
+ public:
+ ::SA_POP::XML::ResourceID const& resourceID () const;
+ void resourceID (::SA_POP::XML::ResourceID const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ResourceID > resourceID_;
+
+ // utilization
+ //
+ public:
+ ::SA_POP::XML::ResourceValue const& utilization () const;
+ void utilization (::SA_POP::XML::ResourceValue const& );
+
+ protected:
+ ::std::auto_ptr< ::SA_POP::XML::ResourceValue > utilization_;
+
+ public:
+ ImplToResource (::SA_POP::XML::TaskImplID const& implID__,
+ ::SA_POP::XML::ResourceID const& resourceID__,
+ ::SA_POP::XML::ResourceValue const& utilization__);
+
+ ImplToResource (::XSCRT::XML::Element< wchar_t > const&);
+ ImplToResource (ImplToResource const& s);
+
+ ImplToResource&
+ operator= (ImplToResource const& s);
+
+ private:
+ char regulator__;
+ };
+
+
+ class TaskMap : public ::XSCRT::Type
+ {
+ //@@ VC6 anathema
+ typedef ::XSCRT::Type Base__;
+
+ // taskImpl
+ //
+ public:
+ typedef ::std::list< ::SA_POP::XML::TaskImpl >::iterator taskImpl_iterator;
+ typedef ::std::list< ::SA_POP::XML::TaskImpl >::const_iterator taskImpl_const_iterator;
+ taskImpl_iterator begin_taskImpl ();
+ taskImpl_iterator end_taskImpl ();
+ taskImpl_const_iterator begin_taskImpl () const;
+ taskImpl_const_iterator end_taskImpl () const;
+ void add_taskImpl (::SA_POP::XML::TaskImpl const& );
+ size_t count_taskImpl (void) const;
+
+ protected:
+ ::std::list< ::SA_POP::XML::TaskImpl > taskImpl_;
+
+ // resource
+ //
+ public:
+ typedef ::std::list< ::SA_POP::XML::Resource >::iterator resource_iterator;
+ typedef ::std::list< ::SA_POP::XML::Resource >::const_iterator resource_const_iterator;
+ resource_iterator begin_resource ();
+ resource_iterator end_resource ();
+ resource_const_iterator begin_resource () const;
+ resource_const_iterator end_resource () const;
+ void add_resource (::SA_POP::XML::Resource const& );
+ size_t count_resource (void) const;
+
+ protected:
+ ::std::list< ::SA_POP::XML::Resource > resource_;
+
+ // taskToImpl
+ //
+ public:
+ typedef ::std::list< ::SA_POP::XML::TaskToImpl >::iterator taskToImpl_iterator;
+ typedef ::std::list< ::SA_POP::XML::TaskToImpl >::const_iterator taskToImpl_const_iterator;
+ taskToImpl_iterator begin_taskToImpl ();
+ taskToImpl_iterator end_taskToImpl ();
+ taskToImpl_const_iterator begin_taskToImpl () const;
+ taskToImpl_const_iterator end_taskToImpl () const;
+ void add_taskToImpl (::SA_POP::XML::TaskToImpl const& );
+ size_t count_taskToImpl (void) const;
+
+ protected:
+ ::std::list< ::SA_POP::XML::TaskToImpl > taskToImpl_;
+
+ // implToResource
+ //
+ public:
+ typedef ::std::list< ::SA_POP::XML::ImplToResource >::iterator implToResource_iterator;
+ typedef ::std::list< ::SA_POP::XML::ImplToResource >::const_iterator implToResource_const_iterator;
+ implToResource_iterator begin_implToResource ();
+ implToResource_iterator end_implToResource ();
+ implToResource_const_iterator begin_implToResource () const;
+ implToResource_const_iterator end_implToResource () const;
+ void add_implToResource (::SA_POP::XML::ImplToResource const& );
+ size_t count_implToResource (void) const;
+
+ protected:
+ ::std::list< ::SA_POP::XML::ImplToResource > implToResource_;
+
+ public:
+ TaskMap ();
+
+ TaskMap (::XSCRT::XML::Element< wchar_t > const&);
+ TaskMap (TaskMap const& s);
+
+ TaskMap&
+ operator= (TaskMap const& s);
+
+ private:
+ char regulator__;
+ };
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ ::SA_POP::XML::TaskMap
+ taskMap (xercesc::DOMDocument const*);
+ }
+}
+
+#include "XMLSchema/Traversal.hpp"
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ namespace Traversal
+ {
+ struct TaskID : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::TaskID >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TaskImplID : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::TaskImplID >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct ResourceID : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ResourceID >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ typedef
+ ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ResourceKind >
+ ResourceKind;
+
+ struct ResourceValue : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ResourceValue >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct ImplParamID : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ImplParamID >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct ImplParamKind : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ImplParamKind >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct ImplParamValue : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ImplParamValue >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TimeValue : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::TimeValue >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct Resource : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::Resource >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ resourceID (Type&);
+
+ virtual void
+ resourceID (Type const&);
+
+ virtual void
+ kind (Type&);
+
+ virtual void
+ kind (Type const&);
+
+ virtual void
+ capacity (Type&);
+
+ virtual void
+ capacity (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct ImplParam : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ImplParam >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ paramID (Type&);
+
+ virtual void
+ paramID (Type const&);
+
+ virtual void
+ kind (Type&);
+
+ virtual void
+ kind (Type const&);
+
+ virtual void
+ value (Type&);
+
+ virtual void
+ value (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TaskImpl : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::TaskImpl >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ implID (Type&);
+
+ virtual void
+ implID (Type const&);
+
+ virtual void
+ param (Type&);
+
+ virtual void
+ param (Type const&);
+
+ virtual void
+ param_pre (Type&);
+
+ virtual void
+ param_pre (Type const&);
+
+ virtual void
+ param_next (Type&);
+
+ virtual void
+ param_next (Type const&);
+
+ virtual void
+ param_post (Type&);
+
+ virtual void
+ param_post (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TaskToImpl : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::TaskToImpl >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ taskID (Type&);
+
+ virtual void
+ taskID (Type const&);
+
+ virtual void
+ implID (Type&);
+
+ virtual void
+ implID (Type const&);
+
+ virtual void
+ duration (Type&);
+
+ virtual void
+ duration (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct ImplToResource : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::ImplToResource >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ implID (Type&);
+
+ virtual void
+ implID (Type const&);
+
+ virtual void
+ resourceID (Type&);
+
+ virtual void
+ resourceID (Type const&);
+
+ virtual void
+ utilization (Type&);
+
+ virtual void
+ utilization (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+
+ struct TaskMap : ::XMLSchema::Traversal::Traverser< ::SA_POP::XML::TaskMap >
+ {
+ virtual void
+ traverse (Type&);
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ pre (Type&);
+
+ virtual void
+ pre (Type const&);
+
+ virtual void
+ taskImpl (Type&);
+
+ virtual void
+ taskImpl (Type const&);
+
+ virtual void
+ taskImpl_pre (Type&);
+
+ virtual void
+ taskImpl_pre (Type const&);
+
+ virtual void
+ taskImpl_next (Type&);
+
+ virtual void
+ taskImpl_next (Type const&);
+
+ virtual void
+ taskImpl_post (Type&);
+
+ virtual void
+ taskImpl_post (Type const&);
+
+ virtual void
+ resource (Type&);
+
+ virtual void
+ resource (Type const&);
+
+ virtual void
+ resource_pre (Type&);
+
+ virtual void
+ resource_pre (Type const&);
+
+ virtual void
+ resource_next (Type&);
+
+ virtual void
+ resource_next (Type const&);
+
+ virtual void
+ resource_post (Type&);
+
+ virtual void
+ resource_post (Type const&);
+
+ virtual void
+ taskToImpl (Type&);
+
+ virtual void
+ taskToImpl (Type const&);
+
+ virtual void
+ taskToImpl_pre (Type&);
+
+ virtual void
+ taskToImpl_pre (Type const&);
+
+ virtual void
+ taskToImpl_next (Type&);
+
+ virtual void
+ taskToImpl_next (Type const&);
+
+ virtual void
+ taskToImpl_post (Type&);
+
+ virtual void
+ taskToImpl_post (Type const&);
+
+ virtual void
+ implToResource (Type&);
+
+ virtual void
+ implToResource (Type const&);
+
+ virtual void
+ implToResource_pre (Type&);
+
+ virtual void
+ implToResource_pre (Type const&);
+
+ virtual void
+ implToResource_next (Type&);
+
+ virtual void
+ implToResource_next (Type const&);
+
+ virtual void
+ implToResource_post (Type&);
+
+ virtual void
+ implToResource_post (Type const&);
+
+ virtual void
+ post (Type&);
+
+ virtual void
+ post (Type const&);
+ };
+ }
+ }
+}
+
+#include "XMLSchema/Writer.hpp"
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ namespace Writer
+ {
+ struct TaskID : Traversal::TaskID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::TaskID Type;
+ TaskID (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ TaskID ();
+ };
+
+ struct TaskImplID : Traversal::TaskImplID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::TaskImplID Type;
+ TaskImplID (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ TaskImplID ();
+ };
+
+ struct ResourceID : Traversal::ResourceID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ResourceID Type;
+ ResourceID (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ ResourceID ();
+ };
+
+ struct ResourceKind : Traversal::ResourceKind,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ ResourceKind (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ ResourceKind ();
+ };
+
+ struct ResourceValue : Traversal::ResourceValue,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ResourceValue Type;
+ ResourceValue (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ ResourceValue ();
+ };
+
+ struct ImplParamID : Traversal::ImplParamID,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ImplParamID Type;
+ ImplParamID (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ ImplParamID ();
+ };
+
+ struct ImplParamKind : Traversal::ImplParamKind,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ImplParamKind Type;
+ ImplParamKind (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ ImplParamKind ();
+ };
+
+ struct ImplParamValue : Traversal::ImplParamValue,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::string< wchar_t >, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ImplParamValue Type;
+ ImplParamValue (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ ImplParamValue ();
+ };
+
+ struct TimeValue : Traversal::TimeValue,
+ virtual ::XMLSchema::Writer::FundamentalType< ::XMLSchema::int_, wchar_t >,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::TimeValue Type;
+ TimeValue (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ protected:
+ TimeValue ();
+ };
+
+ struct Resource : Traversal::Resource,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::Resource Type;
+ Resource (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ resourceID (Type &o)
+ {
+
+ this->resourceID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ resourceID (Type const&);
+
+ virtual void
+ kind (Type &o)
+ {
+
+ this->kind (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ kind (Type const&);
+
+ virtual void
+ capacity (Type &o)
+ {
+
+ this->capacity (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ capacity (Type const&);
+
+ protected:
+ Resource ();
+ };
+
+ struct ImplParam : Traversal::ImplParam,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ImplParam Type;
+ ImplParam (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ paramID (Type &o)
+ {
+
+ this->paramID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ paramID (Type const&);
+
+ virtual void
+ kind (Type &o)
+ {
+
+ this->kind (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ kind (Type const&);
+
+ virtual void
+ value (Type &o)
+ {
+
+ this->value (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ value (Type const&);
+
+ protected:
+ ImplParam ();
+ };
+
+ struct TaskImpl : Traversal::TaskImpl,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::TaskImpl Type;
+ TaskImpl (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ implID (Type &o)
+ {
+
+ this->implID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ implID (Type const&);
+
+ virtual void
+ param_pre (Type &o)
+ {
+
+ this->param_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ param_pre (Type const&);
+
+ virtual void
+ param_next (Type &o)
+ {
+
+ this->param_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ param_next (Type const&);
+
+ virtual void
+ param_post (Type &o)
+ {
+
+ this->param_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ param_post (Type const&);
+
+ protected:
+ TaskImpl ();
+ };
+
+ struct TaskToImpl : Traversal::TaskToImpl,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::TaskToImpl Type;
+ TaskToImpl (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ taskID (Type &o)
+ {
+
+ this->taskID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskID (Type const&);
+
+ virtual void
+ implID (Type &o)
+ {
+
+ this->implID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ implID (Type const&);
+
+ virtual void
+ duration (Type &o)
+ {
+
+ this->duration (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ duration (Type const&);
+
+ protected:
+ TaskToImpl ();
+ };
+
+ struct ImplToResource : Traversal::ImplToResource,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::ImplToResource Type;
+ ImplToResource (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ implID (Type &o)
+ {
+
+ this->implID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ implID (Type const&);
+
+ virtual void
+ resourceID (Type &o)
+ {
+
+ this->resourceID (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ resourceID (Type const&);
+
+ virtual void
+ utilization (Type &o)
+ {
+
+ this->utilization (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ utilization (Type const&);
+
+ protected:
+ ImplToResource ();
+ };
+
+ struct TaskMap : Traversal::TaskMap,
+ virtual ::XSCRT::Writer< wchar_t >
+ {
+ typedef ::SA_POP::XML::TaskMap Type;
+ TaskMap (::XSCRT::XML::Element< wchar_t >&);
+
+ virtual void
+ traverse (Type &o)
+ {
+
+ this->traverse (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ traverse (Type const&);
+
+ virtual void
+ taskImpl_pre (Type &o)
+ {
+
+ this->taskImpl_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskImpl_pre (Type const&);
+
+ virtual void
+ taskImpl_next (Type &o)
+ {
+
+ this->taskImpl_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskImpl_next (Type const&);
+
+ virtual void
+ taskImpl_post (Type &o)
+ {
+
+ this->taskImpl_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskImpl_post (Type const&);
+
+ virtual void
+ resource_pre (Type &o)
+ {
+
+ this->resource_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ resource_pre (Type const&);
+
+ virtual void
+ resource_next (Type &o)
+ {
+
+ this->resource_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ resource_next (Type const&);
+
+ virtual void
+ resource_post (Type &o)
+ {
+
+ this->resource_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ resource_post (Type const&);
+
+ virtual void
+ taskToImpl_pre (Type &o)
+ {
+
+ this->taskToImpl_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskToImpl_pre (Type const&);
+
+ virtual void
+ taskToImpl_next (Type &o)
+ {
+
+ this->taskToImpl_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskToImpl_next (Type const&);
+
+ virtual void
+ taskToImpl_post (Type &o)
+ {
+
+ this->taskToImpl_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ taskToImpl_post (Type const&);
+
+ virtual void
+ implToResource_pre (Type &o)
+ {
+
+ this->implToResource_pre (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ implToResource_pre (Type const&);
+
+ virtual void
+ implToResource_next (Type &o)
+ {
+
+ this->implToResource_next (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ implToResource_next (Type const&);
+
+ virtual void
+ implToResource_post (Type &o)
+ {
+
+ this->implToResource_post (const_cast <Type const &> (o));
+ }
+
+
+ virtual void
+ implToResource_post (Type const&);
+
+ protected:
+ TaskMap ();
+ };
+ }
+ }
+}
+
+namespace SA_POP
+{
+ namespace XML
+ {
+ void
+ taskMap (::SA_POP::XML::TaskMap const&, xercesc::DOMDocument*);
+ }
+}
+
+#endif // XML_TASKMAP_HPP