Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <assignment.h>
Public Types | |
enum | Status { OPTIMAL , INFEASIBLE , POSSIBLE_OVERFLOW } |
Public Member Functions | |
SimpleLinearSumAssignment () | |
SimpleLinearSumAssignment (const SimpleLinearSumAssignment &)=delete | |
This type is neither copyable nor movable. | |
SimpleLinearSumAssignment & | operator= (const SimpleLinearSumAssignment &)=delete |
ArcIndex | AddArcWithCost (NodeIndex left_node, NodeIndex right_node, CostValue cost) |
NodeIndex | NumNodes () const |
ArcIndex | NumArcs () const |
Returns the current number of arcs in the graph. | |
NodeIndex | LeftNode (ArcIndex arc) const |
NodeIndex | RightNode (ArcIndex arc) const |
CostValue | Cost (ArcIndex arc) const |
Status | Solve () |
CostValue | OptimalCost () const |
NodeIndex | RightMate (NodeIndex left_node) const |
CostValue | AssignmentCost (NodeIndex left_node) const |
Definition at line 57 of file assignment.h.
Solves the problem (finds the perfect matching that minimizes the cost) and returns the solver status.
Enumerator | |
---|---|
OPTIMAL | |
INFEASIBLE | |
POSSIBLE_OVERFLOW |
Definition at line 95 of file assignment.h.
operations_research::SimpleLinearSumAssignment::SimpleLinearSumAssignment | ( | ) |
The constructor takes no size. New node indices will be created lazily by AddArcWithCost().
Definition at line 25 of file assignment.cc.
|
delete |
This type is neither copyable nor movable.
ArcIndex operations_research::SimpleLinearSumAssignment::AddArcWithCost | ( | NodeIndex | left_node, |
NodeIndex | right_node, | ||
CostValue | cost ) |
Adds an arc from a left node to a right node with a given cost.
Definition at line 27 of file assignment.cc.
|
inline |
Returns the cost of the arc used for "left_node"'s assignment. This works only if Solve() returned OPTIMAL.
Definition at line 121 of file assignment.h.
Definition at line 51 of file assignment.cc.
Returns user-provided data. The implementation will crash if "arc" is not in [0, NumArcs()).
Definition at line 43 of file assignment.cc.
ArcIndex operations_research::SimpleLinearSumAssignment::NumArcs | ( | ) | const |
Returns the current number of arcs in the graph.
Definition at line 41 of file assignment.cc.
NodeIndex operations_research::SimpleLinearSumAssignment::NumNodes | ( | ) | const |
Returns the current number of left nodes which is the same as the number of right nodes. This is one greater than the largest node index seen so far in AddArcWithCost().
Definition at line 39 of file assignment.cc.
|
delete |
|
inline |
Returns the cost of an assignment with minimal cost. This is 0 if the last Solve() didn't return OPTIMAL.
Definition at line 104 of file assignment.h.
|
inline |
Returns the right node assigned to the given left node in the last solution computed by Solve(). This works only if Solve() returned OPTIMAL.
Definition at line 115 of file assignment.h.
Definition at line 47 of file assignment.cc.
SimpleLinearSumAssignment::Status operations_research::SimpleLinearSumAssignment::Solve | ( | ) |
HACK(user): Detect overflows early. In ./linear_assignment.h, the cost of each arc is internally multiplied by cost_scaling_factor_ (which is equal to (num_nodes + 1)) without overflow checking.
Definition at line 55 of file assignment.cc.