ComponentGenerator

With ComponentGenerator components can be generated according to a given inter arrival time (distribution) or a random spread over a given interval.

Examples

sim.ComponentGenerator(Car, iat=sim.Exponential(2))
# generates Cars according to a Poisson arrival

sim.ComponentGenerator(Car, iat=sim.Exponential(2), at=10, till=30, number=10)
# generates maximum 10 Cars according to a Poisson arrival from t=10 to t=30

sim.ComponentGenerator(Car, iat=sim.Exponential(2), at=10, till=30, number=10, force_at=True)
# generates maximum 10 Cars according to a Poisson arrival from t=10 to t=30, first arrival at t=10

sim.ComponentGenerator(sim.Pdf((Car, 0.7, Bus, 0.3)), iat=sim.Uniform(20,40), number=20)
# generates maximum 20 vehicles (70% Car, 30% Bus) according to a uniform inter arrival time

sim.ComponentGenerator(Car, duration=100, n=20)
# generates exactly 20 Cars, random spread over t=now and t=now+100

sim.ComponentGenerator(Car, duration=100, n=20, force_at=True, force_till=True)
# generates exactly 20 Cars, random spread over t=now and t=now+100, with arrivals at t=now and t=now+100

ComponentGenerator is a subclass of Component and therefore has all the normal properties and methods of an ordinary component, altough it is not recommended to use any of the process methods, apart from cancel.

It is possible to ‘propagate’ parameters to a generated component. This holds for the standard salabim parameters, like name, urgent and priority but also for user class defined parameters.

E.g.

sim.ComponentGenerator(Car, iat=sim.Exponential(2), color='red')
# generates Cars with color=color according to a Poisson arrival

sim.ComponentGenerator(Car, iat=sim.Exponential(2), name='ford.')
# generates Cars according to a Poisson arrival with name ford.0, ford.1

The component_class can also be a callable without paramters, most like a distribution.

So we can say

sim.ComponentGenerator(sim.Pdf((Car, Bus, Truck), (50, 30, 20)), iat=sim.Exponential(2))
# generates 50% Cars, 30% Buses and 20% Trucks according to a Poisson arrival