CYCLUS
Loading...
Searching...
No Matches
supply_demand_manager.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_TOOLKIT_SUPPLY_DEMAND_MANAGER_H_
2#define CYCLUS_SRC_TOOLKIT_SUPPLY_DEMAND_MANAGER_H_
3
4#include "agent_managed.h"
5#include "commodity.h"
8
9#include <map>
10#include <set>
11
12namespace cyclus {
13namespace toolkit {
14
15/// This is a manager class that manages a set of commodities. Those
16/// commodities have a certain demand function associated with them
17/// and a list of producers who can produce the commodities.
18///
19/// The SupplyDemandManager simply keeps track of this information and
20/// provides the demand and supply of a commodity at a given time.
21/// What to do with this information is left to the user of the
22/// SupplyDemandManager.
24 public:
27
28 /// Register a new commodity with the manager, along with all the
29 /// necessary information.
30 /// @param commodity the commodity
31 /// @param demand a smart pointer to the demand function
32 inline void RegisterCommodity(Commodity& commodity,
34 demand_functions_.insert(std::make_pair(commodity, demand));
35 }
36
37 /// @return true if the demand for a commodity is managed by this entity
38 /// @param commodity the commodity in question
39 inline bool ManagesCommodity(Commodity& commodity) {
40 return demand_functions_.find(commodity) != demand_functions_.end();
41 }
42
43 /// Adds a commodity producer manager to the set of producer managers
45 managers_.insert(cpm);
46 }
47
48 /// Removes a commodity producer manager from the set of producer
49 /// managers
51 managers_.erase(cpm);
52 }
53
54 /// The demand for a commodity at a given time
55 /// @param commodity the commodity
56 /// @param time the time
57 inline double Demand(Commodity& commodity, int time) {
58 return demand_functions_[commodity]->value(time);
59 }
60
61 /// Returns the demand function for a commodity
62 /// @param commodity the commodity being queried
64 return demand_functions_[commodity];
65 }
66
67 /// Returns the current supply of a commodity
68 /// @param commodity the commodity
69 /// @return the current supply of the commodity
70 double Supply(Commodity& commodity);
71
72 private:
73 /// A container of all demand functions known to the manager
74 std::map<Commodity, SymFunction::Ptr, CommodityCompare> demand_functions_;
75
76 /// A container of all production managers known to the manager
77 std::set<CommodityProducerManager*> managers_;
78};
79
80} // namespace toolkit
81} // namespace cyclus
82
83#endif // CYCLUS_SRC_TOOLKIT_SUPPLY_DEMAND_MANAGER_H_
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
This is a mixin class that provides an interface to access the underlying agent that manages it.
A mixin to provide information about commodity producers.
A simple class defining a commodity; it is currently super simple.
Definition commodity.h:12
This is a manager class that manages a set of commodities.
void RegisterProducerManager(CommodityProducerManager *cpm)
Adds a commodity producer manager to the set of producer managers.
double Supply(Commodity &commodity)
Returns the current supply of a commodity.
void UnregisterProducerManager(CommodityProducerManager *cpm)
Removes a commodity producer manager from the set of producer managers.
bool ManagesCommodity(Commodity &commodity)
SymFunction::Ptr DemandFunction(Commodity &commodity)
Returns the demand function for a commodity.
void RegisterCommodity(Commodity &commodity, SymFunction::Ptr demand)
Register a new commodity with the manager, along with all the necessary information.
double Demand(Commodity &commodity, int time)
The demand for a commodity at a given time.
boost::shared_ptr< SymFunction > Ptr
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