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

CASE 4.2 A MERICAN O FFICE S YSTEMS , I NC .

11

A merican Office Systems, Inc., was established by


the late R. J. Miller, Sr., in 1939. It started as an
office supply story in Mountain View, California, and
experiencing. As you know, it was only yesterday that,
finally, I was able to secure a $750,000 line of credit
for the coming year from Citibank. I might add that it
expanded slowly over the years into the manufacture is at a very favorable interest rate of 16%. This will
of small office equipment, overhead projectors, and partially solve our cash flow problems and it will have
bookkeeping machines. In the 1950s, computers a big effect on both production and advertising deci-
started eroding its market for bookkeeping machines, sions. In addition, there are financial and accounting
so the company diversified into the copy machine factors that must be allowed for in any decision about
market. However, it never captured a large market the adapters.” Olsen interjected, “Wow, this is more
share because bigger firms such as Xerox, Canon, complicated than I anticipated originally. Before we
Sharp, and A. B. Dick were so firmly entrenched. make a decision, I think we ought to use some
A few years ago, American Office Systems’ modern management science techniques to be sure
engineering staff developed an adapter that links a that all the relevant factors are considered. Last week
standard copy machine to personal computers, I hired Carlos Garcia from Stanford. He has a Master’s
allowing a copy machine to be used as a laser printer, Degree in Operations Research. I think this would be
scanner, and fax. The adapters show great promise a good project for him.” However, Williams said that
for both home and office use. However, the company she thinks that an executive, judgmental decision
is not well known by either the financial community would be much better.“Let’s not get carried away with
or the copy machine market, principally due to its any of the quantitative mumbo-jumbo that Rob is
small size and rather lackluster record, so it could always suggesting. Besides, his studies always take too
secure only $15 million in initial financial backing for much time and are so technical that no one can
the adapters. The $15 million was used to finance understand them. We need a decision by the end of
the construction of a small production facility and of next week.” After listening to the discussion, Miller
administrative offices in 1994, and in 1995 produc- decided to appoint an executive action team to study
tion and sales began. Two versions of the adapter the problem and make a recommendation at next
exist, one for IBM-compatible computers and one for week’s meeting.“Rob and Sue, I want both of you to
Macintosh computers. The former sells for $175 and document your arguments in more detail. J.T., be more
the latter for $200. precise with your comments about the cash flow,
At the beginning of December 1995, Dr. R. J. accounting, and financial problems. And, by the way
Miller, II, President, convened a meeting about the Rob, have Carlos look into a model to see if it might
coming year’s plans for the adapters. Rob Olsen,Vice produce some insights.”
President of Production, argued that production Most of the $15 million initial financing was used
facilities should be expanded: “Until we have sufficient to build a five-story building in Mountain View, south
capacity to produce the adapters,” he said,“there is no of San Francisco. Although currently only about 90%
use advertising.” Sue Williams, Director of Marketing, complete, it is being used. The first floor contains the
replied,“On the contrary, without any demand for the production and shipping facilities plus a small storage
adapters, there is no reason to produce them. We area. A larger warehouse, already owned by the
need to focus on advertising first.” J.T. Howell, the company, is located across the street. The other four
Comptroller, pointed out that Olsen and Williams floors of the building are for the engineering depart-
were talking about the situation as if it only involved a ment (second floor), a research lab (third floor), and
decision between production and marketing: “Yes, administration (top two floors). The production
funds need to be allocated between production and facility operates two shifts per day and has a produc-
advertising. However, more important than both is tion capacity of 30 IBM adapters and 10 Macintosh
the cash flow difficulty that the company has been adapters per hour. Olsen uses 20 production days
per month in his planning. Usually there are a few
11
This case was written by William D. Whisler, California State more, but these are reserved for maintenance and
University, Hayward. repairs. The last stage of the initial construction will

210 Chapter 4 Linear Programming Models


be finished by the beginning of the fourth quarter, problem—production, sales, advertising, inventory,
making the building 100% finished. This will increase accounting, and finance. A mixed-integer programming
the production capacity rates by 10%. model appears to be the most appropriate; however,
Howell normally does the company’s financial he asks Garcia to use linear programming as an
planning monthly, and he assumes that cash flows as- approximation due to the time limitations and
sociated with all current operating expenses, sales Williams’s concern about his ideas always being too
revenues (taking collections into account), advertising technical. “There will be more time after next week’s
costs, loans from the line of credit, investments of meeting to refine the model,” he says.
excess cash in short-term government securities, and After discussions with Olsen and Williams,
so forth, occur at the end of the corresponding Garcia feels that something needs to be done to help
month. Because he needs information for the meeting the company handle the uncertainty surrounding
next week, however, he decides to do a rough plan on future sales of the adapters. He points out that it is
a quarterly basis. This means that all the just men- impossible to guarantee that the company will never
tioned cash flows, and so on, will be assumed to occur be out of stock. However, it is possible to decrease
at the end of the quarter. After the meeting, when shortages so that any difficulties associated with
more time is available, the plan will be expanded to them would be small and they would not cause
a monthly basis. To get started, one of his senior major disruptions or additional management prob-
financial analysts prepares the list of quarterly fixed lems, such as excess time and cost spent expediting
operating expenses shown in Table 4.16. In addition, orders, and so forth. Thus, Garcia formulates an
the accounting department calculates that the variable inventory model. To be able to solve the model, he
costs of the adapters are $100 each for the IBM has to check the inventory levels of the adapters
version and $110 each for the Macintosh version. currently on hand in the warehouse. From these
quantities, he calculates that there will be 10,000 IBM
and 5,000 Macintosh adapters on hand at the begin-
Table 4.16 Quarterly Fixed Operating Expenses
ning of 1996. Based on the results of the model, he
Expense Cost recommends that a simple rule of thumb be used:
Administrative expense $1,500,000 production plus the end-of-period inventory for the
Fixed manufacturing costs 750,000 adapters should be at least 10% larger than the
Sales agents’ salaries 750,000 estimated sales for the next period. This would be
Depreciation 100,000 a safety cushion to help prevent shortages of the
adapters. In addition, to provide a smooth transition
At present, American Office Systems is to 1997, the inventory level plus production at the
experiencing a cash flow squeeze due to the large end of the fourth quarter of 1996 should be at least
cash requirements of the startup of the adapter twice the maximum expected sales for that quarter.
production, advertising, and sales costs. If excess cash Garcia says that using these rules of thumb will
is available in any quarter, however, Howell says that minimize annual inventory costs. When explaining
the company policy is to invest it in short-term the inventory model to Olsen, Garcia emphasizes
government securities, such as treasury bills. He the importance of including inventory carrying costs
estimates that during the coming year these as part of any analysis, even though such costs
investments will yield a return of 6%. frequently are not out-of-pocket. He says that his
Olsen asks Garcia to look into the production analysis of data provided by the accounting depart-
and inventory aspects of the situation first, because ment yielded a 1% per month inventory carry cost,
this area was his specialty at Stanford. Then he says and this is what he used in his model.
that he wants him to think about a programming Sales during the first year (1995) for the adapters
model that might integrate all components of the are shown in Table 4.17. Next year’s sales are

Case 4.2 American Office Systems, Inc. 211


uncertain. One reason for the uncertainty is that the third quarter. The remaining 2% are written off
they depend on the advertising. To begin the analysis, and sold to a collection agency for $0.50 on the dollar.
Williams asks her marketing research analyst, Debra
Lu, to estimate the maximum sales levels for the
coming four quarters if no advertising is done. Since Table 4.18 Collections
last year’s sales of both models showed a steady Quarter IBM Adapters Macintosh Adapters
increase throughout the year, Lu projects a 1 0.75 0.80
continuation of the trend. She forecasts that the 2 0.20 0.11
company will be able to sell any number of adapters 3 0.03 0.05
up to the maximum expected sales amounts shown
in Table 4.17.
Questions
Table 4.17 1995 Adapter Sales and Maximum 1. Suppose that you are Garcia. Develop an LP
Expected 1996 Sales spreadsheet model of the situation to help the
executive action team make a decision about
1996 Maximum
1995 Sales Expected Sales how to allocate funds between production and
advertising so that all the cash flow, financial,
IBM Macintosh IBM Macintosh
Quarter Adapters Adapters Adapters Adapters
accounting, marketing, inventory, and production
considerations are taken into account and
1 5,000 1,000 9,000 1,800 American Office Systems’ profits are maximized.
2 6,000 1,200 10,000 2,000 Use the data collected and the estimates made
3 7,000 1,400 11,000 2,200
4 8,000 1,600 12,000 2,400
by the members of the executive action team.
2. Solve the LP model formulated in Question 1.

Miller suggests that advertising in magazines The executive action team has assembled to reconsider
such as PC World and Home Office will increase the plans for the adapters for the coming year. Garcia, who
consumer awareness of both the company and developed the LP model, concludes his presentation by
adapters. The next day, Williams has a meeting with saying,“As everyone can see, the model gives the optimal
several staff members of a San Francisco advertising solution that maximizes profits. Since I have incorporated
agency. They show her recommendations for two the estimates and assumptions that all of you made,
types of ads (one for the IBM adapters and one for clearly it is the best solution. No other alternative can give
the Macintosh adapters), give her cost information, a higher profit.” Even Williams, who initially was skeptical
and the estimated effectiveness of an advertising of using quantitative models for making executive-level
campaign. Armed with this information and some decisions, is impressed and indicates that she will go along
data from Lu, Williams prepares a brief report for with the results.
Miller setting out her reasons for thinking that each Miller says,“Good work, Carlos! This is a complex
$10 spent on advertising will sell an additional IBM problem but your presentation made it all seem so simple.
adapter; the same relationship holds true for the However, remember that those figures you used were
Macintosh adapter. based on estimates made by all of us. Some were little bet-
Based on an analysis of 1995 sales and accounts ter than guesses. What happens if they are wrong? In
receivable, the accounting department determines that other words, your presentation has helped me get a handle
collection experience is as shown in Table 4.18. For on the problem we are facing, and I know that models are
example, 75% of the IBM adapters sold in a quarter useful where hard, accurate, data exist. However, with all
are paid for during the quarter, 20% are paid for dur- the uncertainty in our situation and the many rough esti-
ing the following quarter, and 3% are paid for during mates made, it seems to me that I will still have to make a

212 Chapter 4 Linear Programming Models


judgment call when it comes down to making a final cost $100,000 and will change the collection
decision. Also, there has been a new development. J.T. tells rates to those given in Table 4.19.
me that we might be able to get another $1 million a. Analyze the effect of this new collection
line of credit from a Bahamian bank. It will take a while policy and make a recommendation to Howell
to work out the details and maybe it will cost us a little. about whether to implement the new proce-
I am wondering if it is worth it. What would we do with dure. As before, any accounts receivable not
the $1 million if we got it?” T. J. responds,“We really need collected by the end of the third quarter will
the $1 million. But it is a drop in the bucket. My analysis be sold to a collection agency for $0.50 on
shows that we really need another $8 million line of the dollar.
credit.” b. Howell wonders whether switching to selling
Analyze, as Garcia is going to do, the effect of uncer- adapters for all cash is worth the effort. This
tainty and errors on the results of Questions 1 and 2 by would ameliorate the cash squeeze because it
answering the following questions.They should be would eliminate not only the slow collections
attempted only after Questions 1 and 2 have been but also the use of the collection agency for
answered correctly. accounts that remain unpaid after 9 months.
3. One area where assumptions were made is It would cost about $90,000 more than at
adapter price. present to implement the all-cash policy be-
a. What happens if the prices for the adapters cause the accounting system would need to
are a little weak and they decrease to $173 be modified and personnel would have to be
for the IBM version and $198 for the retrained. Analyze this possibility and make a
Macintosh version? Does this make any recommendation to Howell.
difference?
b. What about decreases to $172 and $197, Table 4.19 New Collections
respectively, for the IBM and Macintosh
Quarter IBM Adapters Macintosh Adapters
versions? Explain the answers in terms that
Miller will understand. 1 0.90 0.92
c. Suppose that American Office Systems can 2 0.07 0.03
increase the price of the adapters to $180 3 0.01 0.01
and $205. How would this affect the original
solution? 6. Yet another variable is advertising effectiveness.
4. Another potential variable is adapter production a. Suppose that Williams overestimated the
cost. effectiveness of advertising. It now appears
a. Suppose that an error was made in determin- that $100 is needed to increase sales by one
ing the costs of the adapters and that they adapter. How will this affect the original solu-
really should have been $102 for the IBM tion? Explain the answer in terms that Miller
version and $112 for the Macintosh version. will understand.
What is the effect of this error? b. What happens if the required advertising
b. What about costs of $105 and $115? Explain outlay is $12.50 per additional adapter sold?
the answers in terms that Miller will 7. Suppose that the line of credit from Citibank that
understand. Howell thought he had arranged did not work
5. Howell notes that one of the contributing factors out because of the poor financial situation of the
to American Office Systems’ cash squeeze is the company. The company can obtain one for the
slow collection of accounts receivable. He is con- same amount from a small local bank; however,
sidering adopting a new collection procedure the interest rate is much higher, 24%. Analyze
recommended by a consulting company. It will how this change affects American Office Systems.

Case 4.2 American Office Systems, Inc. 213


8. The safety cushion for inventory is subject to 10. Williams is worried about the accuracy of
revision. Lu’s 1996 maximum expected sales forecasts. If
a. Suppose that Garcia finds a bug in his original errors in these forecasts have a big effect on the
inventory model. Correcting it results in a company profits, she is thinking about hiring a
safety cushion of 15% instead of the 10% he San Francisco marketing research firm to do a
suggested previously. Determine whether this more detailed analysis. They would charge
is important. $50,000 for a study. Help Williams by analyzing
b. What if the error is 20%? Explain the answers what would happen if Lu’s forecasts are in error
in terms that Miller will understand. by 1,000 for IBM adapters and 200 for Macin-
9. Production capacity is scheduled to increase by tosh adapters each quarter. Should she hire the
10% in the fourth quarter. marketing research firm?
a. Suppose that Miller is advised by the 11. a. To determine whether the extra $1 million
construction company that the work will not line of credit is needed, analyze its effect on
be finished until the following year. How will the original solution given in Question 2.
this delay affect the company’s plans? b. To fully understand the ramifications of the
b. In addition to the delay in part a, suppose extra $1,000,000 line of credit, redo (1) Ques-
that an accident in the production facility tion 3b, (2) Question 4b, (3) Question 6a, and
damages some of the equipment so that the (4) Question 8b. Summarize your results.
capacity is decreased by 10% in the fourth c. What about Howell’s claim that an extra
quarter. Analyze how this will affect the $8,000,000 line of credit is necessary? Use
original solution. that adjustment and redo Question 6a. ■

214 Chapter 4 Linear Programming Models


3/17/2020 Case_Study_Worksheet - final 1.0

MGSC 404 Foundations of Decision Analytics

Case Study Worksheet


Team Members: Ammar Khan, Alexandre Chahtahtinsky, William Horwitz, Maguette Paye, Matanel
Cohen-Weinberg, Maxence Prémont

In [5]: from gurobipy import *


from datascience import *
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
import math
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

Question 1
Assumptions

Our model relies on the following assumptions:

1. American Office Systems, Inc. runs 2 work shifts of 8 hours every day.
2. The IBM and Macintosh adapters sell for $175 and $200 respectively
3. The IBM and Macintosh adapters cost $100 and $110 respectively

Decision Variables

We define the following decision variables:

1. P
A
i
= IBM adapters [in units] produced in quarter i, i = 1, 2, 3, 4
2. P
B
i
= Macintosh adaptors [in units] produced in quarter i, i = 1, 2, 3, 4
3. M
i
A
= IBM adapters marketing expense [in $] in quarter i, i = 1, 2, 3, 4
4. M
i
B
= Macintosh adapters marketing expense [in $] in quarter i, i = 1, 2, 3, 4

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 1/28


3/17/2020 Case_Study_Worksheet - final 1.0

Parameters

We define the following parameters:

1. Q
A
i
= IBM adapters [in units] sold in quarter i, i = 1, 2, 3, 4
2. Q
B
i
= Macintosh adapters [in units] sold in quarter i, i = 1, 2, 3, 4
3. I
A
i
= IBM adapters inventory [in units] at the end of quarter i, i = 1, 2, 3, 4
4. I
B
i
= Macintosh adapters inventory [in units] at the end of quarter i, i = 1, 2, 3, 4

Objective Function

Maximize Total Profits

A B
max (200 ∗ Q ) + (175 ∗ Q ) − Costs
i i
A B ∑ ( )
Q ,Q
i∈{1,2,3,4}

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 2/28


3/17/2020 Case_Study_Worksheet - final 1.0

Constraints
Production Constraints:

1. Pi
A
≤ 28800 maximum IBM adapters [in units] produced in quarter i, i = 1, 2, 3
2. P
A
4
≤ 31680 maximum IBM adapters [in units] produced in the fourth quarter

3. P
B
i
≤ 9600 maximum Macintosh adapters [in units] produced in quarter i, i = 1, 2, 3

4. P
B
4
≤ 10560 maximum Macintosh adapters [in units] produced in the fourth quarter

Invenotry Constraints

1. P
A
i
+ I iA ≥ (QA
j
)*1.1 necessary IBM adapters production for quarter i, i = 1, 2, 3 , where j = i + 1

2. P
A
4
+ I4A
≥ (Q4 )*2 necessary IBM adapters production for fourth quarter
A

3. P
B
i
+ I iB ≥ (Q )*1.1 necessary Macintosh adapters production for quarter i, i
B
j
= 1, 2, 3 , where
j = i + 1

4. P
B
4
+ I 4B ≥ (QB4
)*2 necessary Macintosh adapters production for fourth quarter
5. I
A
i
= I k + Pi - QA
A A
i
ending inventory for IBM adapters [in units] for quarter i, i = 2, 3, 4 , where
k = i − 1

6. I
A
1
= 10000 + PA 1
- QA
1
ending inventory for IBM adapters [in units] for the first quarter
7. I
B
i
= I k + Pi - Qi ending inventory for Macintosh adapters [in units] for quarter i, i =
B B B
2, 3, 4 , where
k = i − 1

8. I
B
1
= 5000 + PB
1
- QB
1
ending inventory for Macintosh adapters [in units] for the first quarter

Quantity Sold Constraints:

1. Q
A
i
= NiA + MiA /10 IBM adapter sold [in units] for quarter i, i = 1, 2, 3, 4

2. Q
B
i
= NiB + MiB /10 IBM adapter sold [in units] for quarter i, i = 1, 2, 3, 4

Budget Constraints:

1. P
A
i
*100 + MiA + PB
i
*110 + MiB ≤ 750000 for quarter i, i = 1, 2, 3, 4

In [6]: prod_capacity_a = [28800,28800,28800,31680]


prod_capacity_b = [9600,9600,9600,10560]
base_sales_a = [9000,10000,11000,12000]
base_sales_b = [1800,2000,2200,2400]

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 3/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [7]: model = Model('Case Study V1')

P_a={} ##Production for IBM


P_b={} ##Production for Macintosh
Q_a={} ##Quantity sold for IBM
Q_b={} ##Quantity sold for Mac
I_a={} ##End of period inventory for IBM
I_b={} ##End of period inventory for Macintosh
M_a={} ##Marketing expense for IBM
M_b={} ##Marketing expense for Macintosh
B={} ##Loan
C={} ##Cash on hand at quarter end
X={} ##Excess Cash

##Creating the production,Quantity sold, and end of period inventory variables


for i in np.arange(4):
P_a[i] = model.addVar(lb=0)
P_b[i] = model.addVar(lb=0)
Q_a[i] = model.addVar(lb=0)
Q_b[i] = model.addVar(lb=0)
I_a[i] = model.addVar(lb=0)
I_b[i] = model.addVar(lb=0)
M_a[i] = model.addVar(lb=0)
M_b[i] = model.addVar(lb=0)
B[i] = model.addVar(lb=0)
C[i] = model.addVar(lb=0)
X[i] = model.addVar(lb=0)

##Creating the constraints for production


con_production ={}
##For IBM
for i in np.arange(4):
con_production[i]=model.addConstr(P_a[i]<=prod_capacity_a[i])

##For Macintosh
for i in np.arange(4):
con_production[i+4]=model.addConstr(P_b[i]<=prod_capacity_b[i])

##Creating the constraints for end of period inventory


con_inventory={}
for i in np.arange(4):
if i==0:
con_inventory[i]=model.addConstr(I_a[i]==10000+P_a[i]-Q_a[i])##Quarter
1 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==5000+P_b[i]-Q_b[i])##Quarte
r 1 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
elif i<3:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##Quat
er 2-3 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])##Qu
arter 2-3 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
else:

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 4/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##Quat
er 4 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])##Qu
arter 4 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=2*Q_a[i])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=2*Q_b[i])

##Creating the constraints for Quantity sold


con_sales={}
##For IBM
for i in np.arange(4):
con_sales[i]=model.addConstr(Q_a[i]==base_sales_a[i]+M_a[i]*0.1) ##For IBM
con_sales[i+4]=model.addConstr(Q_b[i]==base_sales_b[i]+M_b[i]*0.1) ## For
Macintosh

##Creating the constraints for the loan


con_loan={}
for i in np.arange(4):
con_loan[i]=model.addConstr(B[i]<=750000)

##Creating constraints for the cashflow


con_cashflow={}
con_cashflow[0]=model.addConstr(C[0]==B[0]+(175*0.75*Q_a[0] + 175*0.2*8000 + 1
75*0.03*7000 + 175*0.02*0.5*7000)
+(200*0.8*Q_b[0] + 200*0.11*1600 + 200*0.05*140
0 + 200*0.04*0.5*1400)
-(100*P_a[0])-(110*P_b[0])-(100*0.03*I_a[0])-(1
10*0.03*I_b[0])
-M_a[0] - M_b[0]-500000)
con_cashflow[1]=model.addConstr(C[1]==B[1]+(175*0.75*Q_a[1] + 175*0.2*Q_a[0] +
175*0.03*8000 + 175*0.02*0.5*8000)
+(200*0.8*Q_b[1] + 200*0.11*Q_b[0] + 200*0.05*1
600 + 200*0.04*0.5*1600)
-(100*P_a[1])-(110*P_b[1])-(100*0.03*I_a[1])-(1
10*0.03*I_b[1])
-M_a[1] - M_b[1] - B[0]*1.04-500000)
con_cashflow[2]=model.addConstr(C[2]==B[2]+(175*0.75*Q_a[2] + 175*0.2*Q_a[1] +
175*0.03*Q_a[0] + 175*0.02*0.5*Q_b[0])
+(200*0.8*Q_b[2] + 200*0.11*Q_b[1] + 200*0.05*Q
_b[0] + 200*0.04*0.5*Q_b[0])
-(100*P_a[2])-(110*P_b[2])-(100*0.03*I_a[2])-(1
10*0.03*I_b[2])
-M_a[2] - M_b[2] - B[1]*1.04-500000)
con_cashflow[3]=model.addConstr(C[3]==B[3]+(175*0.75*Q_a[3] + 175*0.2*Q_a[2] +
175*0.03*Q_a[1] + 175*0.02*0.5*Q_b[1])
+(200*0.8*Q_b[3] + 200*0.11*Q_b[2] + 200*0.05*Q
_b[1] + 200*0.04*0.5*Q_b[1])
-(100*P_a[3])-(110*P_b[3])-(100*0.03*I_a[3])-(1
10*0.03*I_b[3])
-M_a[3] - M_b[3] - B[2]*1.04-500000)

##Creating constraints for the excess cash


con_excess_cash={}
for i in np.arange(4):
if C[i]>=0:
con_excess_cash[i]=model.addConstr(X[i]==C[i])
else: con_excess_cash[i]=model.addConstr(X[i]==0)

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 5/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_negative={}
for i in np.arange(4):
con_negative[i]=model.addConstr(P_a[i]>=0)
con_negative[i+4]=model.addConstr(P_b[i]>=0)
con_negative[i+8]=model.addConstr(M_a[i]>=0)
con_negative[i+12]=model.addConstr(M_b[i]>=0)
con_negative[i+16]=model.addConstr(B[i]>=0)

Academic license - for non-commercial use only

In [8]: ##Objective Function


obj = C[0]+C[1]+C[2]+C[3]+(X[0]*0.045+X[1]*0.03+X[2]*0.015)-(B[3]*1.04/1.06**(
1/4))+(175*0.2*Q_a[3] + 175*0.03*Q_a[2] + 175*0.02*0.5*Q_b[2])/(1.06**(1/4))+(
175*0.03*Q_a[3] + 175*0.02*0.5*Q_b[3])/(1.06**(2/4))+ (200*0.11*Q_b[3] + 200*
0.05*Q_b[2] + 200*0.04*0.5*Q_b[2])/(1.06**(1/4))+ (200*0.05*Q_b[3] + 200*0.04*
0.5*Q_b[3])/(1.06**(2/4))
model.setObjective(obj, GRB.MAXIMIZE)

model.optimize()

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 9.3764381e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 9.376438110e+06

In [9]: ##Results
inv_table_a=Table().with_columns('Quarters',[1,2,3,4],'Beginnig Inventory',[10
000,I_a[0].x,I_a[1].x,I_a[2].x]
,'Production IBM',[P_a[0].x,P_a[1].x,P_a[2].x,P_a[3].x]
,'Quantity Sold',[Q_a[0].x,Q_a[1].x,Q_a[2].x,Q_a[3].x]
,'Ending Inventory',[I_a[0].x,I_a[1].x,I_a[2].x,I_a[3].x])
inv_table_a

Out[9]: Quarters Beginnig Inventory Production IBM Quantity Sold Ending Inventory

1 10000 28800 38800 0

2 0 28800 26181.8 2618.18

3 2618.18 25943.8 28562 0

4 0 31680 21120 10560

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 6/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [10]: inv_table_b=Table().with_columns('Quarters',[1,2,3,4],'Beginnig Inventory',[50


00,I_b[0].x,I_b[1].x,I_b[2].x]
,'Production MAC',[P_b[0].x,P_b[1].x,P_b[2].x,P_b[3].x]
,'Quantity Sold',[Q_b[0].x,Q_b[1].x,Q_b[2].x,Q_b[3].x]
,'Ending Inventory',[I_b[0].x,I_b[1].x,I_b[2].x,I_b[3].x])
inv_table_b

Out[10]: Quarters Beginnig Inventory Production MAC Quantity Sold Ending Inventory

1 5000 9600 14600 0

2 0 9600 8727.27 872.727

3 872.727 8647.93 9520.66 0

4 0 10560 7040 3520

Question 2
In [11]: Solution = Table().with_columns([
'Quarters',[1,2,3,4],
'IBM Production',[P_a[0].x,P_a[1].x,P_a[2].x,P_a[3].x],
'Macintosh Production',[P_b[0].x,P_b[1].x,P_b[2].x,P_b[3].x],
'Marketing Expense IBM',[M_a[0].x,M_a[1].x,M_a[2].x,M_a[3].x],
'Marketing Expense Mac',[M_b[0].x,M_b[1].x,M_b[2].x,M_b[3].x]
])
Solution ## Multiply productions by 100 and 110.

Out[11]: IBM Macintosh Marketing Expense Marketing Expense


Quarters
Production Production IBM Mac

1 28800 9600 298000 128000

2 28800 9600 161818 67272.7

3 25943.8 8647.93 175620 73206.6

4 31680 10560 91200 46400

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 7/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [12]: plt.plot( 'Quarters', 'IBM Production', data=Solution, marker='o', markerfacec


olor='blue', markersize=12, color='skyblue', linewidth=4,label="IBM")
plt.plot( 'Quarters', 'Macintosh Production', data=Solution, marker='o', color
='red', markersize=12,linewidth=4, label="Macintosh")
plt.legend() ## Production Graph - label

Out[12]: <matplotlib.legend.Legend at 0x25011cc9d30>

In [13]: plt.plot( 'Quarters', 'Marketing Expense IBM', data=Solution, marker='o', mark


erfacecolor='blue', markersize=12, color='skyblue', linewidth=4,label="IBM")
plt.plot( 'Quarters', 'Marketing Expense Mac', data=Solution, marker='o', colo
r='red', markersize=12,linewidth=4, label="Macintosh")
plt.legend() ## Marketing graph - label

Out[13]: <matplotlib.legend.Legend at 0x25011fb22e8>

Other Questions
In [ ]: ##We need to answer Questions 3,4,6,7,10 and 2 original sensitivity analysis

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 8/28


3/17/2020 Case_Study_Worksheet - final 1.0

Question 3
Selling Price Sensitivity

What if the price of adapters were different?

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 9/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [14]: def sensitivity_price(price_IBM,price_MAC):


model=Model('Price Senstivity Model')

P_a={} ##Production for IBM


P_b={} ##Production for Macintosh
Q_a={} ##Quantity sold for IBM
Q_b={} ##Quantity sold for Mac
I_a={} ##End of period inventory for IBM
I_b={} ##End of period inventory for Macintosh
M_a={} ##Marketing expense for IBM
M_b={} ##Marketing expense for Macintosh
B={} ##Loan
C={} ##Cash on hand at quarter end
X={} ##Excess Cash

##Creating the production,Quantity sold, and end of period inventory varia


bles
for i in np.arange(4):
P_a[i] = model.addVar(lb=0)
P_b[i] = model.addVar(lb=0)
Q_a[i] = model.addVar(lb=0)
Q_b[i] = model.addVar(lb=0)
I_a[i] = model.addVar(lb=0)
I_b[i] = model.addVar(lb=0)
M_a[i] = model.addVar(lb=0)
M_b[i] = model.addVar(lb=0)
B[i] = model.addVar(lb=0)
C[i] = model.addVar(lb=0)
X[i] = model.addVar(lb=0)

##Creating the constraints for production


con_production ={}
##For IBM
for i in np.arange(4):
con_production[i]=model.addConstr(P_a[i]<=prod_capacity_a[i])

##For Macintosh
for i in np.arange(4):
con_production[i+4]=model.addConstr(P_b[i]<=prod_capacity_b[i])

##Creating the constraints for end of period inventory


con_inventory={}
for i in np.arange(4):
if i==0:
con_inventory[i]=model.addConstr(I_a[i]==10000+P_a[i]-Q_a[i])##Qua
rter 1 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==5000+P_b[i]-Q_b[i])##Qu
arter 1 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
elif i<3:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 2-3 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 2-3 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 10/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
else:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 4 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 4 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=2*Q_a[i])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=2*Q_b[i])

##Creating the constraints for Quantity sold


con_sales={}
##For IBM
for i in np.arange(4):
con_sales[i]=model.addConstr(Q_a[i]==base_sales_a[i]+M_a[i]*0.1) ##For
IBM
con_sales[i+4]=model.addConstr(Q_b[i]==base_sales_b[i]+M_b[i]*0.1) ##
For Macintosh

##Creating the constraints for the loan


con_loan={}
for i in np.arange(4):
con_loan[i]=model.addConstr(B[i]<=750000)

##Creating constraints for the cashflow


con_cashflow={}
con_cashflow[0]=model.addConstr(C[0]==B[0]+(price_IBM*0.75*Q_a[0] + price_
IBM*0.2*8000 + price_IBM*0.03*7000 + price_IBM*0.02*0.5*7000)
+(price_MAC*0.8*Q_b[0] + price_MAC*0.11*160
0 + price_MAC*0.05*1400 + price_MAC*0.04*0.5*1400)
-(100*P_a[0])-(110*P_b[0])-(100*0.03*I_a[0
])-(110*0.03*I_b[0])
-M_a[0] - M_b[0]-500000)
con_cashflow[1]=model.addConstr(C[1]==B[1]+(price_IBM*0.75*Q_a[1] + price_
IBM*0.2*Q_a[0] + price_IBM*0.03*8000 + price_IBM*0.02*0.5*8000)
+(price_MAC*0.8*Q_b[1] + price_MAC*0.11*Q_b
[0] + price_MAC*0.05*1600 + price_MAC*0.04*0.5*1600)
-(100*P_a[1])-(110*P_b[1])-(100*0.03*I_a[1
])-(110*0.03*I_b[1])
-M_a[1] - M_b[1] - B[0]*1.04-500000)
con_cashflow[2]=model.addConstr(C[2]==B[2]+(price_IBM*0.75*Q_a[2] + price_
IBM*0.2*Q_a[1] + price_IBM*0.03*Q_a[0] + price_IBM*0.02*0.5*Q_b[0])
+(price_MAC*0.8*Q_b[2] + price_MAC*0.11*Q_b
[1] + price_MAC*0.05*Q_b[0] + price_MAC*0.04*0.5*Q_b[0])
-(100*P_a[2])-(110*P_b[2])-(100*0.03*I_a[2
])-(110*0.03*I_b[2])
-M_a[2] - M_b[2] - B[1]*1.04-500000)
con_cashflow[3]=model.addConstr(C[3]==B[3]+(price_IBM*0.75*Q_a[3] + price_
IBM*0.2*Q_a[2] + price_IBM*0.03*Q_a[1] + price_IBM*0.02*0.5*Q_b[1])
+(price_MAC*0.8*Q_b[3] + price_MAC*0.11*Q_b
[2] + price_MAC*0.05*Q_b[1] + price_MAC*0.04*0.5*Q_b[1])
-(100*P_a[3])-(110*P_b[3])-(100*0.03*I_a[3
])-(110*0.03*I_b[3])
-M_a[3] - M_b[3] - B[2]*1.04-500000)

##Creating constraints for the excess cash


con_excess_cash={}
for i in np.arange(4):

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 11/28


3/17/2020 Case_Study_Worksheet - final 1.0

if C[i]>=0:
con_excess_cash[i]=model.addConstr(X[i]==C[i])
else: con_excess_cash[i]=model.addConstr(X[i]==0)

con_negative={}
for i in np.arange(4):
con_negative[i]=model.addConstr(P_a[i]>=0)
con_negative[i+4]=model.addConstr(P_b[i]>=0)
con_negative[i+8]=model.addConstr(M_a[i]>=0)
con_negative[i+12]=model.addConstr(M_b[i]>=0)
con_negative[i+16]=model.addConstr(B[i]>=0)

obj = C[0]+C[1]+C[2]+C[3]+(X[0]*0.045+X[1]*0.03+X[2]*0.015)-(B[3]*1.04/1.0
6**(1/4))+(price_IBM*0.2*Q_a[3] + price_IBM*0.03*Q_a[2] + price_IBM*0.02*0.5*Q
_b[2])/(1.06**(1/4))+(price_IBM*0.03*Q_a[3] + price_IBM*0.02*0.5*Q_b[3])/(1.06
**(2/4))+ (price_MAC*0.11*Q_b[3] + price_MAC*0.05*Q_b[2] + price_MAC*0.04*0.5*
Q_b[2])/(1.06**(1/4))+ (200*0.05*Q_b[3] + 200*0.04*0.5*Q_b[3])/(1.06**(2/4))
model.setObjective(obj, GRB.MAXIMIZE)

model.optimize()

return model.objVal

The price for adapters decreases to $173 for IBM and to $198 for Macintosh

In [15]: profit_sensitivity_1=sensitivity_price(173,198)
profit_sensitivity_1;

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 9.0615883e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 9.061588340e+06

In [16]: sen_p_1 = [173,198,profit_sensitivity_1]


sen_p_1

Out[16]: [173, 198, 9061588.340067077]

In [17]: x=[175,173,172,180]
y=[200,198,197,205]
z=[950,930,925,975]

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 12/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [279]: ax = plt.axes(projection='3d')

ax.scatter3D(x, y, z, c="red");

The price for adapters decreases to $172 for IBM and to $197 for Macintosh

In [239]: sensitivity_price(172,197)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 8.9041635e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 8.904163455e+06
Out[239]: 8904163.454891495

The price for adapters increasesto $180 for IBM and to $205 for Macintosh

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 13/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [240]: sensitivity_price(180,205)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 1.0163563e+07 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.01 seconds


Optimal objective 1.016356254e+07
Out[240]: 10163562.536296174

Question 4
Prodcution Cost Sensitivity

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 14/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [219]: def sensitivity_vc(vc_IBM,vc_MAC):


model=Model('Production Cost Senstivity Model')

P_a={} ##Production for IBM


P_b={} ##Production for Macintosh
Q_a={} ##Quantity sold for IBM
Q_b={} ##Quantity sold for Mac
I_a={} ##End of period inventory for IBM
I_b={} ##End of period inventory for Macintosh
M_a={} ##Marketing expense for IBM
M_b={} ##Marketing expense for Macintosh
B={} ##Loan
C={} ##Cash on hand at quarter end
X={} ##Excess Cash

##Creating the production,Quantity sold, and end of period inventory varia


bles
for i in np.arange(4):
P_a[i] = model.addVar(lb=0)
P_b[i] = model.addVar(lb=0)
Q_a[i] = model.addVar(lb=0)
Q_b[i] = model.addVar(lb=0)
I_a[i] = model.addVar(lb=0)
I_b[i] = model.addVar(lb=0)
M_a[i] = model.addVar(lb=0)
M_b[i] = model.addVar(lb=0)
B[i] = model.addVar(lb=0)
C[i] = model.addVar(lb=0)
X[i] = model.addVar(lb=0)

##Creating the constraints for production


con_production ={}
##For IBM
for i in np.arange(4):
con_production[i]=model.addConstr(P_a[i]<=prod_capacity_a[i])

##For Macintosh
for i in np.arange(4):
con_production[i+4]=model.addConstr(P_b[i]<=prod_capacity_b[i])

##Creating the constraints for end of period inventory


con_inventory={}
for i in np.arange(4):
if i==0:
con_inventory[i]=model.addConstr(I_a[i]==10000+P_a[i]-Q_a[i])##Qua
rter 1 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==5000+P_b[i]-Q_b[i])##Qu
arter 1 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
elif i<3:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 2-3 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 2-3 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 15/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
else:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 4 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 4 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=2*Q_a[i])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=2*Q_b[i])

##Creating the constraints for Quantity sold


con_sales={}
##For IBM
for i in np.arange(4):
con_sales[i]=model.addConstr(Q_a[i]==base_sales_a[i]+M_a[i]*0.1) ##For
IBM
con_sales[i+4]=model.addConstr(Q_b[i]==base_sales_b[i]+M_b[i]*0.1) ##
For Macintosh

##Creating the constraints for the loan


con_loan={}
for i in np.arange(4):
con_loan[i]=model.addConstr(B[i]<=750000)

##Creating constraints for the cashflow


con_cashflow={}
con_cashflow[0]=model.addConstr(C[0]==B[0]+(175*0.75*Q_a[0] + 175*0.2*8000
+ 175*0.03*7000 + 175*0.02*0.5*7000)
+(200*0.8*Q_b[0] + 200*0.11*1600 + 200*0.05*140
0 + 200*0.04*0.5*1400)
-(vc_IBM*P_a[0])-(vc_MAC*P_b[0])-(vc_IBM*0.03*I
_a[0])-(vc_MAC*0.03*I_b[0])
-M_a[0] - M_b[0]-500000)
con_cashflow[1]=model.addConstr(C[1]==B[1]+(175*0.75*Q_a[1] + 175*0.2*Q_a[
0] + 175*0.03*8000 + 175*0.02*0.5*8000)
+(200*0.8*Q_b[1] + 200*0.11*Q_b[0] + 200*0.05*1
600 + 200*0.04*0.5*1600)
-(vc_IBM*P_a[1])-(vc_MAC*P_b[1])-(vc_IBM*0.03*I
_a[1])-(vc_MAC*0.03*I_b[1])
-M_a[1] - M_b[1] - B[0]*1.04-500000)
con_cashflow[2]=model.addConstr(C[2]==B[2]+(175*0.75*Q_a[2] + 175*0.2*Q_a[
1] + 175*0.03*Q_a[0] + 175*0.02*0.5*Q_b[0])
+(200*0.8*Q_b[2] + 200*0.11*Q_b[1] + 200*0.05*Q
_b[0] + 200*0.04*0.5*Q_b[0])
-(vc_IBM*P_a[2])-(vc_MAC*P_b[2])-(vc_IBM*0.03*I
_a[2])-(vc_MAC*0.03*I_b[2])
-M_a[2] - M_b[2] - B[1]*1.04-500000)
con_cashflow[3]=model.addConstr(C[3]==B[3]+(175*0.75*Q_a[3] + 175*0.2*Q_a[
2] + 175*0.03*Q_a[1] + 175*0.02*0.5*Q_b[1])
+(200*0.8*Q_b[3] + 200*0.11*Q_b[2] + 200*0.05*Q
_b[1] + 200*0.04*0.5*Q_b[1])
-(vc_IBM*P_a[3])-(vc_MAC*P_b[3])-(vc_IBM*0.03*I
_a[3])-(vc_MAC*0.03*I_b[3])
-M_a[3] - M_b[3] - B[2]*1.04-500000)

##Creating constraints for the excess cash


con_excess_cash={}
for i in np.arange(4):

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 16/28


3/17/2020 Case_Study_Worksheet - final 1.0

if C[i]>=0:
con_excess_cash[i]=model.addConstr(X[i]==C[i])
else: con_excess_cash[i]=model.addConstr(X[i]==0)

con_negative={}
for i in np.arange(4):
con_negative[i]=model.addConstr(P_a[i]>=0)
con_negative[i+4]=model.addConstr(P_b[i]>=0)
con_negative[i+8]=model.addConstr(M_a[i]>=0)
con_negative[i+12]=model.addConstr(M_b[i]>=0)
con_negative[i+16]=model.addConstr(B[i]>=0)

obj = C[0]+C[1]+C[2]+C[3]+(X[0]*0.045+X[1]*0.03+X[2]*0.015)-(B[3]*1.04/1.0
6**(1/4))+(175*0.2*Q_a[3] + 175*0.03*Q_a[2] + 175*0.02*0.5*Q_b[2])/(1.06**(1/4
))+(175*0.03*Q_a[3] + 175*0.02*0.5*Q_b[3])/(1.06**(2/4))+ (200*0.11*Q_b[3] + 2
00*0.05*Q_b[2] + 200*0.04*0.5*Q_b[2])/(1.06**(1/4))+ (200*0.05*Q_b[3] + 200*0.
04*0.5*Q_b[3])/(1.06**(2/4))
model.setObjective(obj, GRB.MAXIMIZE)

model.optimize()

return model.objVal

The production cost increase to $102 for IBM and $112 for Macintosh

In [220]: sensitivity_vc(102,112)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 9.0613163e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 9.061316349e+06
Out[220]: 9061316.349095933

The production cost increases to $105 for IBM and $115 for Maintosh

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 17/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [221]: sensitivity_vc(105,115)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 8.5886337e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 8.588633707e+06
Out[221]: 8588633.707112465

Question 6
Advertising Effectiveness Sensitivity

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 18/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [225]: def sensitivity_marketing(advert_effect):


model=Model('Marketing Senstivity Model')

P_a={} ##Production for IBM


P_b={} ##Production for Macintosh
Q_a={} ##Quantity sold for IBM
Q_b={} ##Quantity sold for Mac
I_a={} ##End of period inventory for IBM
I_b={} ##End of period inventory for Macintosh
M_a={} ##Marketing expense for IBM
M_b={} ##Marketing expense for Macintosh
B={} ##Loan
C={} ##Cash on hand at quarter end
X={} ##Excess Cash

##Creating the production,Quantity sold, and end of period inventory varia


bles
for i in np.arange(4):
P_a[i] = model.addVar(lb=0)
P_b[i] = model.addVar(lb=0)
Q_a[i] = model.addVar(lb=0)
Q_b[i] = model.addVar(lb=0)
I_a[i] = model.addVar(lb=0)
I_b[i] = model.addVar(lb=0)
M_a[i] = model.addVar(lb=0)
M_b[i] = model.addVar(lb=0)
B[i] = model.addVar(lb=0)
C[i] = model.addVar(lb=0)
X[i] = model.addVar(lb=0)

##Creating the constraints for production


con_production ={}
##For IBM
for i in np.arange(4):
con_production[i]=model.addConstr(P_a[i]<=prod_capacity_a[i])

##For Macintosh
for i in np.arange(4):
con_production[i+4]=model.addConstr(P_b[i]<=prod_capacity_b[i])

##Creating the constraints for end of period inventory


con_inventory={}
for i in np.arange(4):
if i==0:
con_inventory[i]=model.addConstr(I_a[i]==10000+P_a[i]-Q_a[i])##Qua
rter 1 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==5000+P_b[i]-Q_b[i])##Qu
arter 1 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
elif i<3:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 2-3 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 2-3 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 19/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
else:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 4 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 4 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=2*Q_a[i])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=2*Q_b[i])

##Creating the constraints for Quantity sold


con_sales={}
##For IBM
for i in np.arange(4):
con_sales[i]=model.addConstr(Q_a[i]==base_sales_a[i]+M_a[i]/advert_eff
ect) ##For IBM
con_sales[i+4]=model.addConstr(Q_b[i]==base_sales_b[i]+M_b[i]/advert_e
ffect) ## For Macintosh

##Creating the constraints for the loan


con_loan={}
for i in np.arange(4):
con_loan[i]=model.addConstr(B[i]<=750000)

##Creating constraints for the cashflow


con_cashflow={}
con_cashflow={}
con_cashflow[0]=model.addConstr(C[0]==B[0]+(175*0.75*Q_a[0] + 175*0.2*8000
+ 175*0.03*7000 + 175*0.02*0.5*7000)
+(200*0.8*Q_b[0] + 200*0.11*1600 + 200*0.05*140
0 + 200*0.04*0.5*1400)
-(100*P_a[0])-(110*P_b[0])-(100*0.03*I_a[0])-(1
10*0.03*I_b[0])
-M_a[0] - M_b[0]-500000)
con_cashflow[1]=model.addConstr(C[1]==B[1]+(175*0.75*Q_a[1] + 175*0.2*Q_a[
0] + 175*0.03*8000 + 175*0.02*0.5*8000)
+(200*0.8*Q_b[1] + 200*0.11*Q_b[0] + 200*0.05*1
600 + 200*0.04*0.5*1600)
-(100*P_a[1])-(110*P_b[1])-(100*0.03*I_a[1])-(1
10*0.03*I_b[1])
-M_a[1] - M_b[1] - B[0]*1.04-500000)
con_cashflow[2]=model.addConstr(C[2]==B[2]+(175*0.75*Q_a[2] + 175*0.2*Q_a[
1] + 175*0.03*Q_a[0] + 175*0.02*0.5*Q_b[0])
+(200*0.8*Q_b[2] + 200*0.11*Q_b[1] + 200*0.05*Q
_b[0] + 200*0.04*0.5*Q_b[0])
-(100*P_a[2])-(110*P_b[2])-(100*0.03*I_a[2])-(1
10*0.03*I_b[2])
-M_a[2] - M_b[2] - B[1]*1.04-500000)
con_cashflow[3]=model.addConstr(C[3]==B[3]+(175*0.75*Q_a[3] + 175*0.2*Q_a[
2] + 175*0.03*Q_a[1] + 175*0.02*0.5*Q_b[1])
+(200*0.8*Q_b[3] + 200*0.11*Q_b[2] + 200*0.05*Q
_b[1] + 200*0.04*0.5*Q_b[1])
-(100*P_a[3])-(110*P_b[3])-(100*0.03*I_a[3])-(1
10*0.03*I_b[3])
-M_a[3] - M_b[3] - B[2]*1.04-500000)
##Creating constraints for the excess cash
con_excess_cash={}
for i in np.arange(4):

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 20/28


3/17/2020 Case_Study_Worksheet - final 1.0

if C[i]>=0:
con_excess_cash[i]=model.addConstr(X[i]==C[i])
else: con_excess_cash[i]=model.addConstr(X[i]==0)

con_negative={}
for i in np.arange(4):
con_negative[i]=model.addConstr(P_a[i]>=0)
con_negative[i+4]=model.addConstr(P_b[i]>=0)
con_negative[i+8]=model.addConstr(M_a[i]>=0)
con_negative[i+12]=model.addConstr(M_b[i]>=0)
con_negative[i+16]=model.addConstr(B[i]>=0)

obj = C[0]+C[1]+C[2]+C[3]+(X[0]*0.045+X[1]*0.03+X[2]*0.015)-(B[3]*1.04/1.0
6**(1/4))+(175*0.2*Q_a[3] + 175*0.03*Q_a[2] + 175*0.02*0.5*Q_b[2])/(1.06**(1/4
))+(175*0.03*Q_a[3] + 175*0.02*0.5*Q_b[3])/(1.06**(2/4))+ (200*0.11*Q_b[3] + 2
00*0.05*Q_b[2] + 200*0.04*0.5*Q_b[2])/(1.06**(1/4))+ (200*0.05*Q_b[3] + 200*0.
04*0.5*Q_b[3])/(1.06**(2/4))
model.setObjective(obj, GRB.MAXIMIZE)

model.optimize()

return model.objVal

The advertising effectiveness decreases to $100, where $100 can increase the demand by one unit

In [226]: sensitivity_marketing(100)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-02, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.1122074e+07 3.446418e+05 0.000000e+00 0s
19 2.7772152e+06 0.000000e+00 0.000000e+00 0s

Solved in 19 iterations and 0.02 seconds


Optimal objective 2.777215150e+06
Out[226]: 2777215.150349453

The advertising effectiveness decreases to $12.5, where $12.5 can increase the demand by one unit

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 21/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [228]: sensitivity_marketing(12.5)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [8e-02, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 9.1086150e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 9.108614991e+06
Out[228]: 9108614.990583539

Question 7
Credit Line Interest Sensitivity

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 22/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [231]: def sensitivity_interest(interest):


model=Model('Interest Senstivity Model')

P_a={} ##Production for IBM


P_b={} ##Production for Macintosh
Q_a={} ##Quantity sold for IBM
Q_b={} ##Quantity sold for Mac
I_a={} ##End of period inventory for IBM
I_b={} ##End of period inventory for Macintosh
M_a={} ##Marketing expense for IBM
M_b={} ##Marketing expense for Macintosh
B={} ##Loan
C={} ##Cash on hand at quarter end
X={} ##Excess Cash

##Creating the production,Quantity sold, and end of period inventory varia


bles
for i in np.arange(4):
P_a[i] = model.addVar(lb=0)
P_b[i] = model.addVar(lb=0)
Q_a[i] = model.addVar(lb=0)
Q_b[i] = model.addVar(lb=0)
I_a[i] = model.addVar(lb=0)
I_b[i] = model.addVar(lb=0)
M_a[i] = model.addVar(lb=0)
M_b[i] = model.addVar(lb=0)
B[i] = model.addVar(lb=0)
C[i] = model.addVar(lb=0)
X[i] = model.addVar(lb=0)

##Creating the constraints for production


con_production ={}
##For IBM
for i in np.arange(4):
con_production[i]=model.addConstr(P_a[i]<=prod_capacity_a[i])

##For Macintosh
for i in np.arange(4):
con_production[i+4]=model.addConstr(P_b[i]<=prod_capacity_b[i])

##Creating the constraints for end of period inventory


con_inventory={}
for i in np.arange(4):
if i==0:
con_inventory[i]=model.addConstr(I_a[i]==10000+P_a[i]-Q_a[i])##Qua
rter 1 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==5000+P_b[i]-Q_b[i])##Qu
arter 1 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
elif i<3:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 2-3 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 2-3 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 23/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
else:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 4 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 4 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=2*Q_a[i])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=2*Q_b[i])

##Creating the constraints for Quantity sold


con_sales={}
##For IBM
for i in np.arange(4):
con_sales[i]=model.addConstr(Q_a[i]==base_sales_a[i]+M_a[i]/10) ##For
IBM
con_sales[i+4]=model.addConstr(Q_b[i]==base_sales_b[i]+M_b[i]/10) ## F
or Macintosh

##Creating the constraints for the loan


con_loan={}
for i in np.arange(4):
con_loan[i]=model.addConstr(B[i]<=750000)

##Creating constraints for the cashflow


con_cashflow={}
con_cashflow={}
con_cashflow[0]=model.addConstr(C[0]==B[0]+(175*0.75*Q_a[0] + 175*0.2*8000
+ 175*0.03*7000 + 175*0.02*0.5*7000)
+(200*0.8*Q_b[0] + 200*0.11*1600 + 200*0.05*140
0 + 200*0.04*0.5*1400)
-(100*P_a[0])-(110*P_b[0])-(100*0.03*I_a[0])-(1
10*0.03*I_b[0])
-M_a[0] - M_b[0]-500000)
con_cashflow[1]=model.addConstr(C[1]==B[1]+(175*0.75*Q_a[1] + 175*0.2*Q_a[
0] + 175*0.03*8000 + 175*0.02*0.5*8000)
+(200*0.8*Q_b[1] + 200*0.11*Q_b[0] + 200*0.05*1
600 + 200*0.04*0.5*1600)
-(100*P_a[1])-(110*P_b[1])-(100*0.03*I_a[1])-(1
10*0.03*I_b[1])
-M_a[1] - M_b[1] - B[0]*(1+interest)-500000)
con_cashflow[2]=model.addConstr(C[2]==B[2]+(175*0.75*Q_a[2] + 175*0.2*Q_a[
1] + 175*0.03*Q_a[0] + 175*0.02*0.5*Q_b[0])
+(200*0.8*Q_b[2] + 200*0.11*Q_b[1] + 200*0.05*Q
_b[0] + 200*0.04*0.5*Q_b[0])
-(100*P_a[2])-(110*P_b[2])-(100*0.03*I_a[2])-(1
10*0.03*I_b[2])
-M_a[2] - M_b[2] - B[1]*(1+interest)-500000)
con_cashflow[3]=model.addConstr(C[3]==B[3]+(175*0.75*Q_a[3] + 175*0.2*Q_a[
2] + 175*0.03*Q_a[1] + 175*0.02*0.5*Q_b[1])
+(200*0.8*Q_b[3] + 200*0.11*Q_b[2] + 200*0.05*Q
_b[1] + 200*0.04*0.5*Q_b[1])
-(100*P_a[3])-(110*P_b[3])-(100*0.03*I_a[3])-(1
10*0.03*I_b[3])
-M_a[3] - M_b[3] - B[2]*(1+interest)-500000)
##Creating constraints for the excess cash
con_excess_cash={}
for i in np.arange(4):

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 24/28


3/17/2020 Case_Study_Worksheet - final 1.0

if C[i]>=0:
con_excess_cash[i]=model.addConstr(X[i]==C[i])
else: con_excess_cash[i]=model.addConstr(X[i]==0)

con_negative={}
for i in np.arange(4):
con_negative[i]=model.addConstr(P_a[i]>=0)
con_negative[i+4]=model.addConstr(P_b[i]>=0)
con_negative[i+8]=model.addConstr(M_a[i]>=0)
con_negative[i+12]=model.addConstr(M_b[i]>=0)
con_negative[i+16]=model.addConstr(B[i]>=0)

obj = C[0]+C[1]+C[2]+C[3]+(X[0]*0.045+X[1]*0.03+X[2]*0.015)-(B[3]*(1+inter
est)/1.06**(1/4))+(175*0.2*Q_a[3] + 175*0.03*Q_a[2] + 175*0.02*0.5*Q_b[2])/(1.
06**(1/4))+(175*0.03*Q_a[3] + 175*0.02*0.5*Q_b[3])/(1.06**(2/4))+ (200*0.11*Q_
b[3] + 200*0.05*Q_b[2] + 200*0.04*0.5*Q_b[2])/(1.06**(1/4))+ (200*0.05*Q_b[3]
+ 200*0.04*0.5*Q_b[3])/(1.06**(2/4))
model.setObjective(obj, GRB.MAXIMIZE)

model.optimize()

return model.objVal

In [232]: annual_interest = 0.24


quarterly_interest = annual_interest/4
sensitivity_interest(quarterly_interest)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.01s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 9.3764381e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.02 seconds


Optimal objective 9.376438110e+06
Out[232]: 9376438.11041825

Question 10
Minimum Expected Sales Sensitivity

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 25/28


3/17/2020 Case_Study_Worksheet - final 1.0

In [235]: def sensitivity_base_sales(error_IBM,error_MAC):


model = Model('Base Sales Sensitivity Model')

base_sales_a = [9000-error_IBM,10000-error_IBM,11000-error_IBM,12000-error
_IBM]
base_sales_b = [1800-error_MAC,2000-error_MAC,2200-error_MAC,2400-error_MA
C]

P_a={} ##Production for IBM


P_b={} ##Production for Macintosh
Q_a={} ##Quantity sold for IBM
Q_b={} ##Quantity sold for Mac
I_a={} ##End of period inventory for IBM
I_b={} ##End of period inventory for Macintosh
M_a={} ##Marketing expense for IBM
M_b={} ##Marketing expense for Macintosh
B={} ##Loan
C={} ##Cash on hand at quarter end
X={} ##Excess Cash

##Creating the production,Quantity sold, and end of period inventory varia


bles
for i in np.arange(4):
P_a[i] = model.addVar(lb=0)
P_b[i] = model.addVar(lb=0)
Q_a[i] = model.addVar(lb=0)
Q_b[i] = model.addVar(lb=0)
I_a[i] = model.addVar(lb=0)
I_b[i] = model.addVar(lb=0)
M_a[i] = model.addVar(lb=0)
M_b[i] = model.addVar(lb=0)
B[i] = model.addVar(lb=0)
C[i] = model.addVar(lb=0)
X[i] = model.addVar(lb=0)

##Creating the constraints for production


con_production ={}
##For IBM
for i in np.arange(4):
con_production[i]=model.addConstr(P_a[i]<=prod_capacity_a[i])

##For Macintosh
for i in np.arange(4):
con_production[i+4]=model.addConstr(P_b[i]<=prod_capacity_b[i])

##Creating the constraints for end of period inventory


con_inventory={}
for i in np.arange(4):
if i==0:
con_inventory[i]=model.addConstr(I_a[i]==10000+P_a[i]-Q_a[i])##Qua
rter 1 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==5000+P_b[i]-Q_b[i])##Qu
arter 1 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
elif i<3:

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 26/28


3/17/2020 Case_Study_Worksheet - final 1.0

con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 2-3 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 2-3 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=1.1*Q_a[i+1])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=1.1*Q_b[i+1])
else:
con_inventory[i]=model.addConstr(I_a[i]==I_a[i-1]+P_a[i]-Q_a[i])##
Quater 4 for IBM
con_inventory[i+4]=model.addConstr(I_b[i]==I_b[i-1]+P_b[i]-Q_b[i])
##Quarter 4 for MAC
con_inventory[i+8]=model.addConstr(I_a[i]+P_a[i]>=2*Q_a[i])
con_inventory[i+12]=model.addConstr(I_b[i]+P_b[i]>=2*Q_b[i])

##Creating the constraints for Quantity sold


con_sales={}
##For IBM
for i in np.arange(4):
con_sales[i]=model.addConstr(Q_a[i]==base_sales_a[i]+M_a[i]*0.1) ##For
IBM
con_sales[i+4]=model.addConstr(Q_b[i]==base_sales_b[i]+M_b[i]*0.1) ##
For Macintosh

##Creating the constraints for the loan


con_loan={}
for i in np.arange(4):
con_loan[i]=model.addConstr(B[i]<=750000)

##Creating constraints for the cashflow


con_cashflow={}
con_cashflow[0]=model.addConstr(C[0]==B[0]+(175*0.75*Q_a[0] + 175*0.2*8000
+ 175*0.03*7000 + 175*0.02*0.5*7000)
+(200*0.8*Q_b[0] + 200*0.11*1600 + 200*0.05
*1400 + 200*0.04*0.5*1400)
-(100*P_a[0])-(110*P_b[0])-(100*0.03*I_a[0
])-(110*0.03*I_b[0])
-M_a[0] - M_b[0]-500000)
con_cashflow[1]=model.addConstr(C[1]==B[1]+(175*0.75*Q_a[1] + 175*0.2*Q_a[
0] + 175*0.03*8000 + 175*0.02*0.5*8000)
+(200*0.8*Q_b[1] + 200*0.11*Q_b[0] + 200*0.
05*1600 + 200*0.04*0.5*1600)
-(100*P_a[1])-(110*P_b[1])-(100*0.03*I_a[1
])-(110*0.03*I_b[1])
-M_a[1] - M_b[1] - B[0]*1.04-500000)
con_cashflow[2]=model.addConstr(C[2]==B[2]+(175*0.75*Q_a[2] + 175*0.2*Q_a[
1] + 175*0.03*Q_a[0] + 175*0.02*0.5*Q_b[0])
+(200*0.8*Q_b[2] + 200*0.11*Q_b[1] + 200*0.
05*Q_b[0] + 200*0.04*0.5*Q_b[0])
-(100*P_a[2])-(110*P_b[2])-(100*0.03*I_a[2
])-(110*0.03*I_b[2])
-M_a[2] - M_b[2] - B[1]*1.04-500000)
con_cashflow[3]=model.addConstr(C[3]==B[3]+(175*0.75*Q_a[3] + 175*0.2*Q_a[
2] + 175*0.03*Q_a[1] + 175*0.02*0.5*Q_b[1])
+(200*0.8*Q_b[3] + 200*0.11*Q_b[2] + 200*0.
05*Q_b[1] + 200*0.04*0.5*Q_b[1])
-(100*P_a[3])-(110*P_b[3])-(100*0.03*I_a[3
])-(110*0.03*I_b[3])

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 27/28


3/17/2020 Case_Study_Worksheet - final 1.0

-M_a[3] - M_b[3] - B[2]*1.04-500000)

##Creating constraints for the excess cash


con_excess_cash={}
for i in np.arange(4):
if C[i]>=0:
con_excess_cash[i]=model.addConstr(X[i]==C[i])
else: con_excess_cash[i]=model.addConstr(X[i]==0)

con_negative={}
for i in np.arange(4):
con_negative[i]=model.addConstr(P_a[i]>=0)
con_negative[i+4]=model.addConstr(P_b[i]>=0)
con_negative[i+8]=model.addConstr(M_a[i]>=0)
con_negative[i+12]=model.addConstr(M_b[i]>=0)
con_negative[i+16]=model.addConstr(B[i]>=0)

obj = C[0]+C[1]+C[2]+C[3]+(X[0]*0.045+X[1]*0.03+X[2]*0.015)-(B[3]*1.04/1.0
6**(1/4))+(175*0.2*Q_a[3] + 175*0.03*Q_a[2] + 175*0.02*0.5*Q_b[2])/(1.06**(1/4
))+(175*0.03*Q_a[3] + 175*0.02*0.5*Q_b[3])/(1.06**(2/4))+ (200*0.11*Q_b[3] + 2
00*0.05*Q_b[2] + 200*0.04*0.5*Q_b[2])/(1.06**(1/4))+ (200*0.05*Q_b[3] + 200*0.
04*0.5*Q_b[3])/(1.06**(2/4))
model.setObjective(obj, GRB.MAXIMIZE)

model.optimize()

return model.objVal

In [236]: sensitivity_base_sales(1000,200)

Optimize a model with 64 rows, 44 columns and 163 nonzeros


Coefficient statistics:
Matrix range [1e-01, 2e+02]
Objective range [1e-02, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [2e+03, 8e+05]
Presolve removed 44 rows and 12 columns
Presolve time: 0.03s
Presolved: 20 rows, 32 columns, 99 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time


0 3.8976000e+32 3.000000e+30 3.897600e+02 0s
16 9.3273581e+06 0.000000e+00 0.000000e+00 0s

Solved in 16 iterations and 0.05 seconds


Optimal objective 9.327358110e+06
Out[236]: 9327358.11041825

localhost:8888/nbconvert/html/Case_Study_Worksheet - final 1.0 .ipynb?download=false 28/28

You might also like