/* Copyright 2006 by Sean Luke Licensed under the Academic Free License version 3.0 See the file "LICENSE" for more information */ package ec.select; import ec.*; import ec.util.*; /* * MultiSelection.java * * Created: Wed Dec 29 21:44:50 1999 * By: Sean Luke */ /** * MultiSelection is a SelectionMethod which stores some n subordinate * SelectionMethods. Each time it must produce an individual, * it picks one of these SelectionMethods at random and has it do the production * instead.

Typical Number of Individuals Produced Per produce(...) call
Always 1.

Parameters
base.num-selects
int >= 1
(The number of subordinate SelectionMethods)
base.select.n
classname, inherits and != SelectionMethod
(Subordinate SelectionMethod n)

Default Base
select.multiselect

Parameter bases
base.select.n
Subordinate SelectionMethod n
* @author Sean Luke * @version 1.0 */ public class MultiSelection extends SelectionMethod { public static final String P_NUMSELECTS = "num-selects"; public static final String P_SELECT = "select"; public static final String P_MULTISELECT = "multiselect"; /** The MultiSelection's individuals */ public SelectionMethod selects[]; public Parameter defaultBase() { return SelectDefaults.base().push(P_MULTISELECT); } public Object clone() { MultiSelection c = (MultiSelection)(super.clone()); // make a new array c.selects = new SelectionMethod[selects.length]; // clone the selects -- we won't go through the hassle of // determining if we have a DAG or not -- we'll just clone // it out to a tree. I doubt it's worth it. for(int x=0;x= 1).", base.push(P_NUMSELECTS),def.push(P_NUMSELECTS)); // make our arrays selects = new SelectionMethod[numSelects]; float total = 0.0f; for(int x=0;x= 0.0", p.push(P_PROB),d.push(P_PROB)); else total += selects[x].probability; } state.output.exitIfErrors(); // Now check for valid probability if (total <= 0.0) state.output.fatal("MultiSelection selects do not sum to a positive probability",base); if (total != 1.0) { state.output.message("Must normalize probabilities for " + base); for(int x=0;x