Upload
brianne-shields
View
220
Download
0
Embed Size (px)
Citation preview
1
Advanced Plotting 2(Example from Aj.Jim)
ผศ.ดร.อนั�นัต์ ผลเพิ่��มAnan Phonphoem
http://www.cpe.ku.ac.th/[email protected]
2
Inventory Problem
Here are projected sales for 10 weeks:Week: 1 2 3 4 5 6 7 8 9 10 Sales: 700 1100 800 800 1000 2200 1100 900 1000 1100 Each week the company can manufacture 1,000 units, and
only sells units that are finished and "in stock".So the sales & inventory balance for week k is:
Production = 1000
Sales(k) = minimum( ProjectedSales(k), Inventory(k) )
Inventory(k+1) = Inventory(k) + Production - Sales(k) Starting inventory at week 1 is 200. Compute the actual
sales.
3
Inventory Problem Formulation
1. Formulate your solution method on paper.
2. Write a flow chart for your solution on paper.
3. Create an m-File to implement the flow chart.
4
Inventory Problem Solution (1)
3. Create an m-File to implement the flow chart.% Projected sales for each weekpsales = [ 700 1100 800 800 1000 2200 1100 900 1000 1100 ];% Production each weekproduction = 1000;% Initial inventory:inventory(1) = 200;% Inventory - sales - production balance for week ksales(k) = min( psales(k), inventory(k) );inventory(k + 1) = inventory(k) + production - sales(k);
5
Inventory Problem Solution (2)
3b. Add a "for" loop for each week...% SalesForecast.m% Projected sales for each weekpsales = [700 1100 800 800 1000 2200 1100 900 1000 1100 ];% Production each weekproduction = 1000;% Initial inventory:inventory(1) = 200;% Inventory - sales balance for week kfor k=1:10 sales(k) = min( psales(k), inventory(k) ); inventory(k + 1) = inventory(k) + production - sales(k);end
6
Inventory Problem Solution (3)
Run the m-file and view the actual sales:>> SalesForecast>> salessales = 200 1000 800 800 1000 1400 900 900 1000 1100
>> sum( sales )ans = 9200
Too many numbers to interpret. What were the total sales?
7
Inventory Problem Solution (4)
>> psales - salesans = 500 100 0 0 0 800 100 0 0 0
How many sales were "lost" due to insufficient "stock"?
Maybe we should hire some O.T. during week 1, 5, and 6 to increase production during those weeks?
8
Inventory Problem Solution (5)
Plot proj. sales, actual sales, and inventory on one plot:
>> week = 1:10>> plot( week, psales, 'bo:', week, sales, 'gp--',
week, inventory(1:10), 'rx' )>> legend( 'projected sales', 'sales', 'inventory' )
0 2 4 6 8 10200
400
600
800
1000
1200
1400
1600
1800
2000
2200
projjected salessalesinventory
9
Inventory Problem Solution (6)
Plot projected sales, sales, and excess inventory.
>> week = 1:10>> plot( week, psales, 'bo:', week, sales, 'gp--',
week, inventory(1:10)-sales, 'r^' )>> legend( 'projected sales', 'sales', 'excess inventory' )
0 2 4 6 8 100
500
1000
1500
2000
2500
projjected salessalesexcess inventory
Hmmm... not much surplus inventory in weeks 6-10. If sales are high, we're in bad shape.