diff --git a/TP2/selectionMethods/boltzmannSelection.py b/TP2/selectionMethods/boltzmannSelection.py index 093ad17..573f02b 100644 --- a/TP2/selectionMethods/boltzmannSelection.py +++ b/TP2/selectionMethods/boltzmannSelection.py @@ -9,7 +9,6 @@ def __init__(self , T0 , Tc , k): self.initialT = T0 self.finalT = Tc self.k = k - print("Corre Boltzmann") #Funcion de temperatura dada en clase @@ -17,13 +16,11 @@ def __temperature(self): return self.finalT + (self.initialT - self.finalT) * np.exp( - self.k * self.generation ) def apply(self,selectionIndividuals,targetPopulationSize,replacement=False): - # print(self.__temperature()) valuedIndividuals = [] total = 0 #Por cada individuo calculo su valor (el dividendo de la probabilidad) for individual in selectionIndividuals: value = np.exp(individual.fitness / self.__temperature()) - #print("fitness: " + str(individual.fitness) + "value: " + str(value) ) total += value valuedIndividuals.append((value, individual)) @@ -34,9 +31,7 @@ def apply(self,selectionIndividuals,targetPopulationSize,replacement=False): for valuedIndividual in valuedIndividuals: acumulated+= valuedIndividual[0] / total promediatedIndividuals.append((acumulated , valuedIndividual[1])) - # print("fitness: " + str(valuedIndividual[1].fitness) + "value: " + str(acumulated) ) - - #print("total: " + str(valueAcum) ) + selectedPopulation = [] #tiro la ruleta for i in range(0 , targetPopulationSize): diff --git a/TP2/selectionMethods/eliteSelection.py b/TP2/selectionMethods/eliteSelection.py index d45d185..f530bd1 100644 --- a/TP2/selectionMethods/eliteSelection.py +++ b/TP2/selectionMethods/eliteSelection.py @@ -1,6 +1,4 @@ class EliteSelection: - def __init__(self): - print("Hola TOR") def apply(self,selectionIndividuals,targetPopulationSize,replacement=False): #Ordenamos la poblacion por mayor fitness, y retornamos los primeros "targetPopulationSize" diff --git a/TP2/selectionMethods/rankSelection.py b/TP2/selectionMethods/rankSelection.py index e781cf5..57c003f 100644 --- a/TP2/selectionMethods/rankSelection.py +++ b/TP2/selectionMethods/rankSelection.py @@ -4,9 +4,6 @@ class RankSelection: - def __init__(self): - print("Corre rank") - def apply(self,selectionIndividuals,targetPopulationSize,replacement=False): #Ordenamos los individuos por fitness rankedIndividuals = sorted(selectionIndividuals,key=lambda x: x.fitness,reverse=True) diff --git a/TP2/selectionMethods/rouletteSelection.py b/TP2/selectionMethods/rouletteSelection.py index 66561f3..43572cc 100644 --- a/TP2/selectionMethods/rouletteSelection.py +++ b/TP2/selectionMethods/rouletteSelection.py @@ -4,9 +4,6 @@ class RouletteSelection: - def __init__(self): - print("Corre roulette") - def apply(self,selectionIndividuals,targetPopulationSize,replacement=False): #Sacamos el fitness total #return random.choices(selectionIndividuals , weights=[x.fitness for x in selectionIndividuals] , k=targetPopulationSize )