Simple simulationΒΆ

To build your first SimPype simulation, you simply need a console environment and a text editor. Write the following block of code into a text file, e.g.

# [Mandatory] Import SimPype module
import simpype
import random

# [Mandatory] Create a SimPype simulation object
sim = simpype.Simulation(id = 'simple')

# [Mandatory] Add at least one generator to the simulation
gen0 = sim.add_generator(id = 'gen0')
gen0.random['arrival'] = {
        0: lambda: random.expovariate(2.0)

# [Mandatory] Add at least one resource to the simulation
res0 = sim.add_resource(id = 'res0')
# [Mandatory] Assign a service time
res0.random['service'] = {
        0: lambda: random.expovariate(3.0)

# [Mandatory] Add a pipeline connecting the generator to the resource
p0 = sim.add_pipeline(gen0, res0)

# [Mandatory] Run the simulation e.g. until t=5
#    calls Simpy's
#             Any args passed to is then passed to = 5)

Now run the simulation by typing the following command in the console:

$ python3

If your simulation name has a different name than, just replace with your filename. SimPype automatically logs the simulation results, see Log system for a detailed explaination on how to read the log files.