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
23 explicit ExchangeSolver(bool exclusive_orders = kDefaultExclusive)
24 : exclusive_orders_(exclusive_orders), sim_ctx_(NULL), verbose_(false) {}
25 virtual ~ExchangeSolver() {}
26
27 /// simulation context get/set
28 /// @{
29 inline void sim_ctx(Context* c) { sim_ctx_ = c; }
30 inline Context* sim_ctx() { return sim_ctx_; }
31 /// @}
32
33 /// tell the solver to be verbose
34 inline void verbose() { verbose_ = true; }
35 inline void graph(ExchangeGraph* graph) { graph_ = graph; }
36 inline ExchangeGraph* graph() const { return graph_; }
37
38 /// @brief interface for solving a given exchange graph
39 /// @param a pointer to the graph to be solved
40 double Solve(ExchangeGraph* graph = NULL) {
41 if (graph != NULL) graph_ = graph;
42 return this->SolveGraph();
43 }
44
45 /// @brief Calculates the ratio of the maximum objective coefficient to
46 /// minimum unit capacity plus an added cost. This is guaranteed to be larger
47 /// than any other arc cost measure and can be used as a cost for unmet
48 /// demand.
49 /// @param cost_factor the additional cost for false arc costs, i.e., max_cost
50 /// * (1 + cost_factor)
51 /// @{
52 double PseudoCost();
53 double PseudoCost(double cost_factor);
54 double PseudoCostByCap(double cost_factor);
55 double PseudoCostByPref(double cost_factor);
56 /// @}
57
58 /// return the cost of an arc
59 inline double ArcCost(const Arc& a) { return Cost(a, exclusive_orders_); }
60
61 protected:
62 /// @brief Worker function for solving a graph. This must be implemented by
63 /// any solver.
64 virtual double SolveGraph() = 0;
69};
70
71} // namespace cyclus
72
73#endif // CYCLUS_SRC_EXCHANGE_SOLVER_H_
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:146
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
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