/* 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.spatial; import ec.Initializer; import ec.Individual; import ec.BreedingPipeline; import ec.Breeder; import ec.simple.*; import ec.EvolutionState; import ec.Population; import ec.util.Parameter; import ec.util.*; /* * SpatialBreeder.java * * By: Liviu Panait */ /** * A slight modification of the simple breeder for spatially-embedded EAs. * Breeds each subpopulation separately, with no inter-population exchange, * and using a generational approach. A SpatialBreeder may have multiple * threads; it divvys up a subpopulation into chunks and hands one chunk * to each thread to populate. One array of BreedingPipelines is obtained * from a population's Species for each operating breeding thread. * * * * * @author Liviu Panait * @version 1.0 */ public class SpatialBreeder extends SimpleBreeder { public void setup(final EvolutionState state, final Parameter base) { super.setup(state, base); // check for elitism and warn about it for(int i = 0 ; i < elite.length; i++) if (elite[i] > 0) { state.output.warning("You're using elitism with SpatialBreeder. This is unwise as elitism is done by moving individuals around in the population, thus messing up the spatial nature of breeding.", base.push(P_ELITE).push(""+i)); break; } } protected void breedPopChunk(Population newpop, EvolutionState state, int[] numinds, int[] from, int threadnum) { for(int subpop=0;subpop