Created
December 4, 2014 13:38
-
-
Save felixlindemann/3f1194710fff356718de to your computer and use it in GitHub Desktop.
Repair child according to cond 1&2 in a #Genetic Algortihm
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
repair1 <- function(tour){ | |
#cond 1/2 once arrive/leave | |
#substitute multiple indices by 0(1) --> ALL! | |
#getunique stops | |
y<-unique(tour) | |
y<- y[y!=1] # 1 --> 0 # elminate Depot-Stops | |
#iterate over potentail multiple Stop indices | |
for(i in y){ | |
# which stops have this index? | |
x <- which(tour == i) | |
if(length(x)>1){ | |
# if i is multiple stop | |
tour[x] <- 1 # return to depot | |
} | |
} | |
# Return | |
return (tour) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment