def Simulation(): global NumSold, M, OrderPlaced, NumtoOrder, Clock VBASim.VBASimInit(Calendar,TheQueues,TheCTStats,TheDTStats,TheResources,Clock) for i in range (S): # Initial inventory is S Queue.Add(0,Clock) VBASim.Schedule(Calendar,"DemandArrival",RNG.Expon(MeanTBA, 1),Clock) VBASim.Schedule(Calendar,"EndSimulation",T,Clock) NextEvent = Calendar.Remove() Clock = NextEvent.EventTime if NextEvent.EventType == "DemandArrival": DemandArrival() elif NextEvent.EventType == "ItemArrival": ItemArrival() while NextEvent.EventType != "EndSimulation": NextEvent = Calendar.Remove() Clock = NextEvent.EventTime if NextEvent.EventType == "DemandArrival": DemandArrival() elif NextEvent.EventType == "ItemArrival": ItemArrival()
VBASim.Schedule(Calendar, "Arrival", RNG.Expon(MeanTBA, 1), Clock) VBASim.Schedule(Calendar, "Departure", RNG.Expon(MeanPT, 2), Clock) global MaxCars if ParkingLot.NumQueue() > MaxCars: MaxCars = ParkingLot.NumQueue() def Departure(): DepartingCar = ParkingLot.Remove(Clock) TimeSpent.Record(Clock - DepartingCar.CreateTime) for reps in range(0, 2000, 1): Clock = 0.0 MaxCars = 0 VBASim.VBASimInit(Calendar, TheQueues, TheCTStats, TheDTStats, TheResources, Clock) VBASim.Schedule(Calendar, "Arrival", RNG.Expon(MeanTBA, 1), Clock) VBASim.Schedule(Calendar, "EndSimulation", 8, Clock) NextEvent = Calendar.Remove() Clock = NextEvent.EventTime if NextEvent.EventType == "Arrival": Arrival() elif NextEvent.EventType == "Departure": Departure() while NextEvent.EventType != "EndSimulation": NextEvent = Calendar.Remove() Clock = NextEvent.EventTime