Download presentation
Presentation is loading. Please wait.
1
CS123 Quiz 3
2
Question 5 a) How many units of ammonia must be manufactured and sold daily to maximize the profit? How much money will be made each day for that amount of production? So we need a function to represent daily profit. Assume the daily production is x units The daily production cost is C:=x-> *x+1/10*x^2
3
Given the selling price is 590 dollars per unit
We have the daily income is 590*x dollars So the daily profit is the income minus the cost profit := x -> 590 * x - C(x); Considering that the daily capacity is at most units, we can plot this function as plot(profit(x), x= );
5
Then, get the maximum profit
maxProfit := Optimization[Maximize](profit(x),x= ); The output should be like [ *10^5, [x = 2850.]]
6
Get the daily units that maximize the daily profit
Take the 2nd element of the list maxProfit[2]; we will get [x=2850.] Remove the square bracket op(maxProfit[2]); we will get x=2850. Take the right hand side of the equation rhs(op(maxProfit[2])); we will get 2850 Round it to the nearest integer round(rhs(op(maxProfit[2]))); we will get the final result 2850 Get the aassociated daily profit (use “round” function to get the nearest integer) round(maxProfit[1])
7
b) prices := [600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890]: Use the same C function for the cost C:=x-> *x+(1/10)*x^2: Create a table for new profits based on new prices profitTab := table();
8
Create a list of daily profits
for i from 1 to nops(prices) do profitTab[i]:=prices[i]*x-C(x); end do; Conver the table to a list profitList:=convert(profitTab,list): Use the same technique in a) to define a function to for the unit that make maximize the profit and also output the nearest integer maxProf:=x->round(rhs(op(Optimization[Maximize](x)[2])));
9
Use “map” function to apply this function to the list of daily profits expressions
map(maxProf,profitList); Then you will get a list of units that maximize the daily profits based on different daily prices. [2900, 2950, 3000, 3050, 3100, 3150, 3200, 3250, 3300, 3350, 3400, 3450, 3500, 3550, 3600, 3650, 3700, 3750, 3800, 3850, 3900, 3950, 4000, 4050, 4100, 4150, 4200, 4250, 4300, 4350];
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.