Package: simpype
OverviewSimPype is a simulation framework based onSimPythat relies on the concepts of resource and pipe.
SimPype decouples the resource from its queue (pipe) in such a way multiple queueing techniques can be used with the same resource.
SimPype also allows to create both custom resource and pipe models that can be reused in multiple simulations.SimPype supports only Python >= 3.6. Previous versions of Python are not supported.
The quickest way to install SimPype is throughpip3:>>> pip3 install simpypeSimPype automatically installs SimPy as dependency.SimPype documentation can be found onReadTheDocswhile the source code repository is available onGitHub.ScopeSimPype is tailored to scenarios where the queueing disciplines and the resources occupation are key parts of the system under simulation.
People queueing at a post office, supermarket, car wash, cafeteria, etc. are examples of such scenarios.ConceptA SimPype simulation environment comprises at least onegeneratorand oneresourcewhich are connected via apipeline.
The generator generatesmessageswith a givenarrival time.
Those messages are firs enqueue in the resourcepipeand next processed by the resources according with aservice time.A simple scenario with one generator and one resource can be defined as follows in a python3 console:>>> import simpype
>>> import random
>>> sim = simpype.Simulation(id = 'overview')
>>> gen0 = sim.add_generator(id = 'gen0')
>>> gen0.random['arrival'] = {0: lambda: random.expovariate(1.0)}
>>> res0 = sim.add_resource(id = 'res0')
>>> res0.random['service'] = {0: lambda: random.expovariate(2.0)}
>>> p0 = sim.add_pipeline(gen0, res0)
>>> sim.run(until = 10)The simulation steps can be summarized as follows:The generator waits arandom arrival timeand generates a message;The generatorsends the messageto the resource;Themessage is enqueuedin the resource’s pipe;When the resource becomes available, themessage is dequeuedfrom the pipe;Themessage is servedby the resource;The message leaves the resource after arandom service timeand is sent to the next resource (if any) - Go to step 3.Any simulation steps can be customized as desired. Follows thetutorialto learn how to customize your simulation environment.SimPype also provides a built-in logging system for your simulation that automatically logs the simulation steps 3, 4, and 5.
The built-in system produces the logs in a tidy format where each variable is saved in its own column and each observation is saved in its own row:>>> timestamp,message,seq_num,resource,event
... 0.000000000,gen0,0,res0,pipe.in
... 0.000000000,gen0,0,res0,pipe.out
... 0.030509067,gen0,0,res0,resource.serve
... 4.283987797,gen0,1,res0,pipe.in
... 4.283987797,gen0,1,res0,pipe.out
... 4.296562508,gen0,1,res0,resource.serve
... 4.944812881,gen0,2,res0,pipe.in
... 4.944812881,gen0,2,res0,pipe.out
... 5.128244999,gen0,2,res0,resource.serve
... 6.402898951,gen0,3,res0,pipe.in
... 6.402898951,gen0,3,res0,pipe.out
... 7.044417615,gen0,3,res0,resource.serve
... 7.561061272,gen0,4,res0,pipe.in
... 7.561061272,gen0,4,res0,pipe.out
... 7.729431178,gen0,5,res0,pipe.in
... 8.129979622,gen0,4,res0,resource.serve
... 8.129979622,gen0,5,res0,pipe.out
... 8.171601538,gen0,6,res0,pipe.in
... 8.886733703,gen0,5,res0,resource.serve
... 8.886733703,gen0,6,res0,pipe.out
... 8.949540209,gen0,6,res0,resource.serveThis data format is well-suited for being directly processed by data manipulation tools likepandasortidyverse. SimPype does not provide any tools for parsing the data.