|
ADS
Algorithms and Data Structures
|
The assignment problem, beyond the book: given the costs \( c( i , j ) \) of \( n \) rows and \( n \) columns (the workers and the tasks, the left and the right side of a complete bipartite graph), a perfect matching of the rows to the columns of least total cost, a cost infinity() [see ShortestPaths.h] forbidding its pair. More...
#include "ADS/Contract.h"#include "ADS/Modification.h"#include "ADS/graph/ShortestPaths.h"#include <concepts>#include <cstddef>#include <type_traits>#include <utility>#include <variant>#include <vector>#include "ADS/graph/impl/Assignment.tpp"Go to the source code of this file.
Classes | |
| class | ADS::Assignment< W, P, E > |
| an assignment of least cost of \( n \) rows to \( n \) columns, kept optimal after the changes of the costs, by the code of ADS or, if E is not void, by the engine E More... | |
Namespaces | |
| namespace | ADS |
Concepts | |
| concept | ADS::AssignmentEngine |
| the engines of the solves of an Assignment, objects that it keeps: solve( n , C , all , D , col , u , v ) gives an optimal assignment of the costs \( C \) by rows, infinity() forbidding a pair, in col (the column of each row) and its potentials in \( u \) and \( v \), every reduced cost \( c( i , j ) - u_i - v_j \) of a finite cost nonnegative and those of the pairs zero; \( D \) holds the pairs whose cost changed since the last solve, or all is true when anything may have. | |
The assignment problem, beyond the book: given the costs \( c( i , j ) \) of \( n \) rows and \( n \) columns (the workers and the tasks, the left and the right side of a complete bipartite graph), a perfect matching of the rows to the columns of least total cost, a cost infinity() [see ShortestPaths.h] forbidding its pair.
Assignment< W > solves it by the Hungarian method of Kuhn in the form of the shortest augmenting paths (Jonker and Volgenant, Crouse), in \( O( n^3 ) \), and keeps it optimal after the changes of the costs (see The assignment and its reoptimization): a change of a row or of a column frees one pair, restores the feasibility of the dual by a single potential and augments once, in \( O( n^2 ) \), which is the incremental Hungarian algorithm of Toroslu and Üçoluk, and the dynamic one of Mills-Tettey, Stentz and Dias for the costs that change. A change of a single cost that leaves its reduced cost nonnegative off the matching, or that raises a cost off it, costs \( O( 1 ) \).
The changes are queued by setCost(), setRow() and setColumn(), and worked at the next query, as the observers of Reoptimization.h do, which hold the same counts of the outcomes and of their causes [see Reopt]; the scratch when more than half of the rows and the columns changed is the abandon() of the recompute policy P [see RatioPolicy, with \( \alpha = 1 / 2 \) against the \( n \) rows that a scratch frees]; the observer AssignmentObserver of Reoptimization.h keeps an assignment on the weights of a bipartite graph that changes. The libraries of graphs solve the assignment from scratch (LEMON by its minimum cost flows, SciPy by the algorithm of Crouse), and none keeps the duals for a warm start.
With ADS_WITH_LEMON and a LEMON that has MinCostAssignment (abLEMON) [see Interoperation with LEMON], the solve from scratch of a signed W is delegated to it, on a copy of the finite costs in a lemon::SmartBpGraph, and its matching and its potentials, \( u_i = -\pi( r_i ) \) and \( v_j = \pi( b_j ) \), become those of the assignment, from which the warm repair of ADS goes on; when it finds no perfect matching, the code of ADS solves again. ADS_ASSIGNMENT_LEMON defined to 0 keeps the code of ADS.
The contracts [see Contract.h]: \( n \ge 0 \), the rows and the columns in \( [ 0 , n ) \), the costs finite or infinity(); at the level of the audits each solve() checks the duals: every reduced cost \( c( i , j ) - u_i - v_j \) of a finite cost nonnegative, and zero on the pairs of the assignment. The operations are defined in Assignment.tpp.