CYCLUS
prog_translator.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_PROG_TRANSLATOR_H_
2 #define CYCLUS_SRC_PROG_TRANSLATOR_H_
3 #include "platform.h"
4 #if CYCLUS_HAS_COIN
5 
6 #include <vector>
7 
8 #include "CoinPackedMatrix.hpp"
9 
10 class OsiSolverInterface;
11 
12 namespace cyclus {
13 
14 class ExchangeGraph;
15 class ExchangeNodeGroup;
16 
17 /// @brief struct to hold all problem instance state
19  std::vector<double> obj_coeffs;
20  std::vector<double> row_ubs;
21  std::vector<double> row_lbs;
22  std::vector<double> col_ubs;
23  std::vector<double> col_lbs;
24  CoinPackedMatrix m;
25 };
26 
27 /// a helper class to translate a product exchange into a mathematical
28 /// program.
29 ///
30 /// use as follows:
31 /// @code
32 /// // given a graph, g, and interface, iface
33 /// ProgTranslator t(g, iface);
34 /// t->ToProg();
35 /// // solve the program via the interface
36 /// t->FromProg();
37 /// @endcode
39  public:
40  /// @brief This class is now deprecated.
41  struct Context {
42  Context();
43  ~Context();
44  };
45 
46  /// constructor
47  ///
48  /// @param g the exchange graph
49  /// @param iface the solver interface
50  /// @param exclusive whether or not to include binary-valued arcs
51  /// @param pseudo_cost the cost to use for faux arcs
52  ProgTranslator(ExchangeGraph* g, OsiSolverInterface* iface);
53  ProgTranslator(ExchangeGraph* g, OsiSolverInterface* iface, bool exclusive);
54  ProgTranslator(ExchangeGraph* g, OsiSolverInterface* iface,
55  double pseudo_cost);
56  ProgTranslator(ExchangeGraph* g, OsiSolverInterface* iface,
57  bool exclusive, double pseudo_cost);
58 
59  /// @brief translates the graph, filling the translators Context
60  void Translate();
61 
62  /// @brief populates the solver interface with values from the translators
63  /// Context
64  void Populate();
65 
66  /// @brief translates graph into mathematic program via iface. This method is
67  /// equivalent to calling Translate(), then Populate().
68  void ToProg();
69 
70  /// @brief translates solution from iface back into graph matches
71  void FromProg();
72 
73  const ProgTranslatorContext& ctx() const { return ctx_; }
74 
75  private:
76  void Init();
77 
78  /// @throws if preference is unsatisfactory (i.e., not greater than 0)
79  void CheckPref(double pref);
80 
81  /// perform all translation for a node group
82  /// @param grp a pointer to the node group
83  /// @param req a boolean flag, true if grp is a request group
84  void XlateGrp_(ExchangeNodeGroup* grp, bool req);
85 
86  ExchangeGraph* g_;
87  OsiSolverInterface* iface_;
88  bool excl_;
89  int arc_offset_;
91  double pseudo_cost_;
92 };
93 
94 } // namespace cyclus
95 
96 #endif // CYLCUS_HAS_COIN
97 #endif // CYCLUS_SRC_PROG_TRANSLATOR_H_
A ExchangeNodeGroup is a collection of ExchangeNodes, and is the ExchangeGraph representation of a Bi...
const ProgTranslatorContext & ctx() const
struct to hold all problem instance state
const double g
Definition: material.h:18
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
std::vector< double > row_lbs
This class is now deprecated.
std::vector< double > col_ubs
a helper class to translate a product exchange into a mathematical program.
std::vector< double > obj_coeffs
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
std::vector< double > row_ubs
std::vector< double > col_lbs