|
ADS
Algorithms and Data Structures
|
The solutions that follow the changes of a graph, beyond the book: the observers of an Observable [see Observable.h] that keep the tree of the shortest paths from a node, the minimum spanning forest and the maximum flow between two nodes, each together with a certificate of its optimality, so that after a change they can often prove at once that the solution is still optimal, and otherwise repair it or compute it again by the algorithms of the book [see ShortestPaths.h, MinimumSpanningTree.h, MaxFlow.h]. More...
#include "ADS/Contract.h"#include "ADS/graph/Assignment.h"#include "ADS/graph/Graph.h"#include "ADS/graph/MaxFlow.h"#include "ADS/graph/MinimumSpanningTree.h"#include "ADS/graph/Observable.h"#include "ADS/graph/ShortestPaths.h"#include "ADS/tree/LinkCutTree.h"#include <concepts>#include <cstddef>#include <cstdint>#include <optional>#include <set>#include <span>#include <type_traits>#include <unordered_map>#include <utility>#include <vector>#include "ADS/graph/impl/Reoptimization.tpp"Go to the source code of this file.
Classes | |
| class | ADS::EventQueue< W, P > |
| the queue of the events, the recompute policy P [see ReoptPolicy] and the counts that the observers share More... | |
| class | ADS::ShortestPathsObserver< G, P > |
| the shortest paths from \( r \) in \( g \), kept up to date, by the recompute policy P More... | |
| class | ADS::SpanningForestObserver< G, P > |
| the minimum spanning forest of an unoriented \( g \), kept up to date, by the recompute policy P More... | |
| struct | ADS::AugmentEngine |
| the engine of ADS, both solves by the augmentations how of FlowNetwork::maxFlow() [see MaxFlow.h] More... | |
| 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 More... | |
| 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] More... | |
Namespaces | |
| namespace | ADS |
Concepts | |
| concept | ADS::Reoptimizable |
| a solution that follows the events of weights W | |
| concept | ADS::FlowEngine |
| the engines of the solves of a MaxFlowObserver, objects that the observer keeps: scratch( net , s , t , how ) gives the value of a maximum flow of net from the zero flow, and warm( net , s , t , how ,
v ) that of a maximum flow from the flow that net keeps, of value \( v \) before the capacities changed (a capacity cut below its flow leaving the excess and the deficit that FlowNetwork::maxFlow() routes first); each leaves a maximum flow in net, whose minimum cut the observer reads. | |
The solutions that follow the changes of a graph, beyond the book: the observers of an Observable [see Observable.h] that keep the tree of the shortest paths from a node, the minimum spanning forest and the maximum flow between two nodes, each together with a certificate of its optimality, so that after a change they can often prove at once that the solution is still optimal, and otherwise repair it or compute it again by the algorithms of the book [see ShortestPaths.h, MinimumSpanningTree.h, MaxFlow.h].
The certificates, the tests of the events against them and the reasons of the costs are in Changes of the graph and reoptimization.
An observer models the concept Reoptimizable: apply( e ) and apply( s ) give it one event or a span of them (notify() is the same, for the Observable), solve() brings the solution up to date, and outcome() tells how the last solve() with events to apply did it, i.e., Reopt::SCRATCH (0) by the algorithm of the book, Reopt::WARM (1) by repairing the previous solution, and Reopt::CERTIFIED (2) with no computation at all. The events are queued and the work is done at the next query, i.e., solve() or any read of the solution: the queue is coalesced, and if the recompute policy of the observer says so [see ReoptPolicy of Modification.h; by default RatioPolicy, i.e., when its net events exceed \( \rho \max( m , 1 ) \), \( \rho \) of setRecomputeRatio(), \( 1 / 4 \) by default] the solution is computed from scratch, else each event is tested against the certificate in \( O( 1 ) \) (in \( O( \log n ) \) for the forest), and by Lemma 13 of Changes of the graph and reoptimization the events all harmless prove the solution still optimal. A repair may be abandoned by the policy for one from scratch, on its work counted in nodes, edges or extractions (never a time), and each observer counts its queries by cause (byCause(), the causes of Reopt); the default policy decides as the fixed thresholds of the observers did (Lemma 16 of The recompute policy of the observers), and a computation from scratch in place of a repair is always correct (Lemma 17). An observer that gets Rebuilt (which a batch sends instead of its events when the policy asks it at the close, with RatioPolicy::early) forgets its queue, takes no event until its next query, and computes the solution from scratch there. The shortest paths are repaired after the raises and the deletions of the edges of the tree as well as after the decreases, on the subtrees whose distances are lost (Lemma 14 of Changes of the graph and reoptimization). The maximum flow starts again from the flow there is when an edge of the minimum cut grows, and when a capacity falls below the flow of its edge, after its excess and its deficit are routed [see FlowNetwork::setCapacity()], by the augmenting paths or by the push-relabel: a warm start that the maximum flow of OR-Tools leaves to do.
The contracts [see Contract.h]: the root, and the source and the sink, stay nodes of the graph; the graph of SpanningForestObserver is unoriented; the capacities are nonnegative integers; the observer reads the graph it was built on, which must be the graph of the Observable that sends it the events (or one changed in the same way). At the level of the audits each solve() checks its result: the conditions of Bellman by isShortestPathTree(), the forest by isMinimumSpanningForest() on the graphs of at most 2000 edges, and its total weight within \( 10^{-9} \) times the sum of the absolute weights (exactly, on exact weights), and \( | f | = c( S , V \setminus S ) \) on the graph. The operations are defined in Reoptimization.tpp.