|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Best simple cycle found so far by most_negative_cycle_bounded().
More...
#include <Negative_Cycles.H>
Public Member Functions | |
| template<AlephGraph GT> | |
| Best_Cycle (const Indexed_Graph< GT, Cost_Type > &ig, const size_t L) | |
Prepare the rounding filter for cycles of at most L arcs. | |
| template<AlephGraph GT> | |
| void | offer (const Indexed_Graph< GT, Cost_Type > &ig, const Cost_Type &c, const size_t *candidate, const size_t length) |
Keep the cycle of length arcs candidate[0..length), of plain-sum cost c, if it is cheaper than the best so far, or equally cheap with fewer arcs. | |
Public Attributes | |
| bool | found = false |
| Cost_Type | cost = Cost_Type{0} |
| Array< size_t > | arcs |
Private Member Functions | |
| void | store (const Cost_Type &c, const size_t *candidate, const size_t length) |
Private Attributes | |
| bool | exact_sums_ = true |
| Cost_Type | error_ = Cost_Type{0} |
| Cost_Type | reject_above_ = Cost_Type{0} |
| Exact_Sum< Cost_Type > | exact_best_ |
| Exact_Sum< Cost_Type > | exact_candidate_ |
| Exact_Sum< Cost_Type > | difference_ |
Best simple cycle found so far by most_negative_cycle_bounded().
Definition at line 1408 of file Negative_Cycles.H.
|
inline |
Prepare the rounding filter for cycles of at most L arcs.
| [in] | ig | Indexed graph searched. |
| [in] | L | Largest length of an offered cycle. |
Definition at line 1419 of file Negative_Cycles.H.
References Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::error_, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_sums_, and Aleph::negative_cycles_detail::short_sums_are_exact().
|
inline |
Keep the cycle of length arcs candidate[0..length), of plain-sum cost c, if it is cheaper than the best so far, or equally cheap with fewer arcs.
With floating-point costs "cheaper" compares the exact sums of the weights, so rounding cannot rank the candidates in the wrong order. When every sum of at most L weights is exact, the plain sums already are; otherwise a candidate whose plain sum is above the best one's by more than twice the error bound of both is exactly worse and is dropped without an exact sum. The tie-break only sees the candidates that are offered, not every simple cycle of the graph. Storing the winner reuses the capacity of arcs.
Definition at line 1436 of file Negative_Cycles.H.
References Aleph::negative_cycles_detail::Exact_Sum< T >::add(), ah_domain_error_if, Aleph::and, Aleph::negative_cycles_detail::Indexed_Graph< GT, Cost_Type >::arcs, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::arcs, Aleph::negative_cycles_detail::Exact_Sum< T >::clear(), Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::cost, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::difference_, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::error_, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_best_, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_candidate_, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_sums_, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::found, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::reject_above_, Aleph::negative_cycles_detail::Exact_Sum< T >::sign(), Aleph::Array< T >::size(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::store().
Referenced by Aleph::negative_cycles_detail::offer_simple_components().
|
inlineprivate |
Definition at line 1475 of file Negative_Cycles.H.
References Aleph::Array< T >::append(), Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::arcs, Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::cost, Aleph::Array< T >::empty(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::found.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().
| Array<size_t> Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::arcs |
Definition at line 1412 of file Negative_Cycles.H.
Referenced by Aleph::most_negative_cycle_bounded(), Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::store().
| Cost_Type Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::cost = Cost_Type{0} |
Definition at line 1411 of file Negative_Cycles.H.
Referenced by Aleph::most_negative_cycle_bounded(), Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::store().
|
private |
Definition at line 1493 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().
|
private |
Definition at line 1488 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::Best_Cycle(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().
|
private |
Definition at line 1491 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().
|
private |
Definition at line 1492 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().
|
private |
Definition at line 1487 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::Best_Cycle(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().
| bool Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::found = false |
Definition at line 1410 of file Negative_Cycles.H.
Referenced by Aleph::most_negative_cycle_bounded(), Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer(), and Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::store().
|
private |
Definition at line 1489 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer().