Container Loading Problem
Container Loading Problem
Problem
• A large ship is to be loaded with cargo.
• Cargo is containerized (same size)
• Different containers have different weights.
• The ship can handle cargo load of fixed
capacity.
• Load the ship with maximum number of
containers.
• Model it mathematically.
Mathematical model
• Let wi be the weight of the ith container, where 1 ≤ i
≤ n.
• Let c be the cargo capacity of the ship.
• Let xi be an indicator variable with value 1 or 0 such
that if ith container is loaded then x i is 1 else 0.
• Thus we wish to assign values to x i that satisfy the
constraints ∑ wi xi ≤ c.
• The objective function is : Maximize ∑ x i
Algorithm
• Load the ship one container after another.
• Greedy approach :
– From the remaining containers, select the one
with least weight.
Example
• Suppose that n = 8, [w1, w2, …, w8] = [100, 200, 50, 90, 150,
50, 20, 80], and c = 400.
• Claim : ∑ xi ≥ ∑ yi
• WLOG containers are ordered so that wi ≤ wi+1,
1 ≤ i ≤ n.
• Thus xj = 1, yj = 0.
• Set yj = 1. If y remains a feasible solution then call it z.
• If resulting y is infeasible solution there must be an l in
the range [k+1, n] for which yl = 1. Set yl = 0. Let z
denote the resulting y. As wj ≤ wl, z is a feasible loading.
• In either case ∑zi ≥ ∑yi and z differs from x in
at most p-1 = m positions.