CYCLUS
|
A simulation context provides access to necessary simulation-global functions and state.
All code that writes to the output database, needs to know simulation time, creates/builds facilities, and/or uses loaded composition recipes will need a context pointer. In general, all global state should be accessed through a simulation context.
#include <context.h>
Creates a new context working with the specified timer and datum manager.
The timer does not have to be initialized (yet).
Definition at line 81 of file context.cc.
cyclus::Context::~Context | ( | ) |
Clean up resources including destructing the solver and all agents the context is aware of.
Definition at line 90 of file context.cc.
void cyclus::Context::AddPackage | ( | std::string | name, |
double | fill_min = 0, | ||
double | fill_max = std::numeric_limits<double>::max(), | ||
std::string | strategy = "first" ) |
Adds a package type to a simulation-wide accessible list.
Agents should NOT add their own packages.
Definition at line 194 of file context.cc.
Adds a prototype to a simulation-wide accessible list, a prototype can not be added more than once.
name | the prototype name |
m | a pointer to the agent prototype |
overwrite,allow | overwrites to the prototype listing, default: false |
if | overwrite is false and a prototype name has already been added |
Definition at line 150 of file context.cc.
Definition at line 154 of file context.cc.
void cyclus::Context::AddRecipe | ( | std::string | name, |
Composition::Ptr | c ) |
Adds a composition recipe to a simulation-wide accessible list.
Agents should NOT add their own recipes.
Definition at line 179 of file context.cc.
void cyclus::Context::AddTransportUnit | ( | std::string | name, |
int | fill_min = 0, | ||
int | fill_max = std::numeric_limits<int>::max(), | ||
std::string | strategy = "first" ) |
Adds a transport unit type to a simulation-wide accessible list.
Agents should NOT add their own transport units.
Definition at line 227 of file context.cc.
Destructs and cleans up m (and it's children recursively).
Definition at line 111 of file context.cc.
|
inline |
Package::Ptr cyclus::Context::GetPackage | ( | std::string | name | ) |
Retrieve a registered package.
Definition at line 214 of file context.cc.
Composition::Ptr cyclus::Context::GetRecipe | ( | std::string | name | ) |
Retrieve a registered recipe.
This is intended for retrieving compositions loaded from an input file(s) at the start of a simulation and NOT for communicating compositions between facilities during the simulation.
Definition at line 187 of file context.cc.
TransportUnit::Ptr cyclus::Context::GetTransportUnit | ( | std::string | name | ) |
Retrieve a registered transport unit.
Definition at line 249 of file context.cc.
Initializes the simulation time parameters.
Should only be called once - NOT idempotent.
Definition at line 263 of file context.cc.
void cyclus::Context::KillSim | ( | ) |
Schedules the simulation to be terminated at the end of this timestep.
Definition at line 359 of file context.cc.
|
inline |
|
inline |
Datum * cyclus::Context::NewDatum | ( | std::string | title | ) |
See Recorder::NewDatum documentation.
Definition at line 351 of file context.cc.
|
inline |
int cyclus::Context::random | ( | ) |
Definition at line 317 of file context.cc.
double cyclus::Context::random_01 | ( | ) |
Generates a random number on the range [0,1)].
Definition at line 321 of file context.cc.
int cyclus::Context::random_normal_int | ( | double | mean, |
double | std_dev, | ||
int | low = 0, | ||
int | high = std::numeric_limits<int>::max() ) |
Returns a random number from a lognormal distribution.
Definition at line 338 of file context.cc.
double cyclus::Context::random_normal_real | ( | double | mean, |
double | std_dev, | ||
double | low = 0, | ||
double | high = std::numeric_limits<double>::max() ) |
Returns a random number from a normal distribution.
Definition at line 333 of file context.cc.
Returns a random number from a uniform integer distribution.
Definition at line 325 of file context.cc.
Returns a random number from a uniform real distribution.
Definition at line 329 of file context.cc.
void cyclus::Context::RecordPackage | ( | Package::Ptr | pkg | ) |
Records package information.
Should be used first on unpackaged, then to record user-declared packages
Definition at line 205 of file context.cc.
void cyclus::Context::RecordTransportUnit | ( | TransportUnit::Ptr | tu | ) |
Records transport unit information.
Should be used first on unrestricted, then to record user-declared transport units
Definition at line 239 of file context.cc.
void cyclus::Context::RegisterTimeListener | ( | TimeListener * | tl | ) |
Registers an agent to receive tick/tock notifications every timestep.
Agents should register from their Deploy method.
Definition at line 343 of file context.cc.
Schedules the named prototype to be built for the specified parent at timestep t.
The default t=-1 results in the build being scheduled for the next build phase (i.e. the start of the next timestep).
Definition at line 120 of file context.cc.
Schedules the given Agent to be decommissioned at the specified timestep t.
The default t=-1 results in the decommission being scheduled for the next decommission phase (i.e. the end of the current timestep).
Definition at line 134 of file context.cc.
|
inline |
boost::uuids::uuid cyclus::Context::sim_id | ( | ) |
See Recorder::sim_id documentation.
Definition at line 146 of file context.cc.
|
inline |
void cyclus::Context::Snapshot | ( | ) |
Schedules a snapshot of simulation state to output database to occur at the beginning of the next timestep.
Definition at line 355 of file context.cc.
|
inline |
|
inline |
|
inline |
|
virtual |
Returns the current simulation timestep.
Definition at line 313 of file context.cc.
void cyclus::Context::UnregisterTimeListener | ( | TimeListener * | tl | ) |
Removes an agent from receiving tick/tock notifications.
Agents should unregister from their Decommission method.
Definition at line 347 of file context.cc.