CACS455 Data Analysis and Visualization

Data Analysis and VisualizationUnit 1114 min read

Assignment & Transportation Problems: Models, Solving & Real-World Apps

Unit 11 of Data Analysis and Visualization covers optimization techniques for resource allocation: the assignment problem (matching tasks to agents at minimal cost) and the transportation problem (distributing goods from sources to destinations efficiently). Learn mathematical formulations, solving methods (Hungarian,

TAKEAWAYS:

  • Assignment problems minimize cost by matching n tasks to n agents using a cost matrix and solved via the Hungarian algorithm (O(n³)).
  • Transportation problems distribute goods from m sources to n destinations with supply/demand constraints, solved via northwest corner rule, least-cost method, or MODI.
  • Both problems use linear programming under constraints, with duality theory linking primal and dual solutions.
  • Real-world uses: Pathao’s driver-task assignment, NTC’s fuel depot routing, and bank loan officer allocation.
  • The stepping-stone method and MODI iteratively improve solutions until optimality (no negative cost loops).
  • Duality simplifies complex problems: the dual of an assignment problem is a transportation problem, and vice versa.


1. Assignment Problem: Definition and Mathematical Formulation

The assignment problem is a classic optimization problem where we assign n distinct tasks to n distinct agents (e.g., workers, machines, or contractors) such that the total cost is minimized (or profit maximized). This is a special case of the linear programming (LP) problem with constraints ensuring each task is assigned to exactly one agent and vice versa.

Key Components

  • Cost Matrix (C): A square matrix where represents the cost of assigning agent j to task i. Example: Assigning 4 contractors to 4 maintenance tasks in Kathmandu City Corporation.

  • Decision Variables (x): Binary variables where: if agent j is assigned to task i, otherwise.

  • Objective Function: Minimize total cost:

  • Constraints:

    1. Each task is assigned to exactly one agent:
    2. Each agent is assigned to exactly one task:
    3. Binary constraint:

Visual: Cost Matrix for Kathmandu City Corporation

Assumption: There are 5 contractors but only 4 tasks, so one contractor will be unused.


2. Solving the Assignment Problem: Hungarian Algorithm

The Hungarian algorithm (or Munkres algorithm) is an efficient method to solve assignment problems in O(n³) time. It works by:

  1. Subtracting row minima to create at least one zero in each row.
  2. Subtracting column minima to create at least one zero in each column.
  3. Covering all zeros with the minimum number of lines (rows/columns).
  4. Adjusting the matrix if the number of lines < n (using the modification step).
  5. Selecting optimal assignments from the zeros.

Worked Example: Kathmandu City Corporation

Given:

  • 4 tasks (T1-T4) and 5 contractors (A-E).
  • Cost matrix as above (but we ignore contractor E since there are only 4 tasks).

Step 1: Subtract row minima

Step 2: Subtract column minima

Step 3: Cover zeros with minimum lines

  • Zeros at (T1,B), (T1,D), (T2,A), (T2,C), (T3,D), (T4,A), (T4,D).
  • Minimum lines needed: 2 (e.g., cover rows T1 and T4).
  • Since lines < n (4), we proceed to modification step.

Modification Step:

  1. Find the smallest uncovered element: 1 (at (T2,B)).
  2. Subtract this from all uncovered elements; add to elements covered by two lines.
  3. Repeat until optimal assignment is found.

Optimal Assignment:

  • T1 → B (cost = 8)
  • T2 → A (cost = 7)
  • T3 → D (cost = 7)
  • T4 → A or D? (Conflict resolved by selecting the lowest cost path.)
  • Final assignment:
    • T1 → B (8)
    • T2 → C (5)
    • T3 → D (7)
    • T4 → A (6)
  • Total cost = 8 + 5 + 7 + 6 = 26

3. Transportation Problem: Definition and Formulation

The transportation problem involves distributing goods from m sources (factories, warehouses) to n destinations (stores, cities) at minimum cost, subject to supply and demand constraints.

Key Components

  • Cost Matrix (C): = cost of transporting 1 unit from source i to destination j.

  • Supply (S): = supply capacity of source i.

  • Demand (D): = demand requirement of destination j.

  • Decision Variables (x): = quantity transported from source i to destination j.

  • Objective Function: Minimize total transportation cost:

  • Constraints:

    1. Supply constraints:
    2. Demand constraints:
    3. Non-negativity:

Visual: Transportation Network for NTC Fuel Depots

graph LR
    A["Depot X<br/>Supply: 60"] -->|"12 units"| B["City A<br/>Demand: 65"]
    A -->|"11 units"| C["City B<br/>Demand: 35"]
    A -->|"60 units"| D["City C<br/>Demand: 35"]
    E["Depot Y<br/>Supply: 60"] -->|"7 units"| B
    E -->|"11 units"| C
    E -->|"42 units"| D
    F["Depot Z<br/>Supply: 35"] -->|"2 units"| B
    F -->|"16 units"| C
    F -->|"17 units"| D
Assumption: Total supply (60+60+35=155) ≥ total demand (65+35+35=135).

4. Solving the Transportation Problem

Three methods are commonly used:

  1. Northwest Corner Rule (NWCR): A greedy heuristic (not always optimal).
  2. Least-Cost Method (LCM): Prioritizes the cheapest routes first.
  3. Modified Distribution (MODI) Method: An iterative LP-based method for optimality.

Worked Example: NTC Fuel Depot Routing

Given:

From\To A (65) B (35) C (35) Supply
X (60) 12 11 6 60
Y (60) 7 11 4 60
Z (35) 2 16 3 35
Demand 65 35 35 135
12116071142217Depot XDepot YDepot ZCity ACity BCity C
Optimal routing solution (highlighted edges) after MODI adjustments

Step 1: Apply Northwest Corner Rule (Initial Feasible Solution)

  1. Start at (X,A): Allocate min(60, 65) = 60.
    • X’s supply exhausted; A’s demand = 65 - 60 = 5.
  2. Move to (Y,A): Allocate min(60, 5) = 5.
    • A’s demand exhausted; Y’s supply = 60 - 5 = 55.
  3. Move to (Y,B): Allocate min(55, 35) = 35.
    • B’s demand exhausted; Y’s supply = 55 - 35 = 20.
  4. Move to (Y,C): Allocate min(20, 35) = 20.
    • Y’s supply exhausted; C’s demand = 35 - 20 = 15.
  5. Move to (Z,C): Allocate min(35, 15) = 15.
    • C’s demand exhausted; Z’s supply = 35 - 15 = 20.

Initial Solution:

From\To A B C Supply
X 60 0 0 60
Y 5 35 20 60
Z 0 0 15 35
Demand 65 35 35 135

Step 2: Check Optimality Using MODI Calculate u_i (row potentials) and v_j (column potentials):

  1. Set (arbitrary).
  2. For occupied cells, :
    • →
    • →
    • →
    • →
    • →
  3. Check unoccupied cells for negative :
    • (X,B): → Not optimal!

Step 3: Apply Stepping-Stone Method Find a closed loop for (X,B):

  • (X,B) → (X,A) → (Y,A) → (Y,B) → (X,B).
  • Adjust allocations:
    • .
    • New allocations:
      • X,A: 60 - 5 = 55
      • Y,A: 5 + 5 = 10
      • Y,B: 35 - 5 = 30
      • X,B: 0 + 5 = 5

Updated Solution:

From\To A B C Supply
X 55 5 0 60
Y 10 30 20 60
Z 0 0 15 35

Final Cost Calculation:


## In the Real World

  1. Pathao’s Driver-Task Assignment:

    • Problem: Assign drivers to ride requests in Kathmandu’s chaotic traffic.
    • Solution: Uses a real-time assignment algorithm (similar to the Hungarian method) to match drivers to passengers based on distance, wait time, and driver availability, minimizing total travel time.
    • Example: If a driver near Thapathali is requested for a ride to Koteshwor, the system calculates the cost matrix (time + fuel) and assigns the cheapest route dynamically.
  2. NTC’s Fuel Depot Routing:

    • Problem: Distribute fuel from depots (X, Y, Z) to petrol pumps (A, B, C) with varying demands.
    • Solution: Solves a transportation problem to minimize fuel costs while meeting demand. For example, if Depot X has excess fuel and Pump A is nearby, the algorithm prioritizes routing fuel from X→A at the lowest cost.
  3. Bank Loan Officer Allocation (NMB, Global IME):

    • Problem: Assign loan officers to customers based on risk level, processing time, and expertise.
    • Solution: Models this as an assignment problem where the cost matrix represents time + risk penalty. For example, a high-risk loan (longer processing) might be assigned to an experienced officer, reducing default risk.
  4. Daraz’s Warehouse-to-Customer Delivery:

    • Problem: Route deliveries from warehouses to customers in Pokhara/Lalitpur efficiently.
    • Solution: Uses transportation problem variants to balance delivery cost, vehicle capacity, and time windows. For example, if Warehouse 1 has 100 units and Customer Zone A needs 80, the system calculates the cheapest truck routes.

5. Duality in Assignment and Transportation Problems

Duality is a fundamental concept in LP where every primal problem has a dual problem. For assignment and transportation problems:

Primal Problem Dual Problem
Assignment (min cost) Transportation (max profit)
Transportation (min cost) Assignment (max profit)

Dual of an Assignment Problem

  • Objective: Maximize
  • Constraints:
    • (each agent assigned to at most one task)
    • (each task assigned to at most one agent)

Advantages of Duality

  1. Simplification: Converting a complex primal problem into a simpler dual.
  2. Sensitivity Analysis: Helps understand how changes in costs affect optimal solutions.
  3. Computational Efficiency: Some dual problems are easier to solve numerically.

6. Comparison: Assignment vs. Transportation Problems

Feature Assignment Problem Transportation Problem
Nature One-to-one matching Many-to-many distribution
Constraints Each task/agent assigned exactly once Supply ≤ Demand (or vice versa)
Decision Variables Binary () Continuous ()
Solving Method Hungarian algorithm NWCR, LCM, MODI, stepping-stone
Real-World Example Scheduling workers to tasks Logistics (NTC fuel, Daraz deliveries)
Dual Problem Transportation (max profit) Assignment (max profit)

7. Big M Method for Transportation Problems

When supply ≠ demand, we use the Big M method (a penalty cost approach) to balance the problem:

  1. Add a dummy source or dummy destination to balance supply and demand.
  2. Assign a large penalty cost (M) to routes involving the dummy.
  3. Solve using standard methods (e.g., MODI).

Example: If total supply > total demand, add a dummy destination with demand = supply - total demand, and assign (e.g., M = 1000).


8. Kendall’s Notation for Transportation Problems

Kendall’s notation describes transportation problems as:

  • Balanced: (e.g., 3×4 balanced).
  • Unbalanced: (requires dummy rows/columns).

## Exam Tip

  1. Memorize the Hungarian Algorithm Steps:

    • Always subtract row minima first, then column minima.
    • Cover zeros with minimum lines; if lines < n, modify the matrix.
    • Optimal assignment is found when the number of lines = n.
  2. Transportation Problem Shortcuts:

    • For NWCR/LCM, always start from the northwest corner or least-cost cell.
    • MODI is the most reliable for optimality checks—always verify with u_i and v_j.
    • Stepping-stone method is preferred over Vogel’s approximation in exams (more precise).
  3. Duality Tricks:

    • If asked about duality, convert the primal problem to its dual form.
    • For assignment problems, the dual is a transportation problem (and vice versa).
  4. Real-World Applications:

    • Pathao/Daraz: Use assignment problems for driver-passenger matching.
    • NTC/Nepal Oil: Use transportation problems for fuel logistics.
    • Banks: Use assignment for loan officer allocation.
  5. Common Pitfalls:

    • Ignoring dummy rows/columns in unbalanced problems → incorrect solution.
    • Forgetting to check optimality after initial solution → partial marks lost.
    • Misapplying MODI (e.g., wrong signs for u_i and v_j) → wrong cost calculation.
  6. Worked Example Patterns:

    • Assignment: Always show the cost matrix → row/column reduction → optimal assignment.
    • Transportation: Show initial solution (NWCR/LCM) → MODI check → stepping-stone adjustments.


Based on the TU BCA syllabus for Data Analysis and Visualization (CACS455), unit 11.

Discussion

Loading…