Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Optimization Problem

Views: 311
# Optimization Problem # Goal: To find the amount of each type of books to be sold in order to maximize profits # Variables # x = number of applied version of the book sold # y = number of the traditional version of the book sold # Cx = cost to produce the applied version of the book = 60 # Cy = cost to produce the traditional version of the book = 30 # C = total cost # C = Cx + Cy # sx = selling price of the applied version of the textbook # sy = selling price of the traditional version of the textbook # R = total revenue # R = sx + sy # P = profit # P = R - C # Assumptions # Cx = 60*x # Cy = 30*y # C = 60*x + 30*y # s = 450-0.01*x # s = 450-0.002*y # R = s(x) + s(y) # P = R(x,y) - C(x,y) # Constraint x + y <= 16000 # a- State the model for the profit as a function of the number of applied and traditional books sold Cx(x) = 60*x Cy(y) = 30*y C(x,y) = Cx(x) + Cy(y) s(x) = 450-0.01*x-0.002*y s(y) = 250-0.002*x-0.003*y R(x,y) = s(x)*x + s(y)*y P(x,y) = R(x,y) - C(x,y) show(P)
(x,y)  x(0.00500000000000000x+250)+(0.00200000000000000x0.00300000000000000y+250)y60x30y\displaystyle \left( x, y \right) \ {\mapsto} \ x {\left(-0.00500000000000000 \, x + 250\right)} + {\left(-0.00200000000000000 \, x - 0.00300000000000000 \, y + 250\right)} y - 60 \, x - 30 \, y
# b- Produce a contour plot of the profit function and sketch the feasible region p1=contour_plot(P(x,y),(x,0,17000),(y,0,17000)) p2=implicit_plot(x+y==16000 ,(x,0,17000),(y,0,17000),color='blue') plot(p1+p2)
# c- Determine the amount of each type of book to be sold in order to maximize profits L1 = var('L1') g(x,y) = x+y eq = solve([diff(P,x)==L1*diff(g,x),diff(P,y)==L1*diff(g,y), g(x,y)==16000], x,y,L1)
show(eq)
[[x=(85003)\displaystyle x = \left(\frac{8500}{3}\right), y=(395003)\displaystyle y = \left(\frac{39500}{3}\right), L1=(4063)\displaystyle L_{1} = \left(\frac{406}{3}\right)]]
P(eq[0][0].rhs(),eq[0][1].rhs()) # Maximum profit
2.80016666666667e6
# Test points P(0,0)
0.000000000000000
P(16000,0)
1.76000000000000e6
P(8000,8000)
2.64000000000000e6
P(0,16000)
2.75200000000000e6
# Compute the sensitivity of the number of applied books sold to price elasticity of the applied book ($0.02) Cx(x) = 60*x Cy(y) = 30*y C(x,y) = Cx(x) + Cy(y) sa(x,a) = 450-0.01*x-a*y s(y) = 250-0.002*x-0.003*y R(x,y,a) = sa(x,a)*x + s(y)*y Pa(x,y,a) = R(x,y,a) - C(x,y) show(Pa)
(x,y,a)  (ay0.0100000000000000x+450)x+(0.00200000000000000x0.00300000000000000y+250)y60x30y\displaystyle \left( x, y, a \right) \ {\mapsto} \ {\left(-a y - 0.0100000000000000 \, x + 450\right)} x + {\left(-0.00200000000000000 \, x - 0.00300000000000000 \, y + 250\right)} y - 60 \, x - 30 \, y
L2=var('L2') g(x,y) = x+y eq1 = solve([diff(Pa,x)==L2*diff(g,x),diff(Pa,y)==L2*diff(g,y), g(x,y)==16000], x,y,L2)
show(eq1)
[[x=1000(8000a117)1000a11\displaystyle x = \frac{1000 \, {\left(8000 \, a - 117\right)}}{1000 \, a - 11}, y=1000(8000a59)1000a11\displaystyle y = \frac{1000 \, {\left(8000 \, a - 59\right)}}{1000 \, a - 11}, L2=8(1000000a234125a+229)1000a11\displaystyle L_{2} = -\frac{8 \, {\left(1000000 \, a^{2} - 34125 \, a + 229\right)}}{1000 \, a - 11}]]
sxa(a)=diff(eq1 [0][0].rhs(),a)*a/eq1[0][0].rhs()
show(sxa)
a  1000(1000a11)a(8000a117(1000a11)281000a11)8000a117\displaystyle a \ {\mapsto}\ -\frac{1000 \, {\left(1000 \, a - 11\right)} a {\left(\frac{8000 \, a - 117}{{\left(1000 \, a - 11\right)}^{2}} - \frac{8}{1000 \, a - 11}\right)}}{8000 \, a - 117}
sxa(0.02)
1.49870801033592
# By analysing the elasticity, we can conclude that if the elasticity increases by 1%, the price of applied books will increase by 1.4987%
# e- Compute the sensitivity of the maximum profit to the assumption that the publisher can produce at most 16,000 books # New constraint g(x+y) => 16000 # Let t = the total amount of textbooks produced t = var('t') L3 = var('L3') eq3 = solve([diff(P,x)==L3*diff(g,x),diff(P,y)==L3*diff(g,y), g(x,y)==t],x,y,L3) show(eq3)
[[x=13t2500\displaystyle x = \frac{1}{3} \, t - 2500, y=23t+2500\displaystyle y = \frac{2}{3} \, t + 2500, L3=71500t+210\displaystyle L_{3} = -\frac{7}{1500} \, t + 210]]
Pmaxt = P(eq3[0][0].rhs(),eq3[0][1].rhs())
SPmaxt = Pmaxt.diff(t)*t/Pmaxt
show(SPmaxt)
3t(0.00466666666666667t+210.000000000000)(t7500)(0.00166666666666667t+262.500000000000)+2(t+3750)(0.00266666666666667t+247.500000000000)120t+225000\displaystyle \frac{3 \, t {\left(-0.00466666666666667 \, t + 210.000000000000\right)}}{{\left(t - 7500\right)} {\left(-0.00166666666666667 \, t + 262.500000000000\right)} + 2 \, {\left(t + 3750\right)} {\left(-0.00266666666666667 \, t + 247.500000000000\right)} - 120 \, t + 225000}
n(SPmaxt(16000))
0.773287304327123
# By analyzing the sensitivity of the maximum profit, we can conclude that if the production increase by 1%, the profit will increase by 0.773% # d- What is the maximum amount the publisher should be willing to pay to increase production by 1 book? # According to the answer of the question c- we have: L1 = 406/3 n(406/3)
135.333333333333
# The shadow price is equal to L1 = 135.333333333333. Thus the maximum the publisher should be willing to pay is $135.333333333 # 2 - Suppose that a sudden loss in production materials was such that the publisher cannot produce more than 4,000 applied books. How does this affect the publisher’s maximal profit? Justify # We are going to implement a new constraint which is x <= 4000 p3 = implicit_plot(x==4000,(x,0,17000),(y,0,17000),color = 'red') plot(p1+p2+p3)
L4 = var('L4') L5 = var('L5') g(x,y) = x+y eq4 = solve([diff(P,x)==(L4+L5)*diff(g,x),diff(P,y)==L4*diff(g,y), g(x,y)==16000,x==4000], x,y,L4,L5)
show(eq4)
[[x=4000\displaystyle x = 4000, y=12000\displaystyle y = 12000, L4=140\displaystyle L_{4} = 140, L5=(14)\displaystyle L_{5} = \left(-14\right)]]
# New maximal profit P(4000,12000)
2.79200000000000e6
# The maximal profit without the new constraint was 2.80016666666667e6. 2.80016666666667e6 - 2.79200000000000e6
8166.66666666977
# The sudden loss in production materials will decrease the maximal profit by 8166.66666666977. # Variables # p = price of the manufacture # b = budget for advertising # To = total of unit sold # R = Revenue # C= cost # P = Profit # Assumptions # R(p,b) = To(p,b) * p # To(p,b) = 10000 + 200*(b-50000)/10000 + 5000*(950-p)/100 # C(p,b) = 700 * To(p,b) + b # P(p,b) = R(p,b) - C(p,b) # Constraints # 0 <= p # 50000 <= b # b <= 100000 To(p,b) = 10000 + 200*(b-50000)/10000 + 5000*(950-p)/100 R(p,b) = To(p,b) * p C(p,b) = 700 * To(p,b) + b P(p,b) = R(p,b) - C(p,b) p1 = contour_plot(P(p,b),(p,-10000,10000),(b,50000,100000)) p2 = implicit_plot(p==0, (p,-10000,10000),(b,50000,100000)) plot(p1+p2)
# When gradient = 0 solve([diff(P,p)==0, diff(P,b)==0],p,b)
[[p == 750, b == -825000]]
# constraint b = 50000 solve([diff(P,p)==0,diff(P,b)==L1,b==50000],p,b,L1)
[[p == 925, b == 50000, L1 == (7/2)]]
# constraint b = 100000 solve([diff(P,p)==0,diff(P,b)==L1,b==100000],p,b,L1)
[[p == 935, b == 100000, L1 == (37/10)]]
# Test of Points P(0,50000) P(0,100000) P(925,50000) P(935,100000)
-40300000 -41050000 2481250 2661250
# The manufacturer of the personal computer reachs the maximum profit when he balances advertising to $100000 and price to $935 #b Determine the sensitivity of the decision variables to the price To(p,b,s) = 10000 + 200*(b-50000)/10000 + s*(950-p) R(p,b,s) = To(p,b,s) * p C(p,b,s) = 700 * To(p,b,s) + b P(p,b,s) = R(p,b,s) - C(p,b,s) # constraint b = 100000 L2 = var('L2') eq = solve([diff(P,p)==0,diff(P,s)==L2, b==100000],p,b,L2)
show(eq)
[[p=275(3s+20)s\displaystyle p = \frac{275 \, {\left(3 \, s + 20\right)}}{s}, b=100000\displaystyle b = 100000, L2=15625(s21936)s2\displaystyle L_{2} = \frac{15625 \, {\left(s^{2} - 1936\right)}}{s^{2}}]]
Sp(s) = diff(eq[0][0].rhs())*s/(eq[0][0].rhs())
n(Sp(50))
-0.117647058823529
# Compute the sensitivity of the decision variable to the advertising agency's estimateof 200 new sales each time To(p,b,g) = 10000 + g*(b-50000)/10000 + 5000*(950-p)/100 R(p,b,g) = To(p,b,g) * p C(p,b,g) = 700 * To(p,b,g) + b P(p,b,g) = R(p,b,g) - C(p,b,g)
L3 = var('L3') eq = solve([diff(P,p)==0,diff(P,b)==L3,b==100000],p,b,L3)
show(eq)
[[p=120g+925\displaystyle p = \frac{1}{20} \, g + 925, b=100000\displaystyle b = 100000, L3=1200000g2+9400g1\displaystyle L_{3} = \frac{1}{200000} \, g^{2} + \frac{9}{400} \, g - 1]]
Sg(g) = diff(eq[0][0].rhs())*g/(eq[0][0].rhs())
n(Sg(200))
0.0106951871657754
# The value of the multiplier is L1 in the question (a) is 3.7. it is representative of the monetary value of advertising. It means that if the manufacturer increases $1 in his budget for aadvertising, he will increase the profit of $3.70 ## RISK MANAGEMENT PROJECT ## # Using a large dataset to understand, apply and plot the logarithm of return # # Application of the relative frequency to understand how the the variance of the price might affect the decision making process ```{r,warning=FALSE,message=FALSE} getwd() library (qrmdata) library(xts) data <- read.csv(file="MCD_PriceDaily.csv",head=TRUE,sep=",") class(data) data.first.5 <- data[1:5,] data.first.5 names(data) adjPrice <- data[,7] class(adjPrice) adjPrice n <- 1177 netReturn <- adjPrice[2:n]/adjPrice[1:(n-1)]-1 netReturn logReturn = diff(log(adjPrice)) logReturn plot(netReturn,logReturn,pch=20,cex=0.2,col="blue",main="Log returns vs. Net Returns") abline(h=0,v=0,col="lightblue",lwd=0.5) # the correlation between the net returns and the log returns is positive ``` ```{r} meanNetReturn <- mean(netReturn) meanNetReturn meanLogReturn <- mean(logReturn) meanLogReturn sdNetReturn <- sd(netReturn) sdNetReturn sdLogRreturn <- sd(logReturn) sdLogRreturn ``` ```{r} hist(netReturn, col = "blue") hist(logReturn, col = "red") ``` ```{r} P<-86 # initial stock value mu<-meanLogReturn/253 # daily mean of log return sigma<-sdLogRreturn/sqrt(253) # daily SD of log return event<-function(){ r<-rnorm(20,mean=mu,sd=sigma) # random Normal numbers stock_20days<-P*exp(cumsum(r)) # vector of stock values over 20 days flag<-any(stock_20days<85) # TRUE if any stock value is below 85 return(flag) # return TRUE or FALSE } sample<-replicate(1e4,event()) # replicate random exp mean(sample) # relative frequency of falling below 85