(self,stringLength,fitnessFunction,nEpochs,populationSize=100,mutationProb=-1,crossover='un',nElite=4,tournament=True)
Constructor
Constructor
Constructor
def __init__(self,stringLength,fitnessFunction,nEpochs,populationSize=100,mutationProb=-1,crossover='un',nElite=4,tournament=True):
		""" Constructor"""
		self.stringLength = stringLength
		
		# Population size should be even
		if np.mod(populationSize,2)==0:
			self.populationSize = populationSize
		else:
			self.populationSize = populationSize+1
		
		if mutationProb < 0:
			 self.mutationProb = 1/stringLength
		else:
			 self.mutationProb = mutationProb
			 	  
		self.nEpochs = nEpochs

		self.fitnessFunction = fitnessFunction

		self.crossover = crossover
		self.nElite = nElite
		self.tournment = tournament

		self.population = np.random.rand(self.populationSize,self.stringLength)
		self.population = np.where(self.population<0.5,0,1)
def __init__ ( self , stringLength , fitnessFunction , nEpochs , populationSize = 100 , mutationProb = - 1 , crossover = 'un' , nElite = 4 , tournament = True ) : self . stringLength = stringLength # Population size should be even if np . mod ( populationSize , 2 ) == 0 : self . populationSize = populationSize else : self . populationSize = populationSize + 1 if mutationProb < 0 : self . mutationProb = 1 / stringLength else : self . mutationProb = mutationProb self . nEpochs = nEpochs self . fitnessFunction = fitnessFunction self . crossover = crossover self . nElite = nElite self . tournment = tournament self . population = np . random . rand ( self . populationSize , self . stringLength ) self . population = np . where ( self . population < 0.5 , 0 , 1 )