Using Python for simulation

Darren Hutchinson (darren@aus.hp.com)
Mon, 29 Aug 1994 02:26:23 GMT

G'day.

I'm looking at using python as a language for discreete event simulation.
The 'event' module would provide a solution where each 'actor' is broken
up into a number of sections 'seperated' by events, but it makes the
simulation code harder to understand.

What I'd rather do is something, like simula67, where an object can decide
to suspend its own execution until an event occurs or a (simulated) time
is reached, providing a simulation which is easier to understand.

It seems that pthreads could be used to achieve this, but the environment
that will be used to host the simulation isn't capable of multithreading.

Another option would have been to modify the python interpreter to allow
this but, unfortunately, the 'C' stack seems to be used as the call stack
for python code (this could be solved by stack swapping using setjmp/longjmp
but it gets pretty tacky ...)

There are lots of things that might help me. Maybe someone out there has
implemented something along these lines, or has worked on co-routines
for python, or cooperative multitasking (perhaps by modifying the threads
idea), or even something like 'C' setjmp/lomgjmp ?

Any help greatly appreciated,

-- 
============================================================================
Darren Hutchinson.              darren@hpato.aus.hp.com
ATO Merlin project		Ph: +61 3 272 4047 [Office]
                                Ph: (0414) 203 217 [Dinky mobile phone]
============================================================================