30
Solution to GPE homework #3

Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Solution to GPE homework #3

Page 2: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceTask description

I Find concentrations for each ingredient.

I Respect upper and lower bounds for ingredients.

0.15 <= <= 1

0.08 <= <= 0.2

0.02 <= <= 0.05

0.05 <= <= 1

0.2 <= <= 1

I Stay within 10% of RDA values0.9RDA(n) <=

∑f∈F

vnfxf <= 1.1RDA(n)

I Minimize cost over year:∑

f∈F∑

m∈M cfmxf

Page 3: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceIP model

min∑f∈F

∑m∈M

cfmxf

subject to

0.9RDA(n) <=∑f∈F

vnfxf <= 1.1RDA(n) ∀n ∈ N

lbf <= xf <= ubf ∀f ∈ F∑f∈F

xf = 1 ∀f ∈ F

Page 4: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 1st task

5%

8%

2%

32%

53%

Total cost per year: 9355000For 1200000 bottles per year: 7 per bottle

Page 5: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice2nd task

I can take advantage of seasonal price variations: buy onemonth in advance

I cannot buy more than one month in advance because fruitgoes bad

I at end of year: storage empty

Introduce more variablesI bfm ∈ N: Buy bfm fruits of type f in month mI sfm ∈ N: Amount of fruits of type f bought in monthm that is

available in next month

Introduce more constraintsI bfm + sf ,m−1 − sfm − 100000xf = 0 form 6= JanuaryI bfm − sfm − 100000xf = 0 form = JanuaryI sfm <= 100000 · xf

Page 6: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceIP model for 2nd task

min∑f∈F

∑m∈M

cfmbfm

subject to

0.9RDA(n) <=∑f∈F

vnfxf <= 1.1RDA(n) ∀n ∈ N

lbf <= xf <= ubf ∀f ∈ F∑f∈F

xf = 1 ∀f ∈ F

bfm + sf ,m−1 − sfm − 100000 · xf = 0 ∀f ∈ F, ∀m ∈ M,m 6= January

bfm − sfm − 100000 · xf = 0 ∀f ∈ F,m = January

sfm <= 100000 · xf ∀f ∈ F, ∀m ∈ M

Page 7: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 2nd task

I concentrations stay the sameI sf ,December will be 0 because of minimization

%

1·104

2·104

3·104

4·104

Optimal apple buying policy

32000

January

32000

February

32000

March

32000

April

32000

May

32000

June

32000

July

32000

August

32000

September

64000

October

32000

November

0

December

price development

Page 8: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 2nd task

I concentrations stay the sameI sf ,December will be 0 because of minimization

%

1·104

2·104

3·104

4·104

Optimal apple buying policy

32000

January

32000

February

32000

March

32000

April

32000

May

32000

June

32000

July

32000

August

32000

September

64000

October

32000

November

0

December

price development

Page 9: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 2nd task

I concentrations stay the sameI sf ,December will be 0 because of minimization

%

1·104

2·104

3·104

4·104

Optimal apple buying policy

32000

January

32000

February

32000

March

32000

April

32000

May

32000

June

32000

July

32000

August

32000

September

64000

October

32000

November

0

December

price development

Page 10: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 2nd task

%

1·104

2·104

3·104

4·104

Optimal banana buying policy

8000

January

8000

February

8000

March

8000

April

8000

May

8000

June

8000

July

8000

August

8000

September

8000

October

8000

November

8000

December

price development

%

1·104

2·104

3·104

4·104

Optimal lemon buying policy

2000

January

2000

February

2000

March

2000

April

2000

May

2000

June

2000

July

2000

August

2000

September

2000

October

2000

November

2000

December

price development

Page 11: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 2nd task

%

1·104

2·104

3·104

4·104

Optimal orange buying policy

53000

January

53000

February

106000

March

53000

April

0

May

53000

June

106000

July

0

August

53000

September

53000

October

53000

November

53000

December

price development

Page 12: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 2nd task

%

1·104

2·104

3·104

4·104

Optimal pineapple buying policy

5000

January

10000

February

0

March

5000

April

5000

May

10000

June

0

July

5000

August

10000

September

0

October

5000

November

5000

December

price development

Optimal objective value: 8953000Savings of about 4.49% compared to the first task

Page 13: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3rd task

I two different ways to interpret the discount policyI apply discount for 10000 apples to every 10000−pack of apples

let ca be the original price for an apple.44100 apples cost 40000 ∗ 0.6 ∗ ca + 4000 ∗ 0.8 ∗ ca + 100 ∗ ca.

I or apply discount as soon as we buy more than 10000 applesto all of them44100 apples cost 44100 ∗ 0.6 ∗ ca.

Page 14: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3 with first discount policy

Let S := {1, 100, 1000, 10000}.Let hs be the discount for buying s items at once,hs ∈ {0, 0.1, 0.2, 0.4}.

I Add variables dfms for all f ∈ F,m ∈ M, s ∈ S.I Add constraint bfm =

∑s∈S

s · dfms.

I Minimize ∑f∈F

∑m∈M

cfm∑s∈S

dfms ∗ (1− hs)

Page 15: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceIP model for 3a

min∑f∈F

∑m∈M

cfm∑s∈S

dfms ∗ (1− hs)

subject to

0.9RDA(n) <=∑f∈F

vnfxf <= 1.1RDA(n) ∀n ∈ N

lbf <= xf <= ubf ∀f ∈ F∑f∈F

xf = 1 ∀f ∈ F

bfm + sf ,m−1 − sfm − 100000 · xf = 0 ∀f ∈ F, ∀m ∈ M,m 6= Januarybfm − sfm − 100000 · xf = 0 ∀f ∈ F,m = January

sfm <= 100000 · xf ∀f ∈ F, ∀m ∈ Mbfm =

∑s∈S

s · dfms ∀f ∈ F,m ∈ M

bfm ∈ N, sfm ∈ N, xf ∈ Q, dfms ∈ N

Page 16: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juiceResults for 3a

I Optimal objective function value: 5485600.I Savings compared to first task: 70.54%.I Does not change optimal ingredients of fruit juice.I comparison of buying policies follows

Page 17: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3a comparison of buying policies: apple

%

1·104

2·104

3·104

4·104

Optimal apple buying policy

32000

January

32000

February

32000

March

32000

April

32000

May

32000

June

32000

July

32000

August

32000

September

64000

October

32000

November

0

December

price development

%

1·104

2·104

3·104

4·104

Optimal apple buying policy with discounts a

50000

January

20000

February

50000

March

40000

April

0

May

32000

June

40000

July

50000

August

30000

September

40000

October

32000

November

0

December

price development

Page 18: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3a comparison of buying policies: banana

%

1·104

2·104

3·104

4·104

Optimal banana buying policy

8000

January

8000

February

8000

March

8000

April

8000

May

8000

June

8000

July

8000

August

8000

September

8000

October

8000

November

8000

December

price development

%

1·104

2·104

3·104

4·104

Optimal banana buying policy with discounts a

10000

January

10000

February

10000

March

10000

April

0

May

10000

June

6000

July

10000

August

10000

September

10000

October

10000

November

0

December

price development

Page 19: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3a comparison of buying policies: lemon

%

1·104

2·104

3·104

4·104

Optimal lemon buying policy

2000

January

2000

February

2000

March

2000

April

2000

May

2000

June

2000

July

2000

August

2000

September

2000

October

2000

November

2000

December

price development

%

1·104

2·104

3·104

4·104

Optimal lemon buying policy with discounts a

4000

January

0

February

4000

March

0

April

2000

May

4000

June

0

July

2000

August

2000

September

4000

October

0

November

2000

December

price development

Page 20: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3a comparison of buying policies: pineapple

%

1·104

2·104

3·104

4·104

Optimal pineapple buying policy

5000

January

10000

February

0

March

5000

April

5000

May

10000

June

0

July

5000

August

10000

September

0

October

5000

November

5000

December

price development

%

1·104

2·104

3·104

4·104

Optimal pineapple buying policy with discounts a

10000

January

0

February

10000

March

0

April

10000

May

0

June

10000

July

0

August

10000

September

0

October

10000

November

0

December

price development

Page 21: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3a comparison of buying policies: orange

%

1·104

2·104

3·104

4·104

Optimal orange buying policy

53000

January

53000

February

106000

March

53000

April

0

May

53000

June

106000

July

0

August

53000

September

53000

October

53000

November

53000

December

price development

%

1·104

2·104

3·104

4·104

Optimal orange buying policy with discounts a

60000

January

92000

February

60000

March

50000

April

10000

May

50000

June

100000

July

50000

August

10000

September

50000

October

51000

November

53000

December

price development

Page 22: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3 with second discount policy

I Let di be binary.I Can use inequalities like bfm > 100dfm1, so dfm1 is 1 only if we

buy at least a 100 of fruit f in monthm.I Problem: Would have to put something like

cfmbfm − 0.1d1cfmbfm − 0.1d2cfmbfm − 0.2d3cfmbfm

into objective function, which is not linearI Can of course solve this by fixing bfm to a value computed in

earlier tasksI but this leads to a potentially non-optimal solutionI also, the model is then only used to evaluate the costsI leads to an objective value of 5573600

Page 23: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3 with second discount policy

I have to linearize the nonlinear objectiveI do this similarly to other discount policyI Let S := {1, 100, 1000, 10000}, hs := {0, 0.1, 0, 2, 0.4}.I Introduce variables bfms integer for all f ∈ F,m ∈ M, s ∈ SI they are supposed to denote amount of fruit of type f in

monthm bought at discount hs:∑s∈S

bfms = bfm

I introduce variables dfms binary that regulate whether discounths applies

I only one discount applies:∑s∈S

dfms 6 1

I if discount applies, need to buy the minimum amount for it:bfms > s · dfms for all s ∈ S

I cannot buy at discount if discount doesn’t apply:bfms 6 200000 · dfms

Page 24: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

3 with second discount policy,IP modelmin

∑f∈F

∑m∈M

cfm∑s∈S

hs · bfms

subject to

0.9RDA(n) <=∑f∈F

vnfxf <= 1.1RDA(n) ∀n ∈ N

lbf <= xf <= ubf ∀f ∈ F∑f∈F

xf = 1 ∀f ∈ F

bfm + sf ,m−1 − sfm − 100000 · xf = 0 ∀f ∈ F,∀m ∈ M,m 6= Januarybfm − sfm − 100000 · xf = 0 ∀f ∈ F,m = January

sfm <= 100000 · xf ∀f ∈ F,∀m ∈ M∑s∈S

bfms = bfm ∀f ∈ F,∀m ∈ M∑s∈S

dfms 6 1 ∀f ∈ F,m ∈ M

bfms > s · dfms ∀f ∈ F,m ∈ M,∀s ∈ Sbfms 6 200000 · dfms ∀f ∈ F,m ∈ M,∀s ∈ S

bfms ∈ N, bfm ∈ N, dfms ∈ {0, 1}, xf ∈ Q, sfm ∈ N

Page 25: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

3 with second discount policy,solution

I leads to an optimal value of 5449200I 2.28% better than the solution fixing the values from the 2nd

taskI comparison of buying policies follows

Page 26: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3b comparison of buying policies: apple

%

1·104

2·104

3·104

4·104

Optimal apple buying policy

32000

January

32000

February

32000

March

32000

April

32000

May

32000

June

32000

July

32000

August

32000

September

64000

October

32000

November

0

December

price development

%

1·104

2·104

3·104

4·104

Optimal apple buying policy with discounts b

32000

January

64000

February

0

March

64000

April

0

May

32000

June

64000

July

0

August

64000

September

32000

October

32000

November

0

December

price development

Page 27: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3b comparison of buying policies: banana

%

1·104

2·104

3·104

4·104

Optimal banana buying policy

8000

January

8000

February

8000

March

8000

April

8000

May

8000

June

8000

July

8000

August

8000

September

8000

October

8000

November

8000

December

price development

%

1·104

2·104

3·104

4·104

Optimal banana buying policy with discounts b

10000

January

14000

February

0

March

14000

April

10000

May

0

June

10000

July

14000

August

0

September

14000

October

10000

November

0

December

price development

Page 28: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3b comparison of buying policies: lemon

%

1·104

2·104

3·104

4·104

Optimal lemon buying policy

2000

January

2000

February

2000

March

2000

April

2000

May

2000

June

2000

July

2000

August

2000

September

2000

October

2000

November

2000

December

price development

%

1·104

2·104

3·104

4·104

Optimal lemon buying policy with discounts b

2000

January

2000

February

2000

March

2000

April

2000

May

2000

June

2000

July

2000

August

2000

September

2000

October

2000

November

2000

December

price development

Page 29: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3b comparison of buying policies: pineapple

%

1·104

2·104

3·104

4·104

Optimal pineapple buying policy

5000

January

10000

February

0

March

5000

April

5000

May

10000

June

0

July

5000

August

10000

September

0

October

5000

November

5000

December

price development

%

1·104

2·104

3·104

4·104

Optimal pineapple buying policy with discounts b

10000

January

0

February

10000

March

0

April

10000

May

0

June

10000

July

0

August

10000

September

0

October

10000

November

0

December

price development

Page 30: Solution to GPE homework #3 · fm 2N:Buyb fm fruitsoftypefinmonthm I s fm 2N:Amountoffruitsoftypef boughtinmonthmthatis availableinnextmonth Introducemoreconstraints I b fm +s f,m-1-s

Designing a fruit juice3b comparison of buying policies: orange

%

1·104

2·104

3·104

4·104

Optimal orange buying policy

53000

January

53000

February

106000

March

53000

April

0

May

53000

June

106000

July

0

August

53000

September

53000

October

53000

November

53000

December

price development

%

1·104

2·104

3·104

4·104

Optimal orange buying policy with discounts b

53000

January

53000

February

106000

March

53000

April

0

May

53000

June

106000

July

0

August

53000

September

53000

October

53000

November

53000

December

price development