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),
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;
65
ExchangeGraph
*
graph_
;
66
bool
exclusive_orders_
;
67
bool
verbose_
;
68
Context
*
sim_ctx_
;
69
};
70
71
}
// namespace cyclus
72
73
#endif
// CYCLUS_SRC_EXCHANGE_SOLVER_H_
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:146
cyclus::ExchangeGraph
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
Definition
exchange_graph.h:206
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:40
cyclus::ExchangeSolver::graph_
ExchangeGraph * graph_
Definition
exchange_solver.h:65
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:83
cyclus::ExchangeSolver::~ExchangeSolver
virtual ~ExchangeSolver()
Definition
exchange_solver.h:25
cyclus::ExchangeSolver::ExchangeSolver
ExchangeSolver(bool exclusive_orders=kDefaultExclusive)
Definition
exchange_solver.h:23
cyclus::ExchangeSolver::graph
ExchangeGraph * graph() const
Definition
exchange_solver.h:36
cyclus::ExchangeSolver::sim_ctx
Context * sim_ctx()
Definition
exchange_solver.h:30
cyclus::ExchangeSolver::graph
void graph(ExchangeGraph *graph)
Definition
exchange_solver.h:35
cyclus::ExchangeSolver::exclusive_orders_
bool exclusive_orders_
Definition
exchange_solver.h:66
cyclus::ExchangeSolver::sim_ctx
void sim_ctx(Context *c)
simulation context get/set
Definition
exchange_solver.h:29
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:59
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:67
cyclus::ExchangeSolver::sim_ctx_
Context * sim_ctx_
Definition
exchange_solver.h:68
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:34
cyclus
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition
agent.cc:14
src
exchange_solver.h
Generated by
1.13.2