import umontreal.iro.lecuyer.rng.*; import umontreal.iro.lecuyer.randvar.*; import umontreal.iro.lecuyer.probdist.PoissonDist; import umontreal.iro.lecuyer.stat.Tally; import umontreal.iro.lecuyer.util.Chrono; public class Inventory { double lambda; // Mean demand size. double c; // Sale price. double h; // Inventory cost per item per day. double K; // Fixed ordering cost. double k; // Marginal ordering cost per item. double p; // Probability that an order arrives. RandomVariateGenInt genDemand; RandomStream streamDemand = new MRG32k3a(); RandomStream streamOrder = new MRG32k3a(); Tally statProfit = new Tally ("stats on profit"); public Inventory (double lambda, double c, double h, double K, double k, double p) { this.lambda = lambda; this.c = c; this.h = h; this.K = K; this.k = k; this.p = p; genDemand = new PoissonGen (streamDemand, new PoissonDist (lambda)); } // Simulates the system for m days, with the (s,S) policy, // and returns the average profit per day. public double simulateOneRun (int m, int s, int S) { int Xj = S, Yj; // Stock in the morning and in the evening. double profit = 0.0; // Cumulated profit. for (int j=0; j