CYCLUS
Loading...
Searching...
No Matches
facility.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_FACILITY_H_
2#define CYCLUS_SRC_FACILITY_H_
3
4#include <string>
5#include <vector>
6#include <set>
7
8#include "agent.h"
9#include "time_listener.h"
10#include "trader.h"
11
12namespace cyclus {
13
14// forward declare Material class to avoid full inclusion and dependency
15class Material;
16class Institution;
17
18/// @class Facility
19/// The Facility class is the abstract class/interface used by all
20/// facility agents
21///
22/// This is all that is known externally about facilities
23///
24/// @section intro Introduction
25///
26/// The Facility type plays a primary role in Cyclus. A Facility
27/// facility is where offers and requests are generated and transmitted to a
28/// ResourceExchange and where shipments of material, issued by the exchange, are
29/// executed. The algorithms to determine what offers and requests are issued and
30/// how material shipments are handled are the primary differentiators between
31/// different Facility implementations.
32///
33/// Like all agent implementations, there are a number of implementations that
34/// are distributed as part of the core Cyclus application as well as
35/// implementations contributed by third-party developers. The links below
36/// describe additional parameters necessary for the complete definition of a
37/// facility of that implementation.
38///
39/// @section available Available Core Implementations
40///
41/// - SourceFacility: A facility that can produce a constant (or
42/// infinite) amount of some commodity
43/// - SinkFacility: A facility that can consume a constant (or infinite)
44/// amount of some commodity
45/// - NullFacility: A facility that consumes a constant amount of one
46/// commodity and produces a constant amount of another
47///
48///
49/// @section anticipated Anticipated Core Implementations
50///
51/// Developers are encouraged to add to this list and create pages that
52/// describe the detailed behavior of these agents.
53///
54/// - RecipeReactor: A facility that consumes a fixed fresh fuel recipe
55/// one a time scale governed by reactor cycle lengths and batch sizes,
56/// and produced a fixed/corresponding spent fuel recipe at the same
57/// frequency - SeparationsMatrixFacility: A facility that consumes a
58/// fixed quantity of material of one commodity and produces many
59/// different output streams with the input nuclides distributed across
60/// those output streams according to a fixed matrix
61/// - EnrichmentFacility: A facility that offers a fixed quantity of SWUs
62/// to accomplish enrichment of material
63///
64/// @section thirdparty Third-party Implementations
65///
66/// Collaborators are encouraged to add to this list and link to external
67/// pages that describe how to get the agents and the detailed behavior
68class Facility : public TimeListener, public Agent, public Trader {
69 public:
70 Facility(Context* ctx);
71
72 virtual ~Facility();
73
74 // DO NOT call Agent class implementation of this method
75 virtual void InfileToDb(InfileTree* qe, DbInit di) {}
76
77 // DO NOT call Agent class implementation of this method
78 virtual void InitFrom(QueryableBackend* b) {}
79
80 // DO NOT call Agent class implementation of this method
81 virtual void Snapshot(DbInit di) {}
82
83 /// Copy module members from a source agent
84 /// Any facility subclassing facility agent should invoke their own InitFrom
85 /// method, calling Facility's first!
86 /// @param m the agent to copy from
87 void InitFrom(Facility* m);
88
89 /// @brief builds the facility in the simulation
90 /// @param parent the parent of this facility
91 virtual void Build(Agent* parent);
92
93 /// Called to give the agent an opportunity to register for services.
94 virtual void EnterNotify();
95
96 /// decommissions the facility, default behavior is for the facility
97 /// to delete itself
98 virtual void Decommission();
99
100 /// facilities over write this method if a condition must be met
101 /// before their destructors can be called
102 virtual bool CheckDecommissionCondition();
103
104 /// every agent should be able to print a verbose description
105 virtual std::string str();
106
107 /// @brief default implementation for material requests
108 virtual std::set<RequestPortfolio<Material>::Ptr>
110 return std::set<RequestPortfolio<Material>::Ptr>();
111 }
112
113 /// @brief default implementation for product requests
114 virtual std::set<RequestPortfolio<Product>::Ptr>
116 return std::set<RequestPortfolio<Product>::Ptr>();
117 }
118
119 /// @brief default implementation for material requests
120 virtual std::set<BidPortfolio<Material>::Ptr>
122 return std::set<BidPortfolio<Material>::Ptr>();
123 }
124
125 /// @brief default implementation for product requests
126 virtual std::set<BidPortfolio<Product>::Ptr>
128 return std::set<BidPortfolio<Product>::Ptr>();
129 }
130
131 /// default implementation for material preferences.
133
134 /// default implementation for material preferences.
136
137 /// @brief default implementation for responding to material trades
138 /// @param trades all trades in which this trader is the supplier
139 /// @param responses a container to populate with responses to each trade
140 virtual void GetMatlTrades(
141 const std::vector< Trade<Material> >& trades,
142 std::vector<std::pair<Trade<Material>, Material::Ptr> >& responses) {
143 std::cout << "in material facility getmatltrades\n";
144 }
145
146 /// @brief default implementation for responding to product trades
147 /// @param trades all trades in which this trader is the supplier
148 /// @param responses a container to populate with responses to each trade
149 virtual void GetProductTrades(
150 const std::vector< Trade<Product> >& trades,
151 std::vector<std::pair<Trade<Product>,
152 Product::Ptr> >& responses) {}
153
154 /// @brief default implementation for material trade acceptance
155 virtual void AcceptMatlTrades(
156 const std::vector<std::pair<Trade<Material>,
158
159 /// @brief default implementation for product trade acceptance
161 const std::vector<std::pair<Trade<Product>,
162 Product::Ptr> >& responses) {}
163
164};
165
166} // namespace cyclus
167
168#endif // CYCLUS_SRC_FACILITY_H_
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
Definition agent.h:373
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
DbInit provides an interface for agents to record data to the output db that automatically injects th...
Definition db_init.h:14
The Facility class is the abstract class/interface used by all facility agents.
Definition facility.h:68
virtual void Decommission()
decommissions the facility, default behavior is for the facility to delete itself
Definition facility.cc:45
virtual void EnterNotify()
Called to give the agent an opportunity to register for services.
Definition facility.cc:31
virtual void AdjustMatlPrefs(PrefMap< Material >::type &prefs)
default implementation for material preferences.
Definition facility.h:132
virtual ~Facility()
Definition facility.cc:20
virtual std::string str()
every agent should be able to print a verbose description
Definition facility.cc:37
virtual void InfileToDb(InfileTree *qe, DbInit di)
Translates info for the agent from an input file to the database by reading parameters from the passe...
Definition facility.h:75
virtual void AdjustProductPrefs(PrefMap< Product >::type &prefs)
default implementation for material preferences.
Definition facility.h:135
virtual void Build(Agent *parent)
builds the facility in the simulation
Definition facility.cc:27
virtual std::set< BidPortfolio< Material >::Ptr > GetMatlBids(CommodMap< Material >::type &commod_requests)
default implementation for material requests
Definition facility.h:121
virtual void AcceptProductTrades(const std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
default implementation for product trade acceptance
Definition facility.h:160
virtual std::set< RequestPortfolio< Material >::Ptr > GetMatlRequests()
default implementation for material requests
Definition facility.h:109
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from the database.
Definition facility.h:78
virtual std::set< BidPortfolio< Product >::Ptr > GetProductBids(CommodMap< Product >::type &commod_requests)
default implementation for product requests
Definition facility.h:127
virtual void GetProductTrades(const std::vector< Trade< Product > > &trades, std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
default implementation for responding to product trades
Definition facility.h:149
virtual void AcceptMatlTrades(const std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
default implementation for material trade acceptance
Definition facility.h:155
virtual std::set< RequestPortfolio< Product >::Ptr > GetProductRequests()
default implementation for product requests
Definition facility.h:115
virtual void Snapshot(DbInit di)
Snapshots agent-internal state to the database via the DbInit var di.
Definition facility.h:81
Facility(Context *ctx)
Definition facility.cc:16
virtual bool CheckDecommissionCondition()
facilities over write this method if a condition must be met before their destructors can be called
Definition facility.cc:55
virtual void GetMatlTrades(const std::vector< Trade< Material > > &trades, std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
default implementation for responding to material trades
Definition facility.h:140
A class for extracting information from a given XML parser.
Definition infile_tree.h:22
boost::shared_ptr< Material > Ptr
Definition material.h:75
boost::shared_ptr< Product > Ptr
Definition product.h:24
Interface implemented by backends that support rudimentary querying.
The TimeListener class is an inheritable class for any Agent that requires knowlege of ticks and tock...
A simple API for agents that wish to exchange resources in the simulation.
Definition trader.h:24
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
std::map< std::string, std::vector< Request< T > * > > type
std::map< Request< T > *, std::map< Bid< T > *, double > > type
A Trade is a simple container that associates a request for a resource with a bid for that resource.
Definition trade.h:16