R optimisation max buy/sell dependent on stock level
问题 I would like to find a solution to an optimisation problem. The aim is to maximise profit by buying for low price and selling for a higher one. There are constraints such as maximum stock level, and max buy/sell number of units. Moreover, sell and buy limits depend on the inventory levels. I have asked a similar question albeit without the last condition here R optimisation buy sell. Here is an example: price = c(12, 11, 12, 13, 16, 17, 18, 17, 18, 16, 17, 13) capacity = 25 max_units_buy_30 =