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