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 {
18 double capacity;
19 double cost;
20};
21
22/// A mixin to provide information about produced commodities
24 public:
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
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_
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 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
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
A container to hold information about a commodity.
CommodInfo(double default_capacity=0, double default_cost=kModifierLimit)