R/tournamentSelection.R

Defines functions tournamentSelection

Documented in tournamentSelection

tournamentSelection <-
function(pop,pool_size,tour_size) {
  popSize = nrow(pop);
  Dim = ncol(pop);
  f <- NULL;
  counter <- 1
  while (counter <= pool_size) {
    candidate = sample(popSize,tour_size);      
    tmp <- pop[candidate,];
    f <- rbind(f,tmp[order(tmp[,Dim-1],-tmp[,Dim])[1],]);
    counter <- counter + 1;
  } 
  return(f);
}

Try the nsga2R package in your browser

Any scripts or data that you put into this service are public.

nsga2R documentation built on May 29, 2017, 8:02 p.m.