File: RealTimeFireworks.py

package info (click to toggle)
python-simpy 2.3.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,864 kB
  • sloc: python: 11,171; makefile: 143
file content (25 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
""" RealTimeFireworks.py """
from SimPy.SimulationRT  import *
from random import *
import time
## Model components -----------------------------------------------------------
class Launcher(Process):
	def launch(self):
		while True:
			print "Launch at %2.2f; wallclock: %2.2f"%(now(),time.clock()-startTime)
			yield hold,self,uniform(1,maxFlightTime)
			print "Boom!!! Aaaah!! at %2.2f; wallclock: %2.2f"\
			       %(now(),time.clock()-startTime)
def model():
	initialize()
	for i in range(nrLaunchers):
		lau=Launcher()
		activate(lau,lau.launch())
	simulate(real_time=True,rel_speed=1,until=20) ##unit sim time = 1 sec clock
## Experiment data  -----------------------------------------------------------   
nrLaunchers=2
maxFlightTime=5.0 
startTime=time.clock()
seed(1234567)
## Experiment ----------------------------------------------------------------- 
model()