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
6
namespace
cyclus
{
7
8
class
Context
;
9
class
ExchangeGraph;
10
class
Arc;
11
12
/// @class ExchangeSolver
13
///
14
/// @brief a very simple interface for solving translated resource exchanges
15
class
ExchangeSolver
{
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
),
25
sim_ctx_
(
NULL
),
26
verbose_
(
false
) {}
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
42
double
Solve
(
ExchangeGraph
*
graph
=
NULL
) {
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;
68
ExchangeGraph
*
graph_
;
69
bool
exclusive_orders_
;
70
bool
verbose_
;
71
Context
*
sim_ctx_
;
72
};
73
74
}
// namespace cyclus
75
76
#endif
// CYCLUS_SRC_EXCHANGE_SOLVER_H_
Context
a holding class for information related to a TradeExecutor
cyclus::Arc
An arc represents a possible connection between two nodes in the bipartite resource exchange graph.
Definition
exchange_graph.h:67
cyclus::Context
A simulation context provides access to necessary simulation-global functions and state.
Definition
context.h:145
cyclus::ExchangeGraph
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
Definition
exchange_graph.h:207
cyclus::ExchangeSolver
a very simple interface for solving translated resource exchanges
Definition
exchange_solver.h:15
cyclus::ExchangeSolver::PseudoCostByCap
double PseudoCostByCap(double cost_factor)
Definition
exchange_solver.cc:24
cyclus::ExchangeSolver::Solve
double Solve(ExchangeGraph *graph=NULL)
interface for solving a given exchange graph
Definition
exchange_solver.h:42
cyclus::ExchangeSolver::graph_
ExchangeGraph * graph_
Definition
exchange_solver.h:68
cyclus::ExchangeSolver::SolveGraph
virtual double SolveGraph()=0
Worker function for solving a graph.
cyclus::ExchangeSolver::PseudoCostByPref
double PseudoCostByPref(double cost_factor)
Definition
exchange_solver.cc:86
cyclus::ExchangeSolver::~ExchangeSolver
virtual ~ExchangeSolver()
Definition
exchange_solver.h:27
cyclus::ExchangeSolver::ExchangeSolver
ExchangeSolver(bool exclusive_orders=kDefaultExclusive)
Definition
exchange_solver.h:23
cyclus::ExchangeSolver::graph
ExchangeGraph * graph() const
Definition
exchange_solver.h:38
cyclus::ExchangeSolver::sim_ctx
Context * sim_ctx()
Definition
exchange_solver.h:32
cyclus::ExchangeSolver::graph
void graph(ExchangeGraph *graph)
Definition
exchange_solver.h:37
cyclus::ExchangeSolver::exclusive_orders_
bool exclusive_orders_
Definition
exchange_solver.h:69
cyclus::ExchangeSolver::sim_ctx
void sim_ctx(Context *c)
simulation context get/set
Definition
exchange_solver.h:31
cyclus::ExchangeSolver::PseudoCost
double PseudoCost()
Calculates the ratio of the maximum objective coefficient to minimum unit capacity plus an added cost...
Definition
exchange_solver.cc:16
cyclus::ExchangeSolver::ArcCost
double ArcCost(const Arc &a)
return the cost of an arc
Definition
exchange_solver.h:62
cyclus::ExchangeSolver::kDefaultExclusive
static const bool kDefaultExclusive
default value to allow exclusive orders or not
Definition
exchange_solver.h:18
cyclus::ExchangeSolver::verbose_
bool verbose_
Definition
exchange_solver.h:70
cyclus::ExchangeSolver::sim_ctx_
Context * sim_ctx_
Definition
exchange_solver.h:71
cyclus::ExchangeSolver::Cost
static double Cost(const Arc &a, bool exclusive_orders=kDefaultExclusive)
return the cost of an arc
Definition
exchange_solver.cc:11
cyclus::ExchangeSolver::verbose
void verbose()
tell the solver to be verbose
Definition
exchange_solver.h:36
cyclus
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition
agent.cc:14
cyclus::OptionalQuery
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
Definition
infile_tree.h:121
src
exchange_solver.h
Generated by
1.10.0