/* Copyright 2006 by Sean Luke Licensed under the Academic Free License version 3.0 See the file "LICENSE" for more information */ package ec; import ec.util.*; import java.io.*; /* * Population.java * * Created: Tue Aug 10 20:50:54 1999 * By: Sean Luke */ /** * A Population is the repository for all the Individuals being bred or * evaluated in the evolutionary run at a given time. * A Population is basically an array of Subpopulations, each of which * are arrays of Individuals coupled with a single Species per Subpoulation. * *

The first Population is created using the initializePopulation method * of the Initializer object, which typically calls the Population's * populate() method in turn. On generational systems, subsequent populations * are created on a generation-by-generation basis by the Breeder object, * replacing the previous Population. * *

In a multithreaded area of a run, Populations should be considered * immutable. That is, once they are created, they should not be modified, * nor anything they contain. This protocol helps ensure read-safety under * multithreading race conditions. *

Parameters
base.subpops
int >= 1
(the number of subpopulations)
base.subpop.n
classname, inherits or = ec.Subpopulation
(the class for subpopulation #n)
base.default-subpop
classname, inherits or = ec.Subpopulation
(the class for subpopulation #n if it wasn't specified with base.subpop.n. Don't use this except in unusual circumstances. The parameter base is still base.subpop.n.

Parameter bases
base.subpop.n Subpopulation #n.
* * @author Sean Luke * @version 1.0 */ public class Population implements Group { public Subpopulation[] subpops; public static final String P_SIZE = "subpops"; public static final String P_SUBPOP = "subpop"; public static final String P_DEFAULT_SUBPOP = "default-subpop"; public static final String NUM_SUBPOPS_PREAMBLE = "Number of Subpopulations: "; public static final String SUBPOP_INDEX_PREAMBLE = "Subpopulation Number: "; /** Returns an instance of Population just like it had been before it was populated with individuals. You may need to override this if you override Population. IMPORTANT NOTE: if the size of the array in Population has been changed, then the clone will take on the new array size. This helps some evolution strategies. @see Group#emptyClone() */ public Group emptyClone() { try { Population p = (Population)clone(); p.subpops = new Subpopulation[subpops.length]; for(int x=0;x0.\n",base.push(P_SIZE)); subpops = new Subpopulation[size]; // Load the subpopulations for (int x=0;x