October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Formulate a Placement Problem as a Linear Assignment Problem

Model each item-position pairing with a binary variable, minimize total placement cost, and constrain every item and position to appear exactly once.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the cost matrix and constraints

  1. List the two sets. Identify every item and every position, and define precisely what counts as one placement.
  2. 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.
  3. Create binary variables. Use one variable for each item-position pair.
  4. Add item constraints. Include one equality per item so it is assigned to exactly one position.
  5. Add position constraints. Include one equality per position so it receives exactly one item.
  6. Specify the binary domain. Ensure each variable can only be 0 or 1.
  7. 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.Support on Ko-Fi

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.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.