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