Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Public Member Functions | |
HungarianOptimizer (absl::Span< const std::vector< double > > costs) | |
Setup the initial conditions for the algorithm. | |
void | Maximize (std::vector< int > *preimage, std::vector< int > *image) |
void | Minimize (std::vector< int > *preimage, std::vector< int > *image) |
Like Maximize(), but minimizing the cost instead. | |
Definition at line 28 of file hungarian.cc.
|
explicit |
Setup the initial conditions for the algorithm.
Parameters: costs is a matrix of the cost of assigning each agent to each task. costs[i][j] is the cost of assigning agent i to task j. All the costs must be non-negative. This matrix does not have to be square (i.e. we can have different numbers of agents and tasks), but it must be regular (i.e. there must be the same number of entries in each row of the matrix).
Generate the expanded cost matrix by adding extra 0-valued elements in order to make a square matrix. At the same time, find the greatest cost in the matrix (used later if we want to maximize rather than minimize the overall cost.)
Initially, none of the cells of the matrix are marked.
Definition at line 207 of file hungarian.cc.
void operations_research::HungarianOptimizer::Maximize | ( | std::vector< int > * | preimage, |
std::vector< int > * | image ) |
Find an assignment which maximizes the total cost. Returns the assignment in the two vectors passed as argument. preimage[i] is assigned to image[i].
Find an assignment which maximizes the total cost. Return an array of pairs of integers. Each pair (i, j) corresponds to assigning agent i to task j.
Find a maximal assignment by subtracting each of the original costs from max_cost_ and then minimizing.
Definition at line 273 of file hungarian.cc.
void operations_research::HungarianOptimizer::Minimize | ( | std::vector< int > * | preimage, |
std::vector< int > * | image ) |
Like Maximize(), but minimizing the cost instead.
Find an assignment which minimizes the total cost. Return an array of pairs of integers. Each pair (i, j) corresponds to assigning agent i to task j.
Definition at line 288 of file hungarian.cc.