index.rst 3.24 KB
Newer Older
1
.. only:: html
2

3 4
    .. figure:: _static/simpy-logo-small.png
        :align: center
5

6
        Discrete event simulation for Python
7 8 9

        `News <https://plus.google.com/101634625602509193865>`_ |
        `PyPI <https://pypi.python.org/pypi/simpy>`_ |
10
        `GitLab <https://gitlab.com/team-simpy/simpy/>`_ |
11
        `Issues
12
        <https://gitlab.com/groups/team-simpy/-/issues>`_ |
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        `Mailing list <https://groups.google.com/forum/#!forum/python-simpy>`_

========
Overview
========

.. only:: html

    .. sidebar:: Documentation

        :ref:`Tutorial <intro>`
            learn the basics of SimPy in just a couple of minutes

        :ref:`Topical Guides <guides>`
            guides covering various features of SimPy in-depth

        :ref:`Examples <examples>`
            usage examples for SimPy

        :ref:`API Reference <api>`
            detailed description of SimPys API

        :ref:`Contents <contents>`
            for a complete overview

        :ref:`About <about>`
            non-technical stuff (history, change logs, ports, )

SimPy is a process-based discrete-event simulation framework based on standard
Python.

Processes in SimPy are defined by Python `generator functions
<http://docs.python.org/3/glossary.html#term-generator>`_ and may, for example,
be used to model active components like customers, vehicles or agents.  SimPy
also provides various types of :ref:`shared resources <shared-resources>` to
model limited capacity congestion points (like servers, checkout counters and
tunnels).

Simulations can be performed :ref:`as fast as possible <simulation-control>`,
in :ref:`real time <realtime>` (wall clock time) or by manually :ref:`stepping
<simulation-step>` through the events.

Though it is theoretically possible to do continuous simulations with SimPy, it
has no features that help you with that. On the other hand, SimPy is overkill
for simulations with a fixed step size where your processes dont interact with
each other or with shared resources.

A short example simulating two clocks ticking in different time intervals looks
like this:

>>> import simpy
>>>
>>> def clock(env, name, tick):
...     while True:
...         print(name, env.now)
...         yield env.timeout(tick)
...
>>> env = simpy.Environment()
>>> env.process(clock(env, 'fast', 0.5))
<Process(clock) object at 0x...>
>>> env.process(clock(env, 'slow', 1))
<Process(clock) object at 0x...>
>>> env.run(until=2)
fast 0
slow 0
fast 0.5
slow 1
fast 1.0
fast 1.5

Ontje Lünsdorf's avatar
Ontje Lünsdorf committed
83 84 85
The documentation contains a :ref:`tutorial <intro>`, :ref:`several guides
<guides>` explaining key concepts, a number of :ref:`examples
<examples>` and the :ref:`API reference <api>`.
86 87 88 89 90 91 92 93 94 95 96 97

SimPy is released under the MIT License. Simulation model developers are
encouraged to share their SimPy modeling techniques with the SimPy community.
Please post a message to the `SimPy mailing list
<https://groups.google.com/forum/#!forum/python-simpy>`_.

There is an introductory talk that explains SimPys concepts and provides some
examples: `watch the video <https://www.youtube.com/watch?v=Bk91DoAEcjY>`_ or
`get the slides <http://stefan.sofa-rockers.org/downloads/simpy-ep14.pdf>`_.

SimPy has also been reimplemented in other programming languages. See the
:ref:`list of ports <ports>` for more details.