CYCLUS
Public Types | Public Member Functions | List of all members
cyclus::GreedyPreconditioner Class Reference

Detailed Description

A GreedyPreconditioner conditions an ExchangeGraph for a GreedySolver by ordering the RequestGroups and ExchangeNodes within each RequestGroup weighted by their commodity's importance.

The Graph is conditioned in-place.

Weighting

Commodity weights are provided to the conditioner via its constructor. A larger weight implies a higher level of importance for solving.

The conditioning weight for a node is calculated as $w_cond_i = w_commod_i * (1 + {{p_i}}{1 + {p_i}})$, where $w_cond_i$ is the calculated conditioning weight, $w_commod_i$ is node $i$'s commodity's weight, and ${p_i}$ is the average preference of all bid arcs associated with node $i$.

First, the ExchangeNodes of each RequestGroup are sorted according to their conditioning weights. Then, the average weight of each RequestGroup is determined. Finally, each RequestGroup is sorted according to their average weight.

Example

Consider the following commodity-to-weight mapping: {"spam": 5, "eggs": 2}. Now consider two RequestGroups with the following commodities: #. g1 = {"eggs", "spam", "eggs"} #. g2 = {"eggs", "spam"} And the following preference-commodity mapping: {g1: {"spam": 3/4, "eggs": 1/4}, g2: {"spam": 1, "eggs": 1}.

First, the groups will be ordered by conditioning weights: #. g1 = {"spam", "eggs", "eggs"} #. g2 = {"spam", "eggs"}

Finally, the groups themselves will be ordered by average weight: #. {g2, g1}

Definition at line 60 of file greedy_preconditioner.h.

#include <greedy_preconditioner.h>

Public Types

enum  WgtOrder { REVERSE, END }
 

Public Member Functions

void Condition (ExchangeGraph *graph)
 
bool GroupComp (const RequestGroup::Ptr l, const RequestGroup::Ptr r)
 
bool NodeComp (const ExchangeNode::Ptr l, const ExchangeNode::Ptr r)
 
 GreedyPreconditioner ()
 
 GreedyPreconditioner (const std::map< std::string, double > &commod_weights)
 
 GreedyPreconditioner (const std::map< std::string, double > &commod_weights, WgtOrder order)
 

Member Enumeration Documentation

◆ WgtOrder

the order of commodity weights

Enumerator
REVERSE 
END 

a flag for commodity weights given in the reverse order,

i.e, lightest first default flag, indicating heaviest-first ordering

Definition at line 63 of file greedy_preconditioner.h.

Constructor & Destructor Documentation

◆ GreedyPreconditioner() [1/3]

cyclus::GreedyPreconditioner::GreedyPreconditioner ( )

constructor if weights are given in heaviest-first order

Warning
weights are assumed to be positive

Definition at line 28 of file greedy_preconditioner.cc.

◆ GreedyPreconditioner() [2/3]

cyclus::GreedyPreconditioner::GreedyPreconditioner ( const std::map< std::string, double > &  commod_weights)

Definition at line 30 of file greedy_preconditioner.cc.

◆ GreedyPreconditioner() [3/3]

cyclus::GreedyPreconditioner::GreedyPreconditioner ( const std::map< std::string, double > &  commod_weights,
WgtOrder  order 
)

constructor if weights may not be given in heaviest-first order

Warning
weights are assumed to be positive

Definition at line 37 of file greedy_preconditioner.cc.

Member Function Documentation

◆ Condition()

void cyclus::GreedyPreconditioner::Condition ( ExchangeGraph graph)

conditions the graph as described above

Exceptions
KeyErrorif a commodity is in the graph but not in the weight mapping

Definition at line 45 of file greedy_preconditioner.cc.

◆ GroupComp()

bool cyclus::GreedyPreconditioner::GroupComp ( const RequestGroup::Ptr  l,
const RequestGroup::Ptr  r 
)
inline

a comparitor for ordering containers of Request::Ptrs in descending order based on their average commodity weight

Definition at line 96 of file greedy_preconditioner.h.

◆ NodeComp()

bool cyclus::GreedyPreconditioner::NodeComp ( const ExchangeNode::Ptr  l,
const ExchangeNode::Ptr  r 
)
inline

a comparitor for ordering containers of ExchangeNode::Ptrs in descending order based on their commodity's weight

Definition at line 87 of file greedy_preconditioner.h.


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