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, SymFunction::Ptr demand) {
33 demand_functions_.insert(std::make_pair(commodity, demand));
34 }
35
36 /// @return true if the demand for a commodity is managed by this entity
37 /// @param commodity the commodity in question
38 inline bool ManagesCommodity(Commodity& commodity) {
39 return demand_functions_.find(commodity) != demand_functions_.end();
40 }
41
42 /// Adds a commodity producer manager to the set of producer managers
44 managers_.insert(cpm);
45 }
46
47 /// Removes a commodity producer manager from the set of producer
48 /// managers
50 managers_.erase(cpm);
51 }
52
53 /// The demand for a commodity at a given time
54 /// @param commodity the commodity
55 /// @param time the time
56 inline double Demand(Commodity& commodity, int time) {
57 return demand_functions_[commodity]->value(time);
58 }
59
60 /// Returns the demand function for a commodity
61 /// @param commodity the commodity being queried
63 return demand_functions_[commodity];
64 }
65
66 /// Returns the current supply of a commodity
67 /// @param commodity the commodity
68 /// @return the current supply of the commodity
69 double Supply(Commodity& commodity);
70
71 private:
72 /// A container of all demand functions known to the manager
73 std::map<Commodity, SymFunction::Ptr, CommodityCompare> demand_functions_;
74
75 /// A container of all production managers known to the manager
76 std::set<CommodityProducerManager*> managers_;
77};
78
79} // namespace toolkit
80} // namespace cyclus
81
82#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:50
AgentManaged(Agent *agent=NULL)
A mixin to provide information about commodity producers.
A simple class defining a commodity; it is currently super simple.
Definition commodity.h:12
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