Skip to main content

SimPype is a simulation framework based on Simpy that relies on the concepts of resource and pipe.

Project description

SimPype is a simulation framework based on SimPy that 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.3. Previous versions of Python are not supported. The quickest way to install SimPype is through pip3:

>>> pip3 install simpype

SimPype automatically installs SimPy as dependency.

SimPype documentation can be found on ReadTheDocs while the source code repository is available on GitHub.

Scope

SimPype 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.

Concept

A SimPype simulation environment comprises at least one generator and one resource which are connected via a pipeline. The generator generates messages with a given arrival time. Those messages are firs enqueue in the resource pipe and next processed by the resources according with a service 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:

  1. The generator waits a random arrival time and generates a message;

  2. The generator sends the message to the resource;

  3. The message is enqueued in the resource’s pipe;

  4. When the resource becomes available, the message is dequeued from the pipe;

  5. The message is served by the resource;

  6. The message leaves the resource after a random service time and is sent to the next resource (if any) - Go to step 3.

Any simulation steps can be customized as desired. Follows the tutorial to 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.default.in
... 0.000000000,gen0,0,res0,pipe.default.out
... 0.030509067,gen0,0,res0,resource.serve
... 4.283987797,gen0,1,res0,pipe.default.in
... 4.283987797,gen0,1,res0,pipe.default.out
... 4.296562508,gen0,1,res0,resource.serve
... 4.944812881,gen0,2,res0,pipe.default.in
... 4.944812881,gen0,2,res0,pipe.default.out
... 5.128244999,gen0,2,res0,resource.serve
... 6.402898951,gen0,3,res0,pipe.default.in
... 6.402898951,gen0,3,res0,pipe.default.out
... 7.044417615,gen0,3,res0,resource.serve
... 7.561061272,gen0,4,res0,pipe.default.in
... 7.561061272,gen0,4,res0,pipe.default.out
... 7.729431178,gen0,5,res0,pipe.default.in
... 8.129979622,gen0,4,res0,resource.serve
... 8.129979622,gen0,5,res0,pipe.default.out
... 8.171601538,gen0,6,res0,pipe.default.in
... 8.886733703,gen0,5,res0,resource.serve
... 8.886733703,gen0,6,res0,pipe.default.out
... 8.949540209,gen0,6,res0,resource.serve

This data format is well-suited for being directly processed by data manipulation tools like pandas or dplyr. SimPype does not provide any tools for parsing the data.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpype-1.0.0rc2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpype-1.0.0rc2-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file simpype-1.0.0rc2.tar.gz.

File metadata

  • Download URL: simpype-1.0.0rc2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for simpype-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 93b32ebdc131113e9fa1f173da8089d510c88315a27f558be4f30cddc341894e
MD5 f6ec56ca24d2ea22937fd44c68c2b4c5
BLAKE2b-256 8d46e7dd49cd1dd465a6d5764d06c64406e751bd45eef780eb5529b44a1d2b47

See more details on using hashes here.

File details

Details for the file simpype-1.0.0rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for simpype-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ca747eb0fc5a3cf7b983e00eeadc773d65be00a743d5e146cef01c0e2b7a86b
MD5 744b1a66f147a8c47b1f086e1ff5050f
BLAKE2b-256 1d81da6ae9a9c800d0ba9e9e1e7be07bf8e350053f6043684b1b69ea27254f94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page