From 8fc752c08ed1e27eb10a4ff2573f7f5c8daa2996 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 26 Mar 2021 13:40:46 -0500 Subject: [PATCH 01/36] new files and small name changes to create deploymanagerinst --- src/cycamore.h | 1 + src/deploy_manager_inst.cc | 87 ++++++++++++++ src/deploy_manager_inst.h | 111 ++++++++++++++++++ src/deploy_manager_inst_tests.cc | 194 +++++++++++++++++++++++++++++++ 4 files changed, 393 insertions(+) create mode 100644 src/deploy_manager_inst.cc create mode 100644 src/deploy_manager_inst.h create mode 100644 src/deploy_manager_inst_tests.cc diff --git a/src/cycamore.h b/src/cycamore.h index f4820e7f2d..d952ebc5fd 100644 --- a/src/cycamore.h +++ b/src/cycamore.h @@ -18,6 +18,7 @@ #include "inpro_reactor_tests.h" #include "manager_inst.h" #include "manager_inst_tests.h" +#include "deploy_manager_inst.h" #include "sink.h" #include "sink_tests.h" #include "source.h" diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc new file mode 100644 index 0000000000..144879298b --- /dev/null +++ b/src/deploy_manager_inst.cc @@ -0,0 +1,87 @@ +// Implements the DeployInst class +#include "deploy__manager_inst.h" + +namespace cycamore { + +DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) + : cyclus::Institution(ctx), + latitude(0.0), + longitude(0.0), + coordinates(latitude, longitude) {} + +DeployManagerInst::~DeployManagerInst() {} + +void DeployManagerInst::Build(cyclus::Agent* parent) { + cyclus::Institution::Build(parent); + BuildSched::iterator it; + std::set protos; + for (int i = 0; i < prototypes.size(); i++) { + std::string proto = prototypes[i]; + + std::stringstream ss; + ss << proto; + + if (lifetimes.size() == prototypes.size()) { + cyclus::Agent* a = context()->CreateAgent(proto); + if (a->lifetime() != lifetimes[i]) { + a->lifetime(lifetimes[i]); + + if (lifetimes[i] == -1) { + ss << "_life_forever"; + } else { + ss << "_life_" << lifetimes[i]; + } + proto = ss.str(); + if (protos.count(proto) == 0) { + protos.insert(proto); + context()->AddPrototype(proto, a); + } + } + } + + int t = build_times[i]; + for (int j = 0; j < n_build[i]; j++) { + context()->SchedBuild(this, proto, t); + } + } +} + +void DeployManagerInst::EnterNotify() { + cyclus::Institution::EnterNotify(); + int n = prototypes.size(); + if (build_times.size() != n) { + std::stringstream ss; + ss << "prototype '" << prototype() << "' has " << build_times.size() + << " build_times vals, expected " << n; + throw cyclus::ValueError(ss.str()); + } else if (n_build.size() != n) { + std::stringstream ss; + ss << "prototype '" << prototype() << "' has " << n_build.size() + << " n_build vals, expected " << n; + throw cyclus::ValueError(ss.str()); + } else if (lifetimes.size() > 0 && lifetimes.size() != n) { + std::stringstream ss; + ss << "prototype '" << prototype() << "' has " << lifetimes.size() + << " lifetimes vals, expected " << n; + throw cyclus::ValueError(ss.str()); + } + RecordPosition(); +} + +void DeployManagerInst::RecordPosition() { + std::string specification = this->spec(); + context() + ->NewDatum("AgentPosition") + ->AddVal("Spec", specification) + ->AddVal("Prototype", this->prototype()) + ->AddVal("AgentId", id()) + ->AddVal("Latitude", latitude) + ->AddVal("Longitude", longitude) + ->Record(); +} + +extern "C" cyclus::Agent* ConstructDeployInst(cyclus::Context* ctx) { + return new DeployManagerInst(ctx); +} + +} // namespace cycamore diff --git a/src/deploy_manager_inst.h b/src/deploy_manager_inst.h new file mode 100644 index 0000000000..943a814576 --- /dev/null +++ b/src/deploy_manager_inst.h @@ -0,0 +1,111 @@ +#ifndef CYCAMORE_SRC_DEPLOY_MANAGER_INST_H_ +#define CYCAMORE_SRC_DEPLOY_MANAGER_INST_H_ + +#include +#include +#include + +#include "cyclus.h" +#include "cycamore_version.h" + +namespace cycamore { + +typedef std::map > BuildSched; + +// Builds and manages agents (facilities) according to a manually specified +// deployment schedule. Deployed agents are automatically decommissioned at +// the end of their lifetime. The user specifies a list of prototypes for +// each and corresponding build times, number to build, and (optionally) +// lifetimes. The same prototype can be specified multiple times with any +// combination of the same or different build times, build number, and +// lifetimes. +class DeployManagerInst : public cyclus::Institution, + public cyclus::toolkit::Position { + #pragma cyclus note { \ + "doc": \ + "Builds and manages agents (facilities) according to a manually" \ + " specified deployment schedule. Deployed agents are automatically" \ + " decommissioned at the end of their lifetime. The user specifies a" \ + " list of prototypes for" \ + " each and corresponding build times, number to build, and (optionally)" \ + " lifetimes. The same prototype can be specified multiple times with" \ + " any combination of the same or different build times, build number," \ + " and lifetimes. " \ + } + public: + DeployManagerInst(cyclus::Context* ctx); + + virtual ~DeployManagerInst(); + + virtual std::string version() { return CYCAMORE_VERSION; } + + #pragma cyclus + + virtual void Build(cyclus::Agent* parent); + + virtual void EnterNotify(); + + protected: + #pragma cyclus var { \ + "doc": "Ordered list of prototypes to build.", \ + "uitype": ("oneormore", "prototype"), \ + "uilabel": "Prototypes to deploy", \ + } + std::vector prototypes; + + #pragma cyclus var { \ + "doc": "Time step on which to deploy agents given in prototype list " \ + "(same order).", \ + "uilabel": "Deployment times", \ + } + std::vector build_times; + + #pragma cyclus var { \ + "doc": "Number of each prototype given in prototype list that should be " \ + "deployed (same order).", \ + "uilabel": "Number to deploy", \ + } + std::vector n_build; + + + #pragma cyclus var { \ + "doc": "Lifetimes for each prototype in prototype list (same order)." \ + " These lifetimes override the lifetimes in the original prototype" \ + " definition." \ + " If unspecified, lifetimes from the original prototype definitions"\ + " are used." \ + " Although a new prototype is created in the Prototypes table for" \ + " each lifetime with the suffix '_life_[lifetime]'," \ + " all deployed agents themselves will have the same original" \ + " prototype name (and so will the Agents tables).", \ + "default": [], \ + "uilabel": "Lifetimes" \ + } + std::vector lifetimes; + + private: + #pragma cyclus var { \ + "default": 0.0, \ + "uilabel": "Geographical latitude in degrees as a double", \ + "doc": "Latitude of the agent's geographical position. The value should " \ + "be expressed in degrees as a double." \ + } + double latitude; + + #pragma cyclus var { \ + "default": 0.0, \ + "uilabel": "Geographical longitude in degrees as a double", \ + "doc": "Longitude of the agent's geographical position. The value should " \ + "be expressed in degrees as a double." \ + } + double longitude; + + cyclus::toolkit::Position coordinates; + + /// Records an agent's latitude and longitude to the output db + void RecordPosition(); +}; + +} // namespace cycamore + +#endif // CYCAMORE_SRC_DEPLOY_MANAGER_INST_H_ diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc new file mode 100644 index 0000000000..2ce76836ff --- /dev/null +++ b/src/deploy_manager_inst_tests.cc @@ -0,0 +1,194 @@ +#include + +#include "context.h" +#include "deploy_manager_inst.h" +#include "institution_tests.h" +#include "agent_tests.h" + +// make sure that the deployed agent's prototype name is identical to the +// originally specified prototype name - this is important to test because +// DeployInst does some mucking around with registering name-modded prototypes +// in order to deal with lifetime setting. + +using cyclus::QueryResult; + +TEST(DeployManagerInstTests, ProtoNames) { + std::string config = + " foobar " + " 1 " + " 3 " + " 2 " + ; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + int id = sim.Run(); + + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar';" + ); + stmt->Step(); + EXPECT_EQ(3, stmt->GetInt(0)); +} + +TEST(DeployManagerInstTests, BuildTimes) { + std::string config = + " foobar foobar " + " 1 3 " + " 1 7 " + ; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + int id = sim.Run(); + + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1;" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); + + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 3;" + ); + stmt->Step(); + EXPECT_EQ(7, stmt->GetInt(0)); +} + +// make sure that specified lifetimes are honored both in agent's table record +// and in decommissioning. +TEST(DeployManagerInstTests, FiniteLifetimes) { + std::string config = + " foobar foobar foobar " + " 1 1 2 " + " 1 7 3 " + " 1 2 -1 " + ; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + int id = sim.Run(); + + // check agent deployment + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 1;" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); + + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 2;" + ); + stmt->Step(); + EXPECT_EQ(7, stmt->GetInt(0)); + + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 2 AND Lifetime = -1;" + ); + stmt->Step(); + EXPECT_EQ(3, stmt->GetInt(0)); + + // check decommissioning + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry As e JOIN AgentExit AS x ON x.AgentId = e.AgentId WHERE e.Prototype = 'foobar' AND x.ExitTime = 1;" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); + + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry As e JOIN AgentExit AS x ON x.AgentId = e.AgentId WHERE e.Prototype = 'foobar' AND x.ExitTime = 2;" + ); + stmt->Step(); + EXPECT_EQ(7, stmt->GetInt(0)); + + // agent with -1 lifetime should not be in AgentExit table + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentExit;" + ); + stmt->Step(); + EXPECT_EQ(8, stmt->GetInt(0)); +} + +TEST(DeployManagerInstTests, NoDupProtos) { + std::string config = + " foobar foobar foobar " + " 1 1 2 " + " 1 7 3 " + " 1 1 -1 " + ; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + int id = sim.Run(); + + // don't duplicate same prototypes with same custom lifetime + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM Prototypes WHERE Prototype = 'foobar_life_1';" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); + + // don't duplicate custom lifetimes that are identical to original prototype + // lifetime. + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM Prototypes WHERE Prototype = 'foobar';" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); +} + +TEST(DeployManagerInstTests, PositionInitialize) { + std::string config = + " foobar " + " 1 " + " 3 " + " 2 "; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + int id = sim.Run(); + + QueryResult qr = sim.db().Query("AgentPosition", NULL); + EXPECT_EQ(qr.GetVal("Latitude"), 0.0); + EXPECT_EQ(qr.GetVal("Longitude"), 0.0); +} + +TEST(DeployManagerInstTests, PositionInitialize2) { + std::string config = + " foobar " + " -20.0 " + " 2.0 " + " 1 " + " 3 " + " 2 "; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + int id = sim.Run(); + + QueryResult qr = sim.db().Query("AgentPosition", NULL); + EXPECT_EQ(qr.GetVal("Latitude"), 2.0); + EXPECT_EQ(qr.GetVal("Longitude"), -20.0); +} + +// required to get functionality in cyclus agent unit tests library +cyclus::Agent* DeployManagerInstitutionConstructor(cyclus::Context* ctx) { + return new cycamore::DeployManagerInst(ctx); +} + +#ifndef CYCLUS_AGENT_TESTS_CONNECTED +int ConnectAgentTests(); +static int cyclus_agent_tests_connected = ConnectAgentTests(); +#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected +#endif // CYCLUS_AGENT_TESTS_CONNECTED + +INSTANTIATE_TEST_CASE_P(DeployInst, InstitutionTests, + Values(&DeployManagerInstitutionConstructor)); +INSTANTIATE_TEST_CASE_P(DeployInst, AgentTests, + Values(&DeployManagerInstitutionConstructor)); From 31839c4b355fbd454c9339f0dc1dd26182755bf8 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 26 Mar 2021 14:55:47 -0500 Subject: [PATCH 02/36] fixed typo --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b626877cf5..39970e587c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,8 @@ USE_CYCLUS("cycamore" "deploy_inst") USE_CYCLUS("cycamore" "manager_inst") +USE_CYCLUS("cycamore" "deploy_manager_inst") + USE_CYCLUS("cycamore" "growth_region") USE_CYCLUS("cycamore" "storage") From 2c69856d1cc3d282e0a2df5ab99af86e532abdde Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 26 Mar 2021 15:04:48 -0500 Subject: [PATCH 03/36] missed instance, fixed typo --- src/deploy_manager_inst.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc index 144879298b..1ee51bba90 100644 --- a/src/deploy_manager_inst.cc +++ b/src/deploy_manager_inst.cc @@ -1,5 +1,5 @@ // Implements the DeployInst class -#include "deploy__manager_inst.h" +#include "deploy_manager_inst.h" namespace cycamore { @@ -80,7 +80,7 @@ void DeployManagerInst::RecordPosition() { ->Record(); } -extern "C" cyclus::Agent* ConstructDeployInst(cyclus::Context* ctx) { +extern "C" cyclus::Agent* ConstructDeployManagerInst(cyclus::Context* ctx) { return new DeployManagerInst(ctx); } From 3a53159074d90738e93ae35521852e4679517d1e Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 26 Mar 2021 15:09:16 -0500 Subject: [PATCH 04/36] added test file --- src/cycamore.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cycamore.h b/src/cycamore.h index d952ebc5fd..1bf5df5c3a 100644 --- a/src/cycamore.h +++ b/src/cycamore.h @@ -19,6 +19,7 @@ #include "manager_inst.h" #include "manager_inst_tests.h" #include "deploy_manager_inst.h" +#include "deploy_manager_inst_tests.h" #include "sink.h" #include "sink_tests.h" #include "source.h" From 1a1483d327100c92f8326f4f0bcdb2b7d9fd067b Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 26 Mar 2021 15:27:05 -0500 Subject: [PATCH 05/36] missed a few instances near the end --- src/deploy_manager_inst_tests.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 2ce76836ff..9ae301aeb4 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -188,7 +188,7 @@ static int cyclus_agent_tests_connected = ConnectAgentTests(); #define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected #endif // CYCLUS_AGENT_TESTS_CONNECTED -INSTANTIATE_TEST_CASE_P(DeployInst, InstitutionTests, +INSTANTIATE_TEST_CASE_P(DeployManagerInst, InstitutionTests, Values(&DeployManagerInstitutionConstructor)); -INSTANTIATE_TEST_CASE_P(DeployInst, AgentTests, +INSTANTIATE_TEST_CASE_P(DeployManagerInst, AgentTests, Values(&DeployManagerInstitutionConstructor)); From 064b8500731bc878cf2e6272a3eb82448144cca7 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 2 Apr 2021 09:43:56 -0500 Subject: [PATCH 06/36] inherit from managerinst, installs, tests fail --- src/deploy_manager_inst.cc | 2 +- src/deploy_manager_inst.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc index 1ee51bba90..8cdd06e3e8 100644 --- a/src/deploy_manager_inst.cc +++ b/src/deploy_manager_inst.cc @@ -4,7 +4,7 @@ namespace cycamore { DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) - : cyclus::Institution(ctx), + : cycamore::ManagerInst(ctx), latitude(0.0), longitude(0.0), coordinates(latitude, longitude) {} diff --git a/src/deploy_manager_inst.h b/src/deploy_manager_inst.h index 943a814576..bdb40167c0 100644 --- a/src/deploy_manager_inst.h +++ b/src/deploy_manager_inst.h @@ -7,6 +7,7 @@ #include "cyclus.h" #include "cycamore_version.h" +#include "manager_inst.h" namespace cycamore { @@ -19,7 +20,9 @@ typedef std::map > BuildSched; // lifetimes. The same prototype can be specified multiple times with any // combination of the same or different build times, build number, and // lifetimes. -class DeployManagerInst : public cyclus::Institution, +class DeployManagerInst : + //public cyclus::Institution, + public cycamore::ManagerInst, public cyclus::toolkit::Position { #pragma cyclus note { \ "doc": \ From 3e2d6b8662b5ccbdf7895df702a450d5bbdf0059 Mon Sep 17 00:00:00 2001 From: Katy Huff Date: Thu, 22 Apr 2021 13:44:40 -0500 Subject: [PATCH 07/36] makes explicit calls to functions in cyclus::Institution actually call cyclus::ManagerInst instead. --- src/deploy_manager_inst.cc | 4 ++-- src/deploy_manager_inst.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc index 8cdd06e3e8..436e94088f 100644 --- a/src/deploy_manager_inst.cc +++ b/src/deploy_manager_inst.cc @@ -12,7 +12,7 @@ DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) DeployManagerInst::~DeployManagerInst() {} void DeployManagerInst::Build(cyclus::Agent* parent) { - cyclus::Institution::Build(parent); + cycamore::ManagerInst::Build(parent); BuildSched::iterator it; std::set protos; for (int i = 0; i < prototypes.size(); i++) { @@ -47,7 +47,7 @@ void DeployManagerInst::Build(cyclus::Agent* parent) { } void DeployManagerInst::EnterNotify() { - cyclus::Institution::EnterNotify(); + cycamore::ManagerInst::EnterNotify(); int n = prototypes.size(); if (build_times.size() != n) { std::stringstream ss; diff --git a/src/deploy_manager_inst.h b/src/deploy_manager_inst.h index bdb40167c0..63b1476221 100644 --- a/src/deploy_manager_inst.h +++ b/src/deploy_manager_inst.h @@ -21,7 +21,6 @@ typedef std::map > BuildSched; // combination of the same or different build times, build number, and // lifetimes. class DeployManagerInst : - //public cyclus::Institution, public cycamore::ManagerInst, public cyclus::toolkit::Position { #pragma cyclus note { \ From 8ce30e9700f0ef881a82100610fe0bebe7ae053e Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 26 Apr 2021 07:39:05 -0500 Subject: [PATCH 08/36] pulled in BuildNotify from ManagerInst, tests still fail --- src/deploy_manager_inst.cc | 2 +- src/manager_inst.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc index 436e94088f..44744ef095 100644 --- a/src/deploy_manager_inst.cc +++ b/src/deploy_manager_inst.cc @@ -12,7 +12,7 @@ DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) DeployManagerInst::~DeployManagerInst() {} void DeployManagerInst::Build(cyclus::Agent* parent) { - cycamore::ManagerInst::Build(parent); + cyclus::Institution::Build(parent); BuildSched::iterator it; std::set protos; for (int i = 0; i < prototypes.size(); i++) { diff --git a/src/manager_inst.h b/src/manager_inst.h index ac86d81f1a..203b2e26c2 100644 --- a/src/manager_inst.h +++ b/src/manager_inst.h @@ -44,13 +44,13 @@ class ManagerInst void WriteProducerInformation(cyclus::toolkit::CommodityProducer* producer); - private: /// register a child void Register_(cyclus::Agent* agent); /// unregister a child void Unregister_(cyclus::Agent* agent); - + + protected: #pragma cyclus var { \ "tooltip": "producer facility prototypes", \ "uilabel": "Producer Prototype List", \ From dc1e95125791c9af008a3f7b66e73ebd85dccac6 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 29 Apr 2021 12:17:05 -0500 Subject: [PATCH 09/36] copied functions from ManagerInst, tests pass, works with toy problem --- src/deploy_manager_inst.cc | 56 ++++++++++++++++++++++++++++++++++++-- src/deploy_manager_inst.h | 24 ++++++++++++++-- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc index 44744ef095..4a2e836cc6 100644 --- a/src/deploy_manager_inst.cc +++ b/src/deploy_manager_inst.cc @@ -4,7 +4,8 @@ namespace cycamore { DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) - : cycamore::ManagerInst(ctx), + : cyclus::Institution(ctx), + //cycamore::ManagerInst(ctx), latitude(0.0), longitude(0.0), coordinates(latitude, longitude) {} @@ -47,7 +48,7 @@ void DeployManagerInst::Build(cyclus::Agent* parent) { } void DeployManagerInst::EnterNotify() { - cycamore::ManagerInst::EnterNotify(); + cyclus::Institution::EnterNotify(); int n = prototypes.size(); if (build_times.size() != n) { std::stringstream ss; @@ -68,6 +69,57 @@ void DeployManagerInst::EnterNotify() { RecordPosition(); } +void DeployManagerInst::BuildNotify(Agent* a) { + Register_(a); +} + +void DeployManagerInst::DecomNotify(Agent* a) { + Unregister_(a); +} + +void DeployManagerInst::Register_(Agent* a) { + using cyclus::toolkit::CommodityProducer; + using cyclus::toolkit::CommodityProducerManager; + + CommodityProducer* cp_cast = dynamic_cast(a); + if (cp_cast != NULL) { + LOG(cyclus::LEV_INFO3, "mani") << "Registering agent " + << a->prototype() << a->id() + << " as a commodity producer."; + CommodityProducerManager::Register(cp_cast); + } +} + +void DeployManagerInst::Unregister_(Agent* a) { + using cyclus::toolkit::CommodityProducer; + using cyclus::toolkit::CommodityProducerManager; + + CommodityProducer* cp_cast = dynamic_cast(a); + if (cp_cast != NULL) + CommodityProducerManager::Unregister(cp_cast); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeployManagerInst::WriteProducerInformation( + cyclus::toolkit::CommodityProducer* producer) { + using std::set; + set commodities = + producer->ProducedCommodities(); + set:: + iterator it; + + LOG(cyclus::LEV_DEBUG3, "maninst") << " Clone produces " << commodities.size() + << " commodities."; + for (it = commodities.begin(); it != commodities.end(); it++) { + LOG(cyclus::LEV_DEBUG3, "maninst") << " Commodity produced: " << it->name(); + LOG(cyclus::LEV_DEBUG3, "maninst") << " capacity: " << + producer->Capacity(*it); + LOG(cyclus::LEV_DEBUG3, "maninst") << " cost: " << + producer->Cost(*it); + } +} + void DeployManagerInst::RecordPosition() { std::string specification = this->spec(); context() diff --git a/src/deploy_manager_inst.h b/src/deploy_manager_inst.h index 63b1476221..862c2f74b4 100644 --- a/src/deploy_manager_inst.h +++ b/src/deploy_manager_inst.h @@ -7,7 +7,7 @@ #include "cyclus.h" #include "cycamore_version.h" -#include "manager_inst.h" +//#include "manager_inst.h" namespace cycamore { @@ -21,7 +21,10 @@ typedef std::map > BuildSched; // combination of the same or different build times, build number, and // lifetimes. class DeployManagerInst : - public cycamore::ManagerInst, + public cyclus::Institution, + //public :cycamore::ManagerInst, + public cyclus::toolkit::CommodityProducerManager, + public cyclus::toolkit::Builder, public cyclus::toolkit::Position { #pragma cyclus note { \ "doc": \ @@ -47,6 +50,19 @@ class DeployManagerInst : virtual void EnterNotify(); + virtual void BuildNotify(Agent* m); + virtual void DecomNotify(Agent* m); + /// write information about a commodity producer to a stream + /// @param producer the producer + void WriteProducerInformation(cyclus::toolkit::CommodityProducer* + producer); + + /// register a child + void Register_(cyclus::Agent* agent); + + /// unregister a child + void Unregister_(cyclus::Agent* agent); + protected: #pragma cyclus var { \ "doc": "Ordered list of prototypes to build.", \ @@ -106,6 +122,10 @@ class DeployManagerInst : /// Records an agent's latitude and longitude to the output db void RecordPosition(); + + /// Defines the spec for the DeployManagerInst + // std::string spec_; + }; } // namespace cycamore From d574667081704ed505a7a8c161178810bb6b8c42 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 3 May 2021 14:21:44 -0500 Subject: [PATCH 10/36] added tests from ManagerInst, new tests don't pass --- src/deploy_manager_inst_tests.cc | 57 ++++++++++++++++++++++++++---- src/deploy_manager_inst_tests.h | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 src/deploy_manager_inst_tests.h diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 9ae301aeb4..c73d91009a 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -1,17 +1,38 @@ -#include - -#include "context.h" -#include "deploy_manager_inst.h" -#include "institution_tests.h" -#include "agent_tests.h" - +#include "deploy_manager_inst_tests.h" // make sure that the deployed agent's prototype name is identical to the // originally specified prototype name - this is important to test because // DeployInst does some mucking around with registering name-modded prototypes // in order to deal with lifetime setting. +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//TestProducer::~TestProducer() {} + using cyclus::QueryResult; +void DeployManagerInstTests::SetUp() { + ctx_ = new cyclus::Context(&ti_, &rec_); + src_inst = new cycamore::DeployManagerInst(ctx_); + producer = new TestProducer(ctx_); + commodity = cyclus::toolkit::Commodity("commod"); + capacity = 5; + producer->cyclus::toolkit::CommodityProducer::Add(commodity); + producer->SetCapacity(commodity, capacity); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeployManagerInstTests::TearDown() { + delete producer; + delete src_inst; + delete ctx_; +} + + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + TEST(DeployManagerInstTests, ProtoNames) { std::string config = " foobar " @@ -177,6 +198,28 @@ TEST(DeployManagerInstTests, PositionInitialize2) { EXPECT_EQ(qr.GetVal("Longitude"), -20.0); } +TEST_F(DeployManagerInstTests, producerexists) { + using std::set; + ctx_->AddPrototype("foop", producer); + set::iterator it; + for (it = src_inst->cyclus::toolkit::CommodityProducerManager:: + producers().begin(); + it != src_inst->cyclus::toolkit::CommodityProducerManager:: + producers().end(); + it++) { + EXPECT_EQ(dynamic_cast(*it)->prototype(), + producer->prototype()); + } +} + +TEST_F(DeployManagerInstTests, productioncapacity) { + EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); + src_inst->BuildNotify(producer); + EXPECT_EQ(src_inst->TotalCapacity(commodity), capacity); + src_inst->DecomNotify(producer); + EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); +} + // required to get functionality in cyclus agent unit tests library cyclus::Agent* DeployManagerInstitutionConstructor(cyclus::Context* ctx) { return new cycamore::DeployManagerInst(ctx); diff --git a/src/deploy_manager_inst_tests.h b/src/deploy_manager_inst_tests.h new file mode 100644 index 0000000000..f08fcfc16b --- /dev/null +++ b/src/deploy_manager_inst_tests.h @@ -0,0 +1,59 @@ +#ifndef CYCAMORE_SRC_DEPLOY_MANAGER_INST_TESTS_H_ +#define CYCAMORE_SRC_DEPLOY_MANAGER_INST_TESTS_H_ + +#include + +#include "cyclus.h" +#include "timer.h" +#include "test_context.h" +#include "institution_tests.h" +#include "agent_tests.h" +#include "context.h" + +#include "deploy_manager_inst.h" + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +class TestProducer + : public cyclus::Facility, + public cyclus::toolkit::CommodityProducer { + public: + TestProducer(cyclus::Context* ctx); + ~TestProducer(); + + cyclus::Agent* Clone() { + TestProducer* m = new TestProducer(context()); + m->InitFrom(this); + return m; + } + + void InitFrom(TestProducer* m) { + cyclus::Facility::InitFrom(m); + } + + void InitInv(cyclus::Inventories& inv) {} + + cyclus::Inventories SnapshotInv() { return cyclus::Inventories(); } + + void Tock() {} + void Tick() {} +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +class DeployManagerInstTests : public ::testing::Test { + public: + virtual void SetUp(); + virtual void TearDown(); + + protected: + cycamore::DeployManagerInst* src_inst; + TestProducer* producer; + + cyclus::toolkit::Commodity commodity; + double capacity; + cyclus::Context* ctx_; + cyclus::Timer ti_; + cyclus::Recorder rec_; +}; + +#endif // CYCAMORE_SRC_MANAGER_INST_TESTS_H_ \ No newline at end of file From 2e93d6e271bed69abe8ee25e144917b41e9b7e1c Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 3 May 2021 14:28:28 -0500 Subject: [PATCH 11/36] changed to TEST_F and all tests pass now --- src/deploy_manager_inst_tests.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index c73d91009a..c5aac3ee31 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -33,7 +33,7 @@ void DeployManagerInstTests::TearDown() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TEST(DeployManagerInstTests, ProtoNames) { +TEST_F(DeployManagerInstTests, ProtoNames) { std::string config = " foobar " " 1 " @@ -53,7 +53,7 @@ TEST(DeployManagerInstTests, ProtoNames) { EXPECT_EQ(3, stmt->GetInt(0)); } -TEST(DeployManagerInstTests, BuildTimes) { +TEST_F(DeployManagerInstTests, BuildTimes) { std::string config = " foobar foobar " " 1 3 " @@ -80,7 +80,7 @@ TEST(DeployManagerInstTests, BuildTimes) { // make sure that specified lifetimes are honored both in agent's table record // and in decommissioning. -TEST(DeployManagerInstTests, FiniteLifetimes) { +TEST_F(DeployManagerInstTests, FiniteLifetimes) { std::string config = " foobar foobar foobar " " 1 1 2 " @@ -133,7 +133,7 @@ TEST(DeployManagerInstTests, FiniteLifetimes) { EXPECT_EQ(8, stmt->GetInt(0)); } -TEST(DeployManagerInstTests, NoDupProtos) { +TEST_F(DeployManagerInstTests, NoDupProtos) { std::string config = " foobar foobar foobar " " 1 1 2 " @@ -162,7 +162,7 @@ TEST(DeployManagerInstTests, NoDupProtos) { EXPECT_EQ(1, stmt->GetInt(0)); } -TEST(DeployManagerInstTests, PositionInitialize) { +TEST_F(DeployManagerInstTests, PositionInitialize) { std::string config = " foobar " " 1 " @@ -179,7 +179,7 @@ TEST(DeployManagerInstTests, PositionInitialize) { EXPECT_EQ(qr.GetVal("Longitude"), 0.0); } -TEST(DeployManagerInstTests, PositionInitialize2) { +TEST_F(DeployManagerInstTests, PositionInitialize2) { std::string config = " foobar " " -20.0 " From 607830569521f75c8d0141199818b1c9b161e45a Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 7 May 2021 13:05:19 -0500 Subject: [PATCH 12/36] cleaned up extra lines, added functionality to comments --- src/deploy_manager_inst.cc | 3 +-- src/deploy_manager_inst.h | 21 ++++++++++----------- src/deploy_manager_inst_tests.cc | 11 +---------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc index 4a2e836cc6..3c073a3bf7 100644 --- a/src/deploy_manager_inst.cc +++ b/src/deploy_manager_inst.cc @@ -1,11 +1,10 @@ -// Implements the DeployInst class +// Implements the DeployManagerInst class #include "deploy_manager_inst.h" namespace cycamore { DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) : cyclus::Institution(ctx), - //cycamore::ManagerInst(ctx), latitude(0.0), longitude(0.0), coordinates(latitude, longitude) {} diff --git a/src/deploy_manager_inst.h b/src/deploy_manager_inst.h index 862c2f74b4..49705ad4c0 100644 --- a/src/deploy_manager_inst.h +++ b/src/deploy_manager_inst.h @@ -15,14 +15,15 @@ typedef std::map > BuildSched; // Builds and manages agents (facilities) according to a manually specified // deployment schedule. Deployed agents are automatically decommissioned at -// the end of their lifetime. The user specifies a list of prototypes for -// each and corresponding build times, number to build, and (optionally) -// lifetimes. The same prototype can be specified multiple times with any -// combination of the same or different build times, build number, and -// lifetimes. +// the end of their lifetime. Deployed and decommissioned agents are +// registered and unregistered with a growth region. The user specifies +// a list of prototypes for each and corresponding build times, number to +// build, and (optionally) lifetimes. The same prototype can be specified +// multiple times with any combination of the same or different build times, +// build number, and lifetimes. + class DeployManagerInst : public cyclus::Institution, - //public :cycamore::ManagerInst, public cyclus::toolkit::CommodityProducerManager, public cyclus::toolkit::Builder, public cyclus::toolkit::Position { @@ -30,8 +31,9 @@ class DeployManagerInst : "doc": \ "Builds and manages agents (facilities) according to a manually" \ " specified deployment schedule. Deployed agents are automatically" \ - " decommissioned at the end of their lifetime. The user specifies a" \ - " list of prototypes for" \ + " decommissioned at the end of their lifetime. Deployed and" \ + " decommissioned agents are registered and unregistered with a growth" \ + " region. The user specifies a list of prototypes for" \ " each and corresponding build times, number to build, and (optionally)" \ " lifetimes. The same prototype can be specified multiple times with" \ " any combination of the same or different build times, build number," \ @@ -123,9 +125,6 @@ class DeployManagerInst : /// Records an agent's latitude and longitude to the output db void RecordPosition(); - /// Defines the spec for the DeployManagerInst - // std::string spec_; - }; } // namespace cycamore diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index c5aac3ee31..5650ae71c9 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -1,15 +1,9 @@ #include "deploy_manager_inst_tests.h" // make sure that the deployed agent's prototype name is identical to the // originally specified prototype name - this is important to test because -// DeployInst does some mucking around with registering name-modded prototypes +// DeployManagerInst does some mucking around with registering name-modded prototypes // in order to deal with lifetime setting. -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//TestProducer::~TestProducer() {} - using cyclus::QueryResult; void DeployManagerInstTests::SetUp() { @@ -29,10 +23,7 @@ void DeployManagerInstTests::TearDown() { delete ctx_; } - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TEST_F(DeployManagerInstTests, ProtoNames) { std::string config = " foobar " From 882b853a77e10f70c200712e50fe3f87b3ffaf56 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 21 Jan 2022 08:16:36 -0600 Subject: [PATCH 13/36] added sample test for corner case test --- src/deploy_manager_inst_tests.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 5650ae71c9..2e45cf248b 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -211,6 +211,11 @@ TEST_F(DeployManagerInstTests, productioncapacity) { EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); } +// corner case test +TEST_F(DeployManagerInstTests, cornercase){ + EXPECT_EQ(3,3); +} + // required to get functionality in cyclus agent unit tests library cyclus::Agent* DeployManagerInstitutionConstructor(cyclus::Context* ctx) { return new cycamore::DeployManagerInst(ctx); From ca24a319ea0810b646dc9f96aa69f8d2aeb14fcd Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 21 Jan 2022 11:38:56 -0600 Subject: [PATCH 14/36] filled in test with cyclus mock sim --- src/deploy_manager_inst_tests.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 2e45cf248b..1ae0809177 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -211,11 +211,25 @@ TEST_F(DeployManagerInstTests, productioncapacity) { EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); } -// corner case test TEST_F(DeployManagerInstTests, cornercase){ - EXPECT_EQ(3,3); -} + std::string config = + " foobar " + " 1 " + " 3 " + " 2 "; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); + sim.DummyProto("foobar"); + sim.DummyProto("barfoo"); + int id = sim.Run(); + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 1;" + ); + stmt->Step(); + EXPECT_EQ(0, stmt->GetInt(0)); +} // required to get functionality in cyclus agent unit tests library cyclus::Agent* DeployManagerInstitutionConstructor(cyclus::Context* ctx) { return new cycamore::DeployManagerInst(ctx); From 8fe92de7db22b58694ad7eecca8275dc2ee76ff6 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 21 Jan 2022 15:36:52 -0600 Subject: [PATCH 15/36] changed mocksim definition --- src/deploy_manager_inst_tests.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 1ae0809177..d22a64644e 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -213,23 +213,24 @@ TEST_F(DeployManagerInstTests, productioncapacity) { TEST_F(DeployManagerInstTests, cornercase){ std::string config = - " foobar " - " 1 " - " 3 " - " 2 "; + " foobar1 foobar2 foobar1 " + " 1 1 2 " + " 1 7 3 " + " 1 2 -1 " + ; int simdur = 5; cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); sim.DummyProto("foobar"); - sim.DummyProto("barfoo"); int id = sim.Run(); cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 1;" + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar1' AND EnterTime = 1 AND Lifetime = 1;" ); stmt->Step(); - EXPECT_EQ(0, stmt->GetInt(0)); + EXPECT_EQ(1, stmt->GetInt(0)); } + // required to get functionality in cyclus agent unit tests library cyclus::Agent* DeployManagerInstitutionConstructor(cyclus::Context* ctx) { return new cycamore::DeployManagerInst(ctx); From bb8e75f1b40b5373a5ea48531cb431c559d76d71 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 21 Jan 2022 16:11:29 -0600 Subject: [PATCH 16/36] added definition for prototypes in mocksim --- src/deploy_manager_inst_tests.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index d22a64644e..67aedb3fae 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -212,16 +212,23 @@ TEST_F(DeployManagerInstTests, productioncapacity) { } TEST_F(DeployManagerInstTests, cornercase){ - std::string config = + std::string dmi_config = " foobar1 foobar2 foobar1 " " 1 1 2 " " 1 7 3 " " 1 2 -1 " ; + std::string gr_config = + " commod1" + " 2" + " linear 0 5 " + " " + ; int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), dmi_config, simdur); + sim.DummyProto("foobar1"); + sim.DummyProto("foobar2"); int id = sim.Run(); cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( From bc52e9cfad7eda02e67b8b4dc6b5d649db659b37 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 21 Jan 2022 16:16:29 -0600 Subject: [PATCH 17/36] removed config for growthregion --- src/deploy_manager_inst_tests.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 67aedb3fae..5cc34e7560 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -219,12 +219,6 @@ TEST_F(DeployManagerInstTests, cornercase){ " 1 2 -1 " ; - std::string gr_config = - " commod1" - " 2" - " linear 0 5 " - " " - ; int simdur = 5; cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), dmi_config, simdur); sim.DummyProto("foobar1"); From 797e8fee3576645a36efb5f8d49b1a3ced524a52 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Fri, 21 Jan 2022 16:22:13 -0600 Subject: [PATCH 18/36] changed config name ack --- src/deploy_manager_inst_tests.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index 5cc34e7560..e7eace9598 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -212,7 +212,7 @@ TEST_F(DeployManagerInstTests, productioncapacity) { } TEST_F(DeployManagerInstTests, cornercase){ - std::string dmi_config = + std::string config = " foobar1 foobar2 foobar1 " " 1 1 2 " " 1 7 3 " @@ -220,7 +220,7 @@ TEST_F(DeployManagerInstTests, cornercase){ ; int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), dmi_config, simdur); + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); sim.DummyProto("foobar1"); sim.DummyProto("foobar2"); int id = sim.Run(); From 416ba1f0b07273b99c4879f83459709249979469 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 24 Jan 2022 14:54:42 -0600 Subject: [PATCH 19/36] added additional MockSims, all separate sims, need to combine --- src/deploy_manager_inst_tests.cc | 47 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index e7eace9598..e090d30be5 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -212,24 +212,47 @@ TEST_F(DeployManagerInstTests, productioncapacity) { } TEST_F(DeployManagerInstTests, cornercase){ - std::string config = - " foobar1 foobar2 foobar1 " - " 1 1 2 " - " 1 7 3 " - " 1 2 -1 " + std::string dmi_config = + " foobar1 " + " 1 " + " 3 " + " 3 " ; + std::string mi_config = + " foobar2 " + ; + + std::string gr_config = + " commod1" + " 2" + " linear 0 5 " + " " + ; + int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar1"); - sim.DummyProto("foobar2"); - int id = sim.Run(); + cyclus::MockSim sim1(cyclus::AgentSpec(":cycamore:DeployManagerInst"), dmi_config, simdur); + cyclus::MockSim sim2(cyclus::AgentSpec(":cycamore:ManagerInst"), mi_config, simdur); + cyclus::MockSim sim3(cyclus::AgentSpec(":cycamore:GrowthRegion"),gr_config, simdur); + sim1.DummyProto("foobar1"); + sim2.DummyProto("foobar2"); + sim3.DummyProto("foobar1"); + sim3.DummyProto("foobar2"); + int id1 = sim1.Run(); + int id2 = sim2.Run(); + int id3 = sim3.Run(); + + cyclus::SqlStatement::Ptr stmt = sim3.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar1';" + ); + stmt->Step(); + EXPECT_EQ(0, stmt->GetInt(0)); - cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar1' AND EnterTime = 1 AND Lifetime = 1;" + stmt = sim3.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar2';" ); stmt->Step(); - EXPECT_EQ(1, stmt->GetInt(0)); + EXPECT_EQ(0, stmt->GetInt(0)); } // required to get functionality in cyclus agent unit tests library From 031ab59b39b483af7fa42f741f5219160b8a519a Mon Sep 17 00:00:00 2001 From: abachma2 Date: Tue, 25 Jan 2022 16:53:09 -0600 Subject: [PATCH 20/36] added commodity and capacity to dummyprotos --- src/deploy_manager_inst_tests.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc index e090d30be5..f69060b05e 100644 --- a/src/deploy_manager_inst_tests.cc +++ b/src/deploy_manager_inst_tests.cc @@ -233,13 +233,11 @@ TEST_F(DeployManagerInstTests, cornercase){ int simdur = 5; cyclus::MockSim sim1(cyclus::AgentSpec(":cycamore:DeployManagerInst"), dmi_config, simdur); cyclus::MockSim sim2(cyclus::AgentSpec(":cycamore:ManagerInst"), mi_config, simdur); - cyclus::MockSim sim3(cyclus::AgentSpec(":cycamore:GrowthRegion"),gr_config, simdur); - sim1.DummyProto("foobar1"); - sim2.DummyProto("foobar2"); - sim3.DummyProto("foobar1"); - sim3.DummyProto("foobar2"); - int id1 = sim1.Run(); - int id2 = sim2.Run(); + cyclus::MockSim sim3(cyclus::AgentSpec(":cycamore:ManagerInst"), mi_config, simdur); + sim3.DummyProto("foobar1", "commod1", 1); + sim3.DummyProto("foobar2", "commod1", 1); + sim3.AddSource("enriched_u").Finalize(); + sim3.AddSink("enriched_u"); int id3 = sim3.Run(); cyclus::SqlStatement::Ptr stmt = sim3.db().db().Prepare( From 63ac68ac7fe6cbe4a9fc8641f385a004cb782e8e Mon Sep 17 00:00:00 2001 From: abachma2 Date: Wed, 26 Jan 2022 09:30:22 -0600 Subject: [PATCH 21/36] Removed DeployManagerInst, added feature to DeployInst --- src/deploy_inst.cc | 51 ++++++ src/deploy_inst.h | 23 ++- src/deploy_inst_tests.cc | 22 +++ src/deploy_manager_inst.cc | 138 ---------------- src/deploy_manager_inst.h | 132 --------------- src/deploy_manager_inst_tests.cc | 270 ------------------------------- src/deploy_manager_inst_tests.h | 59 ------- 7 files changed, 93 insertions(+), 602 deletions(-) delete mode 100644 src/deploy_manager_inst.cc delete mode 100644 src/deploy_manager_inst.h delete mode 100644 src/deploy_manager_inst_tests.cc delete mode 100644 src/deploy_manager_inst_tests.h diff --git a/src/deploy_inst.cc b/src/deploy_inst.cc index 1b12dcb978..dc26c937cd 100644 --- a/src/deploy_inst.cc +++ b/src/deploy_inst.cc @@ -68,6 +68,57 @@ void DeployInst::EnterNotify() { RecordPosition(); } +void DeployInst::BuildNotify(Agent* a) { + Register_(a); +} + +void DeployInst::DecomNotify(Agent* a) { + Unregister_(a); +} + +void DeployInst::Register_(Agent* a) { + using cyclus::toolkit::CommodityProducer; + using cyclus::toolkit::CommodityProducerManager; + + CommodityProducer* cp_cast = dynamic_cast(a); + if (cp_cast != NULL) { + LOG(cyclus::LEV_INFO3, "mani") << "Registering agent " + << a->prototype() << a->id() + << " as a commodity producer."; + CommodityProducerManager::Register(cp_cast); + } +} + +void DeployInst::Unregister_(Agent* a) { + using cyclus::toolkit::CommodityProducer; + using cyclus::toolkit::CommodityProducerManager; + + CommodityProducer* cp_cast = dynamic_cast(a); + if (cp_cast != NULL) + CommodityProducerManager::Unregister(cp_cast); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeployInst::WriteProducerInformation( + cyclus::toolkit::CommodityProducer* producer) { + using std::set; + set commodities = + producer->ProducedCommodities(); + set:: + iterator it; + + LOG(cyclus::LEV_DEBUG3, "maninst") << " Clone produces " << commodities.size() + << " commodities."; + for (it = commodities.begin(); it != commodities.end(); it++) { + LOG(cyclus::LEV_DEBUG3, "maninst") << " Commodity produced: " << it->name(); + LOG(cyclus::LEV_DEBUG3, "maninst") << " capacity: " << + producer->Capacity(*it); + LOG(cyclus::LEV_DEBUG3, "maninst") << " cost: " << + producer->Cost(*it); + } +} + void DeployInst::RecordPosition() { std::string specification = this->spec(); context() diff --git a/src/deploy_inst.h b/src/deploy_inst.h index cc6dc3ea15..51b47ebb38 100644 --- a/src/deploy_inst.h +++ b/src/deploy_inst.h @@ -19,14 +19,18 @@ typedef std::map > BuildSched; // lifetimes. The same prototype can be specified multiple times with any // combination of the same or different build times, build number, and // lifetimes. -class DeployInst : public cyclus::Institution, +class DeployInst : + public cyclus::Institution, + public cyclus::toolkit::CommodityProducerManager, + public cyclus::toolkit::Builder, public cyclus::toolkit::Position { #pragma cyclus note { \ "doc": \ "Builds and manages agents (facilities) according to a manually" \ " specified deployment schedule. Deployed agents are automatically" \ - " decommissioned at the end of their lifetime. The user specifies a" \ - " list of prototypes for" \ + " decommissioned at the end of their lifetime. Deployed and" \ + " decommissioned agents are registered and unregistered with a growth" \ + " region. The user specifies a list of prototypes for" \ " each and corresponding build times, number to build, and (optionally)" \ " lifetimes. The same prototype can be specified multiple times with" \ " any combination of the same or different build times, build number," \ @@ -45,6 +49,19 @@ class DeployInst : public cyclus::Institution, virtual void EnterNotify(); + virtual void BuildNotify(Agent* m); + virtual void DecomNotify(Agent* m); + /// write information about a commodity producer to a stream + /// @param producer the producer + void WriteProducerInformation(cyclus::toolkit::CommodityProducer* + producer); + + /// register a child + void Register_(cyclus::Agent* agent); + + /// unregister a child + void Unregister_(cyclus::Agent* agent); + protected: #pragma cyclus var { \ "doc": "Ordered list of prototypes to build.", \ diff --git a/src/deploy_inst_tests.cc b/src/deploy_inst_tests.cc index 607876245f..96494c1194 100644 --- a/src/deploy_inst_tests.cc +++ b/src/deploy_inst_tests.cc @@ -177,6 +177,28 @@ TEST(DeployInstTests, PositionInitialize2) { EXPECT_EQ(qr.GetVal("Longitude"), -20.0); } +TEST_F(DeployManagerInstTests, producerexists) { + using std::set; + ctx_->AddPrototype("foop", producer); + set::iterator it; + for (it = src_inst->cyclus::toolkit::CommodityProducerManager:: + producers().begin(); + it != src_inst->cyclus::toolkit::CommodityProducerManager:: + producers().end(); + it++) { + EXPECT_EQ(dynamic_cast(*it)->prototype(), + producer->prototype()); + } +} + +TEST_F(DeployManagerInstTests, productioncapacity) { + EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); + src_inst->BuildNotify(producer); + EXPECT_EQ(src_inst->TotalCapacity(commodity), capacity); + src_inst->DecomNotify(producer); + EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); +} + // required to get functionality in cyclus agent unit tests library cyclus::Agent* DeployInstitutionConstructor(cyclus::Context* ctx) { return new cycamore::DeployInst(ctx); diff --git a/src/deploy_manager_inst.cc b/src/deploy_manager_inst.cc deleted file mode 100644 index 3c073a3bf7..0000000000 --- a/src/deploy_manager_inst.cc +++ /dev/null @@ -1,138 +0,0 @@ -// Implements the DeployManagerInst class -#include "deploy_manager_inst.h" - -namespace cycamore { - -DeployManagerInst::DeployManagerInst(cyclus::Context* ctx) - : cyclus::Institution(ctx), - latitude(0.0), - longitude(0.0), - coordinates(latitude, longitude) {} - -DeployManagerInst::~DeployManagerInst() {} - -void DeployManagerInst::Build(cyclus::Agent* parent) { - cyclus::Institution::Build(parent); - BuildSched::iterator it; - std::set protos; - for (int i = 0; i < prototypes.size(); i++) { - std::string proto = prototypes[i]; - - std::stringstream ss; - ss << proto; - - if (lifetimes.size() == prototypes.size()) { - cyclus::Agent* a = context()->CreateAgent(proto); - if (a->lifetime() != lifetimes[i]) { - a->lifetime(lifetimes[i]); - - if (lifetimes[i] == -1) { - ss << "_life_forever"; - } else { - ss << "_life_" << lifetimes[i]; - } - proto = ss.str(); - if (protos.count(proto) == 0) { - protos.insert(proto); - context()->AddPrototype(proto, a); - } - } - } - - int t = build_times[i]; - for (int j = 0; j < n_build[i]; j++) { - context()->SchedBuild(this, proto, t); - } - } -} - -void DeployManagerInst::EnterNotify() { - cyclus::Institution::EnterNotify(); - int n = prototypes.size(); - if (build_times.size() != n) { - std::stringstream ss; - ss << "prototype '" << prototype() << "' has " << build_times.size() - << " build_times vals, expected " << n; - throw cyclus::ValueError(ss.str()); - } else if (n_build.size() != n) { - std::stringstream ss; - ss << "prototype '" << prototype() << "' has " << n_build.size() - << " n_build vals, expected " << n; - throw cyclus::ValueError(ss.str()); - } else if (lifetimes.size() > 0 && lifetimes.size() != n) { - std::stringstream ss; - ss << "prototype '" << prototype() << "' has " << lifetimes.size() - << " lifetimes vals, expected " << n; - throw cyclus::ValueError(ss.str()); - } - RecordPosition(); -} - -void DeployManagerInst::BuildNotify(Agent* a) { - Register_(a); -} - -void DeployManagerInst::DecomNotify(Agent* a) { - Unregister_(a); -} - -void DeployManagerInst::Register_(Agent* a) { - using cyclus::toolkit::CommodityProducer; - using cyclus::toolkit::CommodityProducerManager; - - CommodityProducer* cp_cast = dynamic_cast(a); - if (cp_cast != NULL) { - LOG(cyclus::LEV_INFO3, "mani") << "Registering agent " - << a->prototype() << a->id() - << " as a commodity producer."; - CommodityProducerManager::Register(cp_cast); - } -} - -void DeployManagerInst::Unregister_(Agent* a) { - using cyclus::toolkit::CommodityProducer; - using cyclus::toolkit::CommodityProducerManager; - - CommodityProducer* cp_cast = dynamic_cast(a); - if (cp_cast != NULL) - CommodityProducerManager::Unregister(cp_cast); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DeployManagerInst::WriteProducerInformation( - cyclus::toolkit::CommodityProducer* producer) { - using std::set; - set commodities = - producer->ProducedCommodities(); - set:: - iterator it; - - LOG(cyclus::LEV_DEBUG3, "maninst") << " Clone produces " << commodities.size() - << " commodities."; - for (it = commodities.begin(); it != commodities.end(); it++) { - LOG(cyclus::LEV_DEBUG3, "maninst") << " Commodity produced: " << it->name(); - LOG(cyclus::LEV_DEBUG3, "maninst") << " capacity: " << - producer->Capacity(*it); - LOG(cyclus::LEV_DEBUG3, "maninst") << " cost: " << - producer->Cost(*it); - } -} - -void DeployManagerInst::RecordPosition() { - std::string specification = this->spec(); - context() - ->NewDatum("AgentPosition") - ->AddVal("Spec", specification) - ->AddVal("Prototype", this->prototype()) - ->AddVal("AgentId", id()) - ->AddVal("Latitude", latitude) - ->AddVal("Longitude", longitude) - ->Record(); -} - -extern "C" cyclus::Agent* ConstructDeployManagerInst(cyclus::Context* ctx) { - return new DeployManagerInst(ctx); -} - -} // namespace cycamore diff --git a/src/deploy_manager_inst.h b/src/deploy_manager_inst.h deleted file mode 100644 index 49705ad4c0..0000000000 --- a/src/deploy_manager_inst.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef CYCAMORE_SRC_DEPLOY_MANAGER_INST_H_ -#define CYCAMORE_SRC_DEPLOY_MANAGER_INST_H_ - -#include -#include -#include - -#include "cyclus.h" -#include "cycamore_version.h" -//#include "manager_inst.h" - -namespace cycamore { - -typedef std::map > BuildSched; - -// Builds and manages agents (facilities) according to a manually specified -// deployment schedule. Deployed agents are automatically decommissioned at -// the end of their lifetime. Deployed and decommissioned agents are -// registered and unregistered with a growth region. The user specifies -// a list of prototypes for each and corresponding build times, number to -// build, and (optionally) lifetimes. The same prototype can be specified -// multiple times with any combination of the same or different build times, -// build number, and lifetimes. - -class DeployManagerInst : - public cyclus::Institution, - public cyclus::toolkit::CommodityProducerManager, - public cyclus::toolkit::Builder, - public cyclus::toolkit::Position { - #pragma cyclus note { \ - "doc": \ - "Builds and manages agents (facilities) according to a manually" \ - " specified deployment schedule. Deployed agents are automatically" \ - " decommissioned at the end of their lifetime. Deployed and" \ - " decommissioned agents are registered and unregistered with a growth" \ - " region. The user specifies a list of prototypes for" \ - " each and corresponding build times, number to build, and (optionally)" \ - " lifetimes. The same prototype can be specified multiple times with" \ - " any combination of the same or different build times, build number," \ - " and lifetimes. " \ - } - public: - DeployManagerInst(cyclus::Context* ctx); - - virtual ~DeployManagerInst(); - - virtual std::string version() { return CYCAMORE_VERSION; } - - #pragma cyclus - - virtual void Build(cyclus::Agent* parent); - - virtual void EnterNotify(); - - virtual void BuildNotify(Agent* m); - virtual void DecomNotify(Agent* m); - /// write information about a commodity producer to a stream - /// @param producer the producer - void WriteProducerInformation(cyclus::toolkit::CommodityProducer* - producer); - - /// register a child - void Register_(cyclus::Agent* agent); - - /// unregister a child - void Unregister_(cyclus::Agent* agent); - - protected: - #pragma cyclus var { \ - "doc": "Ordered list of prototypes to build.", \ - "uitype": ("oneormore", "prototype"), \ - "uilabel": "Prototypes to deploy", \ - } - std::vector prototypes; - - #pragma cyclus var { \ - "doc": "Time step on which to deploy agents given in prototype list " \ - "(same order).", \ - "uilabel": "Deployment times", \ - } - std::vector build_times; - - #pragma cyclus var { \ - "doc": "Number of each prototype given in prototype list that should be " \ - "deployed (same order).", \ - "uilabel": "Number to deploy", \ - } - std::vector n_build; - - - #pragma cyclus var { \ - "doc": "Lifetimes for each prototype in prototype list (same order)." \ - " These lifetimes override the lifetimes in the original prototype" \ - " definition." \ - " If unspecified, lifetimes from the original prototype definitions"\ - " are used." \ - " Although a new prototype is created in the Prototypes table for" \ - " each lifetime with the suffix '_life_[lifetime]'," \ - " all deployed agents themselves will have the same original" \ - " prototype name (and so will the Agents tables).", \ - "default": [], \ - "uilabel": "Lifetimes" \ - } - std::vector lifetimes; - - private: - #pragma cyclus var { \ - "default": 0.0, \ - "uilabel": "Geographical latitude in degrees as a double", \ - "doc": "Latitude of the agent's geographical position. The value should " \ - "be expressed in degrees as a double." \ - } - double latitude; - - #pragma cyclus var { \ - "default": 0.0, \ - "uilabel": "Geographical longitude in degrees as a double", \ - "doc": "Longitude of the agent's geographical position. The value should " \ - "be expressed in degrees as a double." \ - } - double longitude; - - cyclus::toolkit::Position coordinates; - - /// Records an agent's latitude and longitude to the output db - void RecordPosition(); - -}; - -} // namespace cycamore - -#endif // CYCAMORE_SRC_DEPLOY_MANAGER_INST_H_ diff --git a/src/deploy_manager_inst_tests.cc b/src/deploy_manager_inst_tests.cc deleted file mode 100644 index f69060b05e..0000000000 --- a/src/deploy_manager_inst_tests.cc +++ /dev/null @@ -1,270 +0,0 @@ -#include "deploy_manager_inst_tests.h" -// make sure that the deployed agent's prototype name is identical to the -// originally specified prototype name - this is important to test because -// DeployManagerInst does some mucking around with registering name-modded prototypes -// in order to deal with lifetime setting. - -using cyclus::QueryResult; - -void DeployManagerInstTests::SetUp() { - ctx_ = new cyclus::Context(&ti_, &rec_); - src_inst = new cycamore::DeployManagerInst(ctx_); - producer = new TestProducer(ctx_); - commodity = cyclus::toolkit::Commodity("commod"); - capacity = 5; - producer->cyclus::toolkit::CommodityProducer::Add(commodity); - producer->SetCapacity(commodity, capacity); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DeployManagerInstTests::TearDown() { - delete producer; - delete src_inst; - delete ctx_; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TEST_F(DeployManagerInstTests, ProtoNames) { - std::string config = - " foobar " - " 1 " - " 3 " - " 2 " - ; - - int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); - int id = sim.Run(); - - cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar';" - ); - stmt->Step(); - EXPECT_EQ(3, stmt->GetInt(0)); -} - -TEST_F(DeployManagerInstTests, BuildTimes) { - std::string config = - " foobar foobar " - " 1 3 " - " 1 7 " - ; - - int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); - int id = sim.Run(); - - cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1;" - ); - stmt->Step(); - EXPECT_EQ(1, stmt->GetInt(0)); - - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 3;" - ); - stmt->Step(); - EXPECT_EQ(7, stmt->GetInt(0)); -} - -// make sure that specified lifetimes are honored both in agent's table record -// and in decommissioning. -TEST_F(DeployManagerInstTests, FiniteLifetimes) { - std::string config = - " foobar foobar foobar " - " 1 1 2 " - " 1 7 3 " - " 1 2 -1 " - ; - - int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); - int id = sim.Run(); - - // check agent deployment - cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 1;" - ); - stmt->Step(); - EXPECT_EQ(1, stmt->GetInt(0)); - - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 1 AND Lifetime = 2;" - ); - stmt->Step(); - EXPECT_EQ(7, stmt->GetInt(0)); - - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = 2 AND Lifetime = -1;" - ); - stmt->Step(); - EXPECT_EQ(3, stmt->GetInt(0)); - - // check decommissioning - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry As e JOIN AgentExit AS x ON x.AgentId = e.AgentId WHERE e.Prototype = 'foobar' AND x.ExitTime = 1;" - ); - stmt->Step(); - EXPECT_EQ(1, stmt->GetInt(0)); - - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry As e JOIN AgentExit AS x ON x.AgentId = e.AgentId WHERE e.Prototype = 'foobar' AND x.ExitTime = 2;" - ); - stmt->Step(); - EXPECT_EQ(7, stmt->GetInt(0)); - - // agent with -1 lifetime should not be in AgentExit table - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM AgentExit;" - ); - stmt->Step(); - EXPECT_EQ(8, stmt->GetInt(0)); -} - -TEST_F(DeployManagerInstTests, NoDupProtos) { - std::string config = - " foobar foobar foobar " - " 1 1 2 " - " 1 7 3 " - " 1 1 -1 " - ; - - int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); - int id = sim.Run(); - - // don't duplicate same prototypes with same custom lifetime - cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM Prototypes WHERE Prototype = 'foobar_life_1';" - ); - stmt->Step(); - EXPECT_EQ(1, stmt->GetInt(0)); - - // don't duplicate custom lifetimes that are identical to original prototype - // lifetime. - stmt = sim.db().db().Prepare( - "SELECT COUNT(*) FROM Prototypes WHERE Prototype = 'foobar';" - ); - stmt->Step(); - EXPECT_EQ(1, stmt->GetInt(0)); -} - -TEST_F(DeployManagerInstTests, PositionInitialize) { - std::string config = - " foobar " - " 1 " - " 3 " - " 2 "; - - int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); - int id = sim.Run(); - - QueryResult qr = sim.db().Query("AgentPosition", NULL); - EXPECT_EQ(qr.GetVal("Latitude"), 0.0); - EXPECT_EQ(qr.GetVal("Longitude"), 0.0); -} - -TEST_F(DeployManagerInstTests, PositionInitialize2) { - std::string config = - " foobar " - " -20.0 " - " 2.0 " - " 1 " - " 3 " - " 2 "; - - int simdur = 5; - cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployManagerInst"), config, simdur); - sim.DummyProto("foobar"); - int id = sim.Run(); - - QueryResult qr = sim.db().Query("AgentPosition", NULL); - EXPECT_EQ(qr.GetVal("Latitude"), 2.0); - EXPECT_EQ(qr.GetVal("Longitude"), -20.0); -} - -TEST_F(DeployManagerInstTests, producerexists) { - using std::set; - ctx_->AddPrototype("foop", producer); - set::iterator it; - for (it = src_inst->cyclus::toolkit::CommodityProducerManager:: - producers().begin(); - it != src_inst->cyclus::toolkit::CommodityProducerManager:: - producers().end(); - it++) { - EXPECT_EQ(dynamic_cast(*it)->prototype(), - producer->prototype()); - } -} - -TEST_F(DeployManagerInstTests, productioncapacity) { - EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); - src_inst->BuildNotify(producer); - EXPECT_EQ(src_inst->TotalCapacity(commodity), capacity); - src_inst->DecomNotify(producer); - EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); -} - -TEST_F(DeployManagerInstTests, cornercase){ - std::string dmi_config = - " foobar1 " - " 1 " - " 3 " - " 3 " - ; - - std::string mi_config = - " foobar2 " - ; - - std::string gr_config = - " commod1" - " 2" - " linear 0 5 " - " " - ; - - int simdur = 5; - cyclus::MockSim sim1(cyclus::AgentSpec(":cycamore:DeployManagerInst"), dmi_config, simdur); - cyclus::MockSim sim2(cyclus::AgentSpec(":cycamore:ManagerInst"), mi_config, simdur); - cyclus::MockSim sim3(cyclus::AgentSpec(":cycamore:ManagerInst"), mi_config, simdur); - sim3.DummyProto("foobar1", "commod1", 1); - sim3.DummyProto("foobar2", "commod1", 1); - sim3.AddSource("enriched_u").Finalize(); - sim3.AddSink("enriched_u"); - int id3 = sim3.Run(); - - cyclus::SqlStatement::Ptr stmt = sim3.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar1';" - ); - stmt->Step(); - EXPECT_EQ(0, stmt->GetInt(0)); - - stmt = sim3.db().db().Prepare( - "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar2';" - ); - stmt->Step(); - EXPECT_EQ(0, stmt->GetInt(0)); -} - -// required to get functionality in cyclus agent unit tests library -cyclus::Agent* DeployManagerInstitutionConstructor(cyclus::Context* ctx) { - return new cycamore::DeployManagerInst(ctx); -} - -#ifndef CYCLUS_AGENT_TESTS_CONNECTED -int ConnectAgentTests(); -static int cyclus_agent_tests_connected = ConnectAgentTests(); -#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected -#endif // CYCLUS_AGENT_TESTS_CONNECTED - -INSTANTIATE_TEST_CASE_P(DeployManagerInst, InstitutionTests, - Values(&DeployManagerInstitutionConstructor)); -INSTANTIATE_TEST_CASE_P(DeployManagerInst, AgentTests, - Values(&DeployManagerInstitutionConstructor)); diff --git a/src/deploy_manager_inst_tests.h b/src/deploy_manager_inst_tests.h deleted file mode 100644 index f08fcfc16b..0000000000 --- a/src/deploy_manager_inst_tests.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef CYCAMORE_SRC_DEPLOY_MANAGER_INST_TESTS_H_ -#define CYCAMORE_SRC_DEPLOY_MANAGER_INST_TESTS_H_ - -#include - -#include "cyclus.h" -#include "timer.h" -#include "test_context.h" -#include "institution_tests.h" -#include "agent_tests.h" -#include "context.h" - -#include "deploy_manager_inst.h" - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -class TestProducer - : public cyclus::Facility, - public cyclus::toolkit::CommodityProducer { - public: - TestProducer(cyclus::Context* ctx); - ~TestProducer(); - - cyclus::Agent* Clone() { - TestProducer* m = new TestProducer(context()); - m->InitFrom(this); - return m; - } - - void InitFrom(TestProducer* m) { - cyclus::Facility::InitFrom(m); - } - - void InitInv(cyclus::Inventories& inv) {} - - cyclus::Inventories SnapshotInv() { return cyclus::Inventories(); } - - void Tock() {} - void Tick() {} -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -class DeployManagerInstTests : public ::testing::Test { - public: - virtual void SetUp(); - virtual void TearDown(); - - protected: - cycamore::DeployManagerInst* src_inst; - TestProducer* producer; - - cyclus::toolkit::Commodity commodity; - double capacity; - cyclus::Context* ctx_; - cyclus::Timer ti_; - cyclus::Recorder rec_; -}; - -#endif // CYCAMORE_SRC_MANAGER_INST_TESTS_H_ \ No newline at end of file From a0010622975ef908c217d217bb97015707b05fd9 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Wed, 26 Jan 2022 10:50:39 -0600 Subject: [PATCH 22/36] added input for integration tests --- input/growth/deploy_and_manager_insts.xml | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 input/growth/deploy_and_manager_insts.xml diff --git a/input/growth/deploy_and_manager_insts.xml b/input/growth/deploy_and_manager_insts.xml new file mode 100644 index 0000000000..6440a6f3fe --- /dev/null +++ b/input/growth/deploy_and_manager_insts.xml @@ -0,0 +1,109 @@ + + + 10 + 1 + 2018 + never + + + + cycamoreGrowthRegion + cycamoreDeployInst + cycamoreManagerInst + cycamoreSource + cycamoreSink + + + + commidity1 + 1.0 + + + + Source1 + + + commodity1 + 1 + + + + + + Source2 + + + commodity1 + 1 + + + + + + Sink + + + + commodity1 + + + + + + + Single Region + + + + + commod1 + + + 5 + + linear + 0 5 + + + + + + + + + + First Institution + + + Sink + 1 + + + + + + Source2 + + + + + + + Second Institution + + + + Source1 + + + 1 + + + 1 + + + + + + + From 43ac611fb47abc63053e48559bb89022850da38e Mon Sep 17 00:00:00 2001 From: abachma2 Date: Wed, 26 Jan 2022 10:51:09 -0600 Subject: [PATCH 23/36] moved functions around to make unit tests build and pass --- src/CMakeLists.txt | 2 -- src/cycamore.h | 3 +- src/deploy_inst_tests.cc | 41 +++++++++++++++++++++------ src/deploy_inst_tests.h | 58 +++++++++++++++++++++++++++++++++++++++ src/manager_inst_tests.cc | 4 +-- 5 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 src/deploy_inst_tests.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39970e587c..b626877cf5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,8 +23,6 @@ USE_CYCLUS("cycamore" "deploy_inst") USE_CYCLUS("cycamore" "manager_inst") -USE_CYCLUS("cycamore" "deploy_manager_inst") - USE_CYCLUS("cycamore" "growth_region") USE_CYCLUS("cycamore" "storage") diff --git a/src/cycamore.h b/src/cycamore.h index 1bf5df5c3a..a17995e402 100644 --- a/src/cycamore.h +++ b/src/cycamore.h @@ -8,6 +8,7 @@ #include "batch_reactor.h" #include "batch_reactor_tests.h" #include "deploy_inst.h" +#include "deploy_inst_tests.h" #include "enrichment.h" #include "enrichment_tests.h" #if CYCLUS_HAS_COIN @@ -18,8 +19,6 @@ #include "inpro_reactor_tests.h" #include "manager_inst.h" #include "manager_inst_tests.h" -#include "deploy_manager_inst.h" -#include "deploy_manager_inst_tests.h" #include "sink.h" #include "sink_tests.h" #include "source.h" diff --git a/src/deploy_inst_tests.cc b/src/deploy_inst_tests.cc index 96494c1194..248c0d171c 100644 --- a/src/deploy_inst_tests.cc +++ b/src/deploy_inst_tests.cc @@ -2,6 +2,7 @@ #include "context.h" #include "deploy_inst.h" +#include "deploy_inst_tests.h" #include "institution_tests.h" #include "agent_tests.h" @@ -10,9 +11,33 @@ // DeployInst does some mucking around with registering name-modded prototypes // in order to deal with lifetime setting. +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +TestProducer::~TestProducer() {} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeployInstTests::SetUp() { + ctx_ = new cyclus::Context(&ti_, &rec_); + src_inst = new cycamore::DeployInst(ctx_); + producer = new TestProducer(ctx_); + commodity = cyclus::toolkit::Commodity("commod"); + capacity = 5; + producer->cyclus::toolkit::CommodityProducer::Add(commodity); + producer->SetCapacity(commodity, capacity); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeployInstTests::TearDown() { + delete producer; + delete src_inst; + delete ctx_; +} + using cyclus::QueryResult; -TEST(DeployInstTests, ProtoNames) { +TEST_F(DeployInstTests, ProtoNames) { std::string config = " foobar " " 1 " @@ -32,7 +57,7 @@ TEST(DeployInstTests, ProtoNames) { EXPECT_EQ(3, stmt->GetInt(0)); } -TEST(DeployInstTests, BuildTimes) { +TEST_F(DeployInstTests, BuildTimes) { std::string config = " foobar foobar " " 1 3 " @@ -59,7 +84,7 @@ TEST(DeployInstTests, BuildTimes) { // make sure that specified lifetimes are honored both in agent's table record // and in decommissioning. -TEST(DeployInstTests, FiniteLifetimes) { +TEST_F(DeployInstTests, FiniteLifetimes) { std::string config = " foobar foobar foobar " " 1 1 2 " @@ -112,7 +137,7 @@ TEST(DeployInstTests, FiniteLifetimes) { EXPECT_EQ(8, stmt->GetInt(0)); } -TEST(DeployInstTests, NoDupProtos) { +TEST_F(DeployInstTests, NoDupProtos) { std::string config = " foobar foobar foobar " " 1 1 2 " @@ -141,7 +166,7 @@ TEST(DeployInstTests, NoDupProtos) { EXPECT_EQ(1, stmt->GetInt(0)); } -TEST(DeployInstTests, PositionInitialize) { +TEST_F(DeployInstTests, PositionInitialize) { std::string config = " foobar " " 1 " @@ -158,7 +183,7 @@ TEST(DeployInstTests, PositionInitialize) { EXPECT_EQ(qr.GetVal("Longitude"), 0.0); } -TEST(DeployInstTests, PositionInitialize2) { +TEST_F(DeployInstTests, PositionInitialize2) { std::string config = " foobar " " -20.0 " @@ -177,7 +202,7 @@ TEST(DeployInstTests, PositionInitialize2) { EXPECT_EQ(qr.GetVal("Longitude"), -20.0); } -TEST_F(DeployManagerInstTests, producerexists) { +TEST_F(DeployInstTests, producerexists) { using std::set; ctx_->AddPrototype("foop", producer); set::iterator it; @@ -191,7 +216,7 @@ TEST_F(DeployManagerInstTests, producerexists) { } } -TEST_F(DeployManagerInstTests, productioncapacity) { +TEST_F(DeployInstTests, productioncapacity) { EXPECT_EQ(src_inst->TotalCapacity(commodity), 0); src_inst->BuildNotify(producer); EXPECT_EQ(src_inst->TotalCapacity(commodity), capacity); diff --git a/src/deploy_inst_tests.h b/src/deploy_inst_tests.h new file mode 100644 index 0000000000..638ead3dfe --- /dev/null +++ b/src/deploy_inst_tests.h @@ -0,0 +1,58 @@ +#ifndef CYCAMORE_SRC_DEPLOY_INST_TESTS_H_ +#define CYCAMORE_SRC_DEPLOY_INST_TESTS_H_ + +#include + +#include "cyclus.h" +#include "timer.h" +#include "test_context.h" +#include "institution_tests.h" +#include "agent_tests.h" + +#include "deploy_inst.h" + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +class TestProducer + : public cyclus::Facility, + public cyclus::toolkit::CommodityProducer { + public: + TestProducer(cyclus::Context* ctx); + ~TestProducer(); + + cyclus::Agent* Clone() { + TestProducer* m = new TestProducer(context()); + m->InitFrom(this); + return m; + } + + void InitFrom(TestProducer* m) { + cyclus::Facility::InitFrom(m); + } + + void InitInv(cyclus::Inventories& inv) {} + + cyclus::Inventories SnapshotInv() { return cyclus::Inventories(); } + + void Tock() {} + void Tick() {} +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +class DeployInstTests : public ::testing::Test { + public: + virtual void SetUp(); + virtual void TearDown(); + + protected: + cycamore::DeployInst* src_inst; + TestProducer* producer; + + cyclus::toolkit::Commodity commodity; + double capacity; + cyclus::Context* ctx_; + cyclus::Timer ti_; + cyclus::Recorder rec_; +}; + +#endif // CYCAMORE_SRC_DEPLOY_INST_TESTS_H_ diff --git a/src/manager_inst_tests.cc b/src/manager_inst_tests.cc index e9f931095d..26a55ffab4 100644 --- a/src/manager_inst_tests.cc +++ b/src/manager_inst_tests.cc @@ -1,10 +1,10 @@ #include "manager_inst_tests.h" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} +//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TestProducer::~TestProducer() {} +//TestProducer::~TestProducer() {} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ManagerInstTests::SetUp() { From 3a98763b8a299e3fa71ba1e26d7f35a8c61a4fb8 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 07:58:00 -0600 Subject: [PATCH 24/36] changes suggested from @opotowsky --- input/growth/deploy_and_manager_insts.xml | 160 +++++++++++----------- src/deploy_inst.h | 3 +- src/manager_inst_tests.cc | 6 - 3 files changed, 81 insertions(+), 88 deletions(-) diff --git a/input/growth/deploy_and_manager_insts.xml b/input/growth/deploy_and_manager_insts.xml index 6440a6f3fe..5a2ef5362c 100644 --- a/input/growth/deploy_and_manager_insts.xml +++ b/input/growth/deploy_and_manager_insts.xml @@ -15,95 +15,95 @@ - commidity1 + commodity1 1.0 - - Source1 - - - commodity1 - 1 - - - - - - Source2 - - - commodity1 - 1 - - - + + Source1 + + + commodity1 + 1 + + + - - Sink - - - - commodity1 - - - - + + Source2 + + + commodity1 + 1 + + + - - Single Region - - - - - commod1 - - - 5 - - linear - 0 5 - - - - - - - - - - First Institution - - - Sink - 1 - - + + Sink - - - Source2 - - + + + commodity1 + + - + - - Second Institution + + Single Region - - - Source1 - - - 1 - - - 1 - - + + + + commodity1 + + + 5 + + linear + 0 5 + + + + + + - - + + + First Institution + + + Sink + 1 + + + + + + Source2 + + + + + + + Second Institution + + + + Source1 + + + 1 + + + 1 + + + + + diff --git a/src/deploy_inst.h b/src/deploy_inst.h index 51b47ebb38..8fddaf03eb 100644 --- a/src/deploy_inst.h +++ b/src/deploy_inst.h @@ -22,14 +22,13 @@ typedef std::map > BuildSched; class DeployInst : public cyclus::Institution, public cyclus::toolkit::CommodityProducerManager, - public cyclus::toolkit::Builder, public cyclus::toolkit::Position { #pragma cyclus note { \ "doc": \ "Builds and manages agents (facilities) according to a manually" \ " specified deployment schedule. Deployed agents are automatically" \ " decommissioned at the end of their lifetime. Deployed and" \ - " decommissioned agents are registered and unregistered with a growth" \ + " decommissioned agents are registered and unregistered with a" \ " region. The user specifies a list of prototypes for" \ " each and corresponding build times, number to build, and (optionally)" \ " lifetimes. The same prototype can be specified multiple times with" \ diff --git a/src/manager_inst_tests.cc b/src/manager_inst_tests.cc index 26a55ffab4..893fb8be78 100644 --- a/src/manager_inst_tests.cc +++ b/src/manager_inst_tests.cc @@ -1,11 +1,5 @@ #include "manager_inst_tests.h" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//TestProducer::~TestProducer() {} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ManagerInstTests::SetUp() { ctx_ = new cyclus::Context(&ti_, &rec_); From b8a29258f47c3e4e86dda183a63bf728eda3959c Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 08:12:36 -0600 Subject: [PATCH 25/36] Revert "changes suggested from @opotowsky" This reverts commit 3a98763b8a299e3fa71ba1e26d7f35a8c61a4fb8. --- input/growth/deploy_and_manager_insts.xml | 160 +++++++++++----------- src/deploy_inst.h | 3 +- src/manager_inst_tests.cc | 6 + 3 files changed, 88 insertions(+), 81 deletions(-) diff --git a/input/growth/deploy_and_manager_insts.xml b/input/growth/deploy_and_manager_insts.xml index 5a2ef5362c..6440a6f3fe 100644 --- a/input/growth/deploy_and_manager_insts.xml +++ b/input/growth/deploy_and_manager_insts.xml @@ -15,95 +15,95 @@ - commodity1 + commidity1 1.0 - - Source1 - - - commodity1 - 1 - - - + + Source1 + + + commodity1 + 1 + + + - - Source2 - - - commodity1 - 1 - - - + + Source2 + + + commodity1 + 1 + + + + + + Sink + + + + commodity1 + + + + - - Sink + + Single Region + + + + + commod1 + + + 5 + + linear + 0 5 + + + + + + + + + + First Institution + + + Sink + 1 + + - - - commodity1 - - + + + Source2 + + - + - - Single Region + + Second Institution - - - - commodity1 - - - 5 - - linear - 0 5 - - - - - - + + + Source1 + + + 1 + + + 1 + + - - - First Institution - - - Sink - 1 - - - - - - Source2 - - - - - - - Second Institution - - - - Source1 - - - 1 - - - 1 - - - - - + + diff --git a/src/deploy_inst.h b/src/deploy_inst.h index 8fddaf03eb..51b47ebb38 100644 --- a/src/deploy_inst.h +++ b/src/deploy_inst.h @@ -22,13 +22,14 @@ typedef std::map > BuildSched; class DeployInst : public cyclus::Institution, public cyclus::toolkit::CommodityProducerManager, + public cyclus::toolkit::Builder, public cyclus::toolkit::Position { #pragma cyclus note { \ "doc": \ "Builds and manages agents (facilities) according to a manually" \ " specified deployment schedule. Deployed agents are automatically" \ " decommissioned at the end of their lifetime. Deployed and" \ - " decommissioned agents are registered and unregistered with a" \ + " decommissioned agents are registered and unregistered with a growth" \ " region. The user specifies a list of prototypes for" \ " each and corresponding build times, number to build, and (optionally)" \ " lifetimes. The same prototype can be specified multiple times with" \ diff --git a/src/manager_inst_tests.cc b/src/manager_inst_tests.cc index 893fb8be78..26a55ffab4 100644 --- a/src/manager_inst_tests.cc +++ b/src/manager_inst_tests.cc @@ -1,5 +1,11 @@ #include "manager_inst_tests.h" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//TestProducer::~TestProducer() {} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ManagerInstTests::SetUp() { ctx_ = new cyclus::Context(&ti_, &rec_); From 1fca401bf2bfaa557e562d96f222fdfd6ae3fade Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 08:12:54 -0600 Subject: [PATCH 26/36] Revert "Merge branch 'master' into deploy-manager-inst" This reverts commit ad57d015f44981f1feb4c4d6e5bf59752f1af9c5, reversing changes made to 43ac611fb47abc63053e48559bb89022850da38e. --- src/enrichment.h | 12 ++++-------- src/storage.cc | 7 +++---- src/storage.h | 12 ------------ 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/enrichment.h b/src/enrichment.h index b0e2866885..0d9b74e9a9 100644 --- a/src/enrichment.h +++ b/src/enrichment.h @@ -87,7 +87,7 @@ class NatUConverter : public cyclus::Converter { /// The Enrichment facility is a simple Agent that enriches natural /// uranium in a Cyclus simulation. It does not explicitly compute /// the physical enrichment process, rather it calculates the SWU -/// required to convert a source uranium recipe (ie. natural uranium) +/// required to convert an source uranium recipe (ie. natural uranium) /// into a requested enriched recipe (ie. 4% enriched uranium), given /// the natural uranium inventory constraint and its SWU capacity /// constraint. @@ -109,9 +109,7 @@ class NatUConverter : public cyclus::Converter { /// If multiple output commodities with different enrichment levels are /// requested and the facility does not have the SWU or quantity capacity /// to meet all requests, the requests are fully, then partially filled -/// in unspecified but repeatable order. A request for the product -/// commodity without an associated requested enriched recipe will not be -/// fulfilled. +/// in unspecified but repeatable order. /// /// The Enrichment facility also offers its tails as an output commodity with /// no associated recipe. Bids for tails are constrained only by total @@ -126,7 +124,7 @@ class Enrichment "The Enrichment facility is a simple agent that enriches natural " \ "uranium in a Cyclus simulation. It does not explicitly compute " \ "the physical enrichment process, rather it calculates the SWU " \ - "required to convert a source uranium recipe (i.e. natural uranium) " \ + "required to convert an source uranium recipe (i.e. natural uranium) " \ "into a requested enriched recipe (i.e. 4% enriched uranium), given " \ "the natural uranium inventory constraint and its SWU capacity " \ "constraint." \ @@ -148,9 +146,7 @@ class Enrichment "If multiple output commodities with different enrichment levels are " \ "requested and the facility does not have the SWU or quantity capacity " \ "to meet all requests, the requests are fully, then partially filled " \ - "in unspecified but repeatable order. A request for the product " \ - "commodity without an associated requested enriched recipe will not be " \ - "fulfilled." \ + "in unspecified but repeatable order." \ "\n\n" \ "Accumulated tails inventory is offered for trading as a specifiable " \ "output commodity.", \ diff --git a/src/storage.cc b/src/storage.cc index 1c92e20963..418fdf1710 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -75,10 +75,9 @@ void Storage::EnterNotify() { buy_policy.Start(); if (out_commods.size() == 1) { - sell_policy.Init(this, &stocks, std::string("stocks"), 1e+299, false, sell_quantity) - .Set(out_commods.front()) - .Start(); - + sell_policy.Init(this, &stocks, std::string("stocks")) + .Set(out_commods.front()) + .Start(); } else { std::stringstream ss; ss << "out_commods has " << out_commods.size() << " values, expected 1."; diff --git a/src/storage.h b/src/storage.h index e360193b34..7282acce2c 100644 --- a/src/storage.h +++ b/src/storage.h @@ -32,7 +32,6 @@ namespace cycamore { /// in_recipe (optional) describes the incoming resource by recipe /// /// @section optionalparams Optional Parameters -/// sell_quantity restricts selling to only integer multiples of this value /// max_inv_size is the maximum capacity of the inventory storage /// throughput is the maximum processing capacity per timestep /// @@ -163,17 +162,6 @@ class Storage "range": [0, 12000]} int residence_time; - #pragma cyclus var {"default": 0,\ - "tooltip":"sell quantity (kg)",\ - "doc":"material will be sold in integer multiples of this quantity. If"\ - " the buffer contains less than the sell quantity, no material will be"\ - " offered", \ - "uilabel":"Sell Quantity",\ - "uitype": "range", \ - "range": [0.0, 1e299], \ - "units": "kg"} - double sell_quantity; - #pragma cyclus var {"default": 1e299,\ "tooltip":"throughput per timestep (kg)",\ "doc":"the max amount that can be moved through the facility per timestep (kg)",\ From 7fa2a09a5c7063b5224d939453dce9cf63c704a6 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 08:21:56 -0600 Subject: [PATCH 27/36] changes requested from @opotowsky --- input/growth/deploy_and_manager_insts.xml | 160 +++++++++++----------- src/deploy_inst.h | 3 +- src/manager_inst_tests.cc | 6 - 3 files changed, 81 insertions(+), 88 deletions(-) diff --git a/input/growth/deploy_and_manager_insts.xml b/input/growth/deploy_and_manager_insts.xml index 6440a6f3fe..5a2ef5362c 100644 --- a/input/growth/deploy_and_manager_insts.xml +++ b/input/growth/deploy_and_manager_insts.xml @@ -15,95 +15,95 @@ - commidity1 + commodity1 1.0 - - Source1 - - - commodity1 - 1 - - - - - - Source2 - - - commodity1 - 1 - - - + + Source1 + + + commodity1 + 1 + + + - - Sink - - - - commodity1 - - - - + + Source2 + + + commodity1 + 1 + + + - - Single Region - - - - - commod1 - - - 5 - - linear - 0 5 - - - - - - - - - - First Institution - - - Sink - 1 - - + + Sink - - - Source2 - - + + + commodity1 + + - + - - Second Institution + + Single Region - - - Source1 - - - 1 - - - 1 - - + + + + commodity1 + + + 5 + + linear + 0 5 + + + + + + - - + + + First Institution + + + Sink + 1 + + + + + + Source2 + + + + + + + Second Institution + + + + Source1 + + + 1 + + + 1 + + + + + diff --git a/src/deploy_inst.h b/src/deploy_inst.h index 51b47ebb38..8fddaf03eb 100644 --- a/src/deploy_inst.h +++ b/src/deploy_inst.h @@ -22,14 +22,13 @@ typedef std::map > BuildSched; class DeployInst : public cyclus::Institution, public cyclus::toolkit::CommodityProducerManager, - public cyclus::toolkit::Builder, public cyclus::toolkit::Position { #pragma cyclus note { \ "doc": \ "Builds and manages agents (facilities) according to a manually" \ " specified deployment schedule. Deployed agents are automatically" \ " decommissioned at the end of their lifetime. Deployed and" \ - " decommissioned agents are registered and unregistered with a growth" \ + " decommissioned agents are registered and unregistered with a" \ " region. The user specifies a list of prototypes for" \ " each and corresponding build times, number to build, and (optionally)" \ " lifetimes. The same prototype can be specified multiple times with" \ diff --git a/src/manager_inst_tests.cc b/src/manager_inst_tests.cc index 26a55ffab4..893fb8be78 100644 --- a/src/manager_inst_tests.cc +++ b/src/manager_inst_tests.cc @@ -1,11 +1,5 @@ #include "manager_inst_tests.h" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//TestProducer::~TestProducer() {} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ManagerInstTests::SetUp() { ctx_ = new cyclus::Context(&ti_, &rec_); From ed47d55e7f1b6e323f63a439224d86946914af56 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 09:04:10 -0600 Subject: [PATCH 28/36] added commodity recipe, needed for tests --- input/growth/deploy_and_manager_insts.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/input/growth/deploy_and_manager_insts.xml b/input/growth/deploy_and_manager_insts.xml index 5a2ef5362c..398b1778e3 100644 --- a/input/growth/deploy_and_manager_insts.xml +++ b/input/growth/deploy_and_manager_insts.xml @@ -24,6 +24,7 @@ commodity1 + commod_recipe 1 @@ -34,6 +35,7 @@ commodity1 + commod_recipe 1 @@ -106,4 +108,11 @@ + + commod_recipe + mass + 922350000 0.711 + 922380000 99.289 + + From df920e18abcce1c08128f9b7373e8722a0675f40 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 09:04:36 -0600 Subject: [PATCH 29/36] added new test for integration of deploy and manager insts --- tests/test_regression.py | 53 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/tests/test_regression.py b/tests/test_regression.py index c079cd0781..e350fe0662 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -379,8 +379,10 @@ def test_xaction_specific(self): np.where(self.resource_ids == self.trans_resource[t])] assert_equal(quantity, 2) -class TestGrowth(TestRegression): - """Tests GrowthRegion, ManagerInst, and Source over a 4-time step +class TestGrowth1(TestRegression): + """This class tests the growth.xml + + Tests GrowthRegion, ManagerInst, and Source over a 4-time step simulation. A linear growth demand (y = x + 2) is provided to the growth region. Two @@ -392,16 +394,16 @@ class TestGrowth(TestRegression): to test the demand for multiple commodities. """ def __init__(self, *args, **kwargs): - super(TestGrowth, self).__init__(*args, **kwargs) + super(TestGrowth1, self).__init__(*args, **kwargs) self.inf = "./input/growth.xml" if not cyclus_has_coin(): raise SkipTest('Cyclus not compiled with COIN') def setUp(self): - super(TestGrowth, self).setUp() + super(TestGrowth1, self).setUp() def tearDown(self): - super(TestGrowth, self).tearDown() + super(TestGrowth1, self).tearDown() def test_deployment(self): pass @@ -426,6 +428,47 @@ def test_deployment(self): for x in source3_id: assert_equal(enter_time[np.where(agent_ids == x)], 2) +class TestGrowth2(TestRegression): + """This class tests the ./input/deploy_and_manager_insts.xml + + Tests GrowthRegion, ManagerInst, DeployInst, and Source over a 10-time step + simulation. + + A linear growth demand (y = 5) is provided to the growth region. One + Source is allowed in the ManagerInst, with capacity of 1. + At t=1, a 1-capacity Source is built by the DeployInst, and at + t=5, 1-capacity Sources are expected to be built by the ManagerInst. + + """ + def __init__(self, *args, **kwargs): + super(TestGrowth2, self).__init__(*args, **kwargs) + self.inf = "../input/growth/deploy_and_manager_insts.xml" + if not cyclus_has_coin(): + raise SkipTest('Cyclus not compiled with COIN') + + def setUp(self): + super(TestGrowth2, self).setUp() + + def tearDown(self): + super(TestGrowth2, self).tearDown() + + def test_deployment(self): + pass + agent_ids = self.to_ary(self.agent_entry, "AgentId") + proto = self.to_ary(self.agent_entry, "Prototype") + enter_time = self.to_ary(self.agent_entry, "EnterTime") + + source1_id = self.find_ids("Source1", self.agent_entry, + spec_col="Prototype") + source2_id = self.find_ids("Source2", self.agent_entry, + spec_col="Prototype") + + assert_equal(len(source1_id), 1) + assert_equal(len(source2_id), 4) + + assert_equal(enter_time[np.where(agent_ids == source1_id[0])], 1) + assert_equal(enter_time[np.where(agent_ids == source2_id[0])], 6) + class _Recycle(TestRegression): """This class tests the input/recycle.xml file. """ From 41383f8afde1ac2c0cb4186d540052e1bb71a0b3 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 10:19:44 -0600 Subject: [PATCH 30/36] Revert "Revert "Merge branch 'master' into deploy-manager-inst"" This reverts commit 1fca401bf2bfaa557e562d96f222fdfd6ae3fade. --- src/enrichment.h | 12 ++++++++---- src/storage.cc | 7 ++++--- src/storage.h | 12 ++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/enrichment.h b/src/enrichment.h index 0d9b74e9a9..b0e2866885 100644 --- a/src/enrichment.h +++ b/src/enrichment.h @@ -87,7 +87,7 @@ class NatUConverter : public cyclus::Converter { /// The Enrichment facility is a simple Agent that enriches natural /// uranium in a Cyclus simulation. It does not explicitly compute /// the physical enrichment process, rather it calculates the SWU -/// required to convert an source uranium recipe (ie. natural uranium) +/// required to convert a source uranium recipe (ie. natural uranium) /// into a requested enriched recipe (ie. 4% enriched uranium), given /// the natural uranium inventory constraint and its SWU capacity /// constraint. @@ -109,7 +109,9 @@ class NatUConverter : public cyclus::Converter { /// If multiple output commodities with different enrichment levels are /// requested and the facility does not have the SWU or quantity capacity /// to meet all requests, the requests are fully, then partially filled -/// in unspecified but repeatable order. +/// in unspecified but repeatable order. A request for the product +/// commodity without an associated requested enriched recipe will not be +/// fulfilled. /// /// The Enrichment facility also offers its tails as an output commodity with /// no associated recipe. Bids for tails are constrained only by total @@ -124,7 +126,7 @@ class Enrichment "The Enrichment facility is a simple agent that enriches natural " \ "uranium in a Cyclus simulation. It does not explicitly compute " \ "the physical enrichment process, rather it calculates the SWU " \ - "required to convert an source uranium recipe (i.e. natural uranium) " \ + "required to convert a source uranium recipe (i.e. natural uranium) " \ "into a requested enriched recipe (i.e. 4% enriched uranium), given " \ "the natural uranium inventory constraint and its SWU capacity " \ "constraint." \ @@ -146,7 +148,9 @@ class Enrichment "If multiple output commodities with different enrichment levels are " \ "requested and the facility does not have the SWU or quantity capacity " \ "to meet all requests, the requests are fully, then partially filled " \ - "in unspecified but repeatable order." \ + "in unspecified but repeatable order. A request for the product " \ + "commodity without an associated requested enriched recipe will not be " \ + "fulfilled." \ "\n\n" \ "Accumulated tails inventory is offered for trading as a specifiable " \ "output commodity.", \ diff --git a/src/storage.cc b/src/storage.cc index 418fdf1710..1c92e20963 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -75,9 +75,10 @@ void Storage::EnterNotify() { buy_policy.Start(); if (out_commods.size() == 1) { - sell_policy.Init(this, &stocks, std::string("stocks")) - .Set(out_commods.front()) - .Start(); + sell_policy.Init(this, &stocks, std::string("stocks"), 1e+299, false, sell_quantity) + .Set(out_commods.front()) + .Start(); + } else { std::stringstream ss; ss << "out_commods has " << out_commods.size() << " values, expected 1."; diff --git a/src/storage.h b/src/storage.h index 7282acce2c..e360193b34 100644 --- a/src/storage.h +++ b/src/storage.h @@ -32,6 +32,7 @@ namespace cycamore { /// in_recipe (optional) describes the incoming resource by recipe /// /// @section optionalparams Optional Parameters +/// sell_quantity restricts selling to only integer multiples of this value /// max_inv_size is the maximum capacity of the inventory storage /// throughput is the maximum processing capacity per timestep /// @@ -162,6 +163,17 @@ class Storage "range": [0, 12000]} int residence_time; + #pragma cyclus var {"default": 0,\ + "tooltip":"sell quantity (kg)",\ + "doc":"material will be sold in integer multiples of this quantity. If"\ + " the buffer contains less than the sell quantity, no material will be"\ + " offered", \ + "uilabel":"Sell Quantity",\ + "uitype": "range", \ + "range": [0.0, 1e299], \ + "units": "kg"} + double sell_quantity; + #pragma cyclus var {"default": 1e299,\ "tooltip":"throughput per timestep (kg)",\ "doc":"the max amount that can be moved through the facility per timestep (kg)",\ From f32705696c473e4c5ba21e69428ed6d140efa33e Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 10:49:08 -0600 Subject: [PATCH 31/36] modified doc sting of TestGrowth2 --- tests/test_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_regression.py b/tests/test_regression.py index e350fe0662..a04e741c5e 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -436,8 +436,8 @@ class TestGrowth2(TestRegression): A linear growth demand (y = 5) is provided to the growth region. One Source is allowed in the ManagerInst, with capacity of 1. - At t=1, a 1-capacity Source is built by the DeployInst, and at - t=5, 1-capacity Sources are expected to be built by the ManagerInst. + At t=1, a 1-capacity Source1 is built by the DeployInst, and at + t=6, 4 1-capacity Source2s are expected to be built by the ManagerInst. """ def __init__(self, *args, **kwargs): From 326205688c68c7e0dc6ee5d48989303da9bd25e1 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Thu, 27 Jan 2022 10:51:11 -0600 Subject: [PATCH 32/36] removed extra includes, moved the one non-duplicate --- src/deploy_inst_tests.cc | 5 ----- src/deploy_inst_tests.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/deploy_inst_tests.cc b/src/deploy_inst_tests.cc index 248c0d171c..b08bef67cc 100644 --- a/src/deploy_inst_tests.cc +++ b/src/deploy_inst_tests.cc @@ -1,10 +1,5 @@ -#include -#include "context.h" -#include "deploy_inst.h" #include "deploy_inst_tests.h" -#include "institution_tests.h" -#include "agent_tests.h" // make sure that the deployed agent's prototype name is identical to the // originally specified prototype name - this is important to test because diff --git a/src/deploy_inst_tests.h b/src/deploy_inst_tests.h index 638ead3dfe..3ceb6a5fda 100644 --- a/src/deploy_inst_tests.h +++ b/src/deploy_inst_tests.h @@ -8,7 +8,7 @@ #include "test_context.h" #include "institution_tests.h" #include "agent_tests.h" - +#include "context.h" #include "deploy_inst.h" From 50d1f66727c50b90b59ccf160a8a4a3b3c835786 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 7 Feb 2022 14:59:09 -0600 Subject: [PATCH 33/36] added new test for deployinst + nullregion --- tests/test_regression.py | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/test_regression.py b/tests/test_regression.py index a04e741c5e..ec4f2aa532 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -469,6 +469,47 @@ def test_deployment(self): assert_equal(enter_time[np.where(agent_ids == source1_id[0])], 1) assert_equal(enter_time[np.where(agent_ids == source2_id[0])], 6) +class TestDeployInst(TestRegression): + """This class tests the ../input/deploy_inst.xml + + Tests DeployInst, and NullRegion over a 10-time step + simulation. + + A DeployInst is used to define that a Source agent is to be deployed at + time t=1 within a Null Region. A Sink agent is also deployed as + an initial facility. This input is used to test that the Source and + Sink agents are deployed at their respecitve times and that the correct + number of these agents are deployed. + + """ + def __init__(self, *args, **kwargs): + super(TestDeployInst, self).__init__(*args, **kwargs) + self.inf = "../input/deploy_inst.xml" + if not cyclus_has_coin(): + raise SkipTest('Cyclus not compiled with COIN') + + def setUp(self): + super(TestDeployInst, self).setUp() + + def tearDown(self): + super(TestDeployInst, self).tearDown() + + def test_deployment(self): + pass + agent_ids = self.to_ary(self.agent_entry, "AgentId") + proto = self.to_ary(self.agent_entry, "Prototype") + enter_time = self.to_ary(self.agent_entry, "EnterTime") + + source_id = self.find_ids("Source", self.agent_entry, + spec_col="Prototype") + sink_id = self.find_ids("Sink", self.agent_entry, spec_col="Prototype") + + assert_equal(len(source_id), 1) + assert_equal(len(sink_id), 1) + + assert_equal(enter_time[np.where(agent_ids == source_id[0])], 1) + assert_equal(enter_time[np.where(agent_ids == sink_id[0])], 0) + class _Recycle(TestRegression): """This class tests the input/recycle.xml file. """ From 63843123209aebba743e7250417cc7092137ba12 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 7 Feb 2022 14:59:26 -0600 Subject: [PATCH 34/36] input file for new test --- input/deploy_inst.xml | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 input/deploy_inst.xml diff --git a/input/deploy_inst.xml b/input/deploy_inst.xml new file mode 100644 index 0000000000..4512627ecc --- /dev/null +++ b/input/deploy_inst.xml @@ -0,0 +1,75 @@ + + + 10 + 1 + 2018 + never + + + + agentsNullRegion + cycamoreDeployInst + cycamoreSource + cycamoreSink + + + + Source + + + commodity1 + commod_recipe + 1 + + + + + + Sink + + + + commodity1 + + + + + + + Single Region + + + + + + + + Sink + 1 + + + Single Institution + + + + Source + + + 1 + + + 1 + + + + + + + + commod_recipe + mass + 922350000 0.711 + 922380000 99.289 + + + From f8e3f6e61cf0cadd36b73469cbe6c5ae7e62ae36 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Wed, 9 Feb 2022 16:48:12 -0600 Subject: [PATCH 35/36] made register and unregister private --- src/deploy_inst.h | 1 + src/manager_inst.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/deploy_inst.h b/src/deploy_inst.h index 8fddaf03eb..fd55485a61 100644 --- a/src/deploy_inst.h +++ b/src/deploy_inst.h @@ -55,6 +55,7 @@ class DeployInst : void WriteProducerInformation(cyclus::toolkit::CommodityProducer* producer); + private: /// register a child void Register_(cyclus::Agent* agent); diff --git a/src/manager_inst.h b/src/manager_inst.h index 203b2e26c2..df857e88eb 100644 --- a/src/manager_inst.h +++ b/src/manager_inst.h @@ -44,13 +44,13 @@ class ManagerInst void WriteProducerInformation(cyclus::toolkit::CommodityProducer* producer); + private: /// register a child void Register_(cyclus::Agent* agent); /// unregister a child void Unregister_(cyclus::Agent* agent); - protected: #pragma cyclus var { \ "tooltip": "producer facility prototypes", \ "uilabel": "Producer Prototype List", \ From 43137a2bc80e67b3e9eaa5235f1fe56a4d191cc5 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Wed, 9 Feb 2022 16:50:45 -0600 Subject: [PATCH 36/36] put TestProducer back into manager_inst_tests.cc --- src/deploy_inst_tests.cc | 7 ------- src/manager_inst_tests.cc | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/deploy_inst_tests.cc b/src/deploy_inst_tests.cc index b08bef67cc..a529f9bc05 100644 --- a/src/deploy_inst_tests.cc +++ b/src/deploy_inst_tests.cc @@ -1,4 +1,3 @@ - #include "deploy_inst_tests.h" // make sure that the deployed agent's prototype name is identical to the @@ -6,12 +5,6 @@ // DeployInst does some mucking around with registering name-modded prototypes // in order to deal with lifetime setting. -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TestProducer::~TestProducer() {} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeployInstTests::SetUp() { ctx_ = new cyclus::Context(&ti_, &rec_); diff --git a/src/manager_inst_tests.cc b/src/manager_inst_tests.cc index 893fb8be78..2f9063407a 100644 --- a/src/manager_inst_tests.cc +++ b/src/manager_inst_tests.cc @@ -1,5 +1,10 @@ #include "manager_inst_tests.h" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +TestProducer::~TestProducer() {} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ManagerInstTests::SetUp() { ctx_ = new cyclus::Context(&ti_, &rec_);