Commit 587eedfb authored by Ontje Lünsdorf's avatar Ontje Lünsdorf
Browse files

Merge.

parents 7c6926d2 e11a1226
Changelog for SimPy
==============================
===================
v2.3.1 – 2012-01-28:
......@@ -82,3 +82,7 @@ v2.0.0 - 2009-01-26:
- [NEW] In addition to its existing API, SimPy now also has an object oriented
API.
You can find information on older changes on SimPy’s `history`__ page.
__ https://simpy.readthedocs.org/en/latest/about/history.html
This diff is collapsed.
......@@ -2,27 +2,32 @@ SimPy
=====
SimPy is a process-based discrete-event simulation framework based on standard
Python. Its event dispatcher is based on Python’s `generators`__ and can also be
used for asynchronous networking or to implement multi-agent systems (with
Python. Its event dispatcher is based on Python’s `generators`__ and can also
be used for asynchronous networking or to implement multi-agent systems (with
both, simulated and real communication).
Processes in SimPy are simple Python generator functions and are used to model
active components like customers, vehicles or agents. SimPy also provides
various types of shared *resource* to model limited capacity congestion points
(like servers, checkout counters and tunnels). It will also provides monitoring
capabilities to aid in gathering statistics about resources and processes.
various types of shared *resources* to model limited capacity congestion points
(like servers, checkout counters and tunnels). From version 3.1, it will also
provide monitoring capabilities to aid in gathering statistics about resources
and processes.
Simulations can be performed “as fast as possible”, in real time (wall clock
time) or by manually stepping through the events.
The distribution contains in-depth documentation, tutorials, and a large number
of examples.
SimPy is not suited for continuous simulation. And it is overkill for
simulations with a fixed step size where your processes don’t interact with
each other or with shared resources — use a simple ``while`` loop in this case.
Simpy is released under the GNU LGPL. Simulation model developers are
The SimPy distribution contains tutorials, in-depth documentation, and a large
number of examples.
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-Users mailing list`__.
__ http://docs.python.org/2/glossary.html#term-generator
__ http://docs.python.org/3/glossary.html#term-generator
__ http://lists.sourceforge.net/lists/listinfo/simpy-users
......@@ -54,7 +59,7 @@ Installation
SimPy requires Python 2.7, 3.2, PyPy 2.0 or above.
You can install SimPy easily via `PIP <http://pypi.python.org/pypi/pip>`_::
You can install SimPy easily via `pip <http://pypi.python.org/pypi/pip>`_::
$ pip install -U SimPy
......@@ -71,28 +76,33 @@ To run SimPy’s test suite on your installation, execute::
Getting started
---------------
If you’ve never used SimPy before, the `SimPy tutorial
<https://simpy.readthedocs.org/en/latest/simpy_intro/index.html>`_ is a good
starting point for you. You can also try out some of the `Examples <https://simpy.readthedocs.org/en/latest/examples/index.html>`_ shipped with SimPy.
If you’ve never used SimPy before, the `SimPy tutorial`__ is a good starting
point for you. You can also try out some of the `Examples`__ shipped with
SimPy.
__ https://simpy.readthedocs.org/en/latest/simpy_intro/index.html
__ https://simpy.readthedocs.org/en/latest/examples/index.html
Documentation and Help
----------------------
In our `online documentation <https://simpy.readthedocs.org/>`_, you can find
`a tutorial <https://simpy.readthedocs.org/en/latest/simpy_intro/index.html>`_,
`examples <https://simpy.readthedocs.org/en/latest/examples/index.html>`_,
`topical guides
<https://simpy.readthedocs.org/en/latest/topical_guides/index.html>`_ and an
`API reference
<https://simpy.readthedocs.org/en/latest/api_reference/index.html>`_, as well
as some information about `SimPy and its history
<https://simpy.readthedocs.org/en/latest/about/index.html>`_. For more help,
contact the `SimPy-Users mailing list
<mailto:simpy-users@lists.sourceforge.net>`_. SimPy users are pretty helpful.
If you find any bugs, please post them on our `issue tracker
<https://bitbucket.org/simpy/simpy/issues?status=new&status=open>`_.
You can find `a tutorial`__, `examples`__, `topical guides`__ and an `API
reference`__, as well as some information about `SimPy and its history`__ in
our `online documentation`__. For more help, contact the `SimPy-Users mailing
list`__. SimPy users are pretty helpful. You can, of course, also dig through
the `source code`__.
If you find any bugs, please post them on our `issue tracker`__.
__ https://simpy.readthedocs.org/en/latest/simpy_intro/index.html
__ https://simpy.readthedocs.org/en/latest/examples/index.html
__ https://simpy.readthedocs.org/en/latest/topical_guides/index.html
__ https://simpy.readthedocs.org/en/latest/api_reference/index.html
__ https://simpy.readthedocs.org/en/latest/about/index.html
__ https://simpy.readthedocs.org/
__ mailto:simpy-users@lists.sourceforge.net
__ https://bitbucket.org/simpy/simpy/src
__ https://bitbucket.org/simpy/simpy/issues?status=new&status=open
Enjoy simulation programming in SimPy!
......@@ -4,9 +4,9 @@
{% block body %}
<h1>Welcome</h1>
<div style="width: 20em; margin: 0 0 .5em 1em; float: right;">
<div class="highlight-python"><div class="highlight"><pre style="margin: 0;"><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">simpy</span>
<span class="gp">&gt;&gt;&gt;</span>
<div style="width: 25em; margin: 0 0 .5em 1em; float: right;">
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">simpy</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">clock</span><span class="p">(</span><span class="n">env</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">print</span><span class="p">(</span><span class="n">env</span><span class="o">.</span><span class="n">now</span><span class="p">)</span>
......@@ -14,35 +14,42 @@
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">env</span> <span class="o">=</span> <span class="n">simpy</span><span class="o">.</span><span class="n">Environment</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">env</span><span class="o">.</span><span class="n">start</span><span class="p">(</span><span class="n">clock</span><span class="p">(</span><span class="n">env</span><span class="p">))</span>
<span class="go">Process(clock)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">simpy</span><span class="o">.</span><span class="n">simulate</span><span class="p">(</span><span class="n">env</span><span class="p">,</span> <span class="n">until</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="go">&lt;Process(clock) object at 0x...&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">env</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">until</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="go">0</span>
<span class="go">1</span>
<span class="go">2</span></pre></div>
</div>
<span class="go">2</span>
</pre></div></div>
</div>
<p>SimPy is a process-based discrete-event simulation framework based on
standard Python. Its event dispatcher is based on Python’s <a
href="http://docs.python.org/2/glossary.html#term-generator">generators</a> and
href="http://docs.python.org/3/glossary.html#term-generator">generators</a> and
can also be used for asynchronous networking or to implement multi-agent
systems (with both, simulated and real communication).</p>
<p>Processes in SimPy are simple Python generator functions and are used to
model active components like customers, vehicles or agents. SimPy also provides
various types of shared <em>resources</em> to model limited capacity congestion
points (like servers, checkout counters and tunnels). It also provides
monitoring capabilities to aid in gathering statistics about resources and
processes.</p> <p>Simulations can be performed “as fast as possible”, in real
time (wall clock time) or by manually stepping through the events.</p>
points (like servers, checkout counters and tunnels). From version 3.1, it will
also provide monitoring capabilities to aid in gathering statistics about
resources and processes.</p>
<p>The distribution contains in-depth documentation, tutorials, and a large
<p>Simulations can be performed “as fast as possible”, in real time (wall clock
time) or by manually stepping through the events.</p>
<p>SimPy is not suited for continuous simulation. And it is overkill for
simulations with a fixed step size where your processes don’t interact with
each other or with shared resources — use a simple <tt class="docutils literal">while</tt> loop in this case.</p>
<p>The SimPy distribution contains tutorials, in-depth documentation, and a large
number of examples.</p>
<p>Simpy is released under the GNU LGPL. Simulation model developers are
<p>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 <a
href="http://lists.sourceforge.net/lists/listinfo/simpy-users">SimPy-Users mailing list</a>.</p>
href="http://lists.sourceforge.net/lists/listinfo/simpy-users">SimPy-Users
mailing list</a>.</p>
<h2 style="clear: both;">Documentation</h2>
......
......@@ -2,19 +2,19 @@
``simpy.core`` --- SimPy's core components
==========================================
.. automodule:: simpy.core
Environments
============
.. autoclass:: BaseEnvironment
:members:
.. autoclass:: Environment
:members:
:show-inheritance:
:inherited-members:
.. autoclass:: BaseEnvironment
:members:
Events
======
......@@ -24,52 +24,36 @@ Events
.. autoclass:: Process
:members:
:show-inheritance:
.. autoclass:: Timeout
:members:
:show-inheritance:
.. autoclass:: Condition
:members:
:show-inheritance:
.. autoclass:: Initialize
:members:
:show-inheritance:
.. autoclass:: AllOf
:members:
:show-inheritance:
.. autoclass:: AnyOf
:members:
:show-inheritance:
.. autoclass:: Initialize
:members:
Miscellaneous (Interrupt and constants)
=======================================
.. autoclass:: BoundClass
:members:
.. autoclass:: EmptySchedule
.. autoclass:: Interrupt
:members: cause
.. data:: Infinity = inf
Convenience alias for infinity
.. data:: PENDING = object()
Unique object to identify pending values of events
.. data:: HIGH_PRIORITY = 0
Priority of interrupts and Intialize events
.. data:: DEFAULT_PRIORITY = 1
Default priority used by events
.. data:: LOW_PRIORITY = 2
Priority of timeouts
.. autodata:: Infinity
.. autodata:: PENDING
.. autodata:: HIGH_PRIORITY
.. autodata:: DEFAULT_PRIORITY
.. autodata:: LOW_PRIORITY
==============================
``simpy`` --- The user API
``simpy`` --- The end user API
==============================
.. automodule:: simpy
......@@ -3,5 +3,4 @@ SimPy home
==========
..
_templates/index.html contains the content for this page.
.. _templates/index.html contains the content for this page.
......@@ -16,7 +16,7 @@ setup(
long_description=open('README.txt').read(),
url='https://simpy.readthedocs.org',
download_url='https://bitbucket.org/simpy/simpy/downloads',
license='GNU LGPL',
license='MIT License',
packages=[
'simpy',
'simpy.resources',
......@@ -32,8 +32,7 @@ setup(
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: OS Independent',
'License :: OSI Approved :: GNU Library or Lesser General Public ' + \
'License (LGPL)',
'License :: OSI Approved :: MIT License',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
......
"""
The ``simpy`` module provides SimPy's end-user API. It therefore
aggregates Simpy's various classes and methods:
The ``simpy`` module provides SimPy's end-user API. It aggregates Simpy's most
important classes and methods. This is purely for your convenience. You can of
course also access everything (and more!) via their actual submodules.
Core classes and functions
......@@ -11,7 +12,7 @@ Core classes and functions
- :class:`Environment`: SimPy's central class. It contains
the simulation's state and lets the PEMs interact with it (i.e.,
schedule events).
- :class:`Process`: This class represents a PEM while
- :class:`Process`: This class represents a process function while
it is executed in an environment. An instance of it is returned by
:meth:`Environment.start()`. It inherits :class:`Event`.
- :class:`Interrupt`: This exception is thrown into a process if it gets
......
This diff is collapsed.
......@@ -12,36 +12,41 @@ from simpy.core import Environment, Infinity
class RealtimeEnvironment(Environment):
"""An environment which uses the real (e.g. wallclock) time.
"""An :class:`~simpy.core.Environment` which uses the real (e.g. wallclock)
time.
A time step will take *factor* seconds of real time (one second by
default), e.g. if you step from ``0`` until ``3`` with ``factor=0.5``, the
default); e.g., if you step from ``0`` until ``3`` with ``factor=0.5``, the
:meth:`simpy.core.BaseEnvironment.run()` call will take at least 1.5
seconds.
If the processing of the events for a time step takes too long,
a :exc:`RuntimeError` is raised in :meth:`step()`. You can disable this
behavior by setting *strict* to ``False``."""
behavior by setting *strict* to ``False``.
"""
def __init__(self, initial_time=0, factor=1.0, strict=True):
Environment.__init__(self, initial_time)
self.env_start = initial_time
self.real_start = time()
self.factor = factor
"""Scaling factor of the realtime."""
"""Scaling factor of the real-time."""
self.strict = strict
"""Running mode of the environment. :meth:`step()` will raise a
:exc:`RuntimeError` if this is set to ``True`` and the processing of
events took too long."""
events takes too long."""
def step(self):
"""Waits until enough realtime has passed for the next event to happen.
"""Waits until enough real-time has passed for the next event to
happen.
The delay is scaled according to the real-time :attr:`factor`. If the
events of a time step are processed too slowly for the given
:attr:`factor` and if :attr:`strict` is enabled, a :exc:`RuntimeError`
is risen."""
is raised.
"""
evt_time = self.peek()
if evt_time is Infinity:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment