Discussion 1: August 29: 1.1.1 Info
Discussion 1: August 29: 1.1.1 Info
Discussion 1: August 29
Lecturer: Erik Bertelli Scribes: Umesh Thillaivasan
1.1.1 Info:
Berkeley Paint Company has 40 hours of production capacity available to produce paint. Formulate an LP
to help Berkeley Paint Company maximize profit.
1.1.2 LP Formulation
Symbolically: Berkeley Paint Company has t = 40 hours of production capacity available to produce n
number of paints.
n
X
P: max pi xi
i=1
n
X 1
s.t. xi t
i=1
ri
0 xi ui for i = 1 . . . n
1-1
Lecture 2: September 5 2-1
Discussion 2: September 5
Lecturer: Erik Bertelli Scribes: Umesh Thillaivasan
2.2.1 Problem:
The state of California would like to plan its power generation capacity for the next 50 years. We know the
following:
3. The state has the option to build two types of power plants:
Solar arrays, which cost st per MW to build in year t and last for 10 years
Nuclear plants, which cost nt per MW to build in year t and last for 20 years
How can California formulate a linear program to find the cheapest way to meet the demand forecast? You
may assume once the plant is built there are no ongoing upkeep or variable costs.
2.2.3 Equations:
t
X
zt = yk
k=max(1,(t19))
Demand constraint: wt + zt + e dt
2.2.4 LP Formulation:
50
X
P: min st xt + nt yt
t=1
s.t. wt + zt + e dt t = 1, . . . , 50
t
X
wt = xk t = 1, . . . , 50
k=max(1,(t9))
t
X
zt = yk t = 1, . . . , 50
k=max(1,(t19))
xt , yt , wt , zt 0 t = 1, . . . , 50
Suppose people in California are afraid of too many nuclear power plants, so the state decides to limit the
total amount of MW that can be made from nuclear at any one time to never exceed 20%. How can you
add this new constraint to the model?
0.8zt 0.2(wt + e)
Remember that we said there is e power being generated already? Lets assume that this is all being produced
by coal plants that are bad for the environment. Now say that California would get dollars from the federal
government if it shut down all of the coal plants being used, and that it would get the equivalent percentage
if only some of the coal plants were shut down. For instance, if they shut down 10% of the coal plants they
get 10% of dollars. How would you add this to the model? Assume that once the coal plant is shut down
it cannot be used again. Let vt = the percent of MWs of coal plants shut down by year t
wt + zt + (1 vt )e dt 0leqvt 1
How do we prevent the model from reopening closed coal plants? For instance, it could set v1 = 0.1 and
v2 = 0 which should not be allowed.
vt vt+1
This will ensure a shut down plant stays shut down
2.2.7 New LP:
How do we add the benefit from shutting down these plants to the model? Remember, California only gets
the money once.
50
X
v5 0 + st xt + nt yt
t=1
Why is it negative? Because we are minimizing costs, and this is money that the state is getting, not
spending.
2-3
IND ENG 240: Optimization Analytics Fall 2017
Discussion 3: September 12
Lecturer: Erik Bertelli Scribes: Umesh Thillaivasan
Primarily AMPL.
3-1
Lecture 4: September 19 4-1
Discussion 4: September 19
Lecturer: Alfonso Lobos Scribes: Umesh Thillaivasan
4.3.0.1 Form 1:
Convert |x| = max {x, x}. We create a new variable z = |x1 + 5x2 | which is 2 components: z x1 + 5x2
and z (x1 + 5x2 ).
P: min z
s.t. x1 3x2 2
z x1 + 5x2
z (x1 + 5x2 )
x1 0
4.3.0.2 Form 2:
Each number can be divided into the difference between its positive and negative parts: 35 = (35) - (0).
-15 = (0) - (15). In general: x = z + z . In the Objective Function it is z + + z because the absolute
value will take the positive values only in the end, and minimize or maximize appropriately.
P: min z + + z
s.t. x1 3x2 2
z + z = x1 + 5x2
x1 , z + , z 0
Can only use absolute value trick when: min +|...| or max |...|
P: max x1 + x2
s.t. x1 + 2x2 5
2x1 x2 4
x1 0
x2 0
To Symmetric becomes:
P: min (x1 + x2 )
s.t. x1 + 2x2 5
(2x1 x2 ) (4)
x1 0
x2 0
Bounded?
cj
1 1
1 2 5
2 1 4
aij bi
Check Bounded Certificate. ai jyi cj s are number of rows and you move down
y1 + 2y2 1
2y1 + y2 1
y1 0
y2 0
P: min 2x1 + x2
s.t. x1 + 2x2 4
3x1 + 2x2 6
x1 0
x2 0
Lecture 4: September 19 4-3
cj
2 1
1 2 4
3 2 6
aij bi
Bounded? Yes, when y1 = y2 = 0, but lets check Unbounded Certificate anyways. Read across matrix rows
for equations 0 and then the top matrix 0.
w1 + 2w2 0
3w1 + 2w2 0
2w1 + w2 < 0
4.7 Certificates
4.7.1 Misunderstandings
1. Problem Infeasible: Infeasibility certificate holds.
1. A LP either satisfies the certificate of feasibility or satisfies the infeasibility certificate. One of the two
certificates always hold.
2. A LP either satisfies the certificate of boundedness or satisfies the unboundedness certificate. One of
the two certificates always hold.
4-4
Lecture 5: September 26 5-1
Discussion 5: September 26
Lecturer: Alfonso Lobos Scribes: Umesh Thillaivasan
The way certificates should be thought, is: if I found xs, ys, ws or zs that satisfy the certificate then
something happens.
Lower Bound for the Primal, use the Boundedness Certificate.
5.9.1 Example 1
Convert to Symmetric. Let x1 = x+
1 x1 and
Now split x1 = x+ +
1 x1 and x2 = x2 x2 into their positive and negative parts. Multiply by -1 to change
inequality sign.
P: min x+ +
1 + x1 + x2 + x2
s.t. x+ +
1 x1 x2 + x2 2
x+ +
1 + x1 + x2 x2 2
x+ +
1 , x1 , x2 , x2 0
Bounded?
cj
1 1 1 1
1 1 1 1 2
1 1 1 1 2
aij bi
Feasible? Yes when x+ +
1 = x1 = x2 = x2 = 0. Now, check Bounded Certificate. ai jyi cj s are number of
rows and you move down
y1 + y2 1
y1 y2 1
y1 y2 1
y1 + y2 1
y1 , y2 0
P P
Optimal? Yes, because Feasible and Bounded when ci xi = bi yi
5.9.2 Example 2
Feasible? Yes, when x1 = 11, x2 = 10, x3 = 0. Could also show that you cannot find an Infeasibility
Certificate.
cj
5 6 4
1 1 4 1
1 3 1 2
aij bi
z1 z2 0
z1 + 3z2 0
4z1 z2 0
z1 , z2 0
1z1 + 2z2 > 0
5-2
Lecture 5: October 3 5-1
Discussion 5: October 3
Lecturer: Erik Bertelli Scribes: Umesh Thillaivasan
How the uncertainty in the output of a mathematical model or system (numerical or otherwise) can be
apportioned to different sources of uncertainty in its inputs
How small
Pn changes in parameter cj , bi , aij affect the current optimal solution x and optimal objective
value i=1 cj xj .
5.11.3 Terminology
Given a feasible solution x1 , . . . , xn :
Decision Variable xj is basic if xj 6= 0
Decision Variable xj is non-basic if xj = 0
Pn Pn
Constraint j=1 aij xj bi is binding if j=1 aij xj = bi
Pn Pn
Constraint j=1 aij xj bi is non-binding if j=1 aij xj > bi
Shadow Price yi :
Change of the objective function from one unit increase in its right-hand side bi . The shadow
price associated with a particular constraint is the change in the optimal value of the objective function
5-4 Lecture 5: October 3
per unit increase in the right hand-side value for that constraint, all other problem data remaining
unchanged.
The dual prices are some of the most interesting values in the solution to a linear program. A
dual price is reported for each constraint. The dual price is only positive when a constraint is binding.
The dual price gives the improvement in the objective function if the constraint is relaxed by one unit.
In the case of a less-than-or-equal constraint, such as a resource constraint, the dual price gives the
value of having one more unit of the resource represented by that constraint. In the case of a greater-
than-or-equal constraint, such as a minimum production level constraint, the dual price gives the cost
of meeting the last unit of the minimum production target. The units of the dual prices are the units
of the objective function divided by the units of the constraint. Knowing the units of the dual prices
can be useful when you are trying to interpret what the dual prices mean.
Reduced Cost rj :
Amount by which the cost coefficient of non-basic variable cj must be lowered for that variable
to becomes basic (=0). The reduced cost associated with the nonnegativity constraint for each variable
is the shadow price of that constraint (i.e., the corresponding change in the objective function per unit
increase in the lower bound of the variable).
Associated with each variable is a reduced cost value. However, the reduced cost value is only
non-zero when the optimal value of a variable is zero. A somewhat intuitive way to think about the
reduced cost variable is to think of it as indicating how much the cost of the activity represented by
the variable must be reduced before any of that activity will be done. More precisely, ... the reduced
cost value indicates how much the objective function coefficient on the corresponding variable must
be improved before the value of the variable will be positive in the optimal solution. In the case of a
minimization problem, improved means reduced. So, in the case of a cost-minimization problem,
where the objective function coefficients represent the per-unit cost of the activities represented by
the variables, the reduced cost coefficients indicate how much each cost coefficient would have to be
reduced before the activity represented by the corresponding variable would be cost-effective. In the
case of a maximization problem, improved means increased. In this case, where, for example, the
objective function coefficient might represent the net profit per unit of the activity, the reduced cost
value indicates how much the profitability of the activity would have to be increased in order for the
activity to occur in the optimal solution. The units of the reduced cost values are the same as the
units of the corresponding objective function coefficients.
If the optimal value of a variable is positive (not zero), then the reduced cost is always zero. If the
optimal value of a variable is zero and the reduced cost corresponding to the variable is also zero, then
there is at least one other corner that is also in the optimal solution. The value of this variable will be
positive at one of the other optimal corners
Allowable Increase/Decrease:
Pn
Optimal solution x and objective
i=1 cj xj may change
Whether a decision variable is basic or non-basic stays unchanged
Whether a constraint is binding or non-binding stays unchanged
If x is optimal for the Primal and y is optimal for the Dual then:
1. rj xj = 0 j = 1 . . . n
2. si yi = 0 i = 1 . . . m
Where rj is the Reduced Cost and sj is the Slack of a Primal constraint.
Slack or Surplus
A slack or surplus value is reported for each of the constraints. The term slack applies to less
than or equal constraints, and the term surplus applies to greater than or equal constraints. If a
constraint is binding, then the corresponding slack or surplus value will equal zero. When a less-than-
or-equal constraint is not binding, then there is some un-utilized, or slack, resource. The slack value is
the amount of the resource, as represented by the less-than-or-equal constraint, that is not being used.
When a greater-than-or-equal constraint is not binding, then the surplus is the extra amount over the
constraint that is being produced or utilized.
The units of the slack or surplus values are the same as the units of the corresponding constraints.
Variable Sensitivity Analysis. Looking at the bounds, if the price of a Quarter Pounder goes above $1.73, it
might not make sense to include it in the optimal solution.
Constraint Sensitivity Analysis. You have all the Cholesterol you can have in the diet, but have not taken
any Total Fat..
5-5
Lecture 7: October 10 7-1
Discussion 7: October 10
Lecturer: Erik Bertelli Scribes: Umesh Thillaivasan
You want to set up an emergency bag in case of an earthquake. Four items can be packed: gold, water,
pillow, brick, with the following data, and you want to pack at least 5 units of water. Suppose your pack
has the maximum volume of 60 and you can bear at most 100 weight. Find how much each item to pack to
maximize the value.
In order for a change to be withing the allowable range, both of these must be true:
Shadow price yi = 0 by Complementary Slackness. For example, when looking at changing b1 from
60 to 80 we know that: 1. Allowable Increase is +. 2. Allowable Decrease is si = 12.5. 3. New Optimal
Solution is unchanged. 4. New Optimal Objective Value is unchanged
Shadow price yi 6= 0 (yi = 0 for binding constraint means degeneracy). For example, when looking at
changing b2 from 100 to 80 we know that: 1. Allowable Increase is 83.33. 2. Allowable
Pn Decrease is 50. 3.
New Optimal Solution is xnew
1 = 1.5, x new
2 = 5. 4. New Optimal Objective Value is i=1 cj x new
j = 61.
Reduces to:
5
x1 = +
2 20
. From (4) we get x1 0 50. And from the x1 equation we get 3x1 20 83.33. We see these
values added to 100 in the constraint bounds.
Reduced Cost rj 6= 0 (rj = 0 for non-nasic variables means multiple optimal solutions).
m
X
rj = cj aij yi
i=1
Consider c3 which has a reduced cost of r3 = 0.4. This means the allowable increase is rj = 0.4. The
allowable decrease is +.
Now consider changing c3 from 2 to 2.1. The new optimal solution remains unchanged. The new optimal
objective value remains unchanged.
Reduced Cost rj = 0.
Consider c2 , the allowable increase is 7 and the allowable decrease is +.
Now consider changing c2 from 5 to 10. Then you get the new optimal solution is unchanged. The new
optimal objective value is
n
X n
X
cnew
j xj = cj xj + x2 = 110
j=1 j=1
7-4 Lecture 7: October 10
Consider a24 , the allowable increase is + and the allowable decrease is 12.5. Changing a24 from 15 to 3
gives an unchanged new optimal solution and an unchanged new optimal objective value.
Lecture 7: October 10 7-5
Ensure the sign of rj is the same as before . For a Maximization problem, if rj 0 before, then rj needs
to also be 0 for the solution to stay optimal. For Minimization, rj 0 before, then rj 0. In this case
r4 = 15 so our new value must also be negative since this is maximization.
r4 0
m
X
c4 ai,4 yi 0 = 3 (6)(0) (15 + )(1.2) (0)(7) 0
i=1
12.5
This brick 12.5 means that we can increase the weight of the brick to + and not care, and if we
decrease the weight of the brick from 15 by more than 12.5, then we might consider taking it and be a part
of the optimal solution, because it would have a positive reduced cost.
Another example: Lets say we found a pillow that for the same weight and value, it uses only 10 of volume
(instead of 14). Would our optimal solution change? Strategy: 1. Remove the whole old column for x3 for
the problem. 2. Enter the updated column again and check the conditions for a new variable (x3 = 0).
Original optimal solution was y1 = 0, y2 = 1.2, y3 = 7. Reduced Cost Check:
r3 = 2 10(y1 ) 2(y2 ) = 2 10(0) 2(1.2) = 0.4 < 0
Given that our original problem is a maximization having a negative reduced cost implies that our original
primal solution continue being optimal.
When adding a new decision variable xn+1 , assume is it non-basic (6= 0) and check rn+1 .
For example, adding a First Aid Kit with value=20, volume=10, weight=10, we check:
n
X
r5 = c5 aij yi = 20 10(0) 10(1.2) + 0(7) = 8 > 0
i=1
Since this problem is a maximization problem, a positive reduced cost means we need to resolve the
problem. For Minimization we want -ve Reduced Cost to remain Optimal
7-6
Lecture 8: October 17 8-1
Discussion 8: October 17
Lecturer: Alfonso Lobos Scribes: Umesh Thillaivasan
Lets obtain the dual of our max problem without changing to symmetric form. P defined as:
4. If going from min to max, P variables change the sign of the D constraints, but P constraints dont
change the sign of D variables
For Example:
Notice that the phase I problem is always feasible and bounded (its objective function value is always 0).
Then there is an optimal primal and dual solution. Any dual optimal solution is a certificate of infeasibility
if the optimal primal function value is positive.
8-3
Lecture 9: October 24 9-1
Discussion 9: October 24
Lecturer: Alfonso Lobos Scribes: Umesh Thillaivasan
9.15.1 Terminology
ILP stands for Integer Linear Programming. MILP for Mixed Integer Linear Programming (notation may
change depending on the reference). A special case of integer is binary. Notice that x binary can also be
written as 0 x 1
n
X
P: min ci x i
i=1
n
X
s.t. aij xi = bj j = 1 . . . m
i=1
xi integer i = 1 . . . n ILP
xi integer or real i = 1 . . . n MILP
Integer variables, and in particular binary variables, are specially well suited to write logical statements.
Usually we think of x = 0 as false, and x = 1 as true .
Super Important: Your reformulation should express no more and no less than what you are trying to
express. For example, if you are trying to express an implication for one direction, you dont want to also
obligate the implication on the other way or extra implications.
We consider the production of a single product over T periods. If we decide to produce at period t, a setup
cost of ct is incurred. For t = 1, . . . , T let dt be the demand for this product in period t, and let pt , be the
unit production and storage cost respectively for period t. Formulate a MILP in order to minimize the total
cost of production, storage, and setup.
9.15.2.1 Variables
9.15.2.2 Formulation
T
X
P: min (zt ct + xt pt + It ht
t=1
T
X
s.t. xt zt ( dt ) t = 1 . . . T
t=1
It = It1 + xt dt t = 1 . . . T
I0 = 0
zt binary t = 1 . . . T
xt 0t = 1 . . . T
It 0t = 1 . . . T
Suppose we allow demand to be lost in every period except for period T, at a cost of bt per unit lost of
demand. Show how to modify the model to handle this option.
Solution: We need to add a new variable `t that is the demand lost in period t. We have to take into account
the fact that it may be optimal to not satisfy demand in period t even if we could in order to use the saved
storage for the next period.
T
X T
X 1
P: min (zt ct + xt pt + It ht + `t bt
t=1 t=1
T
X
s.t. xt zt ( dt ) t = 1 . . . T
t=1
It = It1 + xt dt + `t t = 1 . . . T
IT = IT 1 + xT dT
`t dt t = 1 . . . T
I0 = 0
`t 0 t = 1 . . . T
zt binary t = 1 . . . T
xt 0t = 1 . . . T
It 0t = 1 . . . T
Suppose that production capacity can occur in at most five periods, but no two such periods can be consec-
utive. Show how to modify the model to handle this option.
Solution: Add the following constraints
T
X
zt 5
t=1
zj + zj+1 1 t = 1 . . . T
Suppose you are planning to move your new house. You have n items of size aj , j=1..n that need to be
moved. You have rented a truck that has size Q and you have bought m boxes. Box i has size bi , i=1..m.
Lecture 9: October 24 9-3
9.15.3.1 Variables
zi = binary variable that represents if box i (1..m) is taken in the truck or not
xij = binary variable that represents if item j (1..n) is stored in the box i or not
9.15.3.2 Formulation
m
X
P: min zi
i=1
Xm
s.t. xij = 1 j = 1 . . . n also works
i=1
Xn
aj xij zi bi i = 1 . . . m Box Capacity
j=1
Xn
zi bi Q i = 1 . . . m Truck Capacity
j=1
zj binary i = 1 . . . m
xj binary i = 1 . . . m j = 1...n
Mutually Exclusive x3 + x5 1 (x3 , x5 ) can be 1,0, 0,1, or 0,0 but not 1,1 (both).
9.16.2 Exactly 1 of Projects 2 and 3 must be selected
Multiple Choice x2 + x3 = 1 (x2 , x3 ) can be 1,0, 0,1, but not 0,0 (neither) or 1,1 (both).
Conditional Constraint where x4 depends on x2 . x4 x2 (x4 , x2 ) can be 1,0, 0,1, or 0,0 but not 1,1.
9-4
Lecture 10: October 31 10-1
10.17.1 Terminology
See Slides.
Mondo motorcycles is determining its production schedule for the next four quarters. Demand for motorcycles
will be as follows: quarter 1-40, quarter 2-70, quarter 3-50, quarter 4-20. Mondo incurs four types of costs, 1.
it costs Mondo $400 to manufacturer each motorcycle. 2. At the end of each quarter, a holding cost of $100
per motorcycle is incurred. 3. Increasing production from one quarter to the next incurs costs for training
employees. It is estimated that a cost of $700 per motorcycle is incurred if production is increased from one
quarter to the next. 4. Decreasing production from one quarter to the next incurs costs for severance pay,
increasing morale, and so forth. It is estimated that a cost of $600 per motorcycle is incurred if production
is decreased from on quarter to the next.
Pt = number of motorcycles produced during quarter t ( t = 1, 2, 3, 4)
it = inventory at end of quarter t ( t = 1, 2, 3, 4)
xt = increase in quarter t production over quarter t - 1 production ( t = 1, 2, 3, 4)
xt = decrease in quarter t production from quarter t - 1 production ( t = 1, 2, 3, 4)
min z = 400P1 + 400P2 + 400P3 +400P4 +100i1 + 100i2 + 100i3 + 100i4 + 700x1 + 700x2 + 700x3 +
700x4 +600x1 + 600x2 + 600x3 + 600x4
s.t.
i1 = 0+P1 - 40
i2 = i1 + P2 - 70
i3 = i2 +P3 - 50
i4 = i3 + P4 - 20
P1 - 50 = x1 - x1
P2 - P1 = x2 - x2
P3 - P2 = x3 - x3
P4 - P3 = x4 - x4
it, Pt, xt, xt = 0 ( t = 1, 2, 3, 4)
Suppose that Mondo no longer must meet demands on time. For each quarter that demand for a motorcycle
is unmet, a penalty or shortage cost of $110 per motorcycle short is assessed. Thus, demand can now be
backlogged. All demands must be met, however, by the end of quarter 4. Modify the formulation of the
Mondo Problem that follows to allow for backlogged demand.
min z = 400P1 + 400P2 + 400P3 +400P4 +100 + (100i1 + 100i1 + 100i2 + 100i2 + 100i3 + 100i3 + 100i4
+ 110i4) + 700x1 + 700x2 + 700x3 + 700x4 +600x1 + 600x2 + 600x3 + 600x4
s.t.
i1-i1 = 0+P1 - 40
10-2 Lecture 10: October 31
i2-i2 = i1 i1 + P2 - 70
i3-i3 = i2 i2 +P3 - 50
i4-i4 = i3 i3 + P4 - 20
P1 - 50 = x1 - x1
P2 - P1 = x2 - x2
P3 - P2 = x3 - x3
P4 - P3 = x4 - x4
it = 0
it =0
i4 = 0
it, Pt, xt, xt = 0 ( t = 1, 2, 3, 4)