/*
 * RandomReproduction.java
 *
 * Created on 3. unor 2006, 12:27
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package cz.pcland.ga.selection;


import cz.pcland.ga.BaseIndividual;
import cz.pcland.ga.MyRand;
/**
 *
 * @author petr
 */
public class RandomSelection implements SelectionOperator {
    
    /** Creates a new instance of TournamentSelection */
    public RandomSelection() {
        super();
    }
    
    public void onStart(BaseIndividual[] population) {
        
    }
    
    public void init(BaseIndividual[] population, double sumOfFitness) {
        
    }
    
    public String toString() {
        return "Random selection" ;
    }
   
    
     public BaseIndividual select(BaseIndividual[] population, int popSize, double sumOfFitness){
         int rand = Math.abs(MyRand.getInt()%(popSize));
         return population[rand];
     }
}
