Professional Documents
Culture Documents
Business Analytics: What Is Optimization?
Business Analytics: What Is Optimization?
Analytics
Session 3
Optimization
Sebastian del Bano Rollin
London Business School
london.edu
Optimization
What is optimization?
What is Optimization?
You can only optimize a single number!
One trivial remark but that is not always understood by your boss is:
• You can only optimize one number.
• But not two or more. E.g. you cannot optimize both revenue and
work hours at the same time.
“Profound” mathematical reason is that
the numbers are ‘ordered’, but the
points in a plane are not.
Optimization
We will use the Solver Add-in which is built-in Excel but needs to be
activated.
To do so, in Windows, do File->
Options->Manage->Excel Add-ins->
Go and select Solver
Add-In.
•
The tool: Excel
Excel Solver Add-ini
Optimization
MODEL
CONSTRAINTS DECISION
VARIABLES
MODEL?
?
?
CONSTRAINTS ? DECISION
VARIABLES ?
london.edu ?
CM24 Business Analytics – Sebastian del Bano Rollin 12
Anatomy of an optimization problem
Linear optimization
DECISION
CONSTRAINTS OUTPUT
INPUTS MODEL
(objective
2x + 6y < 150 x function)
x + .8y < 40 10x + 18y
x + 1.5y < 50 y Maximize
10x + 18y
First example –
Doing things by hand
Additionally:
He has a contract that forces him to manufacture 5 sports mufflers per
month and knows, from historical performance, that demand for family
mufflers in a given month will not exceed 35. These constraints can be
modelled as:
f ≤ 35 (maximum demand)
s≥ 5 (contractual obligation)
25
20
Sports
15
10
0
0 10 20 30 40 50 60 70 80
Family
25
2f+6s>150
20
Sports
15
10
2f+6s<150
5 2f+6s=150
0
0 10 20 30 40 50 60 70 80
Family
Terminology: the feasible region is the set of values that satisfy our
constraints. If we only consider the brackets constraint, this is the blue
region below:
Points outside of the blue region are unfeasible as they use more than
the 150 brackets available.
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 21
2f + 6s ≤ 150 (brackets)
f + 0.8s ≤ 40 (labour)
f + 1.5s ≤ 50 (alloy)
f ≤ 35 (maximum demand)
s ≥5 (contractual obligation)
The feasible region for the model is the yellow region enclosed by all
lines:
2f + 6s ≤ 150 (brackets)
f + 0.8s ≤ 40 (labour)
f + 1.5s ≤ 50 (alloy)
f ≤ 35 (maximum demand)
s ≥5 (contractual obligation)
Optimal
The optimal point is a mix of 25 point
family mufflers and 16.67 sport
mufflers. This combination will
net Bob $550.
Optimization
First example –
Using Excel Solver
• Objective cell: One cell, the objective cell, contains the value of the objective. Solver varies the
values in the changing cells to optimize the value in the objective cell. This cell must be linked,
either directly or indirectly, to the changing cells by formulas.#
• Minimize or Maximize?: In our example we are maximizing profit
• Changing cells: Instead of using variable names, such as x, spreadsheet models use a set of
designated cells for the decision variables. The values in these cells can be changed to optimize
the objective. The values must be allowed to vary, so there should not be any formulas in them.
• Constraints. Excel does not show the constraints directly on the spreadsheet. Instead, they are
specified in a Solver dialog box. For example, a set of related constraints might be specified by,
e.g., B16:C16<=B18:C18
• Non-negativity. Normally, the decision variables –the values in the changing cells – must be non-
negative. Simply check an option in the Solver dialog box.
• Inputs. You might have other numerical inputs that are part of the calculations. These should be
clearly labelled in Excel but they are not needed by the Solver.
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 30
• Solving Method: Choose LP Simplex
Sample Excel model
Decision variables
Constraints
• The first column, Final Value, is the amount of mufflers of each type we should produce.
• The third column, Objective Coefficient, is the profit per muffler, this is what we have set in Excel.
• The last two columns, Allowable increase/decrease, indicate how much you can change the
profit per muffler without affecting the optimal mix
• Family mufflers have a contribution of $10: this is how much money we make by selling a family muffler. If the
contribution of family mufflers stays within the allowable increase of $2 or allowable decrease of $4, or in other words
between 10-4=$6 and 10+2 =$12, the optimal mix would not change.
• Reduced cost only refers to variables where the Final Value is 0. I.e. they were not selected in
the mix. E.g. if they did not result in sufficient profit. Reduced cost will be the improvement in
profit that would result in the item being added in the optimal mix. In the example, Reduced Cost is
0 as both mufflers are included in the optimal mix. More on this later.
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 39
• The first column, Final value is the value the constraint hit in the
optimal mix.
• The third column, Constraint R.H. Side, is the limit constraint value
we have provided. (R.H. Side means right hand side of an inequality)
• For binding constraints we have that these two coincide, as we have
hit the limit.
• Bracket and alloy
constraints are binding.
• None other constraint is
binding.
Optimization
• dd
Remember
• Reduced Cost: The deterioration in the objective function if we force one unit of a
sub-optimal activity (zero level) into the optimal solution. Alternatively, the amount
by which we need to improve the contribution of sub-optimal activities before they
could enter the optimal solution on their own merit.
• Shadow Price: The amount by which the objective value will improve if we relax
the constraint by one unit. It is the most we are willing to pay to obtain an
additional unit of that resource.
Sensitivity analysis show what happens when a single input changes and all others
remain constant. Another way to do sensitivity analysis is to change the inputs and
re-run Solver. This is more straightforward, but can be tedious if there are a lot of
inputs. This “trial and error” approach allows multiple changes in inputs.
Can you think what these numbers will indicate in the business problem at
hand?
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 48
Interpret shadow prices and reduced cost
What do the numbers mean?
Question:
• What is special about the decision variables with non-zero reduced cost?
• What is special about the lines with non-zero shadow price?
• Interpret numbers in yellow and green.
A reduced cost for a product not in the optimal mix (yellow cells)
indicates how much greater its margin would have to be before it would
enter the optimal mix.
Number tested on line 1 Model 2 has a
reduced cost of -20 and a Final Value of 0,
i.e., we are not producing any at all. We can
think of the reduced cost of -20 in two ways:
• Our profit would reduce by $20 if we are forced
to produce a model 2 which is tested on line
1.
A nonzero shadow price (green cells) indicates how much profit would
change for a one-unit increase in that constraint. But this holds only for
changes within the allowable increase and decrease.
Labour hours for assembly has a shadow price = 29.50$. As long as the
number of assembly hours is between 20,000-2,375 and 20,000+3,250,
then any change in
assembly hours will
impact profit by 29.50$.
A zero shadow price
usually indicates that
we have more of the
resource than we need.
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 51
Optimization
Meeting:
• tomato crop has already been paid for and was beginning to arrive
• amount of tomato products to pack for the coming season?
•london.edu
packing operations start MondayCM24 Business Analytics – Sebastian del Bano Rollin 53
Quality
Tucker proposes:
• Use all grade A to sell whole tomatoes
• Can place all existing 600,000 pounds grade A (9 points) plus 200,000 grade B
(5 points) which results in a mix of (600,000*9+200,000*5)/800,000=8 points
• These 800,000 lbs make 44,444 cases.
• And the rest (2,200,000 lbs) sell as paste (5 points).
• This translates into 110,000 cases. But there is a cap on 80,000 cases of paste.
Myer’s Proposal
Let us set an internal price for grade A vs grade B tomatoes
Myers questions the fruit expense numbers above as each product quality
requirements implies a different cost of fruit
• So could use a price proportional to the required quality of fruit to build this in
• So if 1 pound of quality A holds 9 points, and 1 pound of quality B 5 points
• Then our whole stock of 600k lbs quality A and 2.4m lbs quality B holds 17.4 m
points. And each point is worth $540k/17.4m = 3.10 cents
• And one pound of point 8 whole tomato for canning should be worth 8*3.10 = 24.85 cents
($4.47 per case).
• One pound of point 6 tomato for juice 18.64 cents ($3.72 per case).
• One pound of point 5 tomato for paste 15.53 cents ($3.90 per case).
Myer’s Proposal
The variables we will consider are the thousand pounds invested for
each product from each of
the two quality grades: AW,
AJ, AP, BW, BJ, and BP.
Should we buy extra 80,000 extra lbs of Grade A tomatoes at 25.5 c (0.255)/lb?
Should we buy extra 80,000 extra lbs of Grade A tomatoes at 25.5 c (0.255)/lb?
• The shadow price is the increase in the objective if we increase the right-hand side of the corresponding
constraint by 1 unit.
• Shadow price of “Tomato A Pounds Used” (grade A supply constraint): $271 (/1000 pounds)
• We should be willing to pay up to $0.271/lb of grade A tomatoes. This is true for up to an additional 9.13m lbs
grade A tomatoes (“Allowable Increase”), beyond that the value of extra A tomatoes may be less.
• We should buy the 80,000 extra pounds at a price of $255/1000 pounds: net benefit = $271-$255 = $16/1000
pounds, $1,280 (=80*16) in total
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 67
Optimization
Portfolio Optimization
1 1
7% + 11% = 9%
2 2 Equities (stocks)
london.edu CM24 Business Analytics – Sebastian del Bano Rollin -20% -10% 0% 10% 20%
69 30%
1 1 1 1
𝐸 𝑅1 + 𝑅2 = 𝐸 𝑅1 + 𝐸 𝑅2
2 2 2 2
Which is what we had above: the return of the portfolio is just the
average return.
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 70
Combining Assets in a Portfolio
Variability of a Portfolio: standard deviation and variance
2 2 2
1 1 1 1 1
𝑆𝐷2 𝑅1 + 𝑅2 = 𝑆𝐷2 𝑅1 + 𝑆𝐷2 𝑅2 + 2 𝑆𝐷 𝑅1 𝑆𝐷(𝑅2 )𝐶𝑜𝑟𝑟𝑒𝑙 𝑅1 , 𝑅2
london.edu
2 2 2 2
CM24 Business Analytics – Sebastian del Bano Rollin
2 72
Combining Assets in a Portfolio
Variance of a Portfolio
If our portfolio is not 50%/50% but instead defined by two weights, 𝑤1 % and 𝑤2 %, we
just replace the 50%’s by relevant weights:
• In about the 4th century, Rabbi Issac bar Aha proposed the following rule for asset
allocation: “One should always divide his wealth into three parts: a third in land, a
third in merchandise, and a third ready to hand.”
Babylonian Talmud: Tractate Baba Mezi’a,
folio 42a.
• Markowitz (1952) derived the optimal rule for
allocating wealth across risky assets in a static
setting when investors care only about the
mean (return) and variance (risk) of a portfolio’s
return.
The expected return is always the weighted average of the two returns.
But the risk (volatility) depends on the correlation.
It is lowest when the correlation is negative and highest when the two assets are
perfectly correlated.
Portfolio Optimization
We are going to see how to best pick portfolio allocations (the numbers
𝑤1 and 𝑤2 above)
Is that right?
Well, no.
Portfolio Optimization
An example
Stockco can invest in three different stocks. From past data, the means and SDs of
annual returns and correlations between annual returns have been estimated as
follows:
Mean SD Correlations
Stock 1 14% 20% Stocks 1 and 2 = 60%
Stock 2 11% 15% Stocks 1 and 3 = 40%
Stock 3 10% 8% Stocks 2 and 3 = 70%
Stockco wants to find a minimum variance portfolio that yields an expected annual
return of at least 12%
Portfolio Optimization
A B C D E F G H I J
• Correlations 11 Stock 2
12 Stock 3
0.6
0.4
1
0.7
0.7
1
invested, not dollar values. The ones
shown here are not optimal.
13
portfolio fractions to be 23
24
Stock 1 Stock 2 Stock 3
optimized. 25
26 Portfolio variance
27
london.edu CM24 Business Analytics – Sebastian del Bano Rollin 80
28 Portfolio stdev
Portfolio Optimization
A B C D E F G H I J
Portfolio Optimization
Variance for a portfolio with 3 assets
Portfolio Optimization
Portfolio variance with matrix multiplication
In our case we have 3 assets. You could write a very long formula like
the one above for the variance of the portfolio. But it is easier using
matrices:
1 𝜚12 𝜚13 𝑤1 𝜎1
2 𝜚12 1 𝜚23 𝑤2 𝜎2
𝜎𝑃𝑜𝑟𝑡𝑓𝑜𝑙𝑖𝑜 = 𝑤1 𝜎1 , 𝑤2 𝜎2 , 𝑤3 𝜎3
𝜚13 𝜚23 1 𝑤3 𝜎3
deviations. 11 Stock 2
12 Stock 3
0.6
0.4
1
0.7
0.7
1
13
14 Investment decision
Then we are ready to go. 15
16 Fractions to invest
Stock 1
0.5
Stock 2
0
Stock 3
0.5
Total
1 =
Required
1
17
18 Expected portfolio return
Just run solver as usual and 19 Actual Required
minimize variance. 20
21
0.12 >= 0.12
No money in stock 2 10
11
Stock 1
Stock 2
1
0.6
0.6
1
0.4
0.7
12 Stock 3 0.4 0.7 1
13
14 Investment decision
15 Stock 1 Stock 2 Stock 3 Total Required
met exactly
18 Expected portfolio return
from the Solver.
19 Actual Required
20 0.12 >= 0.12
21
22 Standard deviations times fractions invested
23 Stock 1 Stock 2 Stock 3
24 0.1 0 0.04
12%
london.edu
29