CYCLUS
Loading...
Searching...
No Matches
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

  • SourceFacility: A facility that can produce a constant (or infinite) amount of some commodity
  • SinkFacility: A facility that can consume a constant (or infinite) amount of some commodity
  • NullFacility: A facility that consumes a constant amount of one commodity and produces a constant amount of another

Anticipated Core Implementations

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

  • RecipeReactor: A facility that consumes a fixed fresh fuel recipe one a time scale governed by reactor cycle lengths and batch sizes, and produced a fixed/corresponding spent fuel recipe at the same frequency - SeparationsMatrixFacility: A facility that consumes a fixed quantity of material of one commodity and produces many different output streams with the input nuclides distributed across those output streams according to a fixed matrix
  • EnrichmentFacility: A facility that offers a fixed quantity of SWUs to accomplish enrichment of material

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 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 void Build (Agent *parent)
 
virtual bool CheckDecommissionCondition ()
 
virtual void Decommission ()
 
virtual void EnterNotify ()
 
 Facility (Context *ctx)
 
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 void InfileToDb (InfileTree *qe, DbInit di)
 
void InitFrom (Facility *m)
 
virtual void InitFrom (QueryableBackend *b)
 
virtual void Snapshot (DbInit di)
 
virtual std::string str ()
 
virtual ~Facility ()
 
- Public Member Functions inherited from cyclus::TimeListener
virtual void Decision ()
 
virtual void Tick ()=0
 
virtual void Tock ()=0
 
- Public Member Functions inherited from cyclus::Agent
 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
 
const int lifetime () const
 
void lifetime (int n_timesteps)
 
void lifetime_force (int n_timesteps)
 
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 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

◆ Facility()

cyclus::Facility::Facility ( Context * ctx)

Definition at line 16 of file facility.cc.

◆ ~Facility()

cyclus::Facility::~Facility ( )
virtual

Definition at line 20 of file facility.cc.

Member Function Documentation

◆ AcceptMatlTrades()

virtual void cyclus::Facility::AcceptMatlTrades ( const std::vector< std::pair< Trade< Material >, Material::Ptr > > & responses)
inlinevirtual

default implementation for material trade acceptance

Reimplemented from cyclus::Trader.

Definition at line 155 of file facility.h.

◆ AcceptProductTrades()

virtual void cyclus::Facility::AcceptProductTrades ( const std::vector< std::pair< Trade< Product >, Product::Ptr > > & responses)
inlinevirtual

default implementation for product trade acceptance

Reimplemented from cyclus::Trader.

Definition at line 160 of file facility.h.

◆ AdjustMatlPrefs()

virtual void cyclus::Facility::AdjustMatlPrefs ( PrefMap< Material >::type & prefs)
inlinevirtual

default implementation for material preferences.

Reimplemented from cyclus::Agent.

Definition at line 132 of file facility.h.

◆ AdjustProductPrefs()

virtual void cyclus::Facility::AdjustProductPrefs ( PrefMap< Product >::type & prefs)
inlinevirtual

default implementation for material preferences.

Reimplemented from cyclus::Agent.

Definition at line 135 of file facility.h.

◆ Build()

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.

◆ CheckDecommissionCondition()

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.

◆ Decommission()

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.

◆ EnterNotify()

void cyclus::Facility::EnterNotify ( )
virtual

Called to give the agent an opportunity to register for services.

Reimplemented from cyclus::Agent.

Definition at line 31 of file facility.cc.

◆ GetMatlBids()

virtual std::set< BidPortfolio< Material >::Ptr > cyclus::Facility::GetMatlBids ( CommodMap< Material >::type & commod_requests)
inlinevirtual

default implementation for material requests

Reimplemented from cyclus::Trader.

Definition at line 121 of file facility.h.

◆ GetMatlRequests()

virtual std::set< RequestPortfolio< Material >::Ptr > cyclus::Facility::GetMatlRequests ( )
inlinevirtual

default implementation for material requests

Reimplemented from cyclus::Trader.

Definition at line 109 of file facility.h.

◆ GetMatlTrades()

virtual void cyclus::Facility::GetMatlTrades ( const std::vector< Trade< Material > > & trades,
std::vector< std::pair< Trade< Material >, Material::Ptr > > & responses )
inlinevirtual

default implementation for responding to material trades

Parameters
tradesall trades in which this trader is the supplier
responsesa container to populate with responses to each trade

Reimplemented from cyclus::Trader.

Definition at line 140 of file facility.h.

◆ GetProductBids()

virtual std::set< BidPortfolio< Product >::Ptr > cyclus::Facility::GetProductBids ( CommodMap< Product >::type & commod_requests)
inlinevirtual

default implementation for product requests

Reimplemented from cyclus::Trader.

Definition at line 127 of file facility.h.

◆ GetProductRequests()

virtual std::set< RequestPortfolio< Product >::Ptr > cyclus::Facility::GetProductRequests ( )
inlinevirtual

default implementation for product requests

Reimplemented from cyclus::Trader.

Definition at line 115 of file facility.h.

◆ GetProductTrades()

virtual void cyclus::Facility::GetProductTrades ( const std::vector< Trade< Product > > & trades,
std::vector< std::pair< Trade< Product >, Product::Ptr > > & responses )
inlinevirtual

default implementation for responding to product trades

Parameters
tradesall trades in which this trader is the supplier
responsesa container to populate with responses to each trade

Reimplemented from cyclus::Trader.

Definition at line 149 of file facility.h.

◆ InfileToDb()

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/*&zwj;/" 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 {
// ...
void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di) {
// 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();
// ...
};
// ...
};
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
Definition datum.cc:22
void Record()
Record this datum to its Recorder.
Definition datum.cc:35
DbInit provides an interface for agents to record data to the output db that automatically injects th...
Definition db_init.h:14
Datum * NewDatum(std::string title)
Returns a new datum to be used exactly as the Context::NewDatum method.
Definition db_init.cc:12
The Facility class is the abstract class/interface used by all facility agents.
Definition facility.h:68
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition facility.h:78
A class for extracting information from a given XML parser.
Definition infile_tree.h:22
virtual std::string GetString(std::string query, int index=0)
investigates the current status and returns a string representing the content of a query at a given i...
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
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.

◆ InitFrom() [1/2]

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.

◆ InitFrom() [2/2]

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 {
// ...
void InitFrom(cyclus::QueryableBackend* b) {
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;
// ...
};
Meta data and results of a query.
T GetVal(std::string field, int row=0)
Convenience method for retrieving a value from a specific row and named field (column).
Interface implemented by backends that support rudimentary querying.
Warning
Agents should NOT create any resource objects in this function.

Reimplemented from cyclus::Agent.

Definition at line 78 of file facility.h.

◆ Snapshot()

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 {
// ...
void Snapshot(cyclus::DbInit di) {
di.NewDatum("MyAgentTable1")
->AddVal("recipe", recipe)
->AddVal("in_commod", in_commod)
->AddVal("cap", cap)
->Record();
// ...
};
std::string recipe;
std::string in_commod;
double cap;
// ...
};
virtual void Snapshot(DbInit di)
Snapshots agent-internal state to the database via the DbInit var di.
Definition facility.h:81
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.

◆ str()

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: