CYCLUS
Loading...
Searching...
No Matches
exchange_solver.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_EXCHANGE_SOLVER_H_
2#define CYCLUS_SRC_EXCHANGE_SOLVER_H_
3
4#include <cstddef>
5
6namespace cyclus {
7
8class Context;
9class ExchangeGraph;
10class Arc;
11
12/// @class ExchangeSolver
13///
14/// @brief a very simple interface for solving translated resource exchanges
16 public:
17 /// default value to allow exclusive orders or not
18 static const bool kDefaultExclusive = true;
19
20 /// return the cost of an arc
21 static double Cost(const Arc& a, bool exclusive_orders = kDefaultExclusive);
22
27 virtual ~ExchangeSolver() {}
28
29 /// simulation context get/set
30 /// @{
31 inline void sim_ctx(Context* c) { sim_ctx_ = c; }
32 inline Context* sim_ctx() { return sim_ctx_; }
33 /// @}
34
35 /// tell the solver to be verbose
36 inline void verbose() { verbose_ = true; }
37 inline void graph(ExchangeGraph* graph) { graph_ = graph; }
38 inline ExchangeGraph* graph() const { return graph_; }
39
40 /// @brief interface for solving a given exchange graph
41 /// @param a pointer to the graph to be solved
43 if (graph != NULL)
44 graph_ = graph;
45 return this->SolveGraph();
46 }
47
48 /// @brief Calculates the ratio of the maximum objective coefficient to
49 /// minimum unit capacity plus an added cost. This is guaranteed to be larger
50 /// than any other arc cost measure and can be used as a cost for unmet
51 /// demand.
52 /// @param cost_factor the additional cost for false arc costs, i.e., max_cost
53 /// * (1 + cost_factor)
54 /// @{
55 double PseudoCost();
56 double PseudoCost(double cost_factor);
57 double PseudoCostByCap(double cost_factor);
58 double PseudoCostByPref(double cost_factor);
59 /// @}
60
61 /// return the cost of an arc
62 inline double ArcCost(const Arc& a) { return Cost(a, exclusive_orders_); }
63
64 protected:
65 /// @brief Worker function for solving a graph. This must be implemented by
66 /// any solver.
67 virtual double SolveGraph() = 0;
72};
73
74} // namespace cyclus
75
76#endif // CYCLUS_SRC_EXCHANGE_SOLVER_H_
a holding class for information related to a TradeExecutor
An arc represents a possible connection between two nodes in the bipartite resource exchange graph.
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
a very simple interface for solving translated resource exchanges
double PseudoCostByCap(double cost_factor)
double Solve(ExchangeGraph *graph=NULL)
interface for solving a given exchange graph
virtual double SolveGraph()=0
Worker function for solving a graph.
double PseudoCostByPref(double cost_factor)
ExchangeSolver(bool exclusive_orders=kDefaultExclusive)
ExchangeGraph * graph() const
void graph(ExchangeGraph *graph)
void sim_ctx(Context *c)
simulation context get/set
double PseudoCost()
Calculates the ratio of the maximum objective coefficient to minimum unit capacity plus an added cost...
double ArcCost(const Arc &a)
return the cost of an arc
static const bool kDefaultExclusive
default value to allow exclusive orders or not
static double Cost(const Arc &a, bool exclusive_orders=kDefaultExclusive)
return the cost of an arc
void verbose()
tell the solver to be verbose
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