Adds an arc from a left node to a right node with a given cost.
* Node indices must be non-negative (>= 0). For a perfect
matching to exist on n nodes, the values taken by "left_node"
must cover [0, n), same for "right_node".
* The arc cost can be any integer, negative, positive or zero.
* After the method finishes, NumArcs() == the returned ArcIndex + 1.
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().
Returns the right node assigned to the given left node in the
last solution computed by Solve(). This works only if Solve()
returned OPTIMAL.
Note: It is possible that there is more than one optimal
solution. The algorithm is deterministic so it will always return
the same solution for a given problem. There is no such guarantee
from one code version to the next, but the code does not change
often.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eSimpleLinearSumAssignment\u003c/code\u003e is a C++ class within the OR-Tools library designed for solving the linear sum assignment problem, finding the minimum cost assignment of agents to tasks.\u003c/p\u003e\n"],["\u003cp\u003eThe class allows adding arcs (connections between agents and tasks) with associated costs using \u003ccode\u003eAddArcWithCost\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSolve()\u003c/code\u003e initiates the optimization process and returns the solution status (e.g., optimal, infeasible).\u003c/p\u003e\n"],["\u003cp\u003ePost-solving, methods like \u003ccode\u003eOptimalCost\u003c/code\u003e, \u003ccode\u003eAssignmentCost\u003c/code\u003e, and \u003ccode\u003eRightMate\u003c/code\u003e provide access to the solution's cost and assigned pairings.\u003c/p\u003e\n"],["\u003cp\u003eNode and arc indices are managed dynamically, with \u003ccode\u003eNumNodes\u003c/code\u003e and \u003ccode\u003eNumArcs\u003c/code\u003e offering information on the problem size.\u003c/p\u003e\n"]]],["The `SimpleLinearSumAssignment` class manages assignments between left and right nodes. Key actions include `AddArcWithCost` to define connections between nodes with associated costs. `NumArcs` and `NumNodes` return the number of arcs and nodes respectively. `Solve` computes an optimal assignment. Results are accessed via `OptimalCost`, `RightMate` (the assigned right node for a left node), and `AssignmentCost` (the cost of the arc used for assignment). Other functions include `Cost`, `LeftNode`, and `RightNode`.\n"],null,["# SimpleLinearSumAssignment\n\nC++ Reference: class SimpleLinearSumAssignment\n==============================================\n\n\nNote: This documentation is automatically generated.\n\n| Method ||\n|------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`AddArcWithCost`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L69) | Return type: `ArcIndex ` Arguments: `NodeIndex left_node, NodeIndex right_node, CostValue cost` Adds an arc from a left node to a right node with a given cost. \\* Node indices must be non-negative (\\\u003e= 0). For a perfect matching to exist on n nodes, the values taken by \"left_node\" must cover \\[0, n), same for \"right_node\". \\* The arc cost can be any integer, negative, positive or zero. \\* After the method finishes, NumArcs() == the returned ArcIndex + 1. |\n| [`AssignmentCost`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L114) | Return type: `CostValue ` Arguments: `NodeIndex left_node` Returns the cost of the arc used for \"left_node\"'s assignment. This works only if Solve() returned OPTIMAL. |\n| [`Cost`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L84) | Return type: `CostValue ` Arguments: `ArcIndex arc` \u003cbr /\u003e |\n| [`LeftNode`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L82) | Return type: `NodeIndex ` Arguments: `ArcIndex arc` Returns user-provided data. The implementation will crash if \"arc\" is not in \\[0, NumArcs()). |\n| [`NumArcs`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L78) | Return type: `ArcIndex ` Returns the current number of arcs in the graph. |\n| [`NumNodes`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L75) | Return type: `NodeIndex ` 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(). |\n| [`OptimalCost`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L97) | Return type: `CostValue ` Returns the cost of an assignment with minimal cost. This is 0 if the last Solve() didn't return OPTIMAL. |\n| [`RightMate`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L108) | Return type: `NodeIndex ` Arguments: `NodeIndex left_node` Returns the right node assigned to the given left node in the last solution computed by Solve(). This works only if Solve() returned OPTIMAL. Note: It is possible that there is more than one optimal solution. The algorithm is deterministic so it will always return the same solution for a given problem. There is no such guarantee from one code version to the next, but the code does not change often. |\n| [`RightNode`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L83) | Return type: `NodeIndex ` Arguments: `ArcIndex arc` \u003cbr /\u003e |\n| [`SimpleLinearSumAssignment`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L61) | The constructor takes no size. New node indices will be created lazily by AddArcWithCost(). |\n| [`Solve`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/assignment.h#L93) | Return type: `Status ` \u003cbr /\u003e |"]]