Block Transfer

Block Transfer is a binary decision problem whose decision unit is the option (model × colour): either all the stock in the store is taken, or none of it is touched. There is no decision on a partial quantity.

This series builds the problem from start to finish: from what is in the store to the mathematical model, from there to the SQL and Python solution, and on to the results.

Articles in this series

You can read the series from start to finish. If you are short of time, the story and results articles each tell the problem and the outcome on their own; the technical articles carry the whole model and the code.

  1. StoryThe store's problem

    A store manager rings on Monday morning, and the problem is born.

  2. ExplainerHow the decision is made

    Cover, STR and shelf life; and why eyeballing it cannot carry 149,600 decisions.

  3. TechnicalThe mathematical model

    Sets, parameters, binary decision variables, the objective function and the constraints.

  4. TechnicalSQL for the candidates, greedy for the decision

    How the trade does it today: DuckDB SQL finds the candidate pairs, and a greedy match in score order makes the decision. Easy to write, an answer in every case, and the price is shown too.

  5. TechnicalSolving it as a MIP — PuLP and CBC

    The same candidate table, this time with real optimisation: binary decision variables, opening routes, the minimum shipment. A better total; a time limit and set-up cost thrown in.

  6. ResultsResults, and where this model falls short

    How much better it got, which assumptions did not hold, and what changes in production.

  7. TechnicalHow a transfer's success is measured

    A transfer is a bet: the same stock, two rails, two different chances of selling. Measuring the benefit also shows how much the model overstates its own.