Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
This class does not take ownership of its underlying graph. More...
#include <linear_assignment.h>
Classes | |
class | BipartiteLeftNodeIterator |
Public Types | |
typedef GraphType::NodeIndex | NodeIndex |
typedef GraphType::ArcIndex | ArcIndex |
Public Member Functions | |
LinearSumAssignment (const GraphType &graph, NodeIndex num_left_nodes) | |
LinearSumAssignment (NodeIndex num_left_nodes, ArcIndex num_arcs) | |
LinearSumAssignment (const LinearSumAssignment &)=delete | |
This type is neither copyable nor movable. | |
LinearSumAssignment & | operator= (const LinearSumAssignment &)=delete |
~LinearSumAssignment () | |
void | SetGraph (const GraphType *graph) |
void | SetCostScalingDivisor (CostValue factor) |
operations_research::PermutationCycleHandler< typename GraphType::ArcIndex > * | ArcAnnotationCycleHandler () |
Passes ownership of the cycle handler to the caller. | |
void | OptimizeGraphLayout (GraphType *graph) |
const GraphType & | Graph () const |
Allows tests, iterators, etc., to inspect our underlying graph. | |
NodeIndex | Head (ArcIndex arc) const |
CostValue | ArcCost (ArcIndex arc) const |
void | SetArcCost (ArcIndex arc, CostValue cost) |
Sets the cost of an arc already present in the given graph. | |
bool | FinalizeSetup () |
bool | ComputeAssignment () |
CostValue | GetCost () const |
NodeIndex | NumNodes () const |
Returns the total number of nodes in the given problem. | |
NodeIndex | NumLeftNodes () const |
ArcIndex | GetAssignmentArc (NodeIndex left_node) const |
Returns the arc through which the given node is matched. | |
CostValue | GetAssignmentCost (NodeIndex node) const |
NodeIndex | GetMate (NodeIndex left_node) const |
Returns the node to which the given node is matched. | |
std::string | StatsString () const |
This class does not take ownership of its underlying graph.
Definition at line 225 of file linear_assignment.h.
GraphType::ArcIndex operations_research::LinearSumAssignment< GraphType >::ArcIndex |
Definition at line 228 of file linear_assignment.h.
GraphType::NodeIndex operations_research::LinearSumAssignment< GraphType >::NodeIndex |
Definition at line 227 of file linear_assignment.h.
operations_research::LinearSumAssignment< GraphType >::LinearSumAssignment | ( | const GraphType & | graph, |
NodeIndex | num_left_nodes ) |
Constructor for the case in which we will build the graph incrementally as we discover arc costs, as might be done with any of the dynamic graph representations such as StarGraph or ForwardStarGraph.
Definition at line 964 of file linear_assignment.h.
operations_research::LinearSumAssignment< GraphType >::LinearSumAssignment | ( | NodeIndex | num_left_nodes, |
ArcIndex | num_arcs ) |
Constructor for the case in which the underlying graph cannot be built until after all the arc costs are known, as is the case with ForwardStarStaticGraph. In this case, the graph is passed to us later via the SetGraph() method, below.
Definition at line 987 of file linear_assignment.h.
|
delete |
This type is neither copyable nor movable.
|
inline |
Definition at line 245 of file linear_assignment.h.
PermutationCycleHandler< typename GraphType::ArcIndex > * operations_research::LinearSumAssignment< GraphType >::ArcAnnotationCycleHandler | ( | ) |
Passes ownership of the cycle handler to the caller.
Returns a permutation cycle handler that can be passed to the TransformToForwardStaticGraph method so that arc costs get permuted along with arcs themselves.
Passes ownership of the cycle handler to the caller.
Definition at line 1085 of file linear_assignment.h.
|
inline |
Returns the original arc cost for use by a client that's iterating over the optimum assignment.
Definition at line 294 of file linear_assignment.h.
bool operations_research::LinearSumAssignment< GraphType >::ComputeAssignment | ( | ) |
Computes the optimum assignment. Returns true on success. Return value of false implies the given problem is infeasible.
Definition at line 1451 of file linear_assignment.h.
bool operations_research::LinearSumAssignment< GraphType >::FinalizeSetup | ( | ) |
Completes initialization after the problem is fully specified. Returns true if we successfully prove that arithmetic calculations are guaranteed not to overflow. ComputeAssignment() calls this method itself, so only clients that care about obtaining a warning about the possibility of arithmetic precision problems need to call this method explicitly.
Separate from ComputeAssignment() for white-box testing and for clients that need to react to the possibility that arithmetic overflow is not ruled out.
FinalizeSetup() is idempotent.
epsilon_ must be greater than kMinEpsilon so that in the case where the largest arc cost is zero, we still do a Refine() iteration.
Initialize left-side node-indexed arrays and check incidence precondition.
Initialize right-side node-indexed arrays. Example: prices are stored only for right-side nodes.
Definition at line 1391 of file linear_assignment.h.
|
inline |
Returns the arc through which the given node is matched.
Definition at line 341 of file linear_assignment.h.
|
inline |
Returns the cost of the assignment arc incident to the given node.
Definition at line 348 of file linear_assignment.h.
CostValue operations_research::LinearSumAssignment< GraphType >::GetCost | ( | ) | const |
Returns the cost of the minimum-cost perfect matching. Precondition: success_ == true, signifying that we computed the optimum assignment for a feasible problem.
It is illegal to call this method unless we successfully computed an optimum assignment.
Definition at line 1476 of file linear_assignment.h.
|
inline |
Returns the node to which the given node is matched.
Definition at line 353 of file linear_assignment.h.
|
inline |
Allows tests, iterators, etc., to inspect our underlying graph.
Definition at line 284 of file linear_assignment.h.
|
inline |
These handy member functions make the code more compact, and we expose them to clients so that client code that doesn't have direct access to the graph can learn about the optimum assignment once it is computed.
Definition at line 290 of file linear_assignment.h.
|
inline |
Returns the number of nodes on the left side of the given problem.
Definition at line 338 of file linear_assignment.h.
|
inline |
Returns the total number of nodes in the given problem.
Return a guess that must be true if ultimately we are given a feasible problem to solve.
Definition at line 326 of file linear_assignment.h.
|
delete |
void operations_research::LinearSumAssignment< GraphType >::OptimizeGraphLayout | ( | GraphType * | graph | ) |
Optimizes the layout of the graph for the access pattern our implementation will use.
REQUIRES for LinearSumAssignment template instantiation if a call to the OptimizeGraphLayout() method is compiled: GraphType is a dynamic graph, i.e., one that implements the GroupForwardArcsByFunctor() member template method.
If analogous optimization is needed for LinearSumAssignment instances based on static graphs, the graph layout should be constructed such that each node's outgoing arcs are sorted by head node index before the LinearSumAssignment<GraphType>::SetGraph() method is called.
The graph argument is only to give us a non-const-qualified handle on the graph we already have. Any different graph is nonsense.
Definition at line 1091 of file linear_assignment.h.
void operations_research::LinearSumAssignment< GraphType >::SetArcCost | ( | ArcIndex | arc, |
CostValue | cost ) |
Sets the cost of an arc already present in the given graph.
Definition at line 1010 of file linear_assignment.h.
|
inline |
Sets the cost-scaling divisor, i.e., the amount by which we divide the scaling parameter on each iteration.
Definition at line 257 of file linear_assignment.h.
|
inline |
Sets the graph used by the LinearSumAssignment instance, for use when the graph layout can be determined only after arc costs are set. This happens, for example, when we use a ForwardStarStaticGraph.
Definition at line 250 of file linear_assignment.h.
|
inline |
Definition at line 360 of file linear_assignment.h.