/* 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 ec.steadystate.*; /* * BreedingPipeline.java * * Created: Tue Aug 17 21:37:10 1999 * By: Sean Luke */ /** * A BreedingPipeline is a BreedingSource which provides "fresh" individuals which * can be used to fill a new population. BreedingPipelines might include * Crossover pipelines, various Mutation pipelines, etc. This abstract class * provides some default versions of various methods to simplify matters for you. * It also contains an array of breeding sources for your convenience. You don't * have to use them of course, but this means you have to customize the * default methods below to make sure they get distributed to your special * sources. Note that these sources may contain references to the same * object -- they're not necessarily distinct. This is to provide both * some simple DAG features and also to conserve space. * * *

A BreedingPipeline implements SteadyStateBSourceForm, meaning that * it receives the individualReplaced(...) and sourcesAreProperForm(...) messages. * however by default it doesn't do anything with these except distribute them * to its sources. You might override these to do something more interesting.

Parameters
base.num-sources
int >= 1
(User-specified number of sources to the pipeline. Some pipelines have hard-coded numbers of sources; others indicate (with the java constant DYNAMIC_SOURCES) that the number of sources is determined by this user parameter instead.)
base.source.n
classname, inherits and != BreedingSource, or the value same
(Source n for this BreedingPipeline. If the value is set to same, then this source is the exact same source object as base.source.n-1, and further parameters for this object will be ignored and treated as the same as those for n-1. same is not valid for base.source.0)

Parameter bases
base.source.n
Source n
* @author Sean Luke * @version 1.0 */ public abstract class BreedingPipeline extends BreedingSource implements SteadyStateBSourceForm { /** Indicates that a source is the exact same source as the previous source. */ public static final String V_SAME = "same"; /** Indicates the probability that the Breeding Pipeline will perform its mutative action instead of just doing reproduction. */ public static final String P_LIKELIHOOD = "likelihood"; /** Indicates that the number of sources is variable and determined by the user in the parameter file. */ public static final int DYNAMIC_SOURCES = 0; /** Standard parameter for number of sources (only used if numSources returns DYNAMIC_SOURCES */ public static final String P_NUMSOURCES = "num-sources"; /** Standard parameter for individual-selectors associated with a BreedingPipeline */ public static final String P_SOURCE = "source"; /** My parameter base -- I keep it around so I can print some messages that are useful with it (not deep cloned) */ public Parameter mybase; public float likelihood; /** Array of sources feeding the pipeline */ public BreedingSource[] sources; /** Returns the number of sources to this pipeline. Called during BreedingPipeline's setup. Be sure to return a value > 0, or DYNAMIC_SOURCES which indicates that setup should check the parameter file for the parameter "num-sources" to make its determination. */ public abstract int numSources(); /** Returns the minimum among the typicalIndsProduced() for any children -- a function that's useful internally, not very useful for you to call externally. */ public int minChildProduction() { if (sources.length==0) return 0; int min = sources[0].typicalIndsProduced(); for(int x=1;x cur) min = cur; } return min; } /** Returns the maximum among the typicalIndsProduced() for any children -- a function that's useful internally, not very useful for you to call externally. */ public int maxChildProduction() { if (sources.length==0) return 0; int max = sources[0].typicalIndsProduced(); for(int x=1;x 1.0f) state.output.fatal("Breeding Pipeline likelihood must be a value between 0.0 and 1.0 inclusive", base.push(P_LIKELIHOOD), def.push(P_LIKELIHOOD)); int numsources = numSources(); if (numsources <= DYNAMIC_SOURCES) { // figure it from the file numsources = state.parameters.getInt( base.push(P_NUMSOURCES), def.push(P_NUMSOURCES),1); if (numsources==0) state.output.fatal("Breeding pipeline num-sources value must be > 0", base.push(P_NUMSOURCES), def.push(P_NUMSOURCES)); } sources = new BreedingSource[numsources]; for(int x=0;x