Inventory on a shared shelf
Eight products, each with its own demand distribution and its own cost of running short, share one shelf of 1020 units. For a single product there is a textbook formula; once the products compete for the shelf, there is none. The model below states the expected shortage cost over 500 sampled scenarios the way you would write it in code, max(d − Q, 0) included, and Quicopt solves it as written.
Splitting the shelf in proportion to average demand costs 1347.0 per day. The optimized allocation costs 1014.5, about 24% less, and stays there on scenarios it was not optimized on.