Free tools Windows power users keep installed
One-click scans. No signup required.
Represent each possible item–position pairing with a binary decision variable, assign it a cost, then minimize the sum of the selected costs. Add one constraint requiring each item to be assigned once and another requiring each position to be used once. This standard linear assignment problem (LAP) fits when placements are one-to-one and each pairing’s cost is independent of the other choices.
Write the model
Let I be the set of items and J the set of positions. For each item i and position j, let cij be the cost of placing item i in position j. Costs might represent distance, time, or a penalty; use a consistent unit and make sure lower values really mean more desirable placements.
Define xij as 1 if item i is assigned to position j, and 0 otherwise. The basic model is:
Minimize ∑i∈I ∑j∈J cijxij
subject to:
- ∑j∈J xij = 1 for every item i ∈ I
- ∑i∈I xij = 1 for every position j ∈ J
- xij ∈ {0, 1} for every item-position pair
The first constraint assigns each item exactly once. The second prevents two items from occupying the same position and requires every position to be filled. The binary domain makes each pairing a yes-or-no choice. This is the standard one-to-one formulation described in the linear assignment problem literature.
#1 Best Overall
Build the cost matrix and constraints
- List the two sets. Identify every item and every position, and define precisely what counts as one placement.
- Set a cost for each allowed pair. Populate the cost matrix with the cost of assigning each item to each position. Avoid using a proxy that could change which assignment is best.
- Create binary variables. Use one variable for each item-position pair.
- Add item constraints. Include one equality per item so it is assigned to exactly one position.
- Add position constraints. Include one equality per position so it receives exactly one item.
- Specify the binary domain. Ensure each variable can only be 0 or 1.
- Check the solution. Verify that every item and position appears exactly once, then recalculate the objective by summing the costs of the selected pairs.
Check whether the basic LAP fits
Pair costs must be additive and independent
The objective assumes that the total cost is the sum of individual item-position costs. It cannot capture an effect such as the cost of placing item A at position 1 changing when item B occupies position 2. Such cross-placement interactions require a richer model, such as a quadratic assignment problem.
Assignments must be one-to-one
The standard constraints require exactly one item per position and exactly one position per item. If a position can hold multiple items, or an item consumes a limited resource shared with other assignments, add the appropriate capacity constraints and reassess the model. For example, the generalized assignment problem assigns each job once while limiting the resources consumed on each agent; it is not the plain one-to-one LAP. See an overview of assignment problem variants.
Choose minimization or maximization to match the goal
If the matrix contains costs, minimizing their sum is natural. If it contains scores where higher is better, formulate a maximization objective instead. H. W. Kuhn’s 1955 paper introduced the assignment problem in score-maximization terms: “Assuming that numerical scores are available for the performance of each of n persons on each of n jobs, the ‘assignment problem’ is the quest for an assignment of persons to jobs so that the sum of the n scores so obtained is as large as possible.” Read Kuhn’s paper. Converting scores into costs is possible only when the conversion preserves the ranking of assignments relevant to the objective.
Handle unequal set sizes and impossible pairs
The displayed equalities assume the same number of items and positions. When the set sizes differ, decide which side is allowed to remain unmatched and what that means in the real process. A rectangular assignment solver may be useful, but its matching behavior must meet the application’s requirements. Add dummy items or positions only when an unmatched choice has a deliberate interpretation and a defensible penalty; a dummy should not conceal a requirement that cannot be met.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #3
If certain item-position combinations are forbidden, exclude those variables or use the solver’s documented way to represent forbidden pairs. Then check that the remaining feasible combinations still allow a full assignment. Arbitrarily large penalties can distort results if their scale is inappropriate.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Solve and validate the assignment
The Hungarian method is a classical approach to the assignment problem. The original formulation in Kuhn’s 1955 paper seeks the assignment with the largest total score. A scholarly paper on the linear assignment problem reports the classical Hungarian algorithm’s running-time bound as O(n³); that is a complexity result, not a runtime guarantee for a particular machine or data set. See the paper’s discussion of the LAP.
Rank #4
- Used Book in Good Condition
For a software implementation, SciPy provides scipy.optimize.linear_sum_assignment, documented in its current reference. Check the installed SciPy version and the function’s input and output conventions before relying on it in production. After solving, independently verify feasibility and recompute the total from the selected matrix entries.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




