コード例 #1
0
		chemFolderPath = os.path.join(folderName, chemFolder)
		if not os.path.isdir(chemFolderPath):
			try:
				os.mkdir(chemFolderPath)
			except:
				print "Impossible to create statistic directory", chemFolderPath; sys.exit(1)	
		
		# CREATE ARTIFICIAL CHEMISTRY
		# Create foodlist
		foodList = range(int(2**(args.lastFood+1)-2))
		# Create species List
		speciesList = sp.createCompleteSpeciesPopulation(args.maxDim, parameters[14])
		originalSpeciesList = deepcopy(speciesList)
		# Crate chemist
		# compute population cardinality
		totSpecies = sp.getTotNumberOfSpeciesFromCompletePop(args.maxDim)
		
		# Compute overall conceivable number of reactions
		totCleavage = reactions.getNumOfCleavages(originalSpeciesList)
		
		# Compute the number of reactions according to the chemistry type adopted
		if args.creationMethod == 1: totCond = reactions.getNumOfCondensations(totSpecies)
		else: totCond = 0
		totRcts = totCleavage + totCond
		
		# If the reaction probability is 0, it is set to the critical value of 1 reaction per species on average
		if parameters[21] == 0: prob = (1 / float(totRcts)) * args.avgCon
		else: prob = parameters[21]
		rctToCat = int(round(totSpecies * args.avgCon))

		# Create chemistry 
コード例 #2
0
			timeAnalysisVector = []
			for instanceID, instance in enumerate((range(iterations))): # FOR EACH ITERATION
				
				# Flush standard output
				sys.stdout.flush()
				
				nCleavage = 0
				nCondensa = 0
				
				# Create the complete population of species according to the Max Length and the alphabet
				alphabet = ['A', 'B']
				speciesList = sp.createCompleteSpeciesPopulation(maxlength, alphabet)
				originalSpeciesList = deepcopy(speciesList)
				
				# compute population carinality
				totSpecies = sp.getTotNumberOfSpeciesFromCompletePop(maxlength)
				
				# Compute overall conceivable number of reactions
				totCleavage = reactions.getNumOfCleavages(speciesList)
				
				if (args.creationMethod == 1) | (args.creationMethod == 4): totCond = reactions.getNumOfCondensations(totSpecies)
				else: totCond = 0
				totRcts = totCleavage + totCond
				
				# If the reaction probability is 0, it is set to the critical value of 1 reaction per species on average
				prob = (1 / float(totRcts)) * averageConn
				
				
				if instanceID == 0: print '|- Max Length: ', maxlength, ' - AVG CON: ', averageConn, ' - Species: ', \
									totSpecies, '- Reactions: ', totRcts, ' <- Condensations: ', totCond, ' - Cleavage: ', totCleavage
				# Compute reactions to catalyse according to the probability