Beispiel #1
0
def simRandomRoad(G=None,vis=True, anim=False):
	"""
	Generates a random road, and simulates the forwarder on it.
	"""
	if not G: G=globalVar()
	if not G.areaPoly: G.areaPoly=[(0.0,0.0), (100.0, 0.0), (100.0,100.0), (180, 180), (100, 170),(-100,100.0)]
	if not G.roadNet: G.roadNet=ga.construct.makeRoadGraph(L=24,ulim=(0,1),angle=0.2, areaPoly=G.areaPoly, grid='square')
	for e in G.roadNet.edges(data=True):
		e[2]['r']=Road(endPoints=e[0:2]) #road instance, that can be used in simulations.
	ForwarderSim(G, vis, anim)
Beispiel #2
0
def createThinningMovies():
	G=globalVar()
	G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
	G.terrain=Terrain()
	G.terrain.readTrees('terrainFiles/thinning/GA-210.DAT') #the best treefile
	ThinningSim(G=G,vis=False, anim=True, head='BC', nCranes=2)
	try:
		os.rename('animation.mpg', 'BC2arm.mpg')
	except: pass
	ThinningSim(G=G,vis=False, anim=True, head='BC', nCranes=1)
	try:
		os.rename('animation.mpg', 'BC1arm.mpg')
	except: pass
	ThinningSim(G=G,vis=False, anim=True, head='conv', nCranes=1)
	try:
		os.rename('animation.mpg', 'conventionalHead.mpg')
	except: pass
Beispiel #3
0
		elif sys.argv[1]=='varyAll':
			PM.varyAll(iterations)
		elif sys.argv[1]=='tDCTM':#tryDiffConfigThinningMachine
			TH.tryDiffConfigThinningMachine(it=100)
		elif sys.argv[1]=='btDCTM':#bashtryDiffConfigThinningMachine
			TH.bashTryDiffConfigThinningMachine(it=iterations, head=head, nCranes=nCranes, bundler=bundler, twigCrack=twigCrack, simNumber=simNumber, rowNumber=rowNumber, treeFile=treeFile)
		else:
			raise Exception('could not read input argument %s'%str(sys.argv[1]))
		
	else:
		import cProfile
		from sim.planting.plantMTerrain import PlantMTerrain
		seed=int(random.uniform(0,100000))
		#seed=35342
		random.seed(seed)
		print "seed2:", seed
		G=tools.globalVar()
		G.noMonitors=True
		G.seed=seed
		#G.terrain=PlantMTerrain(G, ttype='0')
	   	#s=PM.PlantmSim(vis=True,anim=anim,G=G, mtype='2a4h')
		#TH.ThinningSim(vis=True,anim=anim,G=G, head='BC', nCranes=2)
		#G.terrain=PlantMTerrain(G, ttype='5')
		G.plotDelay=10
	   	#s=PM.PlantmSim(vis=True,anim=anim,G=G, mtype='2a4h')
		TH.ThinningSim(vis=True,anim=anim,G=G, head='BC', nCranes=2, bundler=False, twigCrack=True, observer=True)
		#FW.ForwarderSim(vis=True, anim=anim, G=G)
		#FW.simRandomRoad(vis=True, anim=anim, G=G)
		#cProfile.run('FW.ForwarderSim(vis=True, anim=anim, G=G)')
		#cProfile.run('''PM.PlantmSim(vis=False,G=G,anim=anim, mtype='2a2h', ttype=4)''')
Beispiel #4
0
	def __init__(self,it=1, head='BC', nCranes=1, bundler=False, twigCrack=False, simNumber=1, rowNumber=1, treeFile=210):
		if bundler==1: bundler=False
		elif bundler==2: bundler=True
		else: raise Exception('bundler should be 1 or 2 from bash')
		if twigCrack==1: twigCrack=False
		elif twigCrack==2: twigCrack=True
		else: raise Exception('twigCrack should be 1 or 2 from bash')
		self.G=globalVar()
		#self.G.plotDelay=500 #for debug only
		self.G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
		self.G.terrain=Terrain(G=self.G)
		self.folder='outputFiles/NewThinning_2012'
		today=datetime.date.today()
		self.filename=self.folder+'/'+'ThinningWawoBundler.xls'
		e=ExcelOutput(template='outputFiles/NewThinning_2012/ThinningWawoBundler.xls', out=self.filename)
		self.Paramrow=rowNumber

		self.G.terrain.treeFile=treeFile
		self.G.terrain.readTrees()
		G=copy.deepcopy(self.G)
		self.s=ThinningSim(G=G, vis=False, anim=False, head=head, nCranes=nCranes, bundler=bundler, twigCrack=twigCrack, observer=True)						
		self.s.stats['machineConfig']=self.getConfig(head,nCranes,twigCrack,bundler)
		self.s.stats['simNumber']=simNumber
		self.s.stats['treeFile']=treeFile
		self.s.stats['noHarvTrees']=sum([len(b.trees) for b in G.terrain.piles])
		self.s.stats['noCraneCycles']=sum([pb.craneCycles for pb in G.terrain.piles])
		self.s.stats['harvBiomass']=sum([b.weight for b in self.s.m.trees]) #total mass of the trees that were harvested, before tc?
		self.s.stats['harvStemMass']=sum([t.logWeight for t in self.s.m.trees])# total weight of the stems of the trees that are harvested. Not what's in the bundles or piles, but rather what was in terrain before chop.
		self.s.stats['harvStemVol']=sum([t.vol for t in self.s.m.trees])# total volume of the stems of the trees that are harvested. Not what's in the bundles or piles
		self.s.stats['noBundlesOrPiles']=len(G.terrain.piles)
		self.s.stats['minBunPileMass']=min([b.biomass for b in G.terrain.piles])
		self.s.stats['maxBunPileMass']=max([b.biomass for b in G.terrain.piles])
		self.s.stats['totBunPileMass']=sum([b.biomass for b in G.terrain.piles])
		self.s.stats['minBunPileVol']=min([self.getVol(b) for b in G.terrain.piles])
		self.s.stats['maxBunPileVol']=max([self.getVol(b) for b in G.terrain.piles])
		self.s.stats['totBunPileVol']=sum([self.getVol(b) for b in G.terrain.piles])
		self.s.stats['noMainStops']=len(self.s.m.positions)-1 #Here I assume what is meant is number of stops on the mainroad for harvesting.
		self.s.stats['totTimeConsumed']=self.s.now()
		if bundler==True:
			#self.s.stats['bundlingTime']=self.o.tstep*sum([c[1] for c in self.o.bundlerActiveMoni]) could be used instead, but does not give exact result as expected. Deviates by some 5%
			self.s.stats['bundlingTime']=self.s.stats['noBundlesOrPiles']*self.s.m.bundler.timeBundle
		else: self.s.stats['bundlingTime']=0
		self.s.stats['work time']#operator active time
		print self.s.stats['noBundlesOrPiles'], 'piles or bundles'
		print self.s.stats['noCraneCycles'], 'was the number of crane cycles'
		print self.s.stats['bundlingTime'], self.s.stats['totTimeConsumed']
		print '---------------------------------------------------------------------'
		
		"""This part here writes the data to the excel file"""
		e.modify(self.Paramrow,0,self.s.stats['machineConfig'])
		e.modify(self.Paramrow,1,self.s.stats['treeFile'])
		e.modify(self.Paramrow,2,self.s.stats['simNumber'])
		e.modify(self.Paramrow,3,self.s.stats['noHarvTrees'])
		e.modify(self.Paramrow,4,self.s.stats['noCraneCycles'])
		e.modify(self.Paramrow,5,self.s.stats['harvBiomass'])
		e.modify(self.Paramrow,6,self.s.stats['harvStemMass'])
		e.modify(self.Paramrow,7,self.s.stats['harvStemVol'])
		e.modify(self.Paramrow,8,self.s.stats['noBundlesOrPiles'])
		e.modify(self.Paramrow,9,self.s.stats['minBunPileMass'])#
		e.modify(self.Paramrow,10,self.s.stats['maxBunPileMass'])
		e.modify(self.Paramrow,11,self.s.stats['totBunPileMass'])
		e.modify(self.Paramrow,12,self.s.stats['minBunPileVol'])
		e.modify(self.Paramrow,13,self.s.stats['maxBunPileVol'])
		e.modify(self.Paramrow,14,self.s.stats['totBunPileVol'])
		e.modify(self.Paramrow,15,self.s.stats['noMainStops'])
		e.modify(self.Paramrow,16,self.s.stats['totTimeConsumed'])
		e.modify(self.Paramrow,17,self.s.stats['bundlingTime'])
		e.modify(self.Paramrow,18,self.s.stats['work time'])
		e.modify(self.Paramrow,19,self.s.stats['oneCraneWorkTime'])
		e.modify(self.Paramrow,20,self.s.stats['twoCranesWorkTime'])
		e.modify(self.Paramrow,21,self.s.stats['oneCraneWaitDriverTime'])
		e.modify(self.Paramrow,22,self.s.stats['twoCranesWaitDriverTime'])
		e.modify(self.Paramrow,23,self.s.stats['oneCraneWaitBundlerTime'])
		e.modify(self.Paramrow,24,self.s.stats['twoCranesWaitBundlerTime'])
		e.modify(self.Paramrow,25,self.s.stats['noCraneWaitings'])
		e.modify(self.Paramrow,26,self.s.stats['noCraneWaitingsTwo'])
		e.save()#To be sure to save after each simulation, if something should go wrong
Beispiel #5
0
	def __init__(self,it=1):
		self.G=globalVar()
		self.G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
		self.G.terrain=Terrain(G=self.G)
		self.folder='outputFiles/NewThinning_2012'
		today=datetime.date.today()
		self.filename=self.folder+'/'+'ThinningWawoBundler_'+'%s'%(string.join([string.strip(a) for a in string.split(time.ctime(time.time()))], "_"))+'.xls'
		e=ExcelOutput(template='sim/thinning/template.xls', out=self.filename)
		self.Paramrow=1
		for treeFile in self.G.terrain.thinningFiles:
			self.G.terrain.treeFile=treeFile
			self.G.terrain.readTrees()
			
			for head in ['BC','convAcc']:
				for nCranes in [1,2]:
					for bundler in [False, True]:
						for twigCrack in [False, True]:
							for simNumber in range(1,it+1):
								G=copy.deepcopy(self.G)
								self.s=ThinningSim(G=G, vis=False, anim=False, head=head, nCranes=nCranes, bundler=bundler, twigCrack=twigCrack, observer=True)
								self.s.stats['machineConfig']=self.getConfig(head,nCranes,twigCrack,bundler)
								self.s.stats['simNumber']=simNumber
								self.s.stats['treeFile']=treeFile
								self.s.stats['noHarvTrees']=sum([len(b.trees) for b in G.terrain.piles])
								self.s.stats['noCraneCycles']=sum([pb.craneCycles for pb in G.terrain.piles])
								self.s.stats['harvBiomass']=sum([b.weight for b in self.s.m.trees]) #total mass of the trees that were harvested, before tc?
								self.s.stats['harvStemMass']=sum([t.logWeight for t in self.s.m.trees])#total weight of the stems of the trees that are harvested. Not what's in the bundles or piles, but rather what was in terrain before chop.
								self.s.stats['harvStemVol']=sum([t.vol for t in self.s.m.trees])# total volume of the stems of the trees that are harvested. Not what's in the bundles or piles
								self.s.stats['noBundlesOrPiles']=len(G.terrain.piles)
								self.s.stats['minBunPileMass']=min([b.biomass for b in G.terrain.piles])
								self.s.stats['maxBunPileMass']=max([b.biomass for b in G.terrain.piles])
								self.s.stats['totBunPileMass']=sum([b.biomass for b in G.terrain.piles])
								self.s.stats['minBunPileVol']=min([self.getVol(b) for b in G.terrain.piles])
								self.s.stats['maxBunPileVol']=max([self.getVol(b) for b in G.terrain.piles])
								self.s.stats['totBunPileVol']=sum([self.getVol(b) for b in G.terrain.piles])
								self.s.stats['noMainStops']=len(self.s.m.positions)-1 #Here I assume what is meant is number of stops on the mainroad for harvesting. Not number of places with piles close by. Is this a good assumption. Gives seven all the time.. should be len(self.s.m.positions)-1 maybe?
								self.s.stats['totTimeConsumed']=self.s.now()
								if bundler==True:
									#self.s.stats['bundlingTime']=self.o.tstep*sum([c[1] for c in self.o.bundlerActiveMoni]) can be used instead, but does not give exact result as expected.see below
									self.s.stats['bundlingTime']=self.s.stats['noBundlesOrPiles']*self.s.m.bundler.timeBundle
								else: self.s.stats['bundlingTime']=0
								self.s.stats['work time']#operator active time
								print self.s.stats['noBundlesOrPiles'], 'piles or bundles'
								print self.s.stats['noCraneCycles'], 'was the number of crane cycles'
								print self.s.stats['bundlingTime'], self.s.stats['totTimeConsumed']
								print '---------------------------------------------------------------------'
								
								"""This part here writes the data to the excel file"""
								e.modify(self.Paramrow,0,self.s.stats['machineConfig'])
								e.modify(self.Paramrow,1,self.s.stats['treeFile'])
								e.modify(self.Paramrow,2,self.s.stats['simNumber'])
								e.modify(self.Paramrow,3,self.s.stats['noHarvTrees'])
								e.modify(self.Paramrow,4,self.s.stats['noCraneCycles'])
								e.modify(self.Paramrow,5,self.s.stats['harvBiomass'])
								e.modify(self.Paramrow,6,self.s.stats['harvStemMass'])
								e.modify(self.Paramrow,7,self.s.stats['harvStemVol'])
								e.modify(self.Paramrow,8,self.s.stats['noBundlesOrPiles'])
								e.modify(self.Paramrow,9,self.s.stats['minBunPileMass'])#
								e.modify(self.Paramrow,10,self.s.stats['maxBunPileMass'])
								e.modify(self.Paramrow,11,self.s.stats['totBunPileMass'])
								e.modify(self.Paramrow,12,self.s.stats['minBunPileVol'])
								e.modify(self.Paramrow,13,self.s.stats['maxBunPileVol'])
								e.modify(self.Paramrow,14,self.s.stats['totBunPileVol'])
								e.modify(self.Paramrow,15,self.s.stats['noMainStops'])
								e.modify(self.Paramrow,16,self.s.stats['totTimeConsumed'])
								e.modify(self.Paramrow,17,self.s.stats['bundlingTime'])
								e.modify(self.Paramrow,18,self.s.stats['work time'])
								e.modify(self.Paramrow,19,self.s.stats['oneCraneWorkTime'])
								e.modify(self.Paramrow,20,self.s.stats['twoCranesWorkTime'])
								e.modify(self.Paramrow,21,self.s.stats['oneCraneWaitDriverTime'])
								e.modify(self.Paramrow,22,self.s.stats['twoCranesWaitDriverTime'])
								e.modify(self.Paramrow,23,self.s.stats['oneCraneWaitBundlerTime'])
								e.modify(self.Paramrow,24,self.s.stats['twoCranesWaitBundlerTime'])
								e.modify(self.Paramrow,25,self.s.stats['noCraneWaitings'])
								e.modify(self.Paramrow,26,self.s.stats['noCraneWaitingsTwo'])
								self.Paramrow+=1
								e.save()#To be sure to save after each simulation, if something should go wrong
		print 'Congratulations, all your simulations has been run and the data has successfully been stored in the excel-file named ThinningWawoBundler_date and time.xls, to be found in tota/outputFiles/NewThinning_2012.'