Week4 ShortVersion
Week4 ShortVersion
2023-2024 Spring
Week 4
Integer Programming – Branch & Bound Method
Solution:
Sort the items in nonincreasing order of 𝑐𝑖 /𝑎𝑖 .
Include items starting from the first, until the resource is totally
used.
Example.
Item 𝒄𝒊 𝒂𝒊 𝒄𝒊 /𝒂𝒊
1 16 5 3.2
2 22 7 3.14
3 12 4 3
4 8 3 2.67
Order: 1-2-3-4
0 ≤ 𝑥𝑗 ≤ 1
𝑥3 = 0 𝑥3 = 1
SP 2 SP 3
𝑥3 = 1
𝑥3 = 0
t=2
SP 2 SP 3
𝑥1 = 1 Model for SP3
𝑥2 = 5/7 Max z = 16𝑥1 + 22𝑥2 + 8𝑥4
𝑥3 = 1
𝑧 = 43.71 5𝑥1 + 7𝑥2 + 3𝑥4 ≤ 10
0 ≤ 𝑥𝑗 ≤ 1
𝑥3 = 0 𝑥3 = 1
SP 2 SP 3
𝑥1 = 1
𝑥2 = 5/7 t=2
𝑥3 = 1
𝑧 = 43.71
𝑥2 = 0 𝑥2 = 1
SP 4 SP 5
𝑥3 = 0 𝑥3 = 1
SP 3
SP 2 t=2
𝑧 = 43.71
𝑥2 = 0 𝑥2 = 1
SP 4 SP 5
𝑥1 = 1
t=3 𝑥3 = 1
𝑥4 = 1
𝑧 = 36
𝑥3 = 0 𝑥3 = 1
SP 3
SP 2 t=2
𝑧 = 43.71
Model for SP5
𝑥2 = 0 𝑥2 = 1 Max z = 16𝑥1 + 8𝑥4
5𝑥1 + 3𝑥4 ≤ 3
SP 4
0 ≤ 𝑥𝑗 ≤ 1
SP 5
𝑥1 = 1 𝑥1 = 3/5
t=3 𝑥3 = 1 𝑥2 = 1 t=4
𝑥4 = 1 𝑥3 = 1
𝑧 = 36 𝑧 = 43.6
Candidate Solution
LB=36
Let’s continue
branching on SP5.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 2 SP 3
𝑧 = 43.71 t=2
𝑥2 = 0 𝑥2 = 1
t=4 Model for SP5
SP 4 SP 5 Max z = 16𝑥1 + 8𝑥4
𝑥1 = 1 𝑥1 = 3/5 5𝑥1 + 3𝑥4 ≤ 3
t=3 𝑥3 = 1 𝑥2 = 1
𝑥4 = 1 𝑥3 = 1 0 ≤ 𝑥𝑗 ≤ 1
𝑧 = 36 𝑧 = 43.6
Candidate Solution 𝑥1 = 0 𝑥1 = 1
LB=36
SP 6 SP 7
SP 2 SP 3
𝑧 = 43.71 t=2
𝑥2 = 0 𝑥2 = 1
SP 4 SP 5
𝑥1 = 1 𝑥1 = 3/5
t=3 t=4
𝑥3 = 1 𝑥2 = 1
Candidate Solution 𝑥4 = 1 𝑥3 = 1
LB=36 𝑧 = 36 𝑧 = 43.6
𝑥1 = 0 𝑥1 = 1
SP 6 SP 7
𝑥2 = 1
Model for SP6 t=5 𝑥3 = 1
𝑥4 = 1
Max z = 8𝑥4 𝑧 = 42
3𝑥4 ≤ 3
0 ≤ 𝑥𝑗 ≤ 1 Let’s
Another feasible solution, with a larger z-value continue
than the LB: Update LB as 42. This is the
candidate solution now.
with SP7.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 2 SP 3
𝑧 = 43.71 t=2
𝑥2 = 0 𝑥2 = 1
SP 4 SP 5
𝑥1 = 1 𝑥1 = 3/5
t=3 t=4
𝑥3 = 1 𝑥2 = 1
𝑥4 = 1 𝑥3 = 1
𝑧 = 36 𝑧 = 43.6
𝑥1 = 0
𝑥1 = 1 When 𝑥1 =
𝑥2 = 𝑥3 = 1,
SP 6 t=6 SP 7 the model
𝑥2 = 1 becomes
𝑥3 = 1
t=5 𝑥4 = 1
infeasible.
𝑧 = 42
Candidate Solution
LB=42 Let’s
continue
with SP2.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥1 = 0 𝑥1 = 1
Model for SP2
Max z = 16𝑥1 + 22𝑥2 + 8𝑥4 SP 7 t=6
5𝑥1 + 7𝑥2 + 3𝑥4 ≤ 14 SP 6
0 ≤ 𝑥𝑗 ≤ 1 𝑥2 = 1
t=5 𝑥3 = 1
𝑥4 = 1
𝑧 = 42
Candidate Solution
LB=42
Let’s
continue
branching
on SP2.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥4 = 0 𝑥4 = 1 𝑥1 = 0 𝑥1 = 1
SP 8 SP 9 SP 7 t=6
SP 6
𝑥2 = 1
t=5 𝑥3 = 1
𝑥4 = 1
𝑧 = 42
Candidate Solution
LB=42
Let’s
continue
with SP9.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥4 = 0 𝑥4 = 1 𝑥1 = 0 𝑥1 = 1
SP 8 SP 7 t=6
SP 9 SP 6
𝑥1 = 1 𝑥2 = 1
t=8 𝑥2 = 6/7 t=5 𝑥3 = 1
𝑥4 = 1 𝑥4 = 1
𝑧 = 42.86 𝑧 = 42
Candidate Solution
Model for SP9 LB=42
Max z = 16𝑥1 + 22𝑥2
5𝑥1 + 7𝑥2 ≤ 11
0 ≤ 𝑥𝑗 ≤ 1
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥4 = 0 𝑥4 = 1 𝑥1 = 0 𝑥1 = 1
SP 8 SP 7 t=6
SP 9 SP 6
𝑥1 = 1 𝑥2 = 1
t=8 𝑥2 = 6/7 t=5 𝑥3 = 1
𝑥4 = 1 𝑥4 = 1
𝑧 = 42.86 𝑧 = 42
Candidate Solution
If we continue with SP9, the best solution LB=42
we can find would have a z-value of 42 the Let’s
most. continue
No need to find alternative solutions. with SP8.
Fathom this node, and do not continue.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥4 = 0 𝑥4 = 1 𝑥1 = 0 𝑥1 = 1
t=9
SP 9 SP 7 t=6
SP 8 t=8 SP 6
𝑥1 = 1 𝑧 = 42.86
𝑥2 = 1
𝑥2 = 1 t=5 𝑥3 = 1
𝑧 = 38
𝑥4 = 1
𝑧 = 42
Candidate Solution
Model for SP8 LB=42
Max z = 16𝑥1 + 22𝑥2 Let’s
5𝑥1 + 7𝑥2 ≤ 14 continue
0 ≤ 𝑥𝑗 ≤ 1 with SP8.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥4 = 0 𝑥4 = 1 𝑥1 = 0 𝑥1 = 1
t=9
SP 9 SP 7 t=6
SP 8 t=8 SP 6
𝑥1 = 1 𝑧 = 42.86
𝑥2 = 1
𝑥2 = 1 t=5 𝑥3 = 1
𝑧 = 38
𝑥4 = 1
𝑧 = 42
Candidate Solution
z-value of SP8 (38) < LB (42) LB=42
Fathom SP8.
SP 1
t=1 𝑧 = 44 Order: 1-2-3-4
𝑥3 = 0 𝑥3 = 1
SP 3 t=2
SP 2 𝑧 = 43.71
𝑥1 = 1 𝑥2 = 1
t=7 𝑥2 = 1 𝑥2 = 0
𝑥4 = 2/3
𝑧 = 43.33 SP 4 SP 5 t=4
t=3 𝑧 = 36 𝑧 = 43.6
𝑥4 = 0 𝑥4 = 1 𝑥1 = 0 𝑥1 = 1
t=9
SP 9 SP 7 t=6
SP 8 t=8 SP 6
𝑥1 = 1 𝑧 = 42.86
𝑥2 = 1
𝑥2 = 1 t=5 𝑥3 = 1
𝑧 = 38
𝑥4 = 1
𝑧 = 42
Optimal Solution
- Examples:
Machine scheduling (10 jobs to be completed by due dates, how
to schedule those jobs)
We will start B&B with deciding on the job that is last processed.
D denotes the total delay.
23
23-8 23-16
Branch&Bound Method – Machine Scheduling Job pi di
1 6 8
önceki delayler + işin yapılmasından kalan zaman - o işin delayi
2 4 4
3 5 12
4 8 16
15 23
? 4
7 + (15-8)
10 15 23
? 3 4
10 15 23
? 3 4
UB =12
0 4 10 15 23 0 6 10 15 23
2 1 3 4 1 2 3 4
Branch&Bound Method – Machine Scheduling Job pi di
1 6 8
2 4 4
3 5 12
4 8 16
18 23
? 3
18 23
? 3
Note that we
employ Optimal solution.
Jumptracking Total delay:12
method. Order: 2-1-3-4
Branch&Bound Method – Traveling Salesperson Problem
We are at depot (node 0). We need to visit 5 cities and come back to
the depot. Find a tour that crosses each node once and minimizes
the total cost?
2
1
5
3
0
4
1 2 This is a possible
5
solution for this
3
problem. There are
0
4 subtours!
Traveling Salesperson Problem
Mathematical Model
Assignment
Problem
2 Eliminates subtours
E.g. 𝑢2 − 𝑢3 + 6𝑥23 ≤ 5 𝑢3 − 𝑢2 + 6𝑥32 ≤ 5 Both 𝑥23 and 𝑥32
If 𝑥23 = 1, 𝑢2 + 1 ≤ 𝑢3 . If 𝑥32 = 1, 𝑢3 + 1 ≤ 𝑢2 . cannot be 1.
3
Branch&Bound - Traveling Salesperson Problem
𝑐𝑖𝑗 1 2 3 4 5 𝑐𝑖𝑗 1 2 3 4 5
1 - 132 217 164 58 1 M 132 217 164 58
2 132 - 290 201 79 2 132 M 290 201 79
3 217 290 - 113 303 3 217 290 M 113 303
4 164 201 113 - 196 4 164 201 113 M 196
5 58 79 303 196 - 5 58 79 303 196 M
1 3
5
4
2
1 2
4
5
3
1 2
3
5
4
7
7
z=668
𝑥13 = 𝑥34 = Alternative
𝑥42 = 𝑥25 = Optimal.
𝑥51 = 1
UB=668
Heuristics for TSP
You can start from each city and find a tour, then use the best tour.
Cheapest-Insertion Heuristic
𝑐𝑖𝑗 1 2 3 4 5 Cheapest-Insertion Heuristic
1 - 132 217 164 58 - Begin at any city and find the closest
neighbor. Create a subtour with these
2 132 - 290 201 79
cities.
3 217 290 - 113 303 -Break an arc & insert a city in between,
4 164 201 113 - 196 which results in the least cost.
5 58 79 303 196 -
1 5
1 5
3 2
1 5
4 2
Continue with the 2nd solution.
1 5
4
3 2
1 5
Length= Initial
length+added lengths
=116+153+233+166 = 668