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

The warm starts of the algorithms of LEMON and the solvers of ADS that use them, beyond the book (see Interoperation with LEMON). More...

#include "ADS/Contract.h"
#include "ADS/Modification.h"
#include "ADS/graph/MaxFlow.h"
#include "ADS/graph/Reoptimization.h"
#include "ADS/graph/ShortestPaths.h"
#include <lemon/core.h>
#include <lemon/network_simplex.h>
#include <lemon/preflow.h>
#include <lemon/smart_graph.h>
#include <cstddef>
#include <memory>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

class  ADS::lemon_interop::PreflowEngine
 the engine of MaxFlowObserver on the Preflow of LEMON, with its warm start from the flow of the network More...
class  ADS::lemon_interop::NetworkSimplexAssignment< W >
 an engine of Assignment on the NetworkSimplex of LEMON, warm after changes of finite costs More...
class  ADS::lemon_interop::MinCostFlowObserver< GR, A, CM, UM, SM >
 a minimum cost flow of a digraph of LEMON by the algorithm A, kept up to date as an observer of the maps of its costs, upper bounds and supplies, and of the taps of its arcs and nodes More...

Namespaces

namespace  ADS
namespace  ADS::lemon_interop

Detailed description

The warm starts of the algorithms of LEMON and the solvers of ADS that use them, beyond the book (see Interoperation with LEMON).

LEMON has no warm start of its minimum cost flows and of its maximum flow: they are written, with ADS_WITH_LEMON, into private copies of six of its headers (network_simplex.h, cost_scaling.h, cycle_canceling.h, capacity_scaling.h, bits/mcf_feasible_flow.h, preflow.h), rewritten at configure time by the rules of ADS/interop/lemon/shim/rewrites.txt and put on the include path before LEMON, which defines ADS_LEMON_SHIM. Each rule is header|anchor|what, the anchor a whole line of the header of LEMON that must be there exactly once, or the rewrite stops, and what a block inserted before the line, a text appended to it or a line in its place. They add:

  • runWarm() to NetworkSimplex, from the basis of the last run, whose potentials are computed again after a change of the costs and whose tree flow is computed again after a change of the upper bounds or of the supplies, a subtree whose flow no longer fits being hung from the root by its artificial arc; to CostScaling and CycleCanceling, from the flow of the last run put within the new bounds and made to meet the new supplies by feasibleFlow(), which starts from it, the scaling of the first starting from the largest violation of the optimality conditions under the potentials of the last run; to CapacityScaling, from the flow of the last run at the bound that its reduced cost under the last potentials says, the excess sent by the shortest augmenting paths. A change of the lower bounds, of the supply type, of the digraph or of all the parameters drops the warm start, and runWarm() then does what run() does;
  • warmCost( a , c ), warmUpper( a , u ) and warmSupply( n , s ), the changes of one arc or of one node in \( O( 1 ) \) time, which the map setters do in \( \Theta( m ) \) by a scan of the arcs, and warmReady(), whether runWarm() has a last run to start from;
  • initWarm( flow ) and runWarm() to Preflow: the flow given (the last one, for runWarm()) put within the capacities, and the deficit left at a node other than the source, after a capacity fell below the flow of its arc, moved forward along the arcs that carry flow out of it, until only the source has one; the excesses left at the tails are those that the two phases send on. init( flow ) of LEMON refuses such a flow.

A program must see one rewritten copy of each of these headers: two different rewrites of one header in one binary give two layouts of one class, a violation of the one definition rule that compilers do not diagnose. The same holds for a C++20 module of LEMON, which must be built from the rewritten headers.

On these, the solvers of ADS that keep a solution of LEMON warm:

  • PreflowEngine, the engine of MaxFlowObserver [see Reoptimization.h] on the Preflow of LEMON: the network of ADS copied into a SmartDigraph once, its new edges appended, the capacities and the flow of the network read in \( \Theta( m ) \), a warm run, and the flow written back by FlowNetwork::assignFlow(). The push-relabel of ADS stays the default engine of the observer;
  • NetworkSimplexAssignment< W >, an engine of Assignment [see Assignment.h] on the NetworkSimplex of LEMON, the rows of supply 1, the columns of demand 1 and an arc for each finite cost: after changes of finite costs alone, one warmCost() per pair and runWarm(), and a new solve when a pair is forbidden or allowed again; the potentials of LEMON, \( c( i , j ) + \pi( r_i ) - \pi( b_j ) \ge 0 \), give \( u_i = - \pi( r_i ) \) and \( v_j = \pi( b_j ) \);
  • MinCostFlowObserver< GR , A , CM , UM , SM >, a minimum cost flow of a digraph of LEMON by the algorithm A (NetworkSimplex by default, or CostScaling, CycleCanceling, CapacityScaling), kept up to date as an observer of the ObservedMaps of its costs, of its upper bounds and of its supplies (the attributes mod::Cost, mod::Upper, mod::Supply) [see Maps.h], each change given to the algorithm by the setter of its arc or of its node, and of a LemonTap of its arcs or of its nodes [see Observers.h], after whose events the algorithm is reset; solve() runs runWarm(), or run() after a reset, and counts both.

The contracts [see Contract.h]: those of LEMON; the digraph of a MinCostFlowObserver changes only through the taps and the maps observed. The classes are defined in this file.

See also
B. Dezső, A. Jüttner, P. Kovács, LEMON - an open source C++ graph template library, Electronic Notes in Theoretical Computer Science 264(5), 23-45, 2011, doi:10.1016/j.entcs.2011.06.003
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
A. V. Goldberg, R. E. Tarjan, A new approach to the maximum-flow problem, Journal of the ACM 35(4), 921-940, 1988, doi:10.1145/48014.61051
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa