Monitor_plot
class Simulation: ## Methods ---------------------------------- __init__(self) initialize(self) now(self) stopSimulation(self) allEventNotices(self) allEventTimes(self) activate(self, obj, process, at='undefined', delay='undefined', prior=False) reactivate(self, obj, at='undefined', delay='undefined', prior=False) startCollection(self, when=0.0, monitors=None, tallies=None) simulate(self, until=0)
class Monitor (subclass of list) records time series of observed data values for a simulation variable
m = Monitor(name=‘’,ylab=‘y’,tlab=‘t’)
Attributes:
m.yseries() returns a list of the recorded data values.
m.tseries() returns a list of the recorded times.
m.total() returns the sum of the y values
m.count() returns the current number of observations.
m.mean() returns the simple average of the observations
m.var() returns the simple variance of the observations.
m.timeAverage() returns the time-average of the integrated y values,
===========================================================================
# Monitorplot.py
from __future__ import generators
from SimPy.Simulation import *
from SimPy.SimPlot import *
from random import uniform
class Source(Process):
def __init__(self,monitor):
Process.__init__(self)
self.moni=monitor
self.arrived=0
def arrivalGenerator(self):
while True:
yield hold,self,uniform(0,20)
self.arrived+=1
self.moni.observe(self.arrived)
initialize()
moni=Monitor(name="Arrivals",ylab="nr arrived")
s=Source(moni)
activate(s,s.arrivalGenerator())
simulate(until=100)
plt=SimPlot()
plt.plotStep(moni,color='blue',windowsize=(300,200))
plt.mainloop()
=========================
# Monitorplot.py
from __future__ import generators
from SimPy.Simulation import *
from SimPy.Monitor import *
from SimPy.SimPlot import *
from random import *
class Source(Process):
def __init__(self,monitor):
Process.__init__(self)
self.moni=monitor
self.arrived=0
def arrivalGenerator(self):
while True:
yield hold,self,uniform(0,20)
self.arrived+=1
self.moni.observe(self.arrived)
initialize()
moni=Monitor(name="Arrivals",ylab="nr arrived")
s=Source(moni)
activate(s,s.arrivalGenerator())
simulate(until=100)
plt=SimPlot()
plt.plotStep(moni,color='blue')
plt.mainloop()
=============================