You can build a mathematical model in GAMS or Matlab. (GAMs is much easier)
Since the demand is stochastic, therfore you cant choose deterministic optimization. Two possible solution exist if data is uncertain ( Robust optimization or Scenario based optimization). In your case, robust optimization fits provided you have good information of the uncertain data Bounds.
You can build a model for optimization with application of a statistic software, as MINITAB, MATLAB. this is very easy. you should have some data. you can get this data with some run of experiments.
If your main issue is how to create a "function" to optimize, you could look at this publication: "Evolutionary generation of dispatching rule sets for complex dynamic scheduling problems"
In dynamic scheduling problems, the demand (the orders placed) are also stochastic. If I remember correctly, in that publication they simply tested each solution over a large number of orders, randomly generated under reasonable constraints.
In your problem, you could model the variations in the demand with some stochastic distributions, starting from real-world data: and then, every time you evaluate a candidate solution to your problem, you simply test the solution against a large number of randomly generated "demands".
As a general advice, in dynamic problems the average performance is of course important, but you should also consider the standard deviation, as a solution with really low standard deviation might be preferable to another solution with higher average, but also high standard deviation.
Something that may be similar to the last mentioned direction: you can build a stochastic model for your cost depending on the random behavior of the demand considering your supplies as decision variables. Then you simulate the model and obtain a large sample of results then do some risk analysis (mean, VaR, TVaR, etc..) on these samples to study what would be the acceptable previously taken decision on your supplies. Some kind of trial and error procedure.
It depends on the amount of detail you want/ are willing to pay for in your model. For the most robust solution, I would recommend looking at an agent-based model in AnyLogic Software. Annylogic lets you combine systems dynamics and agent-based modeling, so you could easily generate variable demand based on a customer stream that incorporates time-based factors, customer preferences for product/price trade-offs and matches demand to supply stocks and re-stocking schedules. The level of detail with respect to customer characteristics and the level of representation of the supply process are then just a matter of the amount of time you're willing to invest in developing the model. Such a model would help determine potential bottlenecks or other demand vs. supply problems, and parametric variation of agent characteristics could help overcome any limitations in the available real-world data. AnyLogic supports interactive Monte Carlo simulation of supermarkets operation, parametric simulation experiments of such operations, and a variety of more traditional optimization analyses.
Programming language is not important, you're model is. I do everything in VBA and Python. Matlab is too expensive (company researcher) and less suitable language for commercialization.
1) Choose your model for sampling: Dynamic programming with stochastic sampling (choose and calibrate also the distribution function) of the customers (use multiple samples for a certain set of optimization parameters).
2) Define your optimization parameters (probably critical threshold levels for avoiding supply failure)
3) Define your objective function (output): cost minimization probably or profit maximization
4) Define your constraints (for instance max % permitted system failures, maximum supplys)
5) Use a good optimization heuristic suitable for your problem, identify your solution space characteristics. Is it convex, non-convex? Linear, quadratic, polynomial? Can you split it in independent convex sub problems? Maybe you can use some derivative free search (what I use), or gradient search type heuristics,...
I recommend you Tecnomatix Plant Simulation, it is very easy to use and in it you can model almost anything.
First you need a layout of your super market, so you can build the model according to the layout.
Then you need storage capacity of the shelves that will determine the buffer sizes in the model.
Your model should look very simple, since you are modeling supermarket it will contain only buffers, and little bit of tables of demand and restocking.
If you have access to the sales in the super market and you can use that data to determine the statistic distribution how the demand for certain product is changing.
Also you need access to the restocking so you can insert it in the model, or your stock will get empty very fast.
Using Tecnomatix you can track stock during the hole simulation and you can see which stock should be reduced and which should be increased...