public void setup(final EvolutionState state, final Parameter base) { super.setup(state, base); Parameter def = defaultBase(); double val = state.parameters.getDouble(base.push(P_SIZE), def.push(P_SIZE), 1.0); if (val < 1.0) state.output.fatal("Tournament size must be >= 1.", base.push(P_SIZE), def.push(P_SIZE)); else if (val > 1 && val < 2) // pick with probability { size = 2; probabilityOfSelection = (val / 2); } else if (val != (int) val) // it's not an integer state.output.fatal( "If >= 2, Tournament size must be an integer.", base.push(P_SIZE), def.push(P_SIZE)); else { size = (int) val; probabilityOfSelection = 1.0; } val = state.parameters.getDouble(base.push(P_SIZE2), def.push(P_SIZE2), 1.0); if (val < 1.0) state.output.fatal("Tournament size2 must be >= 1.", base.push(P_SIZE2), def.push(P_SIZE2)); else if (val > 1 && val < 2) // pick with probability { size2 = 2; probabilityOfSelection2 = (val / 2); } else if (val != (int) val) // it's not an integer state.output.fatal( "If >= 2, Tournament size2 must be an integer.", base.push(P_SIZE2), def.push(P_SIZE2)); else { size2 = (int) val; probabilityOfSelection2 = 1.0; } doLengthFirst = state.parameters.getBoolean(base.push(P_DOLENGTHFIRST), def.push(P_DOLENGTHFIRST), true); pickWorst = state.parameters.getBoolean(base.push(P_PICKWORST), def.push(P_PICKWORST), false); pickWorst2 = state.parameters.getBoolean(base.push(P_PICKWORST2), def.push(P_PICKWORST2), false); }