CYCLUS
|
The abstract base class used by all types of agents that live and interact in a simulation.
There are several functions that must be implemented in support of simulation initialization, snapshotting and restart: InfileToDb, InitFrom(QueryableBackend*), Snapshot, SnapshotInv, and InitInv. These functions all do inter-related things. Notably, the InfileToDb, InitFrom, and Snapshot functions must all write/read to/from the same database tables (and table schemas).
#include <agent.h>
Protected Member Functions | |
virtual std::string | InformErrorMsg (std::string msg) |
void | InitFrom (Agent *m) |
Protected Attributes | |
std::string | kind_ |
cyclus::Agent::Agent | ( | Context * | ctx | ) |
|
virtual |
default implementation for material preferences.
Reimplemented in cyclus::Facility.
default implementation for material preferences.
Reimplemented in cyclus::Facility.
|
inlinevirtual |
Called when the agent enters the smiulation as an active participant and is only ever called once.
Agents should NOT register for services (such as ticks/tocks and resource exchange) in this function. If agents implement this function, they must call their superclass' Build function at the BEGINING of their Build function.
parent | this agent's parent. NULL if this agent has no parent. |
Reimplemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
Returns a newly created/allocated prototype that is an exact copy of this.
All initialization and state cloning operations should be done in the agent's InitFrom(Agent*) function. The new agent instance should NOT be created using a default copy-constructor. New agent instances should generally be created using a constructor that takes a single Context argument (the same context of the agent being cloned). Example:
Implements cyclus::StateWrangler.
Implemented in cyclus::Dummy.
|
inline |
|
virtual |
Decommissions the agent, removing it from the simulation.
Results in destruction of the agent object. If agents write their own Decommission function, they must call their superclass' Decommission function at the END of their Decommission function.
Reimplemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
|
virtual |
Called to give the agent an opportunity to register for services (e.g.
ticks/tocks and resource exchange). Note that this may be called more than once, and so agents should track their registrations carefully. If agents implement this function, they must call their superclass's EnterNotify function at the BEGINNING of their EnterNotify function.
Reimplemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
Returns the default time step at which this agent will exit the simulation (-1 if the agent has an infinite lifetime).
Deomissioning happens at the end of a time step. With a lifetime of 1, we expect an agent to go through only 1 entire time step. In this case, the agent should be decommissioned on the same time step it was created. Therefore, for agents with non-infinite lifetimes, the exit_time will be the enter time plus its lifetime less 1.
std::vector< std::string > cyclus::Agent::GetTreePrintOuts | ( | Agent * | m | ) |
The agent instance's unique ID within a simulation.
Implements cyclus::Ider.
|
virtual |
Translates info for the agent from an input file to the database by reading parameters from the passed InfileTree (parsed from xml) and recording data via the DbInit variable.
The simulation id and agent id are automatically injected in all data transfered to the database through DbInit. This function must be implemented by all agents. This function must call the superclass' InfileToDb function before doing any other work.
Agent parameters in the InfileTree are scoped in the "agent/*‍/" path. The superclass InitFrom expects the scope InfileTree passed to it to be unchanged from the agent's InfileTree arg.
Example:
Implements cyclus::StateWrangler.
Reimplemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
|
protectedvirtual |
Initializes a agent by copying parameters from the passed agent m.
This function must be implemented by all agents. This function must call the superclass' InitFrom function. The InitFrom function should only initialize this class' members - not inherited state. The superclass InitFrom should generally be called before any other work is done.
m | the agent containing state that should be used to initialize this agent. |
Example:
|
virtual |
Intializes an agent's internal state from the database.
Appropriate simulation id, agent id, and time filters are automatically included in all queries. If the agent is a direct subclass of the Agent class, than it should NOT call its superclass' InitFrom(QueryableBackend*) function. If, however, it is a subclasses other Agent subclasses (e.g. subclass of Facility, Region, etc.), then it MUST call its superclass' InitFrom(QueryableBackend*) function. Example:
Implements cyclus::StateWrangler.
Reimplemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
|
pure virtual |
Provides an agent's initial inventory of resources before a simulation begins.
The resources are keyed in the same way as given in the agent's SnapshotInv function. Agents should iterate through each named inventory provided and populate their corresponding resource containers with the given resources.
Implemented in cyclus::Institution, and cyclus::Region.
|
inline |
Sets the number of time steps this agent operates between building and decommissioning (-1 if the agent has an infinite lifetime).
This should generally only be called BEFORE an agent is added to a context as a prototype. Throws ValueError if the agent has already been deployed.
|
inline |
std::string cyclus::Agent::PrintChildren | ( | ) |
|
inline |
|
inline |
|
inlinevirtual |
Returns an agent's xml rng schema for initializing from input files.
All concrete agents should override this function. This must validate the same xml input that the InfileToDb function receives.
Implements cyclus::StateWrangler.
Snapshots agent-internal state to the database via the DbInit var di.
The simulation id , agent id, and the simulation time are automatically injected in all information transfered to the database through DbInit. If the agent is a direct subclass of the Agent class, than it should NOT call its superclass' Snapshot function. If, however, it subclasses other Agent subclasses (e.g. subclass of Facility, Region, etc.), then it MUST call its superclass' Snapshot function. Example:
Implements cyclus::StateWrangler.
Implemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
|
pure virtual |
Snapshots an agent's resource inventories to the database.
The set of resources in each container should be stored under a string key unique for that container that will be used when re-initializing inventories for restarted simulations in the InitInv function.
Implemented in cyclus::Institution, and cyclus::Region.
|
inline |
|
inline |
|
virtual |
Description of this agent.
Reimplemented in cyclus::Facility, cyclus::Institution, and cyclus::Region.
|
protected |