4 #include <boost/uuid/uuid_generators.hpp> 26 explicit_inventory(false),
27 explicit_inventory_compact(false),
28 parent_sim(
boost::uuids::nil_uuid()),
29 parent_type(
"init") {}
65 parent_sim(parent_sim),
66 parent_type(parent_type),
67 branch_time(branch_time),
80 if (solver_ != NULL) {
86 std::vector<Agent*> to_del;
87 std::set<Agent*>::iterator it;
88 for (it = agent_list_.begin(); it != agent_list_.end(); ++it) {
89 if ((*it)->parent() == NULL) {
90 to_del.push_back(*it);
93 for (
int i = 0; i < to_del.size(); ++i) {
99 int n = agent_list_.erase(m);
111 int pid = (parent != NULL) ? parent->
id() : -1;
115 ->
AddVal(
"Prototype", proto_name)
128 ->AddVal(
"SchedTime",
time())
129 ->AddVal(
"DecomTime", t)
142 if (!overwrite && protos_.find(name) != protos_.end()) {
143 throw KeyError(
"Prototype name " + name +
" has already been added" +
144 " and cannot be overwritten.");
151 ->
AddVal(
"Prototype", name)
153 ->AddVal(
"Spec", p->
spec())
157 if (rec_ver_.count(spec) == 0) {
158 rec_ver_.insert(spec);
170 ->
AddVal(
"QualId", c->id())
175 if (recipes_.count(name) == 0) {
176 throw KeyError(
"Invalid recipe name " + name);
178 return recipes_[
name];
211 ->
AddVal(
"DurationSecs", static_cast<int>(si.
dt))
virtual std::string version()
Composition::Ptr GetRecipe(std::string name)
Retrieve a registered recipe.
boost::uuids::uuid sim_id()
returns the unique id associated with this cyclus simulation.
boost::shared_ptr< Composition > Ptr
void AddRecipe(std::string name, Composition::Ptr c)
Adds a composition recipe to a simulation-wide accessible list.
std::string handle
user-defined label associated with a particular simulation
int branch_time
timestep at which simulation branching occurs if any
double cy_eps
generic epsilon values
double eps
Epsilon in the simulation.
void RegisterTimeListener(TimeListener *agent)
Registers an agent to receive tick/tock notifications every timestep.
boost::uuids::uuid sim_id()
See Recorder::sim_id documentation.
virtual const int id() const
The agent instance's unique ID within a simulation.
std::string name(int nuc)
int duration
length of the simulation in timesteps (months)
void Snapshot()
Schedules a snapshot of simulation state to output database to occur at the beginning of the next tim...
void UnregisterTimeListener(TimeListener *tl)
Removes an agent from receiving tick/tock notifications.
void UnregisterTimeListener(TimeListener *tl)
Removes an agent from receiving tick/tock notifications.
int y0
start year for the simulation (e.g. 1973);
bool explicit_inventory
True if per-agent inventories should be explicitly queried/recorded every time step in a table (i...
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.
~Context()
Clean up resources including destructing the solver and all agents the context is aware of...
uint64_t dt
Duration in seconds of a single time step in the simulation.
Context(Timer *ti, Recorder *rec)
Creates a new context working with the specified timer and datum manager.
virtual int time()
Returns the current simulation timestep.
Used to specify and send a collection of key-value pairs to the Recorder for recording.
const uint64_t kDefaultTimeStepDur
int parent(int nuc, unsigned int rx, std::string z="n")
struct pyne::decay decay
a struct matching the '/decay/decays' table in nuc_data.h5.
void Initialize(Context *ctx, SimInfo si)
Sets intial time-related parameters for the simulation.
boost::uuids::uuid parent_sim
id for the parent simulation if any
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
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...
std::string decay
"manual" if use of the decay function is allowed, "never" otherwise
double eps_rsrc
Epsilon for resources in the simulation.
int m0
start month for the simulation: Jan = 1, ..., Dec = 12
SimInfo()
constructs a SimInfo instance with default variables
Collects and manages output data generation for the cyclus core and agents during a simulation...
double cy_eps_rsrc
epsilon values to be used by resources
std::string parent_type
One of "init", "branch", "restart" indicating the relationship of this simulation to its parent simul...
void RegisterTimeListener(TimeListener *tl)
Registers an agent to receive tick/tock notifications every timestep.
int time()
Returns the current time, in months since the simulation started.
The TimeListener class is an inheritable class for any Agent that requires knowlege of ticks and tock...
Datum * NewDatum(std::string title)
Creates a new datum namespaced under the specified title.
Container for a static simulation-global parameters that both describe the simulation and affect its ...
Code providing rudimentary logging capability for the Cyclus core.
bool explicit_inventory_compact
True if per-agent inventories should be explicitly queried/recorded every time step in a table (i...
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.
void KillSim()
Schedules the simulation to be terminated at the end of this timestep.
void Record()
Record this datum to its Recorder.
void PyDelAgent(int i)
Removes a single Python agent from the reference cache.
void SchedBuild(Agent *parent, std::string proto_name, int t)
Schedules the named prototype to be built for the specified parent at timestep t. ...
void Snapshot()
Schedules a snapshot of simulation state to output database to occur at the beginning of the next tim...
void KillSim()
Schedules the simulation to be terminated at the end of this timestep.
void SchedDecom(Agent *m, int time)
Schedules the given Agent to be decommissioned at the specified timestep t.
static void SnapAgent(Agent *m)
Records a snapshot of the agent's current internal state into the simulation's output database...
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
For failed retrieval/insertion of key-based data into/from data structures.
void SchedDecom(Agent *m, int time=-1)
Schedules the given Agent to be decommissioned at the specified timestep t.
void DelAgent(Agent *m)
Destructs and cleans up m (and it's children recursively).
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. ...
Controls simulation timestepping and inter-timestep phases.