22 std::vector<Cond>
conds;
24 conds.push_back(
Cond(
"SimTime",
"==",
static_cast<int>(0)));
25 conds.push_back(
Cond(
"AgentId",
"==",
a->id()));
30 a->Agent::InitFrom(&pi);
38int MockAgent::nextid_ = 0;
85 std::stringstream
xml;
86 xml <<
"<facility><name>" << proto_ <<
"</name><lifetime>" << lifetime_
87 <<
"</lifetime><config><SrcSnkAgent>";
90 xml <<
"<commod>" << commod_ <<
"</commod>";
92 xml <<
"<in_commods><val>" << commod_ <<
"</val></in_commods>";
94 xml <<
"<capacity>" << cap_ <<
"</capacity>";
96 xml <<
"<recipe_name>" << recipe_ <<
"</recipe_name>";
98 xml <<
"</SrcSnkAgent></config></facility>";
116 : ctx_(&ti_, &rec_), back_(
NULL), agent(
NULL) {
125 : ctx_(&ti_, &rec_), back_(
NULL), agent(
NULL) {
134 std::stringstream
xml;
135 xml <<
"<facility><name>agent_being_tested</name><config><foo>" <<
config
136 <<
"</foo></config></facility>";
144 : ctx_(&ti_, &rec_), back_(
NULL), agent(
NULL) {
153 std::stringstream
xml;
155 <<
"<lifetime>" << lifetime <<
"</lifetime>"
156 <<
"<name>agent_being_tested</name>"
157 <<
"<config><foo>" <<
config <<
"</foo></config>"
168 std::stringstream
xml;
169 xml <<
"<facility><name>" << name <<
"</name>"
171 <<
"<commod>alongunusedcommodityname</commod>"
172 <<
"<capacity>0</capacity>"
173 <<
"</foo></config></facility>";
182 std::stringstream
xml;
183 xml <<
"<facility><name>" << name <<
"</name>"
185 <<
"<commod>" <<
"commod" <<
"</commod>"
186 <<
"<capacity>" << capacity <<
"</capacity>"
187 <<
"</foo></config></facility>";
The abstract base class used by all types of agents that live and interact in a simulation.
virtual void Build(Agent *parent)
Called when the agent enters the smiulation as an active participant and is only ever called once.
virtual const int id() const
The agent instance's unique ID within a simulation.
boost::shared_ptr< Composition > Ptr
Wrapper class for QueryableBackends that injects a set of Cond's into every query before being execut...
Represents a condition used to filter rows returned by a query.
A simulation context provides access to necessary simulation-global functions and state.
T * CreateAgent(std::string proto_name)
Create a new agent by cloning the named prototype.
void SchedBuild(Agent *parent, std::string proto_name, int t=-1)
Schedules the named prototype to be built for the specified parent at timestep t.
void AddPrototype(std::string name, Agent *m)
Adds a prototype to a simulation-wide accessible list, a prototype can not be added more than once.
void AddRecipe(std::string name, Composition::Ptr c)
Adds a composition recipe to a simulation-wide accessible list.
void InitSim(SimInfo si)
Initializes the simulation time parameters.
DbInit provides an interface for agents to record data to the output db that automatically injects th...
static Agent * Make(Context *ctx, AgentSpec spec)
Returns a newly constructed agent for the given module spec.
static const void SetNucDataPath()
Initializes the path to the cyclus_nuc_data.h5 file.
A class for extracting information from a given XML parser.
boost::shared_ptr< Material > Ptr
MockAgent is a template for accumulating configuration information used to generate a source or sink ...
MockAgent recipe(std::string recipe)
Sets the recipe to be offered/requested by the source/sink.
MockAgent lifetime(int duration)
Sets the lifetime in time steps of the source/sink before it is decommissioned.
MockAgent commod(std::string commod)
Sets the commodity to be offered/requested by the source/sink.
MockAgent start(int timestep)
Sets the time step in the simulation that the source/sink should be deployed.
MockAgent capacity(double cap)
Sets the per time step capacity/throughput limit for provided/received material in kg for the source/...
MockAgent(Context *ctx, Recorder *rec, SqliteBack *b, bool is_source)
Initializes a MockAgent to create a source (is_source == true) or a sink (is_source == false) in the ...
std::string Finalize()
Finalize MUST be called after configuration is complete to actually create the source/sink agent (or ...
MockSim(int duration)
Creates and initializes a new empty mock simulation environment where duration is the length of the s...
Product::Ptr GetProduct(int resid)
Reconstructs a product object from the simulation results database with the given resource state id.
MockAgent AddSink(std::string commod)
AddSink adds a sink facility that can request+receive material from the archetype being tested.
void AddRecipe(std::string name, Composition::Ptr c)
AddRecipe adds a recipe to the mock simulation environment (i.e.
Agent * agent
the agent being tested by the mock simulation environment.
void DummyProto(std::string name)
Adds a dummy prototype to the simulation that can be used by institutions and other agents for deploy...
Material::Ptr GetMaterial(int resid)
Reconstructs a material object from the simulation results database with the given resource state id.
SqliteBack & db()
Returns the underlying in-memory database containing results for the simulation.
int Run()
Runs the simulation.
MockAgent AddSource(std::string commod)
AddSource adds a source facility that can offer/provide material to the archetype being tested.
Wrapper class for QueryableBackends that injects prefix in front of the title/table for every query b...
boost::shared_ptr< Product > Ptr
Collects and manages output data generation for the cyclus core and agents during a simulation.
void RegisterBackend(RecBackend *b)
Registers b to receive Datum notifications for all Datum objects collected by the Recorder and to rec...
void Flush()
Flushes all buffered Datum objects and flushes all registered backends.
void Close()
Flushes all buffered Datum objects and flushes all registered backends.
Container for a static simulation-global parameters that both describe the simulation and affect its ...
static Product::Ptr BuildProduct(QueryableBackend *b, int resid)
Convenience function for reconstructing an untracked product object with the given resource state id ...
static Material::Ptr BuildMaterial(QueryableBackend *b, int resid)
Convenience function for reconstructing an untracked material object with the given resource state id...
An Recorder backend that writes data to an sqlite database.
void RunSim()
Runs the simulation.
A helper class to hold xml file data and provide automatic validation.
void Init(const std::stringstream &input)
initializes a parser with an xml snippet
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
void InitAgent(Agent *a, std::stringstream &config, Recorder *rec, SqliteBack *back)
unsigned int warn_limit
This is maximum number of times to issue a warning of each kind.
void PyStop(void)
Closes the current Python session.
void PyStart(void)
Initialize Python functionality, this is a no-op if Python was not installed along with Cyclus.
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
static const double CY_LARGE_DOUBLE
maximum (+) value for a linear variable