CYCLUS
Public Member Functions | Protected Member Functions | List of all members
cyclus::GreedySolver Class Reference

Detailed Description

The GreedySolver provides the implementation for a "greedy" solution to a resource exchange graph.

Given an ExchangeGraph, the greedy solver will march through each RequestGroup in the graph, matching request nodes "greedily" with supply nodes. Each request node will attempt to be supplied by supplier arcs as long as those supplier arcs have some excess capacity. The possible suppliers will be ordered by descending preference. The algorithm terminates when one of the following conditions is met: 1) All RequestGroups are satisfied 2) All SupplySets are at capacity

Warning
the GreedySolver is responsible for deleting is conditioner!

Definition at line 63 of file greedy_solver.h.

#include <greedy_solver.h>

Inheritance diagram for cyclus::GreedySolver:
Inheritance graph
[legend]

Public Member Functions

void Condition ()
 
void Init ()
 
virtual ~GreedySolver ()
 
 GreedySolver ()
 
 GreedySolver (bool exclusive_orders)
 
 GreedySolver (GreedyPreconditioner *c)
 
 GreedySolver (bool exclusive_orders, GreedyPreconditioner *c)
 
double Capacity (const Arc &a, double u_curr_qty, double v_curr_qty)
 
double Capacity (const Arc &a)
 
double Capacity (ExchangeNode::Ptr n, const Arc &a, bool min_cap, double curr_qty)
 
double Capacity (ExchangeNode::Ptr n, const Arc &a, bool min_cap)
 
double Capacity (ExchangeNode::Ptr n, const Arc &a, double curr_qty)
 
double Capacity (ExchangeNode::Ptr n, const Arc &a)
 
- Public Member Functions inherited from cyclus::ExchangeSolver
double ArcCost (const Arc &a)
 
 ExchangeSolver (bool exclusive_orders=kDefaultExclusive)
 
void graph (ExchangeGraph *graph)
 
ExchangeGraphgraph () const
 
double Solve (ExchangeGraph *graph=NULL)
 
void verbose ()
 
virtual ~ExchangeSolver ()
 
void sim_ctx (Context *c)
 
Contextsim_ctx ()
 
double PseudoCost ()
 
double PseudoCost (double cost_factor)
 
double PseudoCostByCap (double cost_factor)
 
double PseudoCostByPref (double cost_factor)
 

Protected Member Functions

virtual double SolveGraph ()
 

Additional Inherited Members

- Static Public Member Functions inherited from cyclus::ExchangeSolver
static double Cost (const Arc &a, bool exclusive_orders=kDefaultExclusive)
 
- Static Public Attributes inherited from cyclus::ExchangeSolver
static const bool kDefaultExclusive = true
 
- Protected Attributes inherited from cyclus::ExchangeSolver
bool exclusive_orders_
 
ExchangeGraphgraph_
 
Contextsim_ctx_
 
bool verbose_
 

Constructor & Destructor Documentation

◆ GreedySolver() [1/4]

cyclus::GreedySolver::GreedySolver ( )

GreedySolver constructor.

Parameters
exclusive_ordersa flag for enforcing integral, quantized orders
ca conditioner to use before solving a graph instance
Warning
if a NULL pointer is passed as a conditioner argument, conditioning will NOT occur

Definition at line 32 of file greedy_solver.cc.

◆ GreedySolver() [2/4]

cyclus::GreedySolver::GreedySolver ( bool  exclusive_orders)
explicit

Definition at line 23 of file greedy_solver.cc.

◆ GreedySolver() [3/4]

cyclus::GreedySolver::GreedySolver ( GreedyPreconditioner c)
explicit

Definition at line 28 of file greedy_solver.cc.

◆ GreedySolver() [4/4]

cyclus::GreedySolver::GreedySolver ( bool  exclusive_orders,
GreedyPreconditioner c 
)

Definition at line 19 of file greedy_solver.cc.

◆ ~GreedySolver()

cyclus::GreedySolver::~GreedySolver ( )
virtual

Definition at line 36 of file greedy_solver.cc.

Member Function Documentation

◆ Capacity() [1/6]

double cyclus::GreedySolver::Capacity ( const Arc a,
double  u_curr_qty,
double  v_curr_qty 
)

the capacity of the arc

Exceptions
StateErrorif either ExchangeNode does not have a ExchangeNodeGroup
Parameters
athe arc
u_curr_qtythe current quantity assigned to the unode (if solving piecemeal)
v_curr_qtythe current quantity assigned to the vnode (if solving piecemeal)
Returns
The minimum of the unode and vnode's capacities

Definition at line 79 of file greedy_solver.cc.

◆ Capacity() [2/6]

double cyclus::GreedySolver::Capacity ( const Arc a)
inline

Definition at line 101 of file greedy_solver.h.

◆ Capacity() [3/6]

double cyclus::GreedySolver::Capacity ( ExchangeNode::Ptr  n,
const Arc a,
bool  min_cap,
double  curr_qty 
)

the capacity of a node

Exceptions
StateErrorif ExchangeNode does not have a ExchangeNodeGroup
Parameters
nthe node
min_capwhether to use the minimum or maximum capacity value. In general, nodes that represent bids use the minimum (i.e., the capacities represents a less-than constraint) and nodes that represent requests use the maximum value (i.e., the capacities represents a greater-than constraint).
curr_qtythe currently allocated node quantity (if solving piecemeal)
Returns
The minimum of the node's nodegroup capacities / the node's unit capacities, or the ExchangeNode's remaining qty – whichever is smaller.

Definition at line 93 of file greedy_solver.cc.

◆ Capacity() [4/6]

double cyclus::GreedySolver::Capacity ( ExchangeNode::Ptr  n,
const Arc a,
bool  min_cap 
)
inline

Definition at line 118 of file greedy_solver.h.

◆ Capacity() [5/6]

double cyclus::GreedySolver::Capacity ( ExchangeNode::Ptr  n,
const Arc a,
double  curr_qty 
)
inline

Definition at line 121 of file greedy_solver.h.

◆ Capacity() [6/6]

double cyclus::GreedySolver::Capacity ( ExchangeNode::Ptr  n,
const Arc a 
)
inline

Definition at line 124 of file greedy_solver.h.

◆ Condition()

void cyclus::GreedySolver::Condition ( )

Uses the provided (or a default) GreedyPreconditioner to condition the solver's ExchangeGraph so that RequestGroups are ordered by average preference and commodity weight.

Warning
this function is called during the Solve step and should most likely not be called independently thereof (except for testing)

Definition at line 41 of file greedy_solver.cc.

◆ Init()

void cyclus::GreedySolver::Init ( )

Initialize member values based on the given graph.

Definition at line 46 of file greedy_solver.cc.

◆ SolveGraph()

double cyclus::GreedySolver::SolveGraph ( )
protectedvirtual

the GreedySolver solves an ExchangeGraph by iterating over each RequestGroup and matching requests with the minimum bids possible, starting from the beginning of the the respective request and bid containers.

Implements cyclus::ExchangeSolver.

Definition at line 60 of file greedy_solver.cc.


The documentation for this class was generated from the following files: