From 99d083c4773592bced2f87a4db866243de60b280 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 2 Dec 2018 23:30:06 -0300 Subject: [PATCH] deleted unused libraries and changed order of variables and methods for better clarity --- GeneticAlgorithm.py | 3 --- README.md | 1 - __pycache__/GeneticAlgorithm.cpython-36.pyc | Bin 3124 -> 3124 bytes best_path_finder.py | 1 - bit_sequence_finder.py | 5 +---- 5 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 README.md diff --git a/GeneticAlgorithm.py b/GeneticAlgorithm.py index f128b36..884b51e 100644 --- a/GeneticAlgorithm.py +++ b/GeneticAlgorithm.py @@ -32,8 +32,6 @@ def __init__(self,mutationRate, populationSize, fitnessFunction, numberOfGenes, self.k = populationSize//2 - - def startAlgorithm(self): self.popCreation() while True: @@ -45,7 +43,6 @@ def startAlgorithm(self): self.best = self.population[self.popFitness.index(max(self.popFitness))] if self.stopCondition(self): - break self.reproduction() self.numberOfGenerations+=1 diff --git a/README.md b/README.md deleted file mode 100644 index 45875af..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -genetic_algorithm diff --git a/__pycache__/GeneticAlgorithm.cpython-36.pyc b/__pycache__/GeneticAlgorithm.cpython-36.pyc index e3081aa1d77d3a721b2aedaa79a60a6b94884913..900d469f0dcd1410b02c02b4916a9dc1146d7022 100644 GIT binary patch delta 103 zcmdlYu|pw6DEJ;y28xO!9V!~ GcMbqCeHl&w delta 103 zcmdlYu|pwlP7=Vy28xMAu#y_ GcMbp)ycrPy diff --git a/best_path_finder.py b/best_path_finder.py index 0beec6d..06bc000 100644 --- a/best_path_finder.py +++ b/best_path_finder.py @@ -63,7 +63,6 @@ def stopCondition(algorithmInstance): ga.startAlgorithm() end = time.time() print("time elapsed: "+str(end - start)) -print(ga.best) plt.figure(1) plt.plot(ga.generation, ga.bestFitness) plt.xlabel('Generation') diff --git a/bit_sequence_finder.py b/bit_sequence_finder.py index 77b0ffa..44e3fc1 100644 --- a/bit_sequence_finder.py +++ b/bit_sequence_finder.py @@ -5,16 +5,12 @@ """ -import numpy as np -from random import randint -from random import random from GeneticAlgorithm import GeneticAlgorithm import time import matplotlib.pyplot as plt bitSequence="01011111100101011001010010101" -geneValues=["0","1"] #hiperparameters mutationRate = 0.05 @@ -24,6 +20,7 @@ #stopCondition Parameters maxGenerations=100 +geneValues=["0","1"] def fitnessFunction(individual): total=0 for i in range(len(individual)):