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

the assignment of least cost of the \( k \) rows \( 0 , \ldots , k - 1 \) of \( g \) to its \( k \) columns \( k , \ldots , 2 k - 1 \), the weights of the edges between them the costs, kept up to date [see Assignment.h] More...

#include <ADS/graph/Reoptimization.h>

Inheritance diagram for ADS::AssignmentObserver< G, P >:
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

 AssignmentObserver (const G &g, int k)
 the assignment of the \( k \) rows of \( g \), computed at the first query; a pair with no edge is forbidden
void solve (void)
 brings the assignment up to date
Assignment< Weight > & assignment (void)
 the assignment, up to date
int partner (int i)
 the column, in \( [ k , 2 k ) \), of the row \( i \), \( -1 \) if none
Weight total (void)
 the total cost of the assignment
P & policy (void)
 the recompute policy, that of the Assignment, which weighs the events only through the rows and the columns that they touch
const P & policy (void) const
 the recompute policy
ReoptStats reoptStats (std::size_t k) const
 the statistics of a query after \( k \) more events, for the policy: the events queued and the \( k^2 \) costs
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>
requires std::is_arithmetic_v< typename G::Weight >
class ADS::AssignmentObserver< G, P >

the assignment of least cost of the \( k \) rows \( 0 , \ldots , k - 1 \) of \( g \) to its \( k \) columns \( k , \ldots , 2 k - 1 \), the weights of the edges between them the costs, kept up to date [see Assignment.h]

Member typedef documentation

◆ Weight

template<Graph G, ReoptPolicy P = RatioPolicy>
using ADS::AssignmentObserver< G, P >::Weight = typename G::Weight

the type of the weights

Constructor and destructor documentation

◆ AssignmentObserver()

template<Graph G, ReoptPolicy P = RatioPolicy>
ADS::AssignmentObserver< G, P >::AssignmentObserver ( const G & g,
int k )

the assignment of the \( k \) rows of \( g \), computed at the first query; a pair with no edge is forbidden

Precondition
\( k \ge 0 \), the nodes of \( g \) are \( 0 , \ldots , 2 k - 1 \), each edge between a row and a column

Member function documentation

◆ assignment()

template<Graph G, ReoptPolicy P = RatioPolicy>
Assignment< Weight > & ADS::AssignmentObserver< G, P >::assignment ( void )
inlinenodiscard

the assignment, up to date

◆ partner()

template<Graph G, ReoptPolicy P = RatioPolicy>
int ADS::AssignmentObserver< G, P >::partner ( int i)
inlinenodiscard

the column, in \( [ k , 2 k ) \), of the row \( i \), \( -1 \) if none

Precondition
\( i \in [ 0 , k ) \)

◆ policy() [1/2]

template<Graph G, ReoptPolicy P = RatioPolicy>
P & ADS::AssignmentObserver< G, P >::policy ( void )
inlinenodiscard

the recompute policy, that of the Assignment, which weighs the events only through the rows and the columns that they touch

◆ policy() [2/2]

template<Graph G, ReoptPolicy P = RatioPolicy>
const P & ADS::AssignmentObserver< G, P >::policy ( void ) const
inlinenodiscard

the recompute policy

◆ reoptStats()

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

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

◆ solve()

template<Graph G, ReoptPolicy P = RatioPolicy>
void ADS::AssignmentObserver< G, P >::solve ( void )

brings the assignment up to date

In pseudocode (beyond the book), the events \( P \) coalesced given to the Assignment [see Assignment::solve()]:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{solve}() \cr 2 & \quad \textbf{if}\ \mathrm{Rebuilt}\ \text{came}\ \textbf{then} \ \text{every row of } c \text{ again from } g \cr 3 & \quad \textbf{foreach}\ ( i , k + j ) \text{ from } w \text{ to } w' \text{ in } P\ \textbf{do}\ c( i , j ) \gets w' \text{, or } \infty \text{ if deleted} \cr 4 & \quad A.\mathrm{solve}() \end{array}} \]

◆ total()

template<Graph G, ReoptPolicy P = RatioPolicy>
Weight ADS::AssignmentObserver< G, P >::total ( void )
inlinenodiscard

the total cost of the assignment


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