|
ADS
Algorithms and Data Structures
|
the queue of the events, the recompute policy P [see ReoptPolicy] and the counts that the observers share More...
#include <ADS/graph/Reoptimization.h>
Public types | |
| using | Event = GraphEvent< W > |
| the type of the events | |
| using | Policy = P |
| the type of the policy | |
Public member functions | |
| void | apply (const Event &e) |
| queues \( e \), unless Rebuilt came since the last query | |
| void | apply (std::span< const Event > s) |
| queues the events of \( s \), unless Rebuilt came | |
| void | notify (const Event &e) |
| apply( e ), for the Observable | |
| void | notify (std::span< const Event > s) |
| apply( s ), 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 | |
| const P & | policy (void) const |
| the recompute policy | |
| void | setRecomputeRatio (double ratio) |
| from scratch when the events coalesced exceed \( \mathit{ratio} \) times the edges: \( \rho \) of the policy | |
Static public member functions | |
| static constexpr unsigned | mask (void) |
| all the kinds of event | |
Protected member functions | |
| 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 | |
| static ReoptStats | stats (std::size_t k, long long m) |
| the statistics of \( k \) events on \( m \) edges | |
Protected attributes | |
| std::vector< Event > | f_q |
| the events queued | |
| P | f_policy {} |
| the recompute policy | |
| bool | f_stale = false |
| whether Rebuilt came | |
| int | f_outcome = Reopt::SCRATCH |
| the last outcome | |
| int | f_cause = Reopt::SCRATCH_BY_EVENT |
| the last cause | |
| long long | f_count [3] = { 0 , 0 , 0 } |
| the solves by outcome | |
| long long | f_byCause [Reopt::CAUSES] = {} |
| the solves by cause | |
the queue of the events, the recompute policy P [see ReoptPolicy] and the counts that the observers share
In pseudocode (beyond the book; Lemma 13 of Changes of the graph and reoptimization and Lemma 17 of The recompute policy of the observers prove it correct), the query of every observer, with \( Q \) the queue and \( p \) the policy:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{solve}() \cr 2 & \quad \textbf{if}\ \text{there is no solution yet, or } \mathrm{Rebuilt}\ \text{came}\ \textbf{then} \ \text{compute it from scratch};\ \textbf{return} \cr 3 & \quad P \gets \mathrm{coalesce}( Q );\ Q \gets \emptyset \cr 4 & \quad \textbf{if}\ p.\mathrm{scratch}( |P| , m )\ \textbf{then} \ \text{compute from scratch};\ \textbf{return} \cr 5 & \quad \textbf{foreach}\ e \in P\ \textbf{do}\ \text{test } e \text{ against the certificate} \cr 6 & \quad \textbf{if}\ \text{an event is fatal, or } p.\mathrm{abandon}( \text{the work})\ \textbf{then}\ \text{compute from scratch} \cr 7 & \quad \textbf{else if}\ \text{an event is repairable} \ \textbf{then}\ \text{repair the solution} \cr 8 & \quad \textbf{else}\ \text{keep it, certified} \cr 9 & \quad p.\mathrm{record}( \text{the cause} , \text{the work} ) \end{array}} \]
| using ADS::EventQueue< W, P >::Event = GraphEvent< W > |
the type of the events
| using ADS::EventQueue< W, P >::Policy = P |
the type of the policy
|
inline |
queues \( e \), unless Rebuilt came since the last query
|
inline |
queues the events of \( s \), unless Rebuilt came
|
inlinenodiscard |
the solves of each cause so far
|
inlinenodiscard |
why: the cause of the last outcome [see Reopt]
|
inlinenodiscard |
the solves of each outcome so far
|
inlineprotected |
the cause of a solve() counted and told to the policy with the work \( w \)
|
inlinenodiscardprotected |
whether a solve from scratch is due before any event: no solution yet, or Rebuilt; the queue then emptied
|
inlinestaticnodiscardconstexpr |
all the kinds of event
|
inline |
apply( e ), for the Observable
|
inline |
apply( s ), for the Observable
|
inlinenoexcept |
forgets the queue, and takes no event until the next query, which computes the solution from scratch
|
inlinenodiscard |
how the last solve() with events to apply, or with no solution yet, did it [see Reopt]
|
inlinenodiscard |
the events waiting for the next query
|
inlinenodiscard |
the recompute policy
|
inlinenodiscard |
the recompute policy
|
inline |
from scratch when the events coalesced exceed \( \mathit{ratio} \) times the edges: \( \rho \) of the policy
|
inlinestaticnodiscardprotected |
the statistics of \( k \) events on \( m \) edges
|
inlineprotected |
the queue coalesced, emptied
|
inlineprotected |
the cause of a solve() counted, not told to the policy
|
inlinenodiscardprotected |
whether the policy wants \( k \) events on \( m \) edges from scratch
|
protected |
the solves by cause
|
protected |
the last cause
|
protected |
the solves by outcome
|
protected |
the last outcome
|
protected |
the recompute policy
|
protected |
the events queued
|
protected |
whether Rebuilt came