1 #ifndef CYCLUS_SRC_CONTEXT_H_ 2 #define CYCLUS_SRC_CONTEXT_H_ 13 #include <boost/uuid/uuid_generators.hpp> 132 friend class ::SimInitTest;
146 boost::uuids::uuid sim_id();
171 inline const std::set<Trader*>&
traders()
const {
181 if (protos_.count(proto_name) == 0) {
182 throw KeyError(
"Invalid prototype name " + proto_name);
185 Agent* m = protos_[proto_name];
188 casted =
dynamic_cast<T*
>(clone);
189 if (casted == NULL) {
192 throw CastError(
"Invalid cast for prototype " + proto_name);
200 void DelAgent(
Agent* m);
210 void SchedDecom(
Agent* m,
int time = -1);
238 inline uint64_t
dt() {
return si_.dt;};
262 if (solver_ == NULL) {
277 return n_prototypes_[type];
283 return n_specs_[impl];
288 inline void RegisterAgent(
Agent* a) {
290 n_specs_[a->
spec()]++;
294 inline void UnregisterAgent(
Agent* a) {
296 n_specs_[a->
spec()]--;
301 std::set<std::string> rec_ver_;
303 std::map<std::string, Agent*> protos_;
304 std::map<std::string, Composition::Ptr> recipes_;
305 std::set<Agent*> agent_list_;
306 std::set<Trader*> traders_;
307 std::map<std::string, int> n_prototypes_;
308 std::map<std::string, int> n_specs_;
319 #endif // CYCLUS_SRC_CONTEXT_H_ const std::set< Trader * > & traders() const
int n_prototypes(std::string type)
SimInfo sim_info() const
Return static simulation info.
void RegisterTrader(Trader *e)
Registers an agent as a participant in resource exchanges.
boost::shared_ptr< Composition > Ptr
std::string handle
user-defined label associated with a particular simulation
const std::string prototype() const
Returns the agent's prototype.
int branch_time
timestep at which simulation branching occurs if any
double eps
Epsilon in the simulation.
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)
A simple API for agents that wish to exchange resources in the simulation.
int y0
start year for the simulation (e.g. 1973);
For failed casts that shouldn't.
bool explicit_inventory
True if per-agent inventories should be explicitly queried/recorded every time step in a table (i...
void sim_ctx(Context *c)
simulation context get/set
std::string spec()
The string representation of the agent spec that uniquely identifies the concrete agent class/module...
void solver(ExchangeSolver *solver)
sets the solver associated with this context
uint64_t dt
Duration in seconds of a single time step in the simulation.
Used to specify and send a collection of key-value pairs to the Recorder for recording.
const uint64_t kDefaultTimeStepDur
void UnregisterTrader(Trader *e)
Unregisters an agent as a participant in resource exchanges.
int parent(int nuc, unsigned int rx, std::string z="n")
boost::uuids::uuid parent_sim
id for the parent simulation if any
T * CreateAgent(std::string proto_name)
Create a new agent by cloning the named prototype.
std::string decay
"manual" if use of the decay function is allowed, "never" otherwise
double eps_rsrc
Epsilon for resources in the simulation.
int n_specs(std::string impl)
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...
std::string parent_type
One of "init", "branch", "restart" indicating the relationship of this simulation to its parent simul...
uint64_t dt()
Returns the duration of a single time step in seconds.
The TimeListener class is an inheritable class for any Agent that requires knowlege of ticks and tock...
virtual Agent * Clone()=0
Returns a newly created/allocated prototype that is an exact copy of this.
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...
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.
a very simple interface for solving translated resource exchanges
void PyDelAgent(int i)
Removes a single Python agent from the reference cache.
Handles initialization of a simulation from the output database.
ExchangeSolver * solver()
Returns the exchange solver associated with this context.
For failed retrieval/insertion of key-based data into/from data structures.
The GreedySolver provides the implementation for a "greedy" solution to a resource exchange graph...
Controls simulation timestepping and inter-timestep phases.