关键词 > Python代写

BDAUU - Assignment IV

发布时间:2021-03-28

BDAUU - Assignment IV

Deadline: March 25th, 2021


        For all problems, you are asked to submit Python codes to Canvas. You can use the codes that are posted on course documents as template. Name your codes as “Q1.py”, “Q2.py”, and “Q3.py”, and compress into one “.zip” file before submitting your answer. Your code should run and print out optimal cost/profit together with the optimal policy. (see print() comment in our examples or code template.)


1) [Inventory Problem with variable cost function]: Suppose over the 10 months, you expect the demand to your product to be as follows:

    At the beginning of the month 1, you have 6 units in inventory. In each month you can produce up to 15 units, and those units can be used to meet the current month’s demand (along with any units in inventory). There is no setup cost for the production and production cost for p units is given by the following formula:

There is space for up to 20 units of inventory and your holding cost is $6 per unit per month. There is no benefit or credit for having leftover inventory at the end of the month 10.

Create a Python program that computes the lowest-cost production plan meeting the specific demands, considering the all of the costs explained above.


2) [Commodity trading strategies]: You expect the price of a commodity to behave as follows over 10 months:

    Your inventory capacity is 25 units and you have 20 units in inventory at the beginning 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, but every transaction, whether you buy or sell, is subject to a $10 transaction charge. Your holding cost is $5 per unit per month, assessed on the inventory at the end of each month. Any units of the commodity left over after month 10 assessed a $50 per unit salvage value.

Create a Python program that maximizes your profits trading the commodity over the next 10 months.

Hint: You may find it helpful to use convention in stage t and state i: a positive value of the decision x[t,i] denotes buying x[t,i] units, and negative value of x[t,i] denotes the selling |x[t,i]|. Furthermore, you may need to consider the capacity in your inventory while deciding on the maximum and minimum amounts that you can sell/buy at each (t,i).


3) [Commodity trading under stochastic price]: Suppose we hold a stock at our portfolio and going to decide whether we should sell it or buy more in the following 5 days. We know that at the after 5 day of trading there will be $5 dividend for each unit of stock we are holding at our portfolio. However, holding one unit of stock at our portfolio costs $1 to us, and there is no transaction cost of selling and buying. Due to restrictions, we can hold at most 5 stocks. Suppose we believe that price of the stock is equally likely to be 2, 3, 4, or 5.

Create a Python program that maximizes your profits from trading the commodity over the next 5 days.