Created
April 12, 2021 12:00
-
-
Save 18182324/24742f043cae306dfdb37c84b43c278b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i=0 | |
fitness = 0 | |
counter = 0 | |
while i < max_iter: | |
if counter > n_repeats: | |
STOP | |
Y = [ ] | |
fit = [ ] | |
pairs = randompairsfrom (X) | |
for j in pairs: | |
y = crossover ( j ) | |
y = randommutation ( y ) | |
Y. append (y) | |
fit.append (fitness(y)) | |
Y, fit = ordermaxtomin (Y, fit ) | |
bestfitness = fit[ 0 ] | |
if bestfitness < fitness: | |
counter = counter+1 | |
else: | |
counter = 0 | |
X = Y [0: N] | |
i=i+1 | |
fitness = bestfitness |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment