Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program that solve each of the following problems by dynamic programming. You expect the price of a commodity to behave as follows

Write a Python program that solve each of the following problems by dynamic programming. You expect the price of a commodity to behave as follows over the next 12 months:
Month 123456789101112
Price ($/unit)10878605697130141100705990133
Your inventory capacity is 25 units and you have 3 units in inventory at the start of month 1. In any given month, you can buy up to 10 units or sell up to 15 units. The prices per unit sold or bought are the same within each month. However, in each month that you buy or sell any units, you must pay a flat $120 transaction charge. For example, if you were to buy 3 units in month 2, your cash flow for that month would be (3 units)\times ($78 per unit) $120= $354. Conversely, if you were to sell 2 units in month 8, your cash flow for that month would be +(2 units)\times ($100 per unit) $120= $80. The only way to avoid the $120 charge for a month is to neither buy nor sell. Your holding cost is $11 per unit per month, assessed on the inventory at the end of each month. There is no residual value or cost associated with having any units of the commodity left over after month 12.
You want to identify the trading pattern that maximizes your total profit over the 12-month time span.
To aid your thinking, in this problem:
The time periods are the 12 months
The state is how many units of the commodity you have in stock at the start of the month
The decision in each time period is how many units to buy or sell (including 0 for doing neither)
The interpretation of the value function is ft(i) is the largest profit you can obtain in months t through 12 if you have i units of the commodity in stock at the start of month t.
Hint: you may find it helpful to use the convention that a positive value of the inner loop decision variable d (whose optimal choice you will store in x[t,i]) denotes buying d units, a negative value of d denotes selling |d| units and a zero value denotes neither buying nor selling. For example,
If you have 3 units in stock at the beginning, you may consider selling up to 3 units, doing nothing, or buying up to 10, so the decision loop variable d should have the range 3,2,1,0,1,2,3,4,5,6,7,8,9,10.
If you have 20 units in stock, you may consider selling up to 15 units, doing nothing, or buying up to 5=2520, so the decision loop variable d should have the range 15,14,13,...,2,1,0,1,2,3,4,5.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Question Can employees make contributions to a profit sharing plan?

Answered: 1 week ago

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago