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

Best simple cycle found so far by most_negative_cycle_bounded(). More...

#include <Negative_Cycles.H>

Collaboration diagram for Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >:
[legend]

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_
 

Detailed Description

template<typename Cost_Type>
struct Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >

Best simple cycle found so far by most_negative_cycle_bounded().

Definition at line 1408 of file Negative_Cycles.H.

Constructor & Destructor Documentation

◆ Best_Cycle()

template<typename Cost_Type >
template<AlephGraph GT>
Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::Best_Cycle ( const Indexed_Graph< GT, Cost_Type > &  ig,
const size_t  L 
)
inline

Prepare the rounding filter for cycles of at most L arcs.

Parameters
[in]igIndexed graph searched.
[in]LLargest 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().

Member Function Documentation

◆ offer()

template<typename Cost_Type >
template<AlephGraph GT>
void Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::offer ( const Indexed_Graph< GT, Cost_Type > &  ig,
const Cost_Type &  c,
const size_t *  candidate,
const size_t  length 
)
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().

◆ store()

Member Data Documentation

◆ arcs

◆ cost

◆ difference_

template<typename Cost_Type >
Exact_Sum<Cost_Type> Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::difference_
private

◆ error_

template<typename Cost_Type >
Cost_Type Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::error_ = Cost_Type{0}
private

◆ exact_best_

template<typename Cost_Type >
Exact_Sum<Cost_Type> Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_best_
private

◆ exact_candidate_

template<typename Cost_Type >
Exact_Sum<Cost_Type> Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_candidate_
private

◆ exact_sums_

template<typename Cost_Type >
bool Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::exact_sums_ = true
private

◆ found

◆ reject_above_

template<typename Cost_Type >
Cost_Type Aleph::negative_cycles_detail::Best_Cycle< Cost_Type >::reject_above_ = Cost_Type{0}
private

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