|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
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>
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> |
Policy iteration over the out-adjacency of a graph in which every node has at least one outgoing arc.
| Cost_Type | Arc weight type. |
Definition at line 626 of file Howard_Min_Mean_Cycle.H.
|
private |
Definition at line 629 of file Howard_Min_Mean_Cycle.H.
|
private |
Definition at line 631 of file Howard_Min_Mean_Cycle.H.
|
private |
Definition at line 630 of file Howard_Min_Mean_Cycle.H.
|
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.
|
inline |
| [in] | adj | Out-adjacency; every node must have an outgoing arc. |
| [in] | n | Number of nodes. |
| [in] | initial | A 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.
|
inline |
| [in] | adj | Out-adjacency; every node must have an outgoing arc. |
| [in] | n | Number 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.
|
inline |
A node whose mean is the smallest: the cycle it reaches is optimal.
Definition at line 842 of file Howard_Min_Mean_Cycle.H.
References Aleph::howard_detail::Solver< Cost_Type >::eta_, and Aleph::howard_detail::Solver< Cost_Type >::n_.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::improve(), Aleph::howard_detail::minimum_mean_cycle(), and Aleph::howard_detail::try_exact().
|
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_.
|
inlineprivate |
Compute eta_ and bias_ of every node for the current policy.
Returns false on overflow.
Definition at line 649 of file Howard_Min_Mean_Cycle.H.
References Aleph::howard_detail::Solver< Cost_Type >::adj_, Aleph::howard_detail::Solver< Cost_Type >::bias_, Aleph::howard_detail::Solver< Cost_Type >::eta_, k, Aleph::howard_detail::Solver< Cost_Type >::n_, Aleph::next(), Aleph::howard_detail::Solver< Cost_Type >::path_, Aleph::howard_detail::Solver< Cost_Type >::policy_, root(), Aleph::howard_detail::Solver< Cost_Type >::state_, and Aleph::howard_detail::Solver< Cost_Type >::successor().
Referenced by Aleph::howard_detail::Solver< Cost_Type >::solve().
|
inlineprivate |
Improve the policy.
Returns true if it changed; on overflow sets overflow_ and returns false.
Definition at line 728 of file Howard_Min_Mean_Cycle.H.
References Aleph::howard_detail::Solver< Cost_Type >::adj_, Aleph::howard_detail::Solver< Cost_Type >::best_node(), Aleph::howard_detail::Solver< Cost_Type >::bias_, Aleph::howard_detail::Solver< Cost_Type >::eta_, Aleph::howard_detail::Solver< Cost_Type >::n_, Aleph::howard_detail::Solver< Cost_Type >::overflow_, and Aleph::howard_detail::Solver< Cost_Type >::policy_.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::solve().
|
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().
|
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().
|
inline |
Iterate until the policy is optimal.
| [in] | limit | Maximum number of improvements. |
| [out] | iterations | Improvements applied. |
Definition at line 827 of file Howard_Min_Mean_Cycle.H.
References Aleph::howard_detail::Solver< Cost_Type >::evaluate(), Aleph::howard_detail::Solver< Cost_Type >::improve(), Aleph::howard_detail::Solver< Cost_Type >::Iteration_Limit, Aleph::howard_detail::Solver< Cost_Type >::Optimal, Aleph::howard_detail::Solver< Cost_Type >::Overflow, and Aleph::howard_detail::Solver< Cost_Type >::overflow_.
Referenced by Aleph::howard_detail::minimum_mean_cycle(), and Aleph::howard_detail::try_exact().
|
inlineprivate |
Definition at line 642 of file Howard_Min_Mean_Cycle.H.
References Aleph::howard_detail::Solver< Cost_Type >::adj_, and Aleph::howard_detail::Solver< Cost_Type >::policy_.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::evaluate(), and Aleph::howard_detail::Solver< Cost_Type >::next_node().
|
private |
Definition at line 633 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::evaluate(), Aleph::howard_detail::Solver< Cost_Type >::improve(), and Aleph::howard_detail::Solver< Cost_Type >::successor().
|
private |
Definition at line 637 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::evaluate(), and Aleph::howard_detail::Solver< Cost_Type >::improve().
|
private |
Definition at line 636 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::best_node(), Aleph::howard_detail::Solver< Cost_Type >::evaluate(), and Aleph::howard_detail::Solver< Cost_Type >::improve().
|
staticconstexprprivate |
Definition at line 628 of file Howard_Min_Mean_Cycle.H.
|
private |
Definition at line 634 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::best_node(), Aleph::howard_detail::Solver< Cost_Type >::evaluate(), and Aleph::howard_detail::Solver< Cost_Type >::improve().
|
private |
Definition at line 640 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::improve(), and Aleph::howard_detail::Solver< Cost_Type >::solve().
|
private |
Definition at line 639 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::evaluate().
|
private |
Definition at line 635 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::Solver(), Aleph::howard_detail::Solver< Cost_Type >::chosen_arc(), Aleph::howard_detail::Solver< Cost_Type >::evaluate(), Aleph::howard_detail::Solver< Cost_Type >::improve(), Aleph::howard_detail::Solver< Cost_Type >::policy(), and Aleph::howard_detail::Solver< Cost_Type >::successor().
|
private |
Definition at line 638 of file Howard_Min_Mean_Cycle.H.
Referenced by Aleph::howard_detail::Solver< Cost_Type >::evaluate().