Created
December 4, 2014 13:53
-
-
Save felixlindemann/d8eb6b89c630e33d4c5b to your computer and use it in GitHub Desktop.
Mutation process with in a genetic algorithm
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
# mutation | |
mutate <- function(tour){ | |
# suche zufällig einen Start knoten aus, der mit einem Endknoten verbunden wird. | |
# combine which stop o[1] with wich stop o[2] | |
o <- sample(1:length(tour), 2) | |
tour[o[1]] <- o[2] + 1 # 1 is depot | |
# mutated tour | |
#immediate Repair | |
tour <- repair1(tour) | |
tour <- repair2(tour) | |
tour <- repair3(tour) | |
return (tour) # mutated + repaired tour | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment