CYCLUS
building_manager.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_TOOLKIT_BUILDING_MANAGER_H_
2 #define CYCLUS_SRC_TOOLKIT_BUILDING_MANAGER_H_
3 
4 #include <map>
5 #include <vector>
6 
7 #include "agent_managed.h"
8 #include "builder.h"
9 #include "commodity_producer.h"
10 
12 
13 namespace cyclus {
14 
15 class ProgTranslatorContext;
16 
17 namespace toolkit {
18 
19 /// A struct for a build order: the number of producers to build.
20 struct BuildOrder {
21  BuildOrder(int n, Builder* b, CommodityProducer* cp);
22  int number;
25 };
26 
27 /// The BuildingManager class is a managing entity that makes decisions
28 /// about which objects to build given certain conditions.
29 ///
30 /// Specifically, the BuildingManager queries the SupplyDemandManager
31 /// to determine if there exists unmet demand for a Commodity, and then
32 /// decides which object(s) amongst that Commodity's producers should be
33 /// built to meet that demand. This decision takes the form of an
34 /// integer program:
35 ///
36 /// \f[
37 /// \min \sum_{i=1}^{N}c_i*y_i \\
38 /// s.t. \sum_{i=1}^{N}\phi_i*y_i \ge \Phi \\
39 /// n_i \in [0,\infty) \forall i \in I, y_i integer
40 /// \f]
41 ///
42 /// Where y_i is the number of objects of type i to build, c_i is the
43 /// cost to build the object of type i, \f$\phi_i\f$ is the nameplate
44 /// capacity of the object, and \f$\Phi\f$ is the capacity demand. Here
45 /// the set I corresponds to all producers of a given commodity.
46 class BuildingManager : public AgentManaged {
47  public:
48  BuildingManager(Agent* agent = NULL) : AgentManaged(agent) {}
49 
50  /// Register a builder with the manager
51  /// @param builder the builder
52  inline void Register(Builder* builder) { builders_.insert(builder); }
53 
54  /// Unregister a builder with the manager
55  /// @param builder the builder
56  inline void Unregister(Builder* builder) { builders_.erase(builder); }
57 
58  /// Given a certain commodity and demand, a decision is made as to
59  /// how many producers of each available type to build this
60  /// function constructs an integer program through the
61  /// SolverInterface
62  /// @param commodity the commodity being demanded
63  /// @param demand the additional capacity required
64  /// @return a vector of build orders as decided
65  std::vector<BuildOrder> MakeBuildDecision(Commodity& commodity,
66  double demand);
67 
68  inline const std::set<Builder*>& builders() const {
69  return builders_;
70  }
71 
72  private:
73  std::set<Builder*> builders_;
74 
75  void SetUp_(OsiCbcSolverInterface& iface,
77  std::map<CommodityProducer*, Builder*>& p_to_b,
78  std::map<int, CommodityProducer*>& idx_to_p,
79  Commodity& commodity,
80  double demand);
81 
82  void Solve_(OsiCbcSolverInterface& iface,
84  std::map<CommodityProducer*, Builder*>& p_to_b,
85  std::map<int, CommodityProducer*>& idx_to_p,
86  std::vector<BuildOrder>& orders);
87 };
88 
89 } // namespace toolkit
90 } // namespace cyclus
91 
92 #endif // CYCLUS_SRC_TOOLKIT_BUILDING_MANAGER_H_
The BuildingManager class is a managing entity that makes decisions about which objects to build give...
void Unregister(Builder *builder)
Unregister a builder with the manager.
A simple class defining a commodity; it is currently super simple.
Definition: commodity.h:12
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
Definition: pyne.cc:11180
void Register(Builder *builder)
Register a builder with the manager.
This is a mixin class that provides an interface to access the underlying agent that manages it...
Definition: agent_managed.h:11
struct to hold all problem instance state
BuildOrder(int n, Builder *b, CommodityProducer *cp)
A mixin to provide information about commodity producers that can be built.
Definition: builder.h:14
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.
CommodityProducer * producer
const std::set< Builder * > & builders() const
A struct for a build order: the number of producers to build.