Integer Programming
Binary Integer Programming
California Manufacturing Company
The company wants to build a new factory in Los Angeles or in San Francisco (or
both). They also want to build utmost one warehouse but restrict it to a city where
they will have a factory. Their budget is 10 million
Decision Question Variable NPV Cost
s
1 Factory in LA X1 8 6
2 Factory in SF X2 5 3
3 Warehouse in LA X3 6 5
4 Warehouse in SF X4 4 2
California Manufacturing Company
Decision Question Variable NPV Cost
s LP solution
1 Factory in LA X1 8 6 X2 = 2.667, X4 =1; Z = 17.333
2 Factory in SF X2 5 3
3 Warehouse in LA X3 6 5 Integer
4 Warehouse in SF X4 4 2 X2 = 3, Z = 15
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 8 𝑋 1 +5 𝑋 2 +6 𝑋 3 + 4 𝑋 4
BIP
6 𝑋 1 +3 𝑋 2 +5 𝑋 3 +2 𝑋 4 ≤10
X1 = 1, X2 =1; Z = 13
𝑋 3+ 𝑋 4 ≤ 1
BIP (at least one WH)
𝑋3 ≤ 𝑋1
X2 = 1, X4 =1; Z = 9
𝑋4 ≤ 𝑋2
Caliente City problem
1 2 3 4 5 6 7 8 Which places do we locate
1 2 8 18 9 23 22 16 28 fire stations?
2 9 3 10 12 16 14 21 25
3 17 8 4 20 21 8 22 17 Response time ≤ 10 minutes
4 10 13 19 2 18 21 6 12
5 21 12 16 13 5 11 9 12 Cost given
6 35 15 7 21 15 3 14 8
7 14 22 18 7 13 15 2 9
8 30 24 15 14 17 9 8 3
2 3 𝑋 1+ 𝑋 2+ 𝑋 4 ≥1
𝑋 1+ 𝑋 2+ 𝑋 3 ≥ 1
1 4
𝑋 2 + 𝑋 3 + 𝑋 6 ≥1
𝑋 1+ 𝑋 4 + 𝑋 7 ≥ 1
8
5 𝑋 5 + 𝑋 7 ≥1
7 6 𝑋 3+ 𝑋 6+ 𝑋 8 ≥ 1
𝑋 4+ 𝑋 7+ 𝑋 8 ≥ 1
𝑋 6+ 𝑋 7+ 𝑋 8 ≥ 1
If fire station in located in 2, column 2 gives the response time
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 350 𝑋 1+250 𝑋 2+450 𝑋 3 +30 0 𝑋 4 +50 𝑋 5 +4 00 𝑋 6 +3 00 𝑋 7 +200 𝑋 8
𝑋 j 𝑏𝑖𝑛𝑎𝑟𝑦
2 3 𝑋 1+ 𝑋 2+ 𝑋 4 ≥1
𝑋 1+ 𝑋 2+ 𝑋 3 ≥ 1
1 4
𝑋 2 + 𝑋 3 + 𝑋 6 ≥1
𝑋 1+ 𝑋 4 + 𝑋 7 ≥ 1
8
5 𝑋 5 + 𝑋 7 ≥1
7 6 𝑋 3+ 𝑋 6+ 𝑋 8 ≥ 1
𝑋 4+ 𝑋 7+ 𝑋 8 ≥ 1
𝑋 6+ 𝑋 7+ 𝑋 8 ≥ 1
Cost = 750
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 350 𝑋 1+250 𝑋 2+450 𝑋 3 +30 0 𝑋 4 +50 𝑋 5 +4 00 𝑋 6 +3 00 𝑋 7 +200 𝑋 8
𝑋 j 𝑏𝑖𝑛𝑎𝑟𝑦
6 x 6 Sudoku example
Can have 1,2,3,4
6 5
1
Xijk = 1 if position
4 6 5 i,j takes value k
5 6 2
Can have 6 only
6
1 2
68 variables, 96 constraints – row, column, box; objective function?
Easy sudoku – LP optimum is
integer valued.
6 5
There will be constraint(s)
1 involving only one variable.
Process of eliminating other
variables gives progressively
4 6 5 single variable in constraint.
1 2
5 6 2 LP solution is binary.
3 Medium and Hard sudoku –
6 LP solution has fractions. –
Binary IP required.
1 2
What is a binary IP problem?
Examples
Assignment problem ?
Travelling Salesman problem
Location problems
Grouping (clustering)
Vehicle Routeing
Supply Chain
Sequencing and Scheduling problems
IP problems are hard
What are hard problems?
Formulating binary IP problems
Binary knapsack
Maximize 4X1 + 6X2 + 9X3 + 2X4
Subject to
2X1 + 4X2 + 5X3 + X4 ≤ 10
Xj = 0,1
I don’t take both phone and i-pod X2 + X 3 ≤ 1
If i take an i-pod, I take a earphone; X4 ≥ X 3
I take maximum 2 items..
Formulating binary IP problems
Location - Allocation
I can locate factories (each capacity 100) in 1, 2 or 3.
Cost is 100, 150 and 200. I have to transport 150 items
to A. Unit Costs 2, 1, 2.
Minimize 100Y1 + 150Y2 + 200Y3 + 2X1 + X2 + 2X3
X1 + X2 + X3 = 150
Training example
X1 + X2 + X3 ≤ 100Y1 + 100Y2 + 100Y3 trainer
Yi binary, Xi ≥ 0 Seen in bin packing
Formulating binary IP problems
Sequencing and scheduling
Three candidates are to be interviewed. The times are
12, 10 and 15. Minimize sum of waiting times of
candidates?
Minimize S1 + S2 + S3
I can do either 1 or 2; either S2 ≥ S1 + t1 or S1 ≥ S2 + t2
S1 + t1 – S2 ≤ 0 or S2 + t2 – S1 ≤ 0
S1 + t1 – S2 ≤ Mδ and S2 + t2 – S1 ≤ M(1-δ);
δ = 0, 1, How many constraints are there
3 pairs and 6 constraints for 10 people?
Formulating binary IP problems
Travelling salesman -- 10 8 9 7
10 -- 10 5 6
X13 = X34 = X42 = X25 = X51 = 1 8 10 -- 8 9
X13 = X34 = X42 = X21 = X55 = 1 9 5 8 -- 6
X13 = X31 = X42 = X25 = X54 = 1 7 6 9 6 --
Xjj = 0 or leave out Xjj variables or use big M as cost
X13 + X31 ≤ 1; Xij + Xji ≤ 1
How many constraints
X42 + X25 + X54 ≤ 2; Xij + Xjk + Xki ≤ 2; for a 10 city TSP?
Travelling salesman -- 10 8 9 7
10 -- 10 5 6
ui – uj + nXij ≤ n-1; i = 1,..,n; j =2..n
8 10 -- 8 9
u1 – u3 + 5X23 ≤ 4 9 5 8 -- 6
u3 – u4 + 5X34 ≤ 4 7 6 9 6 --
u4 – u2 + 5X42 ≤ 4 X13 = X34 = X42 = X25 = X51 = 1
u2 – u5 + 5X25 ≤ 4 X13 = X31 = X42 = X25 = X54 = 1
u1 – u5 + 20 ≤ 16
u4 – u2 + 5X42 ≤ 4
u2 – u5 + 5X25 ≤ 4
u5 – u4 + 5X54 ≤ 4
How many constraints
u1 – u3 + 5X13 ≤ 4 for a 10 city TSP?
3-opt heuristic - Lin (1965)
Identify 3 non
intersecting arcs a-b,
p-q and u-v. We can
create seven new
1a
2bp
solutions
a-b, p-u, q-v
a-p, b-q, u-v
5 v 3q
a-p, b-u, q-v
a-q, u-b, p-v
a-q, u-p, b-v
4 u a-u, q-b, p-v
We can have intersecting arcs! a-u, q-p, b-v
3-opt heuristic - Lin (1965)
Start with 1-2-3-4-5-1
with Z = 41.
a-b, p-q, u-v are
1-2, 2-3 and 4-5
1a
2bp
a-q, u-p, b-v gives a
solution 1-3-4-2-5-1
with Z = 34. No further
improvement
5 v 3q
We get the
optimum and
4 u we know it!
The 3 arcs can be chosen in nC3 ways. An iteration has 7 nC3 solutions
Formulating binary IP problems
Precedence (Workstations
6 tasks and 3 workstations. Task 5 to be done in same
or later station after task 2
X51, X52, X53, X21, X22, X23
Either X51 + X52 + X53 ≥ X21 or X52 + X53 ≥ X22 or X53 ≥ X23
X51 + 2X52 + 3X53 ≥ X21 + 2X22 + 3X23
Bin Packing problems
GS
1-d Bin packing
• Given a bin capacity C>0 and a list of objects
{p1, p2,...., pn}, what is the smallest number of
bins needed to accommodate all of the objects?
( Each pi has size si, such that 0 ≤si≤ C. i.e. none
of the objects too big to fit in a bin)
• Example:
n=10 items with sizes
44, 24, 24, 22, 21, 17, 8, 8, 6, 6
Bin size is C=61
1d bin packing - applications
– Minimizing wastage problem- standard
length of cable
– Fitting ads in a 3 minute slot
– Lorries to pack items
– Processors to do jobs
Bin packing - Applications
• placing computer files with specified sizes
into memory blocks of fixed size
• recording of all of a composer's music,
where the length of the pieces to be
recorded are the weights and the bin
capacity is the amount of time that can be
stored on an audio CD (about 80 minutes)
Formulation
Let Yj=1 if bin j is opened and Xij=1 if item i is packed to bin j.
Minimize Σ Yj
Subject to Σ Xij=1
Σ siXij ≤ C
Xij ≤ Yj, Xij, Yj = 0,1
• Example:
n=13 items with sizes
91, 82, 81, 81, 81, 81, 51, 49, 20, 20, 20, 20, 20
Bin size is C=100. Minimum number of bins needed (LB) = Σsi/C =
697/100= 7.
Optimum = 8 bins
1d- bin packing is NP-hard
LP relaxation gives LB. LP optimum is yj=1/M, Xij=1/M with Z = 1 (LP
relaxation gives a very weak bound)
Tighten with constraint Σ siXij ≤ nYj. Better LB of 6.97
Algorithms
• Branch and Bound
• Lower bound – LP relaxation is always Σti/C
• Can be poor if ti are just greater than C/2 LB to Z
approaches ½
• Better bounds on LB/Z were created
• ¾ is a good bound for LB/Z
• Heuristics
2 Oct 2015
Matching, Assignment, Covering, Location and Grouping problems
1
5 1
5
4 8
3 4 8
3
6
6
2 7 2 7
LP gives binary solution
Unique solution?
Matching – How many pairs can I form?
Matching, Assignment, Covering, Location and Grouping problems
Bipartite Matching – How many pairs can I form?
1 5 1 5
4 8 4 8
3 6 3 6
2 7 2 7
Unique solution?
Matching, Assignment, Covering, Location and Grouping problems
Covering – Where to locate? Minimum nodes to cover all arcs
1
5 1
5
4 8
3 4 8
3
6
6
2 7 2 7
LP gives binary solution. Usually covering is IP
Unique solution?
Matching, Assignment, Covering, Location and Grouping problems
Covering – Where to locate? Cost associated with location
1
5 1
100 400 5
100 400
500 4
8 500 4
100 3 8
100 3
200
200
6
6
100
100
2 7
200 2
200 200 7
200
LP gives binary solution. Usually covering is IP
Min cost covering vs minimum covering
More than 3 locations
Unique solution?
Grouping problem
Formulate the problem
1 to get 3 groups out of 8
5 points?
4 8
3
2 7
Grouping problem
Xjj = 1 if point j is a seed (or median)
1
5
Xij = 1 if a non-median i is assigned to median j
4 8
3
2 7
Grouping problem
1 X66 = X77 = X88 = 1 (medians)
5
X18 = X26 = X37 = X46 = X58 = 1
4 8
3
Z = 312 or 12
2 7
Clustering problem
Maths Physics Chemistry Computer English
Science
Azhar 82 77 79 82 65
Bhaskar 87 73 77 88 60
Cindy 79 69 72 95 72
David 73 86 68 98 67
Elizabeth 80 75 76 77 59
Fredrick 91 90 85 81 80
Ganesh 100 88 62 66 72
Hari 85 79 80 77 75
Formulate the problem to get 3 groups out of 8 people?
Clustering problem
12th Age Proficiency CAT score Can speak
Marks in English (percentile) French?
Azhar 82 27 Medium 92 Y
Bhaskar 87 23 Low 88 N
Cindy 79 32 High 95 N
David 73 30 High 98 N
Elizabeth 80 36 Medium 79 Y
Fredrick 91 29 High 81 Y
Ganesh 98 23 Medium 66 N
Hari 85 19 High 77 Y
Formulate the problem to get 3 groups out of 8 people?
Sportstuff
Zone Demand in Demand in 2003
2000 (in thousands)
Northwest 320000 1866
Southwest 200000 1166
Upper Midwest 160000 933
Lower Midwest 220000 1283
Northeast 350000 2041
Southeast 175000 1020
The inventory holding cost at a warehouse (excluding warehouse
expense) was about $600 F where F is the number of units
flowing through the warehouse per year. Thus, a warehouse
handling 1 million units would incur a cost of $600000 per year.
NW SW UMW LMW NE SE
Seattle 2.0 2.5 3.5 4.0 5.0 5.5
Denver 2.5 2.5 2.5 3.0 4.0 4.5
St. Louis 3.0 3.0 2.5 2.5 3.0 3.5
Atlanta 4.0 4.0 3.0 2.5 3.0 2.5
Philadelphia 4.5 5.0 3.0 3.5 2.5 4.0
Location Small Warehouse Large Warehouse
Fixed Costs Variable Fixed Costs Variable
($/year) costs ($/year) costs
($/unit) ($/unit)
Seattle 300000 0.2 500000 0.2
Denver 250000 0.2 420000 0.2
St. Louis 220000 0.2 375000 0.2
Atlanta 220000 0.2 375000 0.2
Philadelphia 240000 0.2 400000 0.2
Let Yik be the number of warehouses of type k (k = 1 indicates a
large warehouse and k = 2 indicates a small warehouse).
Let Xij represent the quantity transported from warehouses in
city i to demand region j.
Minimize .
The constraints are
Xij ≥ 0, Yik = integer 30 Xij variables, 12 Yij variables, 5
supply constraints and 6 demand
constraints.
Solve MILP and evaluate inventory and TC
NW SW UMW LMW NE SE
Capacity
Seattle 1866 99 2000
Denver 1067 933 2000
Atlanta 1283 41 1020 4000
Philadelphia 2000 2000
1866 1166 933 1283 2041 1020
Fixed Cost = 1165000
Transportation cost = 4965000
Inventory cost = 3456734.66
(evaluated for LP solution)
Total = 9586734.66
Minimize .
Two large and 1 small warehouse at St Louis
NW SW UMW LMW NE SE Capacity
St Louis 1866 1166 933 1283 2041 1020 10000
1866 1166 933 1283 2041 1020
Fixed Cost = 970000 The best load allocation would be
Transportation cost = 6082250 3.1545, 3.1545 and 2 million for
Inventory cost = 1729520 the warehouses. The total
inventory cost is 2976625.88 and
Total = 8781770 the total cost is 10028875.88.
Large WH in Denver, St Louis, Small WH in Atlanta
NW SW UMW LMW NE SE Capacity
Denver 1866 1166 933 4000
St 1283 2041 4000
Louis
Atlanta 1020 2000
1866 1166 933 1283 2041 1020
Fixed Cost = 1015000
Transportation cost = 5448250
Inventory cost = 2894619.18
Total = 9357869.18
Large WH in Denver, St Louis, Small WH in Atlanta
NW SW UMW LMW NE SECapacity
Denver 1866 1166 4000
St Louis 933 1283 2041 1020 6000
1866 1166 933 1283 2041 1020
Fixed Cost = 1015000
Transportation cost = 5734500
Inventory cost = 2429576.03
Total = 9179076.03