Пример #1
0
	def __init__(self,i=10):
		SimSeries.__init__(self,G=None)
		if not self.G.areaPoly:
			G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
		self.G.terrain=Terrain(G=self.G)
		fileheader="i\tcranehead\tprod\ttreefile\tnCorr\tlogsPerCorr\tlogsInMainRoad\tCorrCumLogW\t"
		self._saveToFile(fileheader)
		self._saveToFile("####")
		j=0
		for head in ['BC', 'conv']:
			for tFile in self.G.terrain.thinningFiles:
				for it in range(i):
					G=copy.deepcopy(self.G)
					G.terrain.treeFile=tFile
					G.terrain.readTrees()
					s=self._singleSim(G,nCranes=2, head=head)
					p=s.stats['productivity']
					self._saveToFile("%d\t"%j+head+'\t'+'%.6f\t'%p+str(tFile)+'\t'+str(s.cNum)+'\t'+'%.6f'%s.avTreesPerCorr+'\t'+str(s.treesPerRoad)+'\t'+'%.6f'%s.avCorrTreeWeight)
					j+=1
		self.f.close()
Пример #2
0
	def __init__(self, G):
		SimSeries.__init__(self,G)
		self.reset()
Пример #3
0
	def __init__(self, it=1, G=None):
		SimSeries.__init__(self,G)
		if not G:
			self.G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
			self.G.terrain=Terrain(G=self.G)
		fileheader="i\tcranes\t\tcranehead\t\tProd\tQueuePerc\tWorkPerc\tChopPerc\tgroundAratio\tAmove\tAmoveArmin\tAmoveArmOut\tAdumptrees\tAchop"
		a1={'move': False, 'moveArmIn': False, 'moveArmOut': False, 'dumpTrees': False, 'switchFocus': False, 'chop':False}
		a2={'move': False, 'moveArmIn': True, 'moveArmOut': False, 'dumpTrees': False, 'switchFocus': False, 'chop':False}
		a3={'move': False, 'moveArmIn': True, 'moveArmOut': False, 'dumpTrees': True, 'switchFocus': False, 'chop':False}
	   	a4={'move': False, 'moveArmIn': True, 'moveArmOut': True, 'dumpTrees': True, 'switchFocus': False, 'chop':False}
		a5={'move': False, 'moveArmIn': True, 'moveArmOut': True, 'dumpTrees': True, 'switchFocus': False, 'chop':True}
		outpfolder='outputFiles/'+self.__class__.__name__+string.join([string.strip(a) for a in string.split(time.ctime(time.time()))], "_")
		summary={'1a':{}, '2a':{}}			
		for head in ['BC', 'conv']: #just take the regular 1-arm cases first..
			p=np.array([])
			q=np.array([])
			w=np.array([])
			sims=np.array([])
			outT=np.array([])
			stds=[]
			mean=0
			std=0
			meanStd=10000
			for tFile in self.G.terrain.thinningFiles:
				self.outpfolder=outpfolder+'/'+str(tFile)+'/'
				self.filename=self.outpfolder+'/'+'1a'+head+".txt"
				for i in range(it):
					G=copy.deepcopy(self.G)
					G.automatic=a1
					G.terrain.treeFile=tFile
					G.terrain.readTrees()
					s=self._singleSim(G,nCranes=1, head=head)
					if i==0: #first
 						generalInfo=s.getGeneralStatsString() #general statistics
						self._saveToFile(generalInfo)						
						self._saveToFile(fileheader)
						self._saveToFile("####") #indicates that the data starts here.
					sims=np.append(sims,s)
					p=np.append(p, s.stats['productivity'])
					w=np.append(w, s.stats['work percent'])
					q=np.append(q, s.queuePerc)
					outT=np.append(outT, s.stats['outTake'])
					a=a1 #just to have some values for the automatic tasks...
					self._saveToFile(str(i+1)+'\t1\t'+head+
							 '\t%.4f'%s.stats['productivity']+
							 '\t'+'%0.4f'%s.queuePerc+
							 '\t'+'%0.4f'%s.stats['work percent']+
							 '\t'+'%0.4f'%s.stats['outTake']+
							 '\t'+str(a['move'])+
							 '\t'+str(a['moveArmIn'])+
							 '\t'+str(a['moveArmOut'])+
							 '\t'+ str(a['dumpTrees'])+
							 '\t'+str(a['chop']))
				self.f.close()
				self.f=None
			summary['1a'][head]={}
			summary['1a'][head]['A']={'sims':sims, 'p':p, 'w':w, 'q':q, 'outT':outT}
		#2a:
		autolist=[a1, a2, a3, a4, a5]
		astr=['A','B','C','D','E']
		for head in ['BC', 'conv']:
			summary['2a'][head]={}
			for index,a in enumerate(autolist):
				autoStr=astr[index]
				sims=np.array([])
				means=[]
				stds=[]
				p=np.array([])
				q=np.array([])
				w=np.array([])
				outT=np.array([])
				mean=0
				meanStd=10000
				for tFile in self.G.terrain.thinningFiles:
					self.outpfolder=outpfolder+'/'+str(tFile)+'/'
					self.filename=self.outpfolder+'2a'+head+"_"+autoStr+".txt"
					for i in range(it):
						G=copy.deepcopy(self.G)
						G.automatic=a
						G.terrain.treeFile=tFile
						G.terrain.readTrees()
						s=self._singleSim(G,nCranes=2, head=head) #G is copied later, so does not affect G
						if i==0: #first
							generalInfo=s.getGeneralStatsString() #general statistics
							self._saveToFile(generalInfo)						
							self._saveToFile(fileheader)
							self._saveToFile("####") #indicates that the data starts here.
						sims=np.append(sims, s)
 						p=np.append(p, s.stats['productivity'])
						q=np.append(q, s.queuePerc)
						w=np.append(w, s.stats['work percent'])
						outT=np.append(outT, s.stats['outTake'])
						self._saveToFile(str(i+1)+'\t1\t'+head+
							 '\t'+'%.4f'%s.stats['productivity']+
							 '\t'+'%0.4f'%s.queuePerc+
							 '\t'+'%0.4f'%s.stats['work percent']+
							 '\t'+'%0.4f'%s.stats['outTake']+
							 '\t'+'%0.4f'%s.stats['groundAreaRatio']+
							 '\t'+str(a['move'])+
							 '\t'+str(a['moveArmIn'])+
							 '\t'+str(a['moveArmOut'])+
							 '\t'+str(a['dumpTrees'])+
							 '\t'+str(a['chop']))
					self.f.close()
					self.f=None
					print "No of sims: %d"%(len(sims))
				summary['2a'][head][autoStr]={}
				summary['2a'][head][autoStr]['sims']=sims
				summary['2a'][head][autoStr]['p']=p
				summary['2a'][head][autoStr]['w']=w
				summary['2a'][head][autoStr]['q']=q
				summary['2a'][head][autoStr]['outT']=outT
		#print the summary.
		self.outpfolder=outpfolder
		self.filename=outpfolder+'/'+'summary.txt'
		fileheader="iter\tcranes\thead\tmeanprod\tstdOfmeanProd\tmeanQueue\tstdMeanQueue\tmeanWorkPerc.\tstdMeanW\tmeanOutT\tstdMeanOutT\tAmove\tAmoveArmin\tAmoveArmOut\tAdumptrees\tAchop"
		self._saveToFile(fileheader)
		self._saveToFile("####") #indicates that the data starts here.
		for head in ['BC', 'conv']:
			for arms in [1, 2]:
				if arms==1: aList=['A']
				else: aList=astr
				for a in aList:
					d=summary[str(arms)+'a'][head][a] #the saved data (in a dictionary)..
					auto=d['sims'][0].m.automatic
					self._saveToFile(
						str(i+1)+'\t'+
						str(arms)+'\t'+
						head+'\t'+
						'%0.4f'%np.mean(d['p'])+'\t'+
						'%0.4f'%(np.std(d['p'])/sqrt(len(d['p'])))+'\t'+
						'%0.4f'%np.mean(d['q'])+'\t'+
						'%0.4f'%(np.std(d['q'])/sqrt(len(d['q'])))+'\t'+
						'%0.4f'%np.mean(d['w'])+'\t'+
						'%0.4f'%(np.std(d['w'])/sqrt(len(d['w'])))+'\t'+
						'%0.4f'%np.mean(d['outT'])+'\t'+
						'%0.4f'%(np.std(d['outT'])/sqrt(len(d['outT'])))+'\t'+
					   	str(auto['move'])+'\t'+
						str(auto['moveArmIn'])+'\t'+
						str(auto['moveArmOut'])+'\t'+
						str(auto['dumpTrees'])+'\t'+
						str(auto['chop']))
		self.f.close()