Created
December 4, 2014 14:02
-
-
Save felixlindemann/ad50954c984c2c61ed98 to your computer and use it in GitHub Desktop.
calculate fitnes of a tourplan 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
calcTourplan <- function(cij, tour){ | |
F <- 0 | |
# Speichere die Orte, die keinen Vorgänger haben --> Also vom Depot aus angesteuert werden | |
hasPreDecessor <- rep(FALSE, nrow(locations)) | |
for(i in 1:ncol(tour)){ | |
F<- F + cij[i+1, tour[i]] | |
hasPreDecessor[tour[i]] <- TRUE | |
} | |
I <- which(hasPreDecessor==FALSE) | |
# Welche knoten sind mit dem Depot verbunden? | |
if(length(I)>0){ | |
for(i in I){ | |
F<- F + cij[1, i] # i = 1 is depot | |
} | |
} | |
return (F) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment