18 a->Agent::InfileToDb(&xqe,
DbInit(a,
true));
22 std::vector<Cond> conds;
23 conds.push_back(
Cond(
"SimId",
"==", rec->
sim_id()));
24 conds.push_back(
Cond(
"SimTime",
"==", static_cast<int>(0)));
25 conds.push_back(
Cond(
"AgentId",
"==", a->
id()));
30 a->Agent::InitFrom(&pi);
38 int 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>";
206 MockAgent ms(&ctx_, &rec_, back_,
false);
int Run()
Runs the simulation.
boost::uuids::uuid sim_id()
returns the unique id associated with this cyclus simulation.
boost::shared_ptr< Composition > Ptr
void Close()
Flushes all buffered Datum objects and flushes all registered backends.
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
void AddRecipe(std::string name, Composition::Ptr c)
Adds a composition recipe to a simulation-wide accessible list.
An Recorder backend that writes data to an sqlite database.
MockAgent AddSource(std::string commod)
AddSource adds a source facility that can offer/provide material to the archetype being tested...
Material::Ptr GetMaterial(int resid)
Reconstructs a material object from the simulation results database with the given resource state id...
virtual void InfileToDb(InfileTree *qe, DbInit di)
Translates info for the agent from an input file to the database by reading parameters from the passe...
const std::string prototype() const
Returns the agent's prototype.
A class for extracting information from a given XML parser.
boost::shared_ptr< Material > Ptr
virtual const int id() const
The agent instance's unique ID within a simulation.
std::string name(int nuc)
MockAgent is a template for accumulating configuration information used to generate a source or sink ...
boost::shared_ptr< Product > Ptr
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 ...
void DummyProto(std::string name)
Adds a dummy prototype to the simulation that can be used by institutions and other agents for deploy...
MockSim(int duration)
Creates and initializes a new empty mock simulation environment where duration is the length of the s...
A helper class to hold xml file data and provide automatic validation.
virtual void Build(Agent *parent)
Called when the agent enters the smiulation as an active participant and is only ever called once...
unsigned int warn_limit
This is maximum number of times to issue a warning of each kind.
Product::Ptr GetProduct(int resid)
Reconstructs a product object from the simulation results database with the given resource state id...
std::string spec()
The string representation of the agent spec that uniquely identifies the concrete agent class/module...
void InitSim(SimInfo si)
Initializes the simulation time parameters.
static const void SetNucDataPath()
Initializes the path to the cyclus_nuc_data.h5 file.
static Product::Ptr BuildProduct(QueryableBackend *b, int resid)
Convenience function for reconstructing an untracked product object with the given resource state id ...
Wrapper class for QueryableBackends that injects a set of Cond's into every query before being execut...
void AddRecipe(std::string name, Composition::Ptr c)
AddRecipe adds a recipe to the mock simulation environment (i.e.
MockAgent lifetime(int duration)
Sets the lifetime in time steps of the source/sink before it is decommissioned.
T * CreateAgent(std::string proto_name)
Create a new agent by cloning the named prototype.
void PyStop(void)
Closes the current Python session.
MockAgent commod(std::string commod)
Sets the commodity to be offered/requested by the source/sink.
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...
DbInit provides an interface for agents to record data to the output db that automatically injects th...
MockAgent AddSink(std::string commod)
AddSink adds a sink facility that can request+receive material from the archetype being tested...
void Flush()
Flushes all buffered Datum objects and flushes all registered backends.
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...
MockAgent recipe(std::string recipe)
Sets the recipe to be offered/requested by the source/sink.
std::string Finalize()
Finalize MUST be called after configuration is complete to actually create the source/sink agent (or ...
MockAgent start(int timestep)
Sets the time step in the simulation that the source/sink should be deployed.
void PyStart(void)
Initialize Python functionality, this is a no-op if Python was not installed along with Cyclus...
void RunSim()
Runs the simulation.
Wrapper class for QueryableBackends that injects prefix in front of the title/table for every query b...
Container for a static simulation-global parameters that both describe the simulation and affect its ...
A simulation context provides access to necessary simulation-global functions and state...
The abstract base class used by all types of agents that live and interact in a simulation.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
MockAgent capacity(double cap)
Sets the per time step capacity/throughput limit for provided/received material in kg for the source/...
const double pi
pi = 3.14159265359
static Material::Ptr BuildMaterial(QueryableBackend *b, int resid)
Convenience function for reconstructing an untracked material object with the given resource state id...
Agent * agent
the agent being tested by the mock simulation environment.
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Represents a condition used to filter rows returned by a query.
static Agent * Make(Context *ctx, AgentSpec spec)
Returns a newly constructed agent for the given module spec.
void InitAgent(Agent *a, std::stringstream &config, Recorder *rec, SqliteBack *back)
void Init(const std::stringstream &input)
initializes a parser with an xml snippet
SqliteBack & db()
Returns the underlying in-memory database containing results for the simulation.
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. ...