Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::howard_detail::Solver< Cost_Type > Class Template Reference

Policy iteration over the out-adjacency of a graph in which every node has at least one outgoing arc. More...

#include <Howard_Min_Mean_Cycle.H>

Collaboration diagram for Aleph::howard_detail::Solver< Cost_Type >:
[legend]

Public Types

enum class  Status { Optimal , Iteration_Limit , Overflow }
 How solve() ended. More...
 

Public Member Functions

 Solver (const negative_cycles_detail::Out_Adjacency< Cost_Type > &adj, const size_t n, const Array< size_t > &initial)
 
 Solver (const negative_cycles_detail::Out_Adjacency< Cost_Type > &adj, const size_t n)
 
Status solve (const size_t limit, size_t &iterations)
 Iterate until the policy is optimal.
 
size_t best_node () const
 A node whose mean is the smallest: the cycle it reaches is optimal.
 
size_t chosen_arc (const size_t u) const
 Position in the adjacency of the arc the policy chooses for u.
 
const Array< size_t > & policy () const noexcept
 The policy: for each node, the position in the adjacency of its arc.
 
size_t next_node (const size_t u) const
 Node the policy leads to from u.
 

Private Types

using Ar = Arithmetic< Cost_Type, exact >
 
using Eta = typename Ar::Eta
 
using Bias = typename Ar::Bias
 

Private Member Functions

size_t successor (const size_t u) const
 
bool evaluate ()
 Compute eta_ and bias_ of every node for the current policy.
 
bool improve ()
 Improve the policy.
 

Private Attributes

const negative_cycles_detail::Out_Adjacency< Cost_Type > & adj_
 
const size_t n_
 
Array< size_t > policy_
 
Array< Eta > eta_
 
Array< Bias > bias_
 
Array< unsigned char > state_
 
Array< size_t > path_
 
bool overflow_ = false
 

Static Private Attributes

static constexpr bool exact = exact_arithmetic_v<Cost_Type>
 

Detailed Description

template<typename Cost_Type>
class Aleph::howard_detail::Solver< Cost_Type >

Policy iteration over the out-adjacency of a graph in which every node has at least one outgoing arc.

Template Parameters
Cost_TypeArc weight type.

Definition at line 626 of file Howard_Min_Mean_Cycle.H.

Member Typedef Documentation

◆ Ar

template<typename Cost_Type >
using Aleph::howard_detail::Solver< Cost_Type >::Ar = Arithmetic<Cost_Type, exact>
private

Definition at line 629 of file Howard_Min_Mean_Cycle.H.

◆ Bias

template<typename Cost_Type >
using Aleph::howard_detail::Solver< Cost_Type >::Bias = typename Ar::Bias
private

Definition at line 631 of file Howard_Min_Mean_Cycle.H.

◆ Eta

template<typename Cost_Type >
using Aleph::howard_detail::Solver< Cost_Type >::Eta = typename Ar::Eta
private

Definition at line 630 of file Howard_Min_Mean_Cycle.H.

Member Enumeration Documentation

◆ Status

template<typename Cost_Type >
enum class Aleph::howard_detail::Solver::Status
strong

How solve() ended.

Enumerator
Optimal 

No improvement exists: the policy is optimal.

Iteration_Limit 

The limit was reached first.

Overflow 

A scaled value did not fit the arithmetic.

Definition at line 786 of file Howard_Min_Mean_Cycle.H.

Constructor & Destructor Documentation

◆ Solver() [1/2]

template<typename Cost_Type >
Aleph::howard_detail::Solver< Cost_Type >::Solver ( const negative_cycles_detail::Out_Adjacency< Cost_Type > &  adj,
const size_t  n,
const Array< size_t > &  initial 
)
inline
Parameters
[in]adjOut-adjacency; every node must have an outgoing arc.
[in]nNumber of nodes.
[in]initialA policy over the same adjacency structure to start from, instead of the cheapest arc of each node.

Definition at line 798 of file Howard_Min_Mean_Cycle.H.

◆ Solver() [2/2]

template<typename Cost_Type >
Aleph::howard_detail::Solver< Cost_Type >::Solver ( const negative_cycles_detail::Out_Adjacency< Cost_Type > &  adj,
const size_t  n 
)
inline
Parameters
[in]adjOut-adjacency; every node must have an outgoing arc.
[in]nNumber of nodes.

Definition at line 808 of file Howard_Min_Mean_Cycle.H.

References Aleph::howard_detail::Solver< Cost_Type >::policy_, Aleph::negative_cycles_detail::Out_Adjacency< Cost_Type >::start, and Aleph::negative_cycles_detail::Out_Adjacency< Cost_Type >::weight.

Member Function Documentation

◆ best_node()

template<typename Cost_Type >
size_t Aleph::howard_detail::Solver< Cost_Type >::best_node ( ) const
inline

◆ chosen_arc()

template<typename Cost_Type >
size_t Aleph::howard_detail::Solver< Cost_Type >::chosen_arc ( const size_t  u) const
inline

Position in the adjacency of the arc the policy chooses for u.

Definition at line 852 of file Howard_Min_Mean_Cycle.H.

References Aleph::howard_detail::Solver< Cost_Type >::policy_.

◆ evaluate()

◆ improve()

◆ next_node()

template<typename Cost_Type >
size_t Aleph::howard_detail::Solver< Cost_Type >::next_node ( const size_t  u) const
inline

Node the policy leads to from u.

Definition at line 864 of file Howard_Min_Mean_Cycle.H.

References Aleph::howard_detail::Solver< Cost_Type >::successor().

◆ policy()

template<typename Cost_Type >
const Array< size_t > & Aleph::howard_detail::Solver< Cost_Type >::policy ( ) const
inlinenoexcept

The policy: for each node, the position in the adjacency of its arc.

Definition at line 858 of file Howard_Min_Mean_Cycle.H.

References Aleph::howard_detail::Solver< Cost_Type >::policy_.

Referenced by Aleph::howard_detail::minimum_mean_cycle(), and Aleph::howard_detail::try_exact().

◆ solve()

template<typename Cost_Type >
Status Aleph::howard_detail::Solver< Cost_Type >::solve ( const size_t  limit,
size_t &  iterations 
)
inline

◆ successor()

template<typename Cost_Type >
size_t Aleph::howard_detail::Solver< Cost_Type >::successor ( const size_t  u) const
inlineprivate

Member Data Documentation

◆ adj_

◆ bias_

template<typename Cost_Type >
Array<Bias> Aleph::howard_detail::Solver< Cost_Type >::bias_
private

◆ eta_

◆ exact

template<typename Cost_Type >
constexpr bool Aleph::howard_detail::Solver< Cost_Type >::exact = exact_arithmetic_v<Cost_Type>
staticconstexprprivate

Definition at line 628 of file Howard_Min_Mean_Cycle.H.

◆ n_

◆ overflow_

template<typename Cost_Type >
bool Aleph::howard_detail::Solver< Cost_Type >::overflow_ = false
private

◆ path_

template<typename Cost_Type >
Array<size_t> Aleph::howard_detail::Solver< Cost_Type >::path_
private

◆ policy_

◆ state_

template<typename Cost_Type >
Array<unsigned char> Aleph::howard_detail::Solver< Cost_Type >::state_
private

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