PBILSpecies extends IntegerVectorSpecies { public void setup(final EvolutionState state, final Parameter base) { assert(state != null); assert(base != null); super.setup(state, base); Parameter def = defaultBase(); Parameter subpopDefaultBase = ECDefaults.base().push(Subpopulation.P_SUBPOPULATION); for(int i =0;i<genomeSize;i++) { state.output.message("minGene " + i + " = " + minGene[i]); state.output.message("maxGene " + i + " = " + maxGene[i]); } alpha = state.parameters.getDouble(base.push(P_ALPHA), subpopDefaultBase); if ((alpha < 0) | (alpha > 1)) state.output.fatal(String.format("%s: the %s parameter is %f, but must be a valid number in the range 0 to 1", this.getClass().getSimpleName(), base.push(P_ALPHA), alpha), base.push(P_ALPHA), def.push(P_ALPHA)); b = state.parameters.getInt(base.push(P_B), def.push(P_B), 1); if (b < 1) state.output.fatal(String.format("%s: the %s parameter must be a positive integer.", this.getClass().getSimpleName(), base.push(P_B)), base.push(P_B), def.push(P_B)); distributions = new ArrayList<double[]>(); for(int i=0;i<genomeSize;i++) { double[] marginalDist=new double[(int)maxGene[i]-(int)minGene[i]+1]; for(int j = 0; j <maxGene[i]-minGene[i]+1; j++) { marginalDist[j] = 1.0d / (maxGene[i]-minGene[i]+1); } distributions.add(marginalDist); } state.output.message("alpha: " + alpha); state.output.message("b: " + b); assert(distributions.size() == genomeSize); }  double[] getMarginalDistribution(final int gene); void setup(final EvolutionState state, final Parameter base); Object clone(); Individual newIndividual(final EvolutionState state, int thread); void updateDistribution(final EvolutionState state, final Subpopulation subpop); static final String P_PBIL_SPECIES; static final String P_ALPHA; static final String P_B; public double alpha; public int b; }
@Test public void testSetup1() { PBILSpecies instance = new PBILSpecies(); instance.setup(state, BASE); assertEquals(instance.alpha, 0.5, 0.00001); assertEquals(instance.b, 5); assertEquals(instance.genomeSize, 3); }
@Test (expected = Output.OutputExitException.class) public void testSetup2() { state.parameters.set(BASE.push(PBILSpecies.P_ALPHA), "2.0"); PBILSpecies instance = new PBILSpecies(); instance.setup(state, BASE); }
@Test (expected = Output.OutputExitException.class) public void testSetup3() { state.parameters.set(BASE.push(PBILSpecies.P_ALPHA), "-1.0"); PBILSpecies instance = new PBILSpecies(); instance.setup(state, BASE); }
@Test (expected = Output.OutputExitException.class) public void testSetup4() { state.parameters.set(BASE.push(PBILSpecies.P_B), "0"); PBILSpecies instance = new PBILSpecies(); instance.setup(state, BASE); }