ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::MaxFlowObserver< G, P, E > Class Template Reference

the maximum flow from \( s \) to \( t \) in \( g \), the weights the capacities, kept up to date, the solves made by the engine E, the augmentations of ADS by default More...

#include <ADS/graph/Reoptimization.h>

Inheritance diagram for ADS::MaxFlowObserver< G, P, E >:
ADS::EventQueue< G::Weight, RatioPolicy >

Public types

using Weight = typename G::Weight
 the type of the weights
Public types inherited from ADS::EventQueue< G::Weight, RatioPolicy >
using Event
 the type of the events
using Policy
 the type of the policy

Public member functions

 MaxFlowObserver (const G &g, int s, int t, Augment how=Augment::DINIC)
 the flow from \( s \) to \( t \) in \( g \), computed by how at the first query
void solve (void)
 brings the flow up to date
long long value (void)
 the value of the maximum flow
const std::vector< bool > & minCut (void)
 the side of \( s \) of a minimum cut
ReoptStats reoptStats (std::size_t k) const
 the statistics of a query after \( k \) more events, for the policy: the events queued and the edges
Public member functions inherited from ADS::EventQueue< G::Weight, RatioPolicy >
void apply (const Event &e)
 queues \( e \), unless Rebuilt came since the last query
void notify (const Event &e)
 apply( e ), for the Observable
void on (const mod::Rebuilt &) noexcept
 forgets the queue, and takes no event until the next query, which computes the solution from scratch
std::size_t pending (void) const
 the events waiting for the next query
int outcome (void) const
 how the last solve() with events to apply, or with no solution yet, did it [see Reopt]
int cause (void) const
 why: the cause of the last outcome [see Reopt]
long long count (int outcome) const
 the solves of each outcome so far
long long byCause (int c) const
 the solves of each cause so far
P & policy (void)
 the recompute policy
void setRecomputeRatio (double ratio)
 from scratch when the events coalesced exceed \( \mathit{ratio} \) times the edges: \( \rho \) of the policy

Additional Inherited Members

Static public member functions inherited from ADS::EventQueue< G::Weight, RatioPolicy >
static constexpr unsigned mask (void)
 all the kinds of event
Protected member functions inherited from ADS::EventQueue< G::Weight, RatioPolicy >
std::vector< Event > take (void)
 the queue coalesced, emptied
bool tooMany (std::size_t k, long long m)
 whether the policy wants \( k \) events on \( m \) edges from scratch
bool fresh (bool ready)
 whether a solve from scratch is due before any event: no solution yet, or Rebuilt; the queue then emptied
void tally (int cause)
 the cause of a solve() counted, not told to the policy
void done (int cause, double w)
 the cause of a solve() counted and told to the policy with the work \( w \)
Static protected member functions inherited from ADS::EventQueue< G::Weight, RatioPolicy >
static ReoptStats stats (std::size_t k, long long m)
 the statistics of \( k \) events on \( m \) edges
Protected attributes inherited from ADS::EventQueue< G::Weight, RatioPolicy >
std::vector< Event > f_q
 the events queued
P f_policy
 the recompute policy
bool f_stale
 whether Rebuilt came
int f_outcome
 the last outcome
int f_cause
 the last cause
long long f_count [3]
 the solves by outcome
long long f_byCause [Reopt::CAUSES]
 the solves by cause

Detailed description

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
requires std::is_integral_v< typename G::Weight >
class ADS::MaxFlowObserver< G, P, E >

the maximum flow from \( s \) to \( t \) in \( g \), the weights the capacities, kept up to date, the solves made by the engine E, the augmentations of ADS by default

Member typedef documentation

◆ Weight

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
using ADS::MaxFlowObserver< G, P, E >::Weight = typename G::Weight

the type of the weights

Constructor and destructor documentation

◆ MaxFlowObserver()

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
ADS::MaxFlowObserver< G, P, E >::MaxFlowObserver ( const G & g,
int s,
int t,
Augment how = Augment::DINIC )

the flow from \( s \) to \( t \) in \( g \), computed by how at the first query

Precondition
\( s \) and \( t \) are distinct nodes of \( g \)

Member function documentation

◆ minCut()

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
const std::vector< bool > & ADS::MaxFlowObserver< G, P, E >::minCut ( void )
inlinenodiscard

the side of \( s \) of a minimum cut

◆ reoptStats()

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
ReoptStats ADS::MaxFlowObserver< G, P, E >::reoptStats ( std::size_t k) const
nodiscard

the statistics of a query after \( k \) more events, for the policy: the events queued and the edges

◆ solve()

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
void ADS::MaxFlowObserver< G, P, E >::solve ( void )

brings the flow up to date

In pseudocode (beyond the book), the tests of the events \( P \) coalesced against the minimum cut \( S \) (by Theorem 5 of Flows, cuts and matchings); a capacity cut below the flow of its edge leaves an excess and a deficit that maxFlow() routes first [see FlowNetwork::setCapacity()]:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{solve}() \cr 2 & \quad \mathit{warm} \gets \textbf{false} \cr 3 & \quad \textbf{foreach}\ ( u , v ) \text{ from } c \text{ to } c' \text{ in } P\ \textbf{do} \cr 4 & \qquad \textbf{if}\ c' < f( u , v )\ \textbf{then}\ \mathit{warm} \gets \textbf{true} \cr 5 & \qquad \textbf{if}\ u \in S \textbf{ and } v \notin S \textbf{ and } c' > c\ \textbf{then}\ \mathit{warm} \gets \textbf{true} \cr 6 & \quad \text{set the capacities of } P \cr 7 & \quad \textbf{if}\ \mathit{warm}\ \textbf{then}\ | f | \gets | f | + \mathrm{maxFlow}( s , t ) \text{ from } f; \ S \gets \mathrm{minCut}( s ) \end{array}} \]

◆ value()

template<Graph G, ReoptPolicy P = RatioPolicy, FlowEngine E = AugmentEngine>
long long ADS::MaxFlowObserver< G, P, E >::value ( void )
inlinenodiscard

the value of the maximum flow


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