-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature for DeployInst #529
Changes from 35 commits
8fc752c
31839c4
2c69856
7653f29
3a53159
1a1483d
064b850
3e2d6b8
8ce30e9
dc1e951
d574667
2e93d6e
6078305
882b853
ca24a31
8fe92de
bb8e75f
bc52e9c
797e8fe
416ba1f
031ab59
63ac68a
a001062
43ac611
ad57d01
3a98763
b8a2925
1fca401
7fa2a09
ed47d55
df920e1
41383f8
34c0517
f327056
3262056
50d1f66
6384312
f8e3f6e
43137a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<simulation> | ||
<control> | ||
<duration>10</duration> | ||
<startmonth>1</startmonth> | ||
<startyear>2018</startyear> | ||
<decay>never</decay> | ||
</control> | ||
|
||
<archetypes> | ||
<spec> <lib>cycamore</lib><name>GrowthRegion</name> </spec> | ||
<spec> <lib>cycamore</lib><name>DeployInst</name> </spec> | ||
<spec> <lib>cycamore</lib><name>ManagerInst</name> </spec> | ||
<spec> <lib>cycamore</lib><name>Source</name> </spec> | ||
<spec> <lib>cycamore</lib><name>Sink</name> </spec> | ||
</archetypes> | ||
|
||
<commodity> | ||
<name>commodity1</name> | ||
<solution_priority>1.0</solution_priority> | ||
</commodity> | ||
|
||
<facility> | ||
<name>Source1</name> | ||
<config> | ||
<Source> | ||
<outcommod>commodity1</outcommod> | ||
<outrecipe>commod_recipe</outrecipe> | ||
<throughput>1</throughput> | ||
</Source> | ||
</config> | ||
</facility> | ||
|
||
<facility> | ||
<name>Source2</name> | ||
<config> | ||
<Source> | ||
<outcommod>commodity1</outcommod> | ||
<outrecipe>commod_recipe</outrecipe> | ||
<throughput>1</throughput> | ||
</Source> | ||
</config> | ||
</facility> | ||
|
||
<facility> | ||
<name>Sink</name> | ||
<config> | ||
<Sink> | ||
<in_commods> | ||
<val>commodity1</val> | ||
</in_commods> | ||
</Sink> | ||
</config> | ||
</facility> | ||
|
||
<region> | ||
<name>Single Region</name> | ||
<config> | ||
<GrowthRegion> | ||
<growth> | ||
<item> | ||
<commod>commodity1</commod> | ||
<piecewise_function> | ||
<piece> | ||
<start>5</start> | ||
<function> | ||
<type>linear</type> | ||
<params>0 5</params> | ||
</function> | ||
</piece> | ||
</piecewise_function> | ||
</item> | ||
</growth> | ||
</GrowthRegion> | ||
</config> | ||
|
||
<institution> | ||
<name>First Institution</name> | ||
<initialfacilitylist> | ||
<entry> | ||
<prototype>Sink</prototype> | ||
<number>1</number> | ||
</entry> | ||
</initialfacilitylist> | ||
<config> | ||
<ManagerInst> | ||
<prototypes> | ||
<val>Source2</val> | ||
</prototypes> | ||
</ManagerInst> | ||
</config> | ||
</institution> | ||
|
||
<institution> | ||
<name>Second Institution</name> | ||
<config> | ||
<DeployInst> | ||
<prototypes> | ||
<val>Source1</val> | ||
</prototypes> | ||
<build_times> | ||
<val>1</val> | ||
</build_times> | ||
<n_build> | ||
<val>1</val> | ||
</n_build> | ||
</DeployInst> | ||
</config> | ||
</institution> | ||
</region> | ||
|
||
<recipe> | ||
<name>commod_recipe</name> | ||
<basis>mass</basis> | ||
<nuclide> <id>922350000</id> <comp>0.711</comp> </nuclide> | ||
<nuclide> <id>922380000</id> <comp>99.289</comp> </nuclide> | ||
</recipe> | ||
|
||
</simulation> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,17 @@ typedef std::map<int, std::vector<std::string> > 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::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" \ | ||
" region. The user specifies a list of prototypes for" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to specify that it's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just that it's important to document what kind of region these agents are registered with. I think that's important to note in the documentation, but maybe it's more generic?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is where she previously had "growth region" and I asked that "growth" be removed because in theory it could work within another region? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair - it probably shouldn't be limited to a growth region, specifically, but - on the other hand - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @opotowsky is correct, I removed the word growth to try and make it as region agnostic as possible. I thought that the growth region was the only one currently implemented that uses registration, but this wording would be flexible for if a new one was developed. |
||
" 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 +48,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.", \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,38 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "context.h" | ||
#include "deploy_inst.h" | ||
#include "institution_tests.h" | ||
#include "agent_tests.h" | ||
#include "deploy_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() {} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like these were moved from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did move these lines from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They definitely need to be only defined in one place. If they are in two places, they get compiled twice and then the linker finds two copies when it tries to combine them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can create a file |
||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
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 = | ||
"<prototypes> <val>foobar</val> </prototypes>" | ||
"<build_times> <val>1</val> </build_times>" | ||
|
@@ -32,7 +52,7 @@ TEST(DeployInstTests, ProtoNames) { | |
EXPECT_EQ(3, stmt->GetInt(0)); | ||
} | ||
|
||
TEST(DeployInstTests, BuildTimes) { | ||
TEST_F(DeployInstTests, BuildTimes) { | ||
std::string config = | ||
"<prototypes> <val>foobar</val> <val>foobar</val> </prototypes>" | ||
"<build_times> <val>1</val> <val>3</val> </build_times>" | ||
|
@@ -59,7 +79,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 = | ||
"<prototypes> <val>foobar</val> <val>foobar</val> <val>foobar</val> </prototypes>" | ||
"<build_times> <val>1</val> <val>1</val> <val>2</val> </build_times>" | ||
|
@@ -112,7 +132,7 @@ TEST(DeployInstTests, FiniteLifetimes) { | |
EXPECT_EQ(8, stmt->GetInt(0)); | ||
} | ||
|
||
TEST(DeployInstTests, NoDupProtos) { | ||
TEST_F(DeployInstTests, NoDupProtos) { | ||
std::string config = | ||
"<prototypes> <val>foobar</val> <val>foobar</val> <val>foobar</val> </prototypes>" | ||
"<build_times> <val>1</val> <val>1</val> <val>2</val> </build_times>" | ||
|
@@ -141,7 +161,7 @@ TEST(DeployInstTests, NoDupProtos) { | |
EXPECT_EQ(1, stmt->GetInt(0)); | ||
} | ||
|
||
TEST(DeployInstTests, PositionInitialize) { | ||
TEST_F(DeployInstTests, PositionInitialize) { | ||
std::string config = | ||
"<prototypes> <val>foobar</val> </prototypes>" | ||
"<build_times> <val>1</val> </build_times>" | ||
|
@@ -158,7 +178,7 @@ TEST(DeployInstTests, PositionInitialize) { | |
EXPECT_EQ(qr.GetVal<double>("Longitude"), 0.0); | ||
} | ||
|
||
TEST(DeployInstTests, PositionInitialize2) { | ||
TEST_F(DeployInstTests, PositionInitialize2) { | ||
std::string config = | ||
"<prototypes> <val>foobar</val> </prototypes>" | ||
"<longitude> -20.0 </longitude>" | ||
|
@@ -177,6 +197,28 @@ TEST(DeployInstTests, PositionInitialize2) { | |
EXPECT_EQ(qr.GetVal<double>("Longitude"), -20.0); | ||
} | ||
|
||
TEST_F(DeployInstTests, producerexists) { | ||
using std::set; | ||
ctx_->AddPrototype("foop", producer); | ||
set<cyclus::toolkit::CommodityProducer*>::iterator it; | ||
for (it = src_inst->cyclus::toolkit::CommodityProducerManager:: | ||
producers().begin(); | ||
it != src_inst->cyclus::toolkit::CommodityProducerManager:: | ||
producers().end(); | ||
it++) { | ||
EXPECT_EQ(dynamic_cast<TestProducer*>(*it)->prototype(), | ||
producer->prototype()); | ||
} | ||
} | ||
|
||
TEST_F(DeployInstTests, 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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this block is even needed for this simple simulation. At least, upon skimming the resulting DBs with and without it, I didn't see a difference. We can get someone more knowledgable to weigh in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt like it was good practice to include a sink in the simulation. Also, this way it matches more with the
source_sink_linear.xml
file also in that directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I meant the commodity block with the priority, not the sink. I should have done a better job w that comment :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this is a comment of the lowest priority, btw)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was just a force of habit. If you really think it needs to be removed I can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends if we prefer the input file to be a good example or to be bare bones. I was reviewing from the bare bone perspective, which given the remaining questions in Issue #530 may or may not be valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely not a necessary block, but I would NOT require its remove for this to merge.