Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Fixes #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions geneticAlgo/crossover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ def breed(chromosome1, chromosome2):
k = random.random()
# print (k)
if(k>=0.5):
temp = chromosome1[i]
chromosome1[i] = chromosome2[i]
chromosome2[i] = temp
chromosome1[i], chromosome2[i] = chromosome2[i], chromosome1[i]


def crossover( matingPool, origChromosomes, noOfElite):
Expand Down
4 changes: 1 addition & 3 deletions geneticAlgo/genetic_algo_initial_popu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ def createInitialPopu(maxDishes, initialPopuSize):

initialPopuSize -> Size of initial population pool
"""
population = []
for i in range(1, initialPopuSize+1):
population.append(createChromosome(maxDishes))
population = [createChromosome(maxDishes) for i in range(initialPopuSize)]
return population
8 changes: 3 additions & 5 deletions geneticAlgo/mutate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ def mutatePopulation ( population, noOfElite, mutationRate):
"""
popuLen = len(population)
newPopu = []
for i in range(0,noOfElite):
newPopu.append(deepcopy(population[i]))
for i in range(noOfElite,popuLen):
mutantIndi = mutate(population[i],mutationRate)
newPopu.append(mutantIndi)
newPopu.extend([deepcopy(individual) for individual in population[:noOfElite]])
newPopu.extend([mutate(individual, mutationRate) for individual in population[noOfElite:popuLen]])

return newPopu

# mutate function test
Expand Down