ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
MaterializedAggregate.h File Reference

The aggregate of a structure kept by its events, beyond the book: MaterializedAggregate< G , Period > is an observer [see Modification.h] of a dictionary whose handles are its keys (as those of JoinTree), which keeps the combination by the commutative monoid G [see Augmentation in JoinTree.h] of the values \( \mathrm{from}( k , v ) \) of its pairs, from the events Inserted, Erased, Assigned, Cleared and Rebuilt, and gives it by value(). More...

#include "ADS/Algebra.h"
#include "ADS/Contract.h"
#include "ADS/Modification.h"
#include "ADS/tree/JoinTree.h"
#include <cmath>
#include <concepts>
#include <cstddef>
#include <set>
#include <type_traits>
#include "ADS/tree/impl/MaterializedAggregate.tpp"

Go to the source code of this file.

Classes

class  ADS::MaterializedAggregate< G, Period >
 the combination by the commutative monoid G of the values of the pairs of a dictionary, kept by its events; for an abelian group of inexact values, recomputed from the structure bound every Period changes More...

Namespaces

namespace  ADS

Detailed description

The aggregate of a structure kept by its events, beyond the book: MaterializedAggregate< G , Period > is an observer [see Modification.h] of a dictionary whose handles are its keys (as those of JoinTree), which keeps the combination by the commutative monoid G [see Augmentation in JoinTree.h] of the values \( \mathrm{from}( k , v ) \) of its pairs, from the events Inserted, Erased, Assigned, Cleared and Rebuilt, and gives it by value().

How an event updates the aggregate is decided by the algebra of G at compile time (see Aggregates that change). When G is an abelian group (the static members commutative and inverse()), an insertion combines the aggregate with the new value, an erasure with the inverse of the old one, an assignment with both, each in \( O( 1 ) \) combinations and no memory beyond the aggregate. When G is selective (the static member selective: the combination of two values is one of them, as the maximum), the observer keeps the multiset of the values ordered by G, whose first is the aggregate, in \( O( \log m ) \) per event for \( m \) pairs. Otherwise an insertion combines, and an erasure or an assignment marks the aggregate stale, recomputed at the next value() from the structure given to bind(), in \( O( m ) \).

Rebuilt marks the aggregate stale, Cleared makes it the identity. For an abelian group of inexact values (a floating type), the differences accumulate rounding errors, and the aggregate is marked stale every Period changes (never if 0), so that the next value() recomputes it from the structure bound, which bounds the drift; audit() compares the aggregate with the one recomputed from a structure, by equality for exact values and within a relative tolerance for inexact ones, and is called by the subject at the level of the audits.

The contracts [see Contract.h]: value() of a stale aggregate needs a structure bound; the structure bound outlives the observer, or is bound again; on() of Erased, Cleared and Rebuilt does not throw, which needs a combine() and an order of G that do not throw.

See also
A. Frangioni, A. Manca, A computational study of cost reoptimization for min-cost flow problems, INFORMS Journal on Computing 18(1), 61-70, 2006, doi:10.1287/ijoc.1040.0081 (the audit of an incremental computation by one from scratch)
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa