Introduction - If you have any usage issues, please Google them yourself
tspData <- read.csv( D:\\weka\\hw\\TSP.csv , header = T, sep = , )
#tspData <- `colnames<-`(tspData,c(1:8))
D <- as.matrix(tspData)
tourLength <- function(tour, distMatrix)
{ tour <- c(tour, tour[1])
route <- embed(tour, 2)[, 2:1]
sum(distMatrix[route]) }
tpsFitness <- function(tour, ...) 1/tourLength(tour, ...)
GA.fit <- ga(type = permutation , fitness = tpsFitness, distMatrix = tspData, min = 1, max = 8, popSize = 10, maxiter = 500, run = 100, pmutation = 0.2, monitor = NULL)
summary(GA.fit)