PyDDE: Python/C DDE solver research :: home  

Update. A message from Renato Coutinho: "I just ported PyDDE to work with Python 3, the patches are mostly trivial syntax corrections and a change in the initialization of the C module. If you are interested in updating it, the patches are available at

inside the tarball download. The changes are such that it still works on python2 (at least 2.6 and 2.7)." Thanks, Renato!

PyDDE is an open source numerical solver for systems of delay differential equations (DDEs), implemented as a Python package and written in both Python and C.

PyDDE is built around the back-end of ddesolve (now called PBSddesolve), an R package with the same functionality, which in turn is built on the numerical routines of Simon Wood's Solv95, a C-based DDE solver for Microsoft Windows systems. There is now also a Mac port for Solv95, with Cocoa frontend by Ashley Buckner. If you use a different OS or prefer that your simulations are scriptable within a nice environment like Python, you might wish to read on!

On-going development of PyDDE has ceased. Development does appear to be continuing for PBSddesolve. If you are happy to use R, or RPy, you might consider employing PBSddesolve instead or PyDDE.

Requirements. PyDDE requires Python, of course, and either of the Numeric or NumPy packages, which can be downloaded via the NumPy site.

Download. PyDDE is provided as a source distribution. Updated 7 December 2008.

Installation. PyDDE is very easy to install on most platforms. Instructions can be found in the included file INSTALL.txt, and in the manual linked below. Release notes can be found in README.txt.

Licensing. PyDDE is licensed under the GNU General Public License version 2. Note that it comes with absolutely no warranty. Please read the included file LICENSE.txt for important license and warranty information.

Documentation. The PyDDE documentation describes, with examples, how to install and use PyDDE. The file pyddemanual.pdf is available in PDF format compiled from a LaTeX file, both of which are included in the source distribution.


I welcome any questions or suggestions about PyDDE--particulary if you had problems with the package, and "especially particularly" if you also have the solution! Please contact me via e-mail.

About PyDDE

PyDDE can solve a wide range of ODE and DDE models with discontinuities that may have state-dependent effects but state-independent timings. Simulation is handled by an adaptively-stepping embedded RK2(3) scheme with cubic Hermite interpolation for calculation of delay terms. Some of the advantages of PyDDE are that it is fast, efficient and allows rapid prototyping of scriptable models in a free, platform-independent environment.

Motivation. There is a lack of easily-obtainable numerical solvers of delay differential equations for interpretted languages. Most solvers require either some knowledge of programming in either C or FORTRAN, or run only under proprietary environments such as MATLAB TM.
     One freely-available (open source and distributable for non-commercial purposes) DDE solver is Simon Wood's Solv95, which employs an adaptively stepping embedded RK2(3) scheme with cubic hermite interpolation in calculating delay terms. Some of the advantages of Solv95 are that it is fast, efficient and can solve a wide range of ODE and DDE models. One of its drawbacks is that rapid prototyping of models (that interpretted languages typically provide) is hampered by the requirement that models be written in C. Also, Solv95 was developed for a Microsoft Windows environment and has been ported to the Mac OS 10.4, but is not available to users of other systems without significant modification.
     Python is a free language and interpreter that is available for virtually all modern operating systems and most hardware platforms. It is purpose built to be extremely flexible and extensible. The quotes page gives an idea of the wide range of uses of Python. Because of these advantages I chose Python as an environment in which to wrap Solv95 as a fast, powerful, easy-to-use and cross-platform DDE solver.

Differences between ddesolve and PyDDE. PyDDE started life in late 2005 as a port of Solv95. It was a pretty faithful port, and it worked, but was not very user-friendly. Just when I was looking into creating a new port of Solv95 for R, along came ddesolve (now called PBSddesolve), by Alex Couture-Beil, Jon Schnute and Rowan Haigh from Fisheries and Oceans Canada's Pacific Biological Station. In order to simplify maintenance of both ports (and I personally have used both), I decided to move PyDDE to the same back-end used by ddesolve. Apart from the usual issues likely to be encountered when translating between programming languages, it should be trivial to port models from (PBS)ddesolve to PyDDE.

Differences between Solv95 and PyDDE. PyDDE is built directly on the ddesolve back end, and ddesolve is built directly on the code used in Solv95, but there are a number of differences. The most important are related to speed: since PyDDE uses Python as another layer over the Solv95 algorithms, it is a bit slower than the original. (Note that PyDDE does not wrap the R interface from ddesolve; the interface to the back-end uses only Python and C libraries.) Much of the memory management has been rewritten, so 'mileage may vary' a little here also. However, in practical terms PyDDE should perform comparably in most situations. It also has better error-handling and makes available the power of Python to process solution data, so extra computation time should be more than made up for by much faster model development.

Binary distributions. There are no binary distributions for PyDDE—sorry. Note that there is a Windows binary for ddesolve on CRAN, and there's no reason one couldn't use ddesolve from within Python using the RPy (R from Python) package.
     I have in the past made attempts to create a binary distribution for Python 2.4 for Windows, but while compilation appears to complete without error and the package loads, for unknown reasons it doesn't work. If you can install source distributions but prefer the uninstallation advantages of binaries, try here.

Further development. I am unlikely to develop PyDDE any further, because my research interests have moved on. However, I will provide very limited support if you are having trouble with it (amounting to suggestions on how to fix any problems you migth find). I'm also keen to hear from anyone who has modified the code; that is, after all, how PyDDE itself got started.

Solution to a Lotka-Volterra predator-prey model.
Solution to Gurney & Nisbet's (1981) model for Nicholson's (1954) blowflies.
Solution to a DDE with switches.
© 2005 B.J. Cairns.
© 2002-2010 Benjamin J. Cairns: e-mail ; ph +44 1865 289673 ;
Cancer Epidemiology Unit, University of Oxford, Richard Doll Building, Roosevelt Drive, Oxford OX3 7LF, U.K.