Using CoMETS to optimize a supply chain with an uncertain demand

Using CoMETS to optimize a supply chain with an uncertain demand


We consider a simplified Simulation Digital Twin of a supply chain system, consisting of two retailers, 10 inventories, two suppliers and one assembly operation. The model simulates the supply chain’s evolution over 25 days for a given demand, 30 products per day on average1, and predicts different key performance indicators (KPIs) such as profit and service level.

Example of a digital twin that can be built and simulated with Cosmo Tech’s platform


Optimization experiment

Imagine you want to maximize the profit generated by Retailer 1 by adjusting the stock replenishment policy of its inventory, which is determined here by two decision variables: the reorder point and the reorder quantity.

You first need to declare the allowed bounds for both variables:

Then with a few lines of code, you can configure and launch the optimization:

Configuring and launching the optimization2. You can choose and configure the optimization algorithm or let CoMETS do it for you.

Here, CoMETS would prescribe the ordering of 33 parts each time the stock level gets below 96. This would generate the maximum profit: 6270.

Principle of optimization by simulation. The “magic” of the optimizer is that it autonomously and iteratively chooses (and learns) which “what-if” simulations to run until it has converged.

Uncertainty analysis experiment

The previous optimization implicitly makes the simplifying assumption that you perfectly know what the future demand will be (here 30 products each day). So, it is a good practice to stress test your strategy and estimate the likely variability of your profit forecast.


Principle of an uncertainty analysis experiment

You can therefore instantiate a simulator using the optimized stock replenishment policy (see CoMETS documentation to see how this can be done), configure and launch an uncertainty analysis:

Uncertainty analysis, assuming that each of the 25 day, the demand is distributed according to a geometric distribution with the same mean demand as in the deterministic optimization3

By default, CoMETS computes the mean, standard deviation (std), standard error of the mean (sem) and confidence interval of the mean for the different KPIs (here only the profit). Of course, many other, usual or custom, statistics can be specified when creating the experiment.

Here, given the uncertainty of the demand, the Simulation Digital Twin predicts an average profit of 4649, which is the profit you can expect if you apply this strategy for many products with a similar demand pattern (or for a single product over an extended period). The narrow confidence interval means that you have run enough simulations to get a good estimate: there is a 95% chance that the mean profit will be between 4596 and 4702. As you could expect, it is actually lower than if the demand was completely deterministic (i.e. 6270).

Robust optimization experiment: embedding an uncertainty analysis experiment within an optimization experiment

Plug’n’play composable bricks

Actually, you can even go further. Instead of sequentially running a deterministic optimization then assessing the expected variability, you can directly combine both experiments into a single one, so that during the optimization process the uncertainty of the future demand is taken into account. This will allow you to directly prescribe a more robust strategy4.

Here you first create a new “expected_profit_task” which computes the mean profit using the uncertainty analysis that will feed the optimizer:


With a few lines of code (see online documentation for details) a new simulator (expected_profit_task) is created which includes an uncertainty analysis and is ready for optimization.

Robust optimization (same code as for the deterministic case)

The configuration of the optimization is almost unchanged. However, note that here, each of the 4000 evaluations launched by the optimizer is not a single simulation but a full uncertainty analysis made of 20 simulations each. For these embedded computations, CoMETS automatically handles the right simulation distribution on the machine CPUs to minimize the computation time.

Under the hood, optimization runs several uncertainty analyses each of which in turn runs several simulations with a different demand.

Finally the supply chain with this new strategy will be more robust to the demand variability as shown by a better mean profit: 5100 instead of 4648, i.e. a 10% increase and a reduced variability: 1494 instead of 1916, i.e. a 22% improvement.

Distribution of the future profit. Blue: deterministic optimization, orange: robust optimization

You could go even further and try to directly minimize the variability, or a combination of mean profit and dispersion, minimize the probability that profit gets below a given value, etc.


This simplified example shows that:

In a usual workflow, you would experiment with different settings (what statistics you want to optimize, which optimization algorithm works best for this problem, etc.). Once you are satisfied with the configuration, you can package and deploy CoMETS along with the Simulation Digital Twin and an easy-to-use web application so that operators and business users can make insightful decisions on a regular basis.

In the upcoming developments of CoMETS, a new experiment called Sensitivity Analysis will be added. It will help to design appropriate scenarios to understand which of the action levers impact the most the system KPIs.

Going further

To know more about CoMETS, see the release notes as well the online documentation and tutorials on the Cosmo Tech Developer Portal.


1 The expected demand could actually be different each day.

2 In the code, the “deterministic_demand_task” is the simulator parameterized with a demand set to the mean daily demand and which predicts the profit given the reorder point and the reorder quantity as input decision variables. The simulator parameterization is done with about 5 lines of code, see online documentation.

3 The “uncertainty_task” is the simulator parameterized with the previously found optimized reorder point and reorder quantity and which predicts the profit given the (random) demand forecast over the 25 days as simulation inputs.

4 For simplicity, here we call this experiment a “robust optimization”, whereas technically “stochastic optimization” would be more appropriate, since “robust optimization” is often used to refer to a different, but related, approach.

5 This is because the profit predicted from the mean demand does not equate the predicted mean profit, even if there is no bias in your forecast as is the case in this example (30 products per day on average).