/* Copyright 2006 by Sean Luke and George Mason University Licensed under the Academic Free License version 3.0 See the file "LICENSE" for more information */ package ec.select; import ec.*; import ec.util.*; import ec.steadystate.*; /* * RandomSelection.java * * Created: Tue Sep 3 2002 * By: Liviu Panait */ /** * Picks a random individual in the subpopulation. This is mostly * for testing purposes. *

Default Base
select.random * * @author Sean Luke * @version 1.0 */ public class RandomSelection extends SelectionMethod implements SteadyStateBSourceForm { /** default base */ public static final String P_RANDOM = "random"; public Parameter defaultBase() { return SelectDefaults.base().push(P_RANDOM); } // I hard-code both produce(...) methods for efficiency's sake public int produce(final int subpopulation, final EvolutionState state, final int thread) { return state.random[thread].nextInt( state.population.subpops[subpopulation].individuals.length ); } // I hard-code both produce(...) methods for efficiency's sake public int produce(final int min, final int max, final int start, final int subpopulation, final Individual[] inds, final EvolutionState state, final int thread) { int n = 1; if (n>max) n = max; if (n