CYCLUS
Loading...
Searching...
No Matches
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
10class OsiSolverInterface;
11
12namespace cyclus {
13
14class ExchangeGraph;
15class 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;
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 {
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_
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
A ExchangeNodeGroup is a collection of ExchangeNodes, and is the ExchangeGraph representation of a Bi...
a helper class to translate a product exchange into a mathematical program.
ProgTranslator(ExchangeGraph *g, OsiSolverInterface *iface)
constructor
const ProgTranslatorContext & ctx() const
void FromProg()
translates solution from iface back into graph matches
void Populate()
populates the solver interface with values from the translators Context
void ToProg()
translates graph into mathematic program via iface.
void Translate()
translates the graph, filling the translators Context
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
struct to hold all problem instance state
std::vector< double > col_lbs
std::vector< double > col_ubs
std::vector< double > obj_coeffs
std::vector< double > row_ubs
std::vector< double > row_lbs
This class is now deprecated.