def __init__(self, G=None, vis=True, anim=False, mtype='2a', ttype='random'): SimExtend.__init__(self, G, vis, anim, animDelay=0.3) #animDelay==standard value for animations self.testvar=range(30000000) self.initialize() self.stats={'plant attempts':0, 'mound attempts':0, 'remound attempts':0, 'stumps in WA':None, 'stumps in WA sum diameter':0, 'immobile boulder struck':0, 'immobile vol sum':0, 'number of dibble disr stones in mound':0, 'dibble distr stone vol cum':0, 'queue percent':0,'work percent':0, 'work time':0,'rest time':0 } if not self.G.terrain: self.G.terrain=PlantMTerrain(G=self.G, ttype=ttype) tic=time.clock() if self.G.automatic=='undefined': if mtype[0:2]=='1a': self.G.automatic={'mound': False, 'plant': True, 'automove': False, 'micrositeSelection': False, 'moveToMicro': False,'haltMound':False, 'clearForOtherHead': False} else: self.G.automatic={'mound': True, 'plant': True, 'automove': True, 'micrositeSelection': False, 'moveToMicro': False, 'haltMound':True, 'clearForOtherHead': True} #self.test=testProcess1(name='sdf', sim=self) #self.activate(self.test, self.test.run()) #self.simulate(until=5000) self.m=PlantMachine(name="planter", sim=self, G=self.G, mtype=mtype) self.activate(self.m,self.m.run()) self.simulate(until=self.G.maxtime) return None #postprocessing self.productivity=len(self.m.treesPlanted)/(self.now()/3600.) #trees/hour print "result: %d trees in %d time, productivity: %f trees/hour"%(len(self.m.treesPlanted), self.now(), self.productivity) self.setQueuePerc() print "stumps in WA sum diameter:", self.stats['stumps in WA sum diamater'] print "number of remounds", self.stats['remound attempts'] if self.p: #if we have a plotter instance self.p.terminate() plt.show() #nothing is processed in paralell with this, thus last:
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 __init__(self, G=None, vis=True, anim=False, head='BC',nCranes=2,series=None, bundler=False, twigCrack=False, observer=False): SimExtend.__init__(self,G, vis, anim, animDelay=1.2,series=series) #does some common stuff, e.g. seed #if no file to read the simulationsparameters from: setDefaultThinningParams(self.G.simParam) #sets the parameters to default values if not self.G.terrain: self.G.areaPoly=[(0,0), (25,0), (25,40), (0,40)] #default for thinning files. self.G.terrain=Terrain(G=self.G) self.G.terrain.readTrees(thinning=True) craneMax=self.G.simParam['maxCraneLength'] startPos=[random.uniform(craneMax, 25-craneMax), -4] self.m=ThinningMachine(name="thinny", sim=self, G=self.G, head=head, nCranes=nCranes,startPos=startPos, bundler=bundler,twigCrack=twigCrack) self.treeStats() #do some statistics on the trees self.activate(self.m,self.m.run()) if observer: self.o=Observer(name="obsy", sim=self, G=self.G) self.activate(self.o, self.o.run()) self.simulate(until=10000) #some simulation information: if observer: self.timeStats() """ print self.o.tstep*sum([c[1] for c in self.o.lAMoni]), 'left head active time via monitor' print self.o.tstep*sum([c[1] for c in self.o.lWBMoni]), 'left head waiting for Bundler' print self.stats['oneCraneWorkTime'], 'one crane work time' print self.stats['oneCraneWaitDriverTime'], 'one crane wait for driver time' if self.m.hasBundler: print self.stats['oneCraneWaitBundlerTime'], 'one crane wait for bundler time' if len(self.m.heads)==2: print self.o.tstep*sum([c[1] for c in self.o.rAMoni]), 'right head active time via monitor' print self.o.tstep*sum([c[1] for c in self.o.rWBMoni]), 'right head waiting for Bundler' print self.stats['twoCranesWorkTime'], 'two cranes work time' print self.stats['twoCranesWaitDriverTime'], 'two cranes wait for driver time' if self.m.hasBundler: print self.stats['twoCranesWaitBundlerTime'], 'two cranes wait for bundler time' """ self.stats['productivity']=len(self.m.trees)/self.now()*3600 self.stats['outTake']=100*len(self.m.trees)/float(len(self.G.terrain.trees)) self.stats['groundAreaRatio']=sum([t.dbh**2*pi*0.25 for t in self.m.trees])/max(1,sum([t.dbh**2*pi*0.25 for t in self.G.terrain.trees])) print "Simulation ended. Productivity: %.1f trees/hour. %.1f %% of the trees were harvested"%(len(self.m.trees)/self.now()*3600, self.stats['outTake']) print "average trees per corridor: %f average log weight in corridor: %f trees in main road: %f"%(self.avTreesPerCorr, self.avCorrTreeWeight, self.treesPerRoad) self.setQueuePerc() print self.getGeneralStatsString() if self.p: #plot self.p.terminate() if vis: plt.show()
def __init__(self, G=None, vis=True, anim=False, mtype='2a', ttype='random'): self.initialize() SimExtend.__init__(self, G, vis, anim, animDelay=0.3) #animDelay==standard value for animations if not self.G.simParam: self.G.simParam=paramsForSensAn() assert self.G.simParam self.stats={'plant attempts':0, 'mound attempts':0, 'remound attempts':0, 'stumps in WA':None, 'noStumps in WA':0,'stumps in WA sum diameter':0,'meanSurfBoulderDiamWA':0,'noSurfBouldersWA':0,'immobile boulder struck':0, 'immobile vol sum':0, 'number of dibble disr stones in mound':0, 'dibble distr stone vol cum':0, 'queue percent':0,'work percent':0, 'work time':0,'rest time':0, 'humus depths':[], 'inverting attempts':0, 'reinverting attempts':0} if not self.G.terrain: self.G.terrain=PlantMTerrain(ttype=ttype) else: if ttype!='random': raise Exception('Terrain is already specified. The input ttype is only used if G.terrain=None') self.stats['noSurfBoulders']=self.G.terrain.noSBoulders if self.stats['noSurfBoulders']==0: self.stats['meanSurfBoulderDiam']=0 else: self.stats['meanSurfBoulderDiam']=sum([2*sstone.radius for sstone in self.G.terrain.surfaceBoulders])/float(self.stats['noSurfBoulders']) #gives mean diameter print 'average surface boulder diameter in total area:',self.stats['meanSurfBoulderDiam'] if self.G.automatic=='undefined': if mtype[0:2]=='1a': self.G.automatic={'mound': False, 'plant': True, 'automove': False, 'micrositeSelection': False, 'moveToMicro': False,'haltMound':False, 'clearForOtherHead': False} else: self.G.automatic={'mound': True, 'plant': True, 'automove': True, 'micrositeSelection': False, 'moveToMicro': False, 'haltMound':True, 'clearForOtherHead': True} self.m=PlantMachine(name="planter", sim=self, G=self.G, mtype=mtype) self.activate(self.m,self.m.run()) self.simulate(until=self.G.maxtime) #postprocessing self.productivity=len(self.m.treesPlanted)/(self.now()/3600.) #trees/hour print "result: %d trees in %d time, productivity: %f trees/hour"%(len(self.m.treesPlanted), self.now(), self.productivity) self.setQueuePerc() print "stumps in WA sum diameter:", self.stats['stumps in WA sum diameter'] print 'Mean diameter of surfaceboulders in WA',self.stats['meanSurfBoulderDiamWA'] print 'Number of SurfaceBoulders in WA',self.stats['noSurfBouldersWA'] print "time to search for microsite", self.m.timeConsumption['searchTime'] print "number of remounds", self.stats['remound attempts'] if self.p: #if we have a plotter instance self.p.terminate() plt.show() #nothing is processed in parallell with this, thus last: