I've been working on a optimisation problem at work regarding blending. Essentially we have different types of grain stock with different properties and we bought them for different amounts. We then have a bunch of customer contracts requesting some amount of grain with certain property constraints (e.g. protein content must be less than this amount). We can blend our stocks to fulfill a contract provided that the property constraints of the contract are not violated. We can formulate this pretty easily as an LP problem where our objective function is to minimise the total price of grain stock we allocated to all of our contracts, and the constraints are given by the contracts property constraints, the grain amount specified by the contract and the amount of grain stock we have on hand.

In reality however we are constantly receiving new stock throughout a given year and shipments for contracts will happen at different times. We will also receive new contracts throughout the year too. So at any point in time we potentially don't know stock and contracts we could have in the future. How would I take into account this time varying aspect to formulate this as an optimisation problem such that we could maximise profit for a given year? We were considering just optimising for each batch of contracts that correspond to the same shipping period individually using stock we would have at that point in time but is there a way to formulate this problem as one single global problem?

  • $\begingroup$ Are the amounts of incoming grain stock given, or does your LP model also decide how much stock to order? $\endgroup$
    – prubin
    Commented Nov 17, 2021 at 15:47
  • $\begingroup$ @prubin At a given point in time you'll know how much grain stock you have. But throughout the year we could be buying more grain stock. So we don't know what stock we will have in the future throughout the year. $\endgroup$
    – asett
    Commented Nov 17, 2021 at 23:39
  • $\begingroup$ Meaning the acquisition of grain stock is outside the scope of your model (not something your model decides)? $\endgroup$
    – prubin
    Commented Nov 18, 2021 at 0:11
  • $\begingroup$ @prubin That's right. Though if a formulation is possible if the model does decide that then please let me know. Since we can look at integrating other processes that acquire grain. $\endgroup$
    – asett
    Commented Nov 18, 2021 at 0:22

1 Answer 1


You can formulate this as a multiperiod production model (where "production" in this case means blending). If we start by assuming that arrivals of grain are predetermined (and known), you need variables in each period for end-of-period inventory of each grain type and for the amount of each grain stock used in each customer order. (I'm assuming here that customer contracts must be fulfilled, meaning you have control over how you blend the order but not the amount of grain that ends up getting shipped to the customer.) Your objective function would include the acquisition cost of any grain shipped, plus holding costs for the remaining inventory (if relevant). If you suffer inventory loss (spoilage or pilferage), then ending inventory of each stock would ending inventory of the previous period minus usage minus loss, and you likely would want to include the acquisition cost of lost grain in the objective function.

A model like this can suffer "horizon effects". If you run the model with a 12 month planning period, you might find that it ends the year with a mix of grains that would not be ideal for the start of the following year. There are a couple of heuristic approaches to deal with this. One is to guess values for end-of-year inventories (meaning not acquisition costs but how much a unit of each grain would save you in the future over a unit of a different grain) and include the end-of-year values in the objective (as a "profit", not as a cost). I suspect that might be tricky. An easier approach is called a "rolling horizon". Solve the model over a 12 month horizon, then implement the solution in the first month, first quarter, whatever. Then solve the model again with a new horizon, based on current inventories, use the first portion of that solution, and repeat.

If you have control over the acquisition of grain stocks, you can add purchase volumes as variables and switch objective from the value of the grain stock used to the cost of the grain acquisitions, subject to possible constraints on what suppliers can/will supply. Quantity discounts, if offered, can be handled (although likely requiring an integer program).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.