Download Math 442/542

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Lateral computing wikipedia , lookup

Multi-objective optimization wikipedia , lookup

Mathematical optimization wikipedia , lookup

Multiple-criteria decision analysis wikipedia , lookup

Transcript
Math 4630/5630
Homework 5 Solutions
Problem 1. Solving Inventory Problems by Dynamic Programming.
Recall the inventory considered in the class. Here is a modified version of it.
• A company is producing airplanes
• 4 production periods
• No inventory at the beginning
• Can produce at most 3 airplanes in each period
• Can keep at most 2 airplanes in inventory
• Set-up cost for each period is 3
• The cost of keeping 1 unit in inventory for one period of time is 1
• The production costs and demands for each period of time are given in the following
table:
Period
1
2
3
4
Demand
1
1
2
1
Unit cost
3
4
5
4
Determine a production schedule to minimize the total cost while satisfying the
demand. You need to draw a dynamic programming network and show your
calculations of optimal policies. Give all the optimal solutions if there are multiple
optimal solutions.
Solution
# f(n,s) represents the minimum cost starting from state s of period n
f :=
1 0 29
# at state 0 (no inventory) of stage 1 the minimum cost is 29
2 0 24
2 1 20
2 2 17
3 0 19
3 1 15
32 9
40
41
50
;
7
1
0
# The set of optimal decisions at each state
set opt[1,0] := 2 3;
# at the original state, zero inventory at the beginning of period 1, there are two
optimal decisions, produce 2 or produce 3
set opt[2,0] := 3;
set opt[2,1] := 0;
set opt[2,2] := 0;
set opt[3,0] := 3;
set opt[3,1] := 2;
set opt[3,2] := 0;
set opt[4,0] := 1;
set opt[4,1] := 0;
There are two optimal solutions:
1) x1 = 3, x2 = 0, x3 = 2, x4 =0 with total cost 29
2) x1 = 2, x2 = 0, x3 = 3, x4 =0 with total cost 29
Here is the full AMPL model which includes the recursive formula for computing f(n,s).
param start; # first year of demand
param end; # last year of demand
param demand {n in start..end};
param invLimit;
param prodLimit;
param unitCost {n in start..end};
param setupCost;
param invCost;
param cost{n in start..end, i in 0..prodLimit}:=
if i=0 then 0 else (setupCost + i * unitCost[n]);
# cost of producing i units in period n
set options{n in start..end, s in 0..invLimit}:=
{i in 0..prodLimit: i+s >= demand[n]
and i+s-demand[n] <= invLimit};
# set of allowed production levels
param f{n in start..end+1, s in 0..invLimit}:=
if n = end + 1 then 0 else
min{i in options[n,s]} (cost[n,i] + s*invCost + f[n+1, s+i-demand[n]]);
set opt{n in start..end, s in 0..invLimit}:=
{ i in options[n,s]:
f[n,s] = cost[n,i] + s*invCost + f[n+1, s+i-demand[n]] };
data;
param start:= 1;
param end:= 4;
param demand:=
11
21
32
4 1;
param invLimit:= 2;
param prodLimit:= 3;
param unitCost:=
13
24
35
4 4;
param setupCost:= 3;
param invCost:= 1;
Problem 2. Solving Resource Allocation Problems by Dynamic Programming.
A company is planning its advertising strategy for next year for its three major products.
Since the three products are quite different, each advertising effort will focus on a single
product. In units of millions of dollars, a total of 6 is available for advertising next year,
where the advertising expenditure for each product must be an integer greater than or
equal to 1. The vice-president for marketing has established the objective: Determine
how much to spend on each product in order to maximize total sales. The following table
gives the estimated increase in sales (in appropriate units) for the different advertising
expenditures:
Product
Advertising
expenditure
1
2
3
1
7
4
6
2
10
8
9
3
14
11
13
4
17
14
15
Use dynamic programming to solve this problem. You need to draw a dynamic
programming network and show your calculations of optimal policies. Give all the
optimal solutions if there are multiple optimal solutions.
Solution
# f(n,s) represents the maximum sales amount starting from state s of period n
f :=
1 6 28
2 2 10
2 3 14
2 4 17
2 5 21
31 6
32 9
3 3 13
3 4 15
;
# The set of optimal decisions at each state
set opt[1,6] := 1 3;
set opt[2,2] := 1;
set opt[2,3] := 2;
set opt[2,4] := 1 2 3;
set opt[2,5] := 2;
set opt[3,1] := 1;
set opt[3,2] := 2;
set opt[3,3] := 3;
set opt[3,4] := 4;
There are two optimal solutions:
1) x1 = 1, x2 = 2, x3 = 3 with total sales 28
2) x1 = 3, x2 = 2, x3 = 1 with total sales 28
Here is the full AMPL model which includes the recursive formula for computing f(n,s).
set products;
param totalamount:= 6;
set amounts;
param sales {n in products, i in amounts};
set states{n in products}:=
if n=1 then 6
else 6-(n-1)-3 .. 6-(n-1);
set options{n in products, d in states[n]}:=
if n=3 then d else 1..min( 4, d+n-3 );
param f{n in products, d in states[n]}:=
if n=3 then sales[n,d] else
max{i in options[n,d]} (sales[n,i]+ f[n+1,d-i]) ;
set opt{n in products, d in states[n]: n!=3}:=
{ i in options[n,d]:
f[n,d] = sales[n,i]+ f[n+1,d-i] };
data;
set products:= 1 2 3;
set amounts:= 1 2 3 4;
param sales:
1
1
7
2
4
3
6
;
2
10
8
9
3
14
11
13
4:=
17
14
15