Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

OPTIMIZATION - 2AGI ENIT 2016-2017

Homework #2 Solution

Exercise 1.
Use Branch-and-Bound (B&B) to solve the following problem :
Min z = 4 x1 + 5 x2
s.to x1 + 4 x2 ≥ 5
3 x1 + 2 x2 ≥ 7
x1, x2 ≥ 0

x2

3x1 + 2 x2 = 7

(9/5; 4/5)

(5; 0)
x1 + 4 x2 = 5 x1

56/5 = 11,2 : (9/5; 4/5)


x1 ≤ 1 x1 ≥ 2

14 : (1; 2) 11+3/4 = 11,75 : (2; 3/4)


x2 ≤ 0 x2 ≥ 1

20 : (5 ; 0) 13 : (2 ; 1)

Solution Optimale : x1 = 2, x2 = 1 et z = 13.

1/9
OPTIMIZATION - 2AGI ENIT 2016-2017

Exercise 2.
Use B&B to solve the following problem :
Max z = 3 x1 + x2
s.to 5 x1 + 2 x2 ≤ 10
4 x1 + x2 ≤ 7
x1, x2 ≥ 0
x2 integer

x2
(0; 5)

5x1 + 2 x2 = 10

(4/3; 5/3)

(0; 2)

x1
(2; -1)
4x1 + x2 = 7

5+2/3 = 5,66 : (4/3; 5/3)


x2 ≤ 1 x2 ≥ 2

5+1/2 : (3/2; 1) 2+18/5 = 5,6 : (6/5; 2)

Optimal solution : x1 = 6/5, x2 = 2 and z = 5,6.

Exercise 3.
A company manufactures tables and chairs. A table requires 1 hour of labor and 9 m2 of wood,
and a chair requires 1 hour of labor and 5 m2 of wood. Currently 6 hours and 45 m2 of wood are
available. Each table contributes $8 to profit and each chair contributes $5 to profit. Formulate
and solve an IP to maximize the company’s profit.

2/9
OPTIMIZATION - 2AGI ENIT 2016-2017

Decision variables :
x1 : number of tables to produce,
x2 : number of chairs to produce.

Max z = 8 x1 + 5 x2
S. to x1 + x2 ≤ 6
9 x1 + 5 x2 ≤ 45
x1, x2 ≥ 0
x1, x2 integers

9x1 + 5x2 = 45
x2

(15/4; 9/4)

(6; 0)
x1 + x2 = 6 x1

165/4 = 41,25 : (15/4; 9/4)


x1 ≤ 3 x1 ≥ 4

39 : (3; 3) 41 : (4; 9/5)


x2 ≥ 2
x2 ≤ 1

365/9 = 40,55 : (40/9; 1) Infeasible


x1 ≤ 4 x1 ≥ 5

37 : (4; 1) 40 : (5; 0)

Optimal solution : x1 = 5, x2 = 0 et z = 40. Produce 5 tables and 0 chairs.

3/9
OPTIMIZATION - 2AGI ENIT 2016-2017

Exercise 4.
At the first level of the B&B tree, consider assigning a factory to warehouse 1. Since there are 4
possible ways, create 4 subproblems SPi, i=1, …4, where SPi corresponds to fixing the variable
xi1 to 1. For each SPi, find a lower bound as explained in the hint. Then, select a subproblem to
explore based, for example, on the best lower bound. Below, we choose SP1 since it has a
LB=31. Then branch on this node by considering the 2nd warehouse which has 3 possible
assignment, …etc. Remember, no node cutting can be made until a complete solution is found.

x11 x21 x31 x41 x51


5+5+9+5+5 10+9+5+5+7 5+5+10+5+5 10+5+9+8+5 10+5+9+5+9
5+9+5+5+7 10+10+9+5+5 5+9+5+5+7 8+10+5+9+7 9+9+5+5+10
31 39 31 39 38

x22 x32 x42 x52 x12 x22 x42 x52


5+12+9+5+5 5+5+17+5+5 5+5+9+9+5 5+5+9+5+10
5+12+5+5+7 5+17+5+5+7 5+9+5+9+7 5+10+5+5+11
36 39 35 36 37 37 37 35

x23 x33 x53


35 54 43

x34 x54
35 42

Optimal solution : x11 = x42 = x23 = x34 = x55 = 1.

Exercise 5.
Table 2.2: Processing times and due dates
Job Processing time Due Date
(minutes)
1 7 End of minute 14
2 5 End of minute 13
3 9 End of minute 18
4 11 End of minute 15

If we consider n jobs, one way to design B&B is to define a partial solution as a permutation of
k<n jobs. Then a permutation of n jobs would be a complete feasible solution.

4/9
OPTIMIZATION - 2AGI ENIT 2016-2017

There are two possible ways of defining a partial solution of k jobs: (1) the k jobs are scheduled
in the last k positions: (*, …,* j1, j2, …jk) or (2) the k jobs are scheduled in the first k positions:
(j1, j2, …jk, *, …,*). The first type is much easier in terms of obtaining lower bounds (LB) for their
completions. Let us consider these two ways separately.

(1) Consider a partial solution where k jobs are scheduled in the last k positions. Let us denote
these jobs by ju; u=1,…,k. Since the completion time of all jobs in any solution is Cmax= ∑jpj. The
completion time of the last job jk is indeed Cjk = Cmax = ∑jpj; where pj is the processing time of
job j. Thus, Tjk = max (Cmax-djk; 0). Doing the computation backwards for all jobs ju; u=1, …, k-1 :

Cju = Cmax- ∑i=u+1,kpji and Tju = max (Cju –dju; 0). Note that pji is the processing time of the job ji;
that is the job at the ith position in the sequence. Also, any job j that immediately precedes j1 will
finish at Cj=Cmax-∑i=1,kpji, and its tardiness Tj cannot be less than max{ Cmax-∑i=1,kpji -d, 0} , where
d is the maximum due date among the unscheduled jobs:
T j≥ max{ Cmax-∑i=1,kpji -d, 0}
Therefore It follows that:

∑j=1,…NTj ≥ max{ Cmax-∑i=1,kpji -d, 0} + ∑u=1,…kTju = LB

Consider our example. Any complete solution will finish at Cmax = 7+5+9+11=32. Consider the
partial solution (*,*,2,1). Then job j3= 2 and j4=1. The last job, which is job 1, finishes at 32. Then
T1 = max (32-14;0) = 18. Since job 2 is just before job 1, it finishes at C2 = 32-p1 = 32-7= 25.
Then, T2 = max (25-13;0) = 12. We also know that the job preceding 2 must finish at C2-p2= 25-
5=20. Let j be that job. Then Tj ≥ max (20-d; 0), where d = max{dj; j is a non scheduled job}=
max{d3;d4}=18. Thus Tj ≥ max (20-18; 0)= 2. Therefore LB = 18+12+2=32 for this partial
solution. It means that any sequence that ends with 2 1 has a total tardiness of at least 32.

We will construct a B&B based on this concept, where each subproblem corresponds to a
partial solution and the lower bounds are computed as above. At the first level we consider
partial solutions where only the last job is fixed. Then, at the second level, 2 jobs are fixed, etc.

1 2 3
4
(*,*,*,1) (*,*,*,2) (*,*,*,3) (*,*,*,4)
(≥ 25) (≥ 28) (≥ 22) (≥ 20)

5 6 7
(*,*,1,4) (*,*,2,4) (*,*,3,4)
(≥24) (≥25) (≥20)

8 9
(1,2,3,4)
(2,1,3,4)
(=20) (=20)
The optimal solutions: (1,2,3,4) or (2,1,3,4) with ∑Tj = 20
Note: the number in a grey box shows the order in which the subproblem is created.

5/9
OPTIMIZATION - 2AGI ENIT 2016-2017

(2) [This is a harder in terms of bounding] Consider a partial solution where k jobs are
scheduled in the first k positions. their tardiness are known and computed as : Tju = max (Cju-
dju; 0). The main question is how to find a lower bound (LB) for the optimal completion of this
partial solution ?

In this case, a LB can be computed using the following idea. For any unscheduled job jv, its
tardiness Tjv cannot be less than max{Cjv -d, 0} , where d is the maximum due date among the
unscheduled jobs:
T jv ≥ max{Cjv -d, 0}
Consider the simpler relaxed problem where the unscheduled jobs have a common due date
d = max { djk , djk+1 ,..., d jn} .
The minimum total tardiness with respect to the common due date d can be found by
sequencing the unscheduled jobs in an increasing order of their processing times: this is called
the SPT rule (SPT can be proven to be optimal when all due dates are equal). Thus, completion
times Cjv of the unscheduled jobs and their tardiness Tjv can be found by applying the SPT rule.
Ex: consider the partial solution (1,*,*,*). Then for job 1; T1 = max (7-14;0) = 0

Total tardiness of the remaining jobs 2, 3 and 4 is not less than the minimum total tardiness
calculated with respect to the large common due date d=max{d2, d3, d4}=18. In accordance to
the above result, a lower bound on total tardiness is computed by considering an SPT order of
jobs 2, 3 and 4 : 2 3 4 which gives C2= 12; C3=21 and C4=32.

Therefore T2+T3+T4 ≥ max (12-18;0) + max(21-18;0) + max(32-18;0) = 17 and

T1+T2+T3+T4 ≥ 0+17=17

This means that LB=17 is a lower bound for the partial solution (1,*,*,*). Following this idea the
B&B can be constructed for this example. Here, a mix of best bound and depth search is applied
as a branching rule.

1 2 3 4
(1,*,*,*) (2,*,*,*) (3,*,*,*) (4,*,*,*)
(≥ 17) (≥ 17) (≥ 23) (≥ 19)

10
5 8 9 13
14
(1,2,*,*) (1,3,*,*) (1,4,*,*) (2,1,*,*) (2,3,*,*) (4,1,*,*) (4,2,*,*)
(≥17) (≥23) (2,4,*,*) (4,3,*,*)
(≥ 17) (≥ 23) (≥ 22) (≥19) (≥23) (≥22)
(≥30)
17 18
11 15 16 19
6 7 12
(2,1,3,4) (2,1,4,3) (2,4,1,3) (2,1,3,1)
(1,2,3,4) (1,2,4,3)
(= 20) (= 22) (= 24) (= 26)
(= 20) (= 22)

The optimal solutions: (1,2,3,4) or (2,1,3,4) with ∑Tj = 20

6/9
OPTIMIZATION - 2AGI ENIT 2016-2017
Exercise 6.

Table 2.3: Cost of forming students i,j into a group, for j≥i
j= 1 2 3 4 5 6
I=1 16 10 8 58 198 70
2 10 6 72 50 32
3 15 26 198 24
4 15 14 18
5 13 6
6 10

Design a B&B algorithm and use it to solve the problem of minimum cost grouping.

Let the decision variables be xij = 1 if student i forms a group with student j and 0 otherwise.
Here, i,j=1, …,6 and xii=1 means that students i works alone. A B&B can be developed by
considering , at the first level assigning workmate to student 1, then student 2, at the 2nd level,
etc. The lower for each subproblem can be computed as follows: in the cost matrix cross all
rows and columns i & j such that xij=1. Let k be the number of unassigned students. If k is even
set n=k/2; if it is odd set n=(k+1)/2. Then take the minimum value among all elements in the
remaining matrix. Then take the next minimum, etc. repeat n times. Add all the minimum that
you have found to the cost of all assigned students.

Example: consider the subproblem where x12= 1 and x33=1 then the cost of these assignment is
= 10+15=25. Cross rows 1, 2, 3 and columns 1, 2, 3. There are 3 students to be assigned. Then
set n = 2. This means that there will be at least to pairings to make for these 3 students. Take
the first min= 6 then the second = 10. Then LB = 25+16=41.
as a branching rule.
x11=1
x16=1
x12=1 x13=1 x14=1 x15=1

(≥ 38) (≥ 26) (≥ 24) (≥ 70) (≥200) (≥89)

x36=1 x22=1 x26=1


x33=1
x34=1 x24=1 x25=1
x35=1
(≥42) (≥83)
(≥41) (≥218) (≥47) (≥34) (≥86 (≥80)

x44=1 x46=1
x45=1

=39 =42 =49

Optimal solution: x13=x22=x44=x56=1 ; Cost = 39

7/9
OPTIMIZATION - 2AGI ENIT 2016-2017

Exercise 7.
A company uses a truck of a capacity 7 m3 to deliver merchandise to a set of 3 clients. A delivery
made to client i is composed of one or more units of a package of type i. Each unit of package i is
characterized by its volume and the profit that it can bring to the company if it is delivered to the
corresponding client.

The volumes (in m3) and the profits (in hundreds of Dinars) are given in the following table:

Volume Profit
(m3) (hundreds of Dinars)
Package 1 2 16
Package 2 3 19
Package 3 5 28

The company needs to determine the quantities to deliver to each client.

1. Formulate this problem as an integer program.

Decision variables: xi= number of units of package i to deliver. This is a knapsack


formulation.
Max z = 16 x1 +19 x2 +28 x3
s.to 2 x1 +3 x2 +5 x3 ≤ 7
x1, x2 , x3 ≥ 0, integers

2. Use B&B to solve the above formulated problem. We can use B&B based on LP relaxation.
Note that the LP relaxation is easy to solve: simply sort the variables in decreasing order of
ci/ai where ci and ai are the coefficients, respectively, of the objective function and the left
hand side of the constraint. 16/2 > 19/3 >28/5 corresponding to x1, x2 and x3. In this LP, fix
x1 at the maximum value possible and x2 = x3 = 0. In this case x1=7/2.

56 : (7/2; 0; 0)
x1 ≤ 3 x1 ≥ 4

54+1/3 : (3; 1/3; 0) Infeasible


x2 ≤ 0 x2 ≥ 1

53+3/5 : (3 ; 0; 1/5) 51 : (2 ; 1; 0) ←see example below for how to find this LP solution
x3 ≤ 0 x3 ≥ 1

48 : (3;0;0) 44: (1;0;1)

Optimal solution: x1=2; x2=1; x3=0 and z=51.

8/9
OPTIMIZATION - 2AGI ENIT 2016-2017

Note: to solve a subproblem with constraint xi ≤b, when setting the variable xi, fix it to
minimum (b; max value from the knapsack constraint).
To solve a subproblem having the constraint xi≥b; replace the var xi with x'i = xi+b and proceed
as above. For example, consider the following subproblem (shoxn on the B&B tree):

Max z = 16 x1 +19 x2 +28 x3


s.to 2 x1 +3 x2 +5 x3 ≤ 7
x1 ≤ 3
x2 ≥ 1
x1, x2 , x3 ≥ 0, integers

set x'2= x2-1 Then the subproblem becomes :


Max z = 16 x1 +19 x'2 +28 x3 + 19
s.to 2 x1 +3 x'2 +5 x3 ≤ 7-3=4
x1 ≤ 3
x1, x'2 , x3 ≥ 0, integers
The LP solution would be : x1=2; x'2=0 ⇒ x2=1; x3 =0 and z = 51

Exercise 8.
Solve the following knapsack problem using B&B :

Max 11 x1 + 7 x2 + 5 x3 + x4
s.to 6 x1 + 4 x2 + 3 x3 + x4 ≤ 25
x1 ≤ 3
x1, x2, x3, x4 ≥ 0 ; integers

Ratios: 11/6 >7/4>5/3>1; x1 x2 x3 x4

45.25 : (3; 7/4; 0; 0)


x2 ≤ 1 x2 ≥ 2

45 : (3; 1; 1;0) 45.166 : (17/6; 2; 0;0)

On peut couper cette branche car elle


ne peut pas aboutir à une valeur > 45
(coefficients des xi dans z sont des
entiers)

Optimal solution: x1=3; x2=1; x3=1; x4=0; and z=45.

9/9

You might also like