Concerning the inventory value, I think we can run the model a first time with either the lowest selling price or the production cost of previous month. Then, either we make a correction of the calculated global contribution to take into account the difference between initial inventory value and new production costs, either we re-run the model with inventory value = production cost (we could add a column with calculated production costs to facilitate the re-run). The total contribution will depend on the value of stock but I do not think that the optimal volumes of production and sales will change. (a correction will be needed in any case as we sell the inventory of month M-1 and the production cost is different from month M)