CO 370 Midterm Exam, Fall 2015 Page 1 Question 1

CO 370 Midterm Exam, Fall 2015
Page 1
Question 1 (20 points)
Shoe Inc. forecasts the following demand of pairs of shoes for the next six months:
Month
Demand
1
5000
2
6000
3
5000
4
9000
5
6000
6
5000
Each shoemaker takes 0.25h to make a pair of shoes and can work 150h per month, plus up to 40h
overtime per month. Each shoemaker is paid a regular salary of $2000.00 per month, plus $50 per hour
overtime (if a shoemaker works less than 150h in a month, he/she will still get paid the full $2000).
At the beginning of each month, Shoe Inc. can hire or fire shoemakers. It costs $1500 to hire a worker
and $1900 to fire a worker.
In addition, shoes can be kept in inventory from one month to the next for a cost of $0.7 per pair (up
to a maximum of 10000 pairs).
At the beginning of month 1, Shoe Inc. has 13 workers. You may also assume that the initial and final
stock of shoes is zero and that any shoemakers working on month 6 will not be fired (and will not incur
any additional cost beyond month 6).
Using the following decision variables, write an integer program that can be used to determine the
minimum cost manner to satisfy all demands.
• wt : Number of shoemakers working at month t, for t = 0, 1, . . . , 6 (w0 represents the initial number
of shoemakers)
• ht : Number of shoemakers hired at the beginning of month t, for t = 1, . . . , 6
• ft : Number of shoemakers fired at the beginning of month t, for t = 1, . . . , 6
• rt : Number of shoes produced using regular time hours in month t, for t = 1, . . . , 6
• ot : Number of shoes produced using overtime hours in month t, for t = 1, . . . , 6
• st : Number of shoes kept in stock from month t to t + 1, for t = 0, 1, . . . , 6
Solution:
Let us first write down the constraint that makes sure the number of workers is consistent throughout
the months:
wt = wt−1 + ht − ft , ∀t = 1, . . . , 6
w0 = 13
(1)
Now let us write the constraint that makes sure the number of shoes is consistent throughout the
months. For that, let us define as problem data dt to be the demand for month t, for t = 1, . . . , 6.
For instance, d1 = 5000, d2 = 6000, etc.
st = st−1 − dt + rt + ot , ∀t = 1, . . . , 6
s0 = 0
s6 = 0
st ≤ 10000, ∀t = 1, . . . , 6
(2)
Moreover, we must impose that the number of shoes produced must match the number of workers
available.
rt ≤ 600wt , ∀t = 1, . . . , 6
ot ≤ 160wt , ∀t = 1, . . . , 6
(3)
CO 370 Midterm Exam, Fall 2015
Page 2
The objective function will then be:
min
6
P
2000wt + 1500ht + 1900ft +
50
4 ot
+ 0.7st
2000wt + 1500ht + 1900ft +
50
4 ot
+ 0.7st
t=1
So our final model will be:
min
6
P
t=1
s.t.
(1), (2), (3)
wt , ht , ft , rt , ot , st ∈ Z+ , ∀t = 1, . . . , 6
(4)
CO 370 Midterm Exam, Fall 2015
Page 3
Question 2 (20 points)
Jack decided to earn some extra money during winter by shoveling snow out of driveways.
He has 16 potential potential clients, that appear in the following table, each with a given driveway size,
in a given neighborhood and having agreed to pay a given price:
Houses
1,2,3
4,5,6
7,8
9,10
11
12,13,14
15,16
Size of driveway (in m2 )
30
45
40
60
100
45
50
Neighborhood
1
3
2
1
2
3
1
Agreed price (in $)
20
35
25
40
60
35
45
Jack has enough time to shovel up to 200 m2 every snow day. In addition, he may buy a snowblower for
what he estimates will cost him $125 per snow day. He may also hire a friend to help for $70 per snow
day.
He estimates that a snowblower will increase the area that he can shovel by 200m2 and his friend will
increase the area that he can shovel by 100m2 .
(a) (6 points) Write an IP that Jack can use to decide what his best plan of action is to maximize his
snow-shoveling profits.
Solution:
Let us define the following data:
• si : Size of driveway of house i, for i = 1, . . . , 16
• ni : Neighborhood of house i, for i = 1, . . . , 16
• pi : Agreed price of house i, for i = 1, . . . , 16
We now define our decision variables as follows:
• xi : Binary variable representing if he will shovel house i, for i = 1, . . . , 16
• y: Binary variable representing if he will buy a snowblower
• z: Binary variable representing if he will hire his friend.
The model then becomes:
max
16
P
s.t.
i=1
16
P
pi xi − 125y − 70z
si xi ≤ 200 + 200y + 100z
i=1
x ∈ {0, 1}16 , y, z ∈ {0, 1}
(b) (2 points) Now Jack wants to take into consideration that he wants to shovel at least 3 houses in
his neighborhood (neighborhood 1). What changes does he need to make to his model in part a)
to take this into account.
Solution:
He must add the constraint:
X
i=1,...,16:ni =1
xi ≥ 3
CO 370 Midterm Exam, Fall 2015
Page 4
(c) (4 points) Suppose that Jack now wants to add the following condition: If he decides to serve house
11, then he must either hire his friend or buy a snowblower. How can he model this?
Solution:
He must add the constraint:
x11 ≤ y + z
(d) (8 points) Finally, he wants to model the following condition: If he serves any house in neighborhood
1 and any house in neighborhood 2, then he must not serve any house in neighborhood 3. What
changes does he need to make to his model in part a) to take this into account.
Solution:
Let us introduce a variable uj = 1 if he serves any house in neighborhood j, for j = 1, 2.
Then the condition that we want is that if u1 = 1 and u2 = 1, then he must not serve any
house in neighborhood 3.
This can be modeled as:
xi ≤ uj , ∀j = 1, 2, ∀i = 1, . . . , 16 : ni = j
(5)
u1 + u2 − 1 ≤ (1 − xi ), ∀i = 1, . . . , 16 : ni = 3
(6)
CO 370 Midterm Exam, Fall 2015
Page 5
Question 3 (20 points)
A company has the following demand for a particular equipment during the next 12 weeks:
Week
Demand
1
15
2
20
3
10
4
13
5
18
6
22
7
9
8
17
9
22
10
16
11
19
12
10
To satisfy that demand, the company may buy, at the beginning of any given week, the equipment from
two different manufacturers.
Each equipment bought from manufacturer 1 costs 10 dollars and must be used for 2 weeks, then undergo
maintenance for the next week, then be used for 2 more weeks and then it must be discarded.
Each equipment bought from manufacturer 2 must be used for 5 straight weeks then it must be discarded.
In addition, the cost of the equipment from manufacturer 2 is not linear, since manufacturer 2 is willing
to give a discount if you buy a large number of its equipments (up to a maximum of 100 units). The
actual cost is given by the following function of the number x of equipments bought:

, if 0 ≤ x ≤ 6
 14x
10x + 24 , if 6 ≤ x ≤ 20
f (x) =

8x + 64
if 20 ≤ x ≤ 100
Write an IP that can be used to find out the way to satisfy all demands at a minimum cost.
Solution: First let us declare data that will be used.
We will consider that we have 12 different patterns pj1 , . . . , pj12 , for each j = 1, 2. Each pattern
consists of a set of weeks for which you can count on having the equipment bought according to that
pattern for manufacturer j starting at week w, for w = 1, . . . , 12.
For instance, patterns p11 , . . . , p112 correspond to buying equipment from manufacturer 1 at weeks
1, . . . , 12 and patterns p21 , . . . , p212 correspond to buying equipment from manufacturer 2 at weeks
1, . . . , 12.
So p11 := {1, 2, 4, 5}, p12 := {2, 3, 5, 6}, p13 := {3, 4, 6, 7}, and so on. Also, p21 = {1, 2, 3, 4, 5}, p22 =
{2, 3, 4, 5, 6}, p23 = {3, 4, 5, 6, 7}, and so on. Notice that the last few patterns will be cut off. For
instance p111 = {11, 12} and p112 = {12} and p211 = {11, 12} and p212 = {12}.
In addition, let dw be the demand of week w, for w = 1, . . . , 12.
Then we can define our decision variables as xij to be the number of equipment bought according
to pattern pji for i = 1, . . . , 12, j = 1, 2.
Then, the constraint that one must satisfy the minimum demand will be:
X
xij ≥ dw , ∀w = 1, . . . , 12
(7)
i=1,...,12;j=1,2:w∈pji
Notice now that the cost of equipment from manufacturer 2 is PWL concave, but since we are
minimizing, we cannot model it as an LP.
Therefore, we will need to introduce extra decision variables δ1 , δ2 , δ3 . These will model how much
12
P
the value of
xi2 is over 0, over 6 and over 20 respectively.
i=1
Then our objective function will become:
P
min
10xi1 + 14δ1 + 10δ2 + 8δ3
i=1,...,12
(8)
And now we need to write constraints that make sure that δ’s are actually representing the total
amount bought from manufacturer 2.
X
xi2 = δ1 + δ2 + δ3
(9)
i=1,...,12
CO 370 Midterm Exam, Fall 2015
Page 6
And to make sure that the δ’s behave as expected, we introduce decision variables u1 = 1 if δ2 > 0
and u2 = 1 if δ3 > 0.
So we must have that δ2 > 0 ⇒ u1 = 1 ⇒ δ1 ≥ 6, which can be modeled as:
δ2 ≤ 14u1
6u1 ≤ δ1
(10)
And we must have that δ3 > 0 ⇒ u2 = 1 ⇒ δ2 ≥ 14, which can be modeled as:
δ3 ≤ 80u2
14u2 ≤ δ2
So our final model will be:
min
s.t.
P
10xi1 + 14δ1 + 10δ2 + 8δ3
i=1,...,12 P
xij ≥ dw , ∀w = 1, . . . , 12
i=1,...,12;j=1,2:w∈pji
P
xi2 = δ1 + δ2 + δ3
i=1,...,12
6u1 ≤ δ1 ≤ 6
14u2 ≤ δ2 ≤ 14u1
0 ≤ δ3 ≤ 80u2
xij ∈ Z+ , ∀i = 1, . . . , 12, j = 1, 2
u1 , u2 ∈ {0, 1}
(11)
CO 370 Midterm Exam, Fall 2015
Page 7
Question 4 (30 points)
Smelly Inc. can produce 3 different perfumes: Aqua, Bos and Chanell. Each litre of Aqua sells for $50,
each litre of Bos sells for $30 and each litre of Chanell sells for $20.
The production requirements per litre of perfume are as follows:
Requirement per litre
Raw material (litres)
Labour (in man-hours)
Aqua
2
1
Bos
1
1
Chanell
1
2
There are 40 litres of raw material avaialable and 30 man-hours available.
Answer the following questions.
−1
a b
You may want to use that
=
c d
1
ad−bc
d
−b
−c a
(a) (5 points) Smelly implemented this problem in OPL using the following file (smelly.mod):
int nperf = ...;
int nres = ...;
float profit[ 1..nperf ] = ...;
float use[ 1..nres ][ 1..nperf ] = ...;
float avail[ 1..nres ] = ...;
dvar float+ x[ 1..nperf ];
maximize sum( j in 1..nperf ) profit[j] * x[j];
subject to
{
forall( i in 1..nres ) ct: sum( j in 1..nperf ) use[i][j] * x[j] <= avail[i];
}
Write the data file that should be used for Smelly to solve its problem using the above .mod file.
Solution: smelly.dat:
nperf = 3;
nres = 2;
profit = [ 50, 30, 20 ];
use = [ [ 2, 1, 1 ] ,
[ 1, 1, 2 ] ];
avail = [ 40 , 30 ];
CO 370 Midterm Exam, Fall 2015
Page 8
(b) (3 points) The optimal plan for Smelly is to produce Aqua and Bos by using up all resources
available. How much should Smelly produce of each perfume in order to obtain the maximum
profit? What is the maximum profit Smelly can obtain?
Solution: Let us rewrite the problem in standard form:
max z =
s.t.
50x1 +30x2 +20x3
2x1
+x2
+x3
x1
+x2
+2x3
x1 , x2 , x3 , x4 , x5 ≥ 0
+x4
= 40 (raw material)
= 30
(man-hours)
+x5
The optimal basic variables are x1 and x2 , so we have that AB =
1 −1
−1 2
The values of the basic variables are:
x1
1 −1
40
10
xB =
=
=
x2
−1 2
30
20
2
1
1
1
and A−1
B =
So Smelly should produce 10 litres of Aqua and 20 litres of Bos.
The optimal profit is 10 × 50 + 20 × 30 = $1, 100 (you can obtain this by simply computing the
objective with x1 = 10 and x2 = 20, or by computing cTB A−1
B b).
(c) (4 points) By how much will the profit increase per extra unit of raw material that Smelly obtains?
(you may assume in this item that the changes are within allowable range)
Solution: The increase in profit per extra unit of raw material is given by the shadow price of
the raw material constraint. The shadow prices can be calculated by:
1 −1
T −1
= [20 10]
cB AB = [50 30]
−1 2
So the shadow price of the raw material constraint is 20. Hence, the increase in profit will be
$20.
(d) (4 points) Suppose that Smelly is considering producing perfume Drekkar, which requires 3 litres of
raw material and 3 man-hours per litre. Its current per litre profit is $70. Taking this new product
into consideration, does Smelly’s optimal policy change?
Solution:
Introducing Drekkar will be equivalent of adding a nonbasic variable x6 with the appropriate
costs and constraint coefficients. We need to figure out if the reduced cost of x6 is still less
than or equal to zero.
c̄6 = c6 − cTB A−1
B A6 = 70 − [20 10]
3
3
= −20
So the reduced cost of x6 is indeed nonpositive and the current optimal basic feasible solution
remains optimal. So Smelly’s optimal plan does not change.
CO 370 Midterm Exam, Fall 2015
Page 9
(e) (6 points) After running the sensitivity analysis commands in OPL, Smelly printed the following
output.
// solution (optimal) with objective 1100
Variable name
Reduced cost
Lower
Upper
x(1)
-0.0000
30.0000
60.0000
x(2)
-0.0000
*******
*******
x(3)
-20.0000
-10000000000.0000
40.0000
Constraint name
Dual price
Lower
Upper
ct(1)
*******
*******
*******
ct(2)
*******
*******
*******
However, some entries were unreadable (marked with *******). What should be the entries on line
corresponding to constraint ct(1), assuming that constraint corresponds to raw materials?
Solution: We are trying to figure out the allowable range of the RHS changes in the raw
material constraint.
For this we should check:
• A−1
B b≥0
• cT − cTB A−1
B A≤0
The second condition will be true since we are only changing the RHS b.
Changing the RHS of raw material from 40 to 40 + will make the basic variables assume the
value:
xB =
x1
x2
=
1
−1
−1
2
40 + 30
=
10 + 20 − So the current optimal plan remains unchanged as long as x1 and x2 are nonnegative, that is,
as long as:
10 + ≥ 0 ⇐⇒ ≥ −10
20 − ≥ 0 ⇐⇒ ≤ 20
Therefore, the entries in ct(1) should be:
Constraint name
Dual price
Lower
Upper
ct(1)
20
30
60
where the dual price was obtained from part c), Lower= 40 − 10 and Upper= 40 + 20
(f) (8 points) Now Smelly is trying to increase its monthly profit and has the choice of increasing the
amount of available raw material to 51 litres or increasing the per litre profit of Bos to $60. Which
decision will increase the profit the most?
Solution:
Note that the change in raw material equates to changing the RHS of the raw material constraint
by 11. From what we’ve seen before, this is within the allowable range and will have the effect
of increasing the profit by 11 times the shadow price, that is by $220.
Increasing the per pound profit of Bos to $60 may or may not be within the allowable range.
However, note that the current basic feasible solution remains feasible and its new objective
value is 1,700. Therefore the optimal solution must have an objective value of at least 1700,
which means that the increase in profit will be at least $600. Therefore, this would be the best
decision.
CO 370 Midterm Exam, Fall 2015
Page 10
Question 5 (20 points)
Euing Gas produces 5 types of gasoline from 3 types of oil. Each gallon of gas i must have an average
octane rating of at least oi , and its sale price is si for i = 1, . . . , 5. Each gallon of oil j has octane rating
rj , and currently there are aj gallons of it available, for j = 1, . . . , 3.
In addition, producing one gallon of gasoline i requires di hours in a distiller, for i = 1, . . . , 5. The total
cost of using h hours of the distiller is given as the following function f (h):

, if 0 ≤ h ≤ 300
 0.5h
h − 150
, if 300 ≤ h ≤ 450
f (h) =

2h − 600 , if 450 ≤ h ≤ 720
(the maximum number of hours available for the distiller is 720).
It is assumed that all gas produced will be sold.
(a) (10 points) Write a LINEAR PROGRAM that can be used to maximize the profit Euing Gas can
have producing the 5 types of gas. No integer variables are allowed.
Solution: Let us define the decision variables:
• xij to represent the amount of oil j used to produce gas i, for j = 1, 2, 3, i = 1, 2, 3, 4, 5.
With this we can write the constraints to model the average octane rating of each gas:
3
P
rj xij ≥ oi
j=1
3
P
xij , ∀i = 1, . . . , 5
(12)
j=1
The constraint that takes care of the hours in the distiller is:
5 P
3
P
di xij ≤ h ≤ 720
(13)
i=1 j=1
The constraints that take care of the amount of oil available are:
5
P
xij ≤ aj , ∀j = 1, . . . , 3
(14)
i=1
Finally, note that the cost of using h hours in the distiller is a piecewise linear convex function.
If we want to maximize profit, we will maximize minus one times that function, which will then
become the following PWL concave function:

, if 0 ≤ h ≤ 300
 −0.5h
−h + 150
, if 300 ≤ h ≤ 450
−f (h) =

−2h + 600 , if 450 ≤ h ≤ 720
And the objective function will then be
max
5 P
3
P
si xij + (−f (h))
(15)
i=1 j=1
To linearize this objective, we introduce an auxiliary binary variable z and our final model then
becomes:
max
5 P
3
P
si xij + z
i=1 j=1
s.t.
(12), (13), (14)
z ≤ −0.5h
z ≤ −h + 150
z ≤ −2h + 600
x≥0
CO 370 Midterm Exam, Fall 2015
Page 11
(b) (10 points) Suppose that f (h) is now as follows:

, if 0 ≤ h ≤ 300
 2h
h + 300
, if 300 ≤ h ≤ 450
f (h) =

3h − 600 , if 450 ≤ h ≤ 720
Write an INTEGER LINEAR PROGRAM that can be used to maximize the profit Euing Gas can
have producing the 5 types of gas. You may just write what changes need to be made to the model
to consider the new function f (h).
Solution:
Instead of introducing z, we replace the term −f (h) in the objective function (15) by −2δ1 −
δ2 − 3δ3 , where δ1 , δ2 , δ3 are new decision variables that represent by how much h is above 0,
300, 450 respectively.
Then we must add constraints that link h with the δ’s:
h = δ1 + δ2 + δ3
and introduce binary variables u1 , u2 to satisfy
δ2 > 0 ⇒ u1 = 1 ⇒ δ1 ≥ 300
δ3 > 0 ⇒ u2 = 1 ⇒ δ2 ≥ 150
which can be modeled as
δ2 ≤ 150u1
300u1 ≤ δ1
δ3 ≤ 270u2
150u2 ≤ δ2
So our final model will be:
max
5 P
3
P
si xij − 2δ1 − δ2 − 3δ3
i=1 j=1
s.t.
(12), (13), (14)
h = δ1 + δ2 + δ3
300u1 ≤ δ1 ≤ 300
150u2 ≤ δ2 ≤ 150u1
0 ≤ δ3 ≤ 270u2
x≥0
u1 , u2 ∈ {0, 1}