The project developed a novel theory-based heuristic policy for dynamically sequencing production in compounding pharmacies. The approach combines a fluid (deterministic) model of batch production dynamics with a modified technique from optimal control theory — the State-Dependent Riccati Equation (SDRE) approach — which is widely used in aerospace and robotics but had not previously been applied to production management.
We first develop a fluid model to capture the production dynamics, from which we derive a theoretical lower bound on the best possible performance (minimum average waiting cost), providing a benchmark against which any heuristic can be evaluated. We then construct our heuristic by modifying the SDRE approach for use as a value function approximation, providing a simple index policy. By designing the cost function to approximate the original intractable problem, we unexpectedly find that in our setting there is a closed-form solution to the SDRE which simplifies the computational requirements and implementation dramatically.
The resulting algorithm — the SDRE-Index policy — works by computing a simple score for each medication at each decision point, based on the current queue lengths, arrival rates, and switchover times, and then producing the medication with the lowest score. It requires only basic operational data and can be implemented using free open-source software.
The SDRE-index policy was then evaluated through three progressively more realistic numerical experiments relative to the status-quo policy of producing batches of medication based on what request is the oldest (waiting the longest), a simple policy that performs well at minimizing the maximum waiting times. In a fluid (deterministic) setting with up to 124 medications, the SDRE-Index performed within 11% of the theoretical lower bound on average, while the oldest request policy was approximately 70% greater than the lower bound, demonstrating strong theoretical performance. In a calibrated stochastic simulation using data from a partnering UK compounding pharmacy — covering 1,192 distinct medications — the policy can reduce average waiting times by 49.3%, but increases maximum waiting times substantially. We then show that this can be addressed with a simple a hybrid version of the policy (combining the SDRE-Index with a maximum waiting time limit) which reduced the average cost of waiting by 41% without sacrificing performance on maximum waiting times. In a data-driven simulation using approximately four years of actual historical order data, where arrival rates are unknown and must be estimated, the hybrid algorithm reduced average waiting costs by 32.5% and cut the average time medications spend in the production queue from 40.1 hours to 27.0 hours, with roughly 70% of all medication requests filled faster — all without increasing maximum waiting times.