コード例 #1
0
ファイル: forwSim.py プロジェクト: fiskpralin/pibsgraph
	def __init__(self, G=None, vis=True, anim=False):
		SimExtend.__init__(self,G, vis=vis, anim=anim, animDelay=5) #does some common stuff, i.e seed
		if not self.G.terrain:
			self.G.terrain=setUpTerrain(self.G)
		h=Harvester(self.G) #does all the harvester stuffi n the constructor.
		self.trees=0 #total number of picked up trees
		self.m=Forwarder(name="forwy", sim=self, G=self.G)
		self.activate(self.m,self.m.run())
		self.simulate(until=1000000)
		if self.p:
			self.p.terminate()
			#postprocessing
			plt.show()
		print "simulation is done."
コード例 #2
0
ファイル: forwSim.py プロジェクト: fiskpralin/pibsgraph
class ForwarderSim(SimExtend):
	"""
	class for a single simulation with a 1a or 2a plantmachine
	"""
	def __init__(self, G=None, vis=True, anim=False):
		SimExtend.__init__(self,G, vis=vis, anim=anim, animDelay=5) #does some common stuff, i.e seed
		if not self.G.terrain:
			self.G.terrain=setUpTerrain(self.G)
		h=Harvester(self.G) #does all the harvester stuffi n the constructor.
		self.trees=0 #total number of picked up trees
		self.m=Forwarder(name="forwy", sim=self, G=self.G)
		self.activate(self.m,self.m.run())
		self.simulate(until=1000000)
		if self.p:
			self.p.terminate()
			#postprocessing
			plt.show()
		print "simulation is done."
	def plotMoni(self, ax, number):
		"""
		defines the monitors that should be plotted.
		"""
		if number==1: #plot driver activity
			moni=self.m.totalTreeMoni
			if len(moni)>0:
				ax.plot(moni.tseries(),moni.yseries(), drawstyle='steps-post')
				ax.axis([-0.1, self.now(), -0.1, (max(moni.yseries())+1)])
				ax.grid(True)
				ax.set_xlabel('time(s)')
				ax.set_ylabel('trees picked up')
		elif number==2: #plot trees planted
			moni=self.m.distMoni
			if len(moni)>0:
				ax.plot(moni.tseries(),moni.yseries(), drawstyle='steps-post')
				ax.axis([-0.1, self.now(), -0.1, (max(moni.yseries())+1)])
				ax.grid(True)
				ax.set_xlabel('time(s)')
				ax.set_ylabel('dist. traveled (m)')
		elif number==3:
			#create a new axis..
			plt.delaxes(ax)
			ax=self.p.fig.add_subplot(326, aspect='equal', axisbg='#A2CD5A')
			lim=self.m.pos[0]-15, self.m.pos[0]+15, self.m.pos[1]-15, self.m.pos[1]+15
			self.p.update_world(ax,lim)
		return ax