CYCLUS
Loading...
Searching...
No Matches
commodity_producer.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_TOOLKIT_COMMODITY_PRODUCER_H_
2#define CYCLUS_SRC_TOOLKIT_COMMODITY_PRODUCER_H_
3
4#include <map>
5#include <set>
6
7#include "agent_managed.h"
8#include "cyc_limits.h"
9#include "commodity.h"
10
11namespace cyclus {
12namespace toolkit {
13
14/// A container to hold information about a commodity
15struct CommodInfo {
16 CommodInfo(double default_capacity = 0, double default_cost = kModifierLimit);
17 double capacity;
18 double cost;
19};
20
21/// A mixin to provide information about produced commodities
23 public:
24 CommodityProducer(double default_capacity = 0,
25 double default_cost = kModifierLimit,
26 Agent* agent = NULL);
27 virtual ~CommodityProducer();
28
29 /// @param commodity the commodity in question
30 /// @return true if the commodity is produced by this entity
31 inline bool Produces(const Commodity& commodity) const {
32 return commodities_.find(commodity) != commodities_.end();
33 }
34
35 /// @param commodity the commodity in question
36 /// @return the production capacity for a commodity
37 inline double Capacity(const Commodity& commodity) {
38 return commodities_[commodity].capacity;
39 }
40
41 /// @return the cost to produce a commodity at a given capacity
42 /// @param commodity the commodity in question
43 inline double Cost(const Commodity& commodity) {
44 return commodities_[commodity].cost;
45 }
46
47 /// Set the production capacity for a given commodity
48 /// @param commodity the commodity being produced
49 /// @param capacity the production capacity
50 inline void SetCapacity(const Commodity& commodity, double capacity) {
51 commodities_[commodity].capacity = capacity;
52 }
53
54 /// Set the production cost for a given commodity
55 /// @param commodity the commodity being produced
56 /// @param cost the production cost
57 inline void SetCost(const Commodity& commodity, double cost) {
58 commodities_[commodity].cost = cost;
59 }
60
61 /// Register a commodity as being produced by this object
62 /// @param commodity the commodity being produced
63 inline void Add(const Commodity& commodity) {
64 Add(commodity, CommodInfo(default_capacity_, default_cost_));
65 }
66
67 /// Register a commodity as being produced by this object and set
68 /// its relevant info
69 /// @param commodity the commodity being produced
70 /// @param info the information describing the commodity
71 inline void Add(const Commodity& commodity, const CommodInfo& info) {
72 commodities_.insert(std::make_pair(commodity, info));
73 }
74
75 /// Unregister a commodity as being produced by this object
76 /// @param commodity the commodity being produced
77 inline void Rm(const Commodity& commodity) { commodities_.erase(commodity); }
78
79 /// @return the set of commodities produced by this producers
80 std::set<Commodity, CommodityCompare> ProducedCommodities();
81
82 /// Add all commodities produced by a source
83 /// @param source the original commodity producer
84 void Copy(CommodityProducer* source);
85
86 private:
87 /// A collection of commodities and their production capacities
88 std::map<Commodity, CommodInfo, CommodityCompare> commodities_;
89
90 /// A default production capacity
91 double default_capacity_;
92
93 /// A default production cost
94 double default_cost_;
95};
96
97} // namespace toolkit
98} // namespace cyclus
99
100#endif // CYCLUS_SRC_TOOLKIT_COMMODITY_PRODUCER_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 produced commodities.
void SetCapacity(const Commodity &commodity, double capacity)
Set the production capacity for a given commodity.
double Capacity(const Commodity &commodity)
void SetCost(const Commodity &commodity, double cost)
Set the production cost for a given commodity.
void Add(const Commodity &commodity)
Register a commodity as being produced by this object.
double Cost(const Commodity &commodity)
void Copy(CommodityProducer *source)
Add all commodities produced by a source.
void Rm(const Commodity &commodity)
Unregister a commodity as being produced by this object.
bool Produces(const Commodity &commodity) const
CommodityProducer(double default_capacity=0, double default_cost=kModifierLimit, Agent *agent=NULL)
std::set< Commodity, CommodityCompare > ProducedCommodities()
void Add(const Commodity &commodity, const CommodInfo &info)
Register a commodity as being produced by this object and set its relevant info.
A simple class defining a commodity; it is currently super simple.
Definition commodity.h:12
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
static const double kModifierLimit
maximum value for a function modifier (i.e., a_i for variable x_i)
Definition cyc_limits.h:38
A container to hold information about a commodity.
CommodInfo(double default_capacity=0, double default_cost=kModifierLimit)