CYCLUS
Public Member Functions | List of all members
cyclus::Facility Class Reference

Detailed Description

The Facility class is the abstract class/interface used by all facility agents.

This is all that is known externally about facilities

Introduction

The Facility type plays a primary role in Cyclus. A Facility facility is where offers and requests are generated and transmitted to a ResourceExchange and where shipments of material, issued by the exchange, are executed. The algorithms to determine what offers and requests are issued and how material shipments are handled are the primary differentiators between different Facility implementations.

Like all agent implementations, there are a number of implementations that are distributed as part of the core Cyclus application as well as implementations contributed by third-party developers. The links below describe additional parameters necessary for the complete definition of a facility of that implementation.

Available Core Implementations

Anticipated Core Implementations

Developers are encouraged to add to this list and create pages that describe the detailed behavior of these agents.

Third-party Implementations

Collaborators are encouraged to add to this list and link to external pages that describe how to get the agents and the detailed behavior

Definition at line 68 of file facility.h.

#include <facility.h>

Inheritance diagram for cyclus::Facility:
cyclus::TimeListener cyclus::Agent cyclus::Trader cyclus::Ider cyclus::StateWrangler cyclus::Ider

Public Member Functions

virtual void Build (Agent *parent)
 
virtual bool CheckDecommissionCondition ()
 
virtual void Decommission ()
 
virtual void EnterNotify ()
 
 Facility (Context *ctx)
 
virtual void InfileToDb (InfileTree *qe, DbInit di)
 
virtual void InitFrom (QueryableBackend *b)
 
void InitFrom (Facility *m)
 
virtual void Snapshot (DbInit di)
 
virtual std::string str ()
 
virtual ~Facility ()
 
- Public Member Functions inherited from cyclus::TimeListener
virtual void Tick ()=0
 
virtual void Tock ()=0
 
- Public Member Functions inherited from cyclus::Agent
virtual void AdjustMatlPrefs (PrefMap< Material >::type &prefs)
 
virtual void AdjustProductPrefs (PrefMap< Product >::type &prefs)
 
 Agent (Context *ctx)
 
bool AncestorOf (Agent *other)
 
virtual Json::Value annotations ()
 
virtual void BuildNotify (Agent *m)
 
const std::set< Agent * > & children () const
 
virtual AgentClone ()=0
 
Contextcontext () const
 
bool DecendentOf (Agent *other)
 
virtual void DecomNotify (Agent *m)
 
const int enter_time () const
 
const int exit_time () const
 
std::vector< std::string > GetTreePrintOuts (Agent *m)
 
virtual const int id () const
 
bool InFamilyTree (Agent *other)
 
virtual void InitInv (Inventories &inv)=0
 
const std::string kind () const
 
void lifetime (int n_timesteps)
 
const int lifetime () const
 
Agentparent () const
 
const int parent_id () const
 
std::string PrintChildren ()
 
const std::string prototype () const
 
void prototype (std::string p)
 
virtual std::string schema ()
 
virtual Inventories SnapshotInv ()=0
 
std::string spec ()
 
void spec (std::string new_impl)
 
virtual std::string version ()
 
virtual ~Agent ()
 
- Public Member Functions inherited from cyclus::Trader
virtual void AcceptMatlTrades (const std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
 
virtual void AcceptProductTrades (const std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
 
virtual void AdjustMatlPrefs (PrefMap< Material >::type &prefs)
 
virtual void AdjustProductPrefs (PrefMap< Product >::type &prefs)
 
virtual std::set< BidPortfolio< Material >::Ptr > GetMatlBids (CommodMap< Material >::type &commod_requests)
 
virtual std::set< RequestPortfolio< Material >::Ptr > GetMatlRequests ()
 
virtual void GetMatlTrades (const std::vector< Trade< Material > > &trades, std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
 
virtual std::set< BidPortfolio< Product >::Ptr > GetProductBids (CommodMap< Product >::type &commod_requests)
 
virtual std::set< RequestPortfolio< Product >::Ptr > GetProductRequests ()
 
virtual void GetProductTrades (const std::vector< Trade< Product > > &trades, std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
 
virtual Agentmanager ()
 
 Trader (Agent *manager)
 

Additional Inherited Members

- Protected Member Functions inherited from cyclus::Agent
virtual std::string InformErrorMsg (std::string msg)
 
void InitFrom (Agent *m)
 
- Protected Attributes inherited from cyclus::Agent
std::string kind_
 
- Protected Attributes inherited from cyclus::Trader
Agentmanager_
 

Constructor & Destructor Documentation

cyclus::Facility::Facility ( Context ctx)

Definition at line 16 of file facility.cc.

cyclus::Facility::~Facility ( )
virtual

Definition at line 20 of file facility.cc.

Member Function Documentation

void cyclus::Facility::Build ( Agent parent)
virtual

builds the facility in the simulation

Parameters
parentthe parent of this facility

Reimplemented from cyclus::Agent.

Definition at line 27 of file facility.cc.

bool cyclus::Facility::CheckDecommissionCondition ( )
virtual

facilities over write this method if a condition must be met before their destructors can be called

Definition at line 55 of file facility.cc.

void cyclus::Facility::Decommission ( )
virtual

decommissions the facility, default behavior is for the facility to delete itself

Reimplemented from cyclus::Agent.

Definition at line 45 of file facility.cc.

void cyclus::Facility::EnterNotify ( )
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 from cyclus::Agent.

Definition at line 31 of file facility.cc.

virtual void cyclus::Facility::InfileToDb ( InfileTree qe,
DbInit  di 
)
inlinevirtual

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:

class MyAgentClass : virtual public cyclus::Facility {
// ...
// now do MyAgentClass' initialitions, e.g.:
tree = tree->Query("agent/*"); // rescope the InfileTree
* // retrieve all agent params
* std::string recipe = tree->GetString("recipe");
* std::string in_commod = tree->GetString("in_commod");
* double cap = cyclus::Query<double>(tree, "cap");
* di.NewDatum("MyAgentTable1")
* ->AddVal("recipe", recipe)
* ->AddVal("in_commod", in_commod)
* ->AddVal("cap", cap)
* ->Record();
* // ...
* };
* // ...
* };
*
Warning
because 'SimId' 'SimTime', and 'AgentId' fields are automatically injected, those labels cannot be used for any other fields.
this function MUST NOT modify the agent's state.

Reimplemented from cyclus::Agent.

Definition at line 75 of file facility.h.

virtual void cyclus::Facility::InitFrom ( QueryableBackend b)
inlinevirtual

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:

class MyAgentClass : virtual public cyclus::Facility {
// ...
cyclus::QueryResult qr = b->Query("MyAgentTable1", NULL);
recipe = qr.GetVal<std::string>("recipe");
in_commod = qr.GetVal<std::string>("in_commod");
cap = qr.GetVal<double>("cap");
// ...
};
std::string recipe;
std::string in_commod;
double cap;
// ...
};
Warning
Agents should NOT create any resource objects in this function.

Reimplemented from cyclus::Agent.

Definition at line 78 of file facility.h.

void cyclus::Facility::InitFrom ( Facility m)

Copy module members from a source agent Any facility subclassing facility agent should invoke their own InitFrom method, calling Facility's first!

Parameters
mthe agent to copy from

Definition at line 23 of file facility.cc.

virtual void cyclus::Facility::Snapshot ( DbInit  di)
inlinevirtual

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:

class MyAgentClass : virtual public cyclus::Facility {
// ...
di.NewDatum("MyAgentTable1")
->AddVal("recipe", recipe)
->AddVal("in_commod", in_commod)
->AddVal("cap", cap)
->Record();
// ...
};
std::string recipe;
std::string in_commod;
double cap;
// ...
};
Warning
because 'SimId' 'SimTime', and 'AgentId' fields are automatically injected, those labels cannot be used for any other fields.
This function MUST NOT modify the agent's internal state.
Do not record any information via the context's NewDatum function.

Implements cyclus::Agent.

Definition at line 81 of file facility.h.

std::string cyclus::Facility::str ( )
virtual

every agent should be able to print a verbose description

Reimplemented from cyclus::Agent.

Definition at line 37 of file facility.cc.


The documentation for this class was generated from the following files: