@Test(expected = OutputExitException.class) public void testSetup4() { params.remove(BASE.push(AntSystemUpdateRule.P_DEPOSIT_RULE)); final AntSystemUpdateRule instance = new AntSystemUpdateRule(); instance.setup(state, BASE); }
@Override public void setup(final EvolutionState state, final Parameter base) { assert(state != null); assert(base != null); decayRate = state.parameters.getDouble(base.push(P_DECAY_RATE), null); if (decayRate < 0.0 || decayRate >= 1.0 || Double.isInfinite(decayRate) || Double.isNaN(decayRate)) state.output.fatal(String.format("%s: '%s' parameter is set to '%f,' but must be on the interval [0,1).", this.getClass().getSimpleName(), base.push(P_DECAY_RATE), decayRate)); q = state.parameters.exists(base.push(P_Q), null) ? state.parameters.getDouble(base.push(P_Q), null) : 1.0; if (q <= 0.0) state.output.fatal(String.format("%s: parameter '%s' has a value of %f, but must be positive.", this.getClass().getSimpleName(), base.push(P_Q), q)); String depositString = state.parameters.getString(base.push(P_DEPOSIT_RULE), null); if (depositString == null) state.output.fatal(String.format("%s: missing required parameter '%s'.", this.getClass().getSimpleName(), base.push(P_DEPOSIT_RULE))); try { depositString = depositString.replace('-', '_'); depositRule = DepositRule.valueOf(depositString); } catch (final NullPointerException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } catch (final IllegalArgumentException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } assert(repOK()); }
AntSystemUpdateRule implements UpdateRule { @Override public void setup(final EvolutionState state, final Parameter base) { assert(state != null); assert(base != null); decayRate = state.parameters.getDouble(base.push(P_DECAY_RATE), null); if (decayRate < 0.0 || decayRate >= 1.0 || Double.isInfinite(decayRate) || Double.isNaN(decayRate)) state.output.fatal(String.format("%s: '%s' parameter is set to '%f,' but must be on the interval [0,1).", this.getClass().getSimpleName(), base.push(P_DECAY_RATE), decayRate)); q = state.parameters.exists(base.push(P_Q), null) ? state.parameters.getDouble(base.push(P_Q), null) : 1.0; if (q <= 0.0) state.output.fatal(String.format("%s: parameter '%s' has a value of %f, but must be positive.", this.getClass().getSimpleName(), base.push(P_Q), q)); String depositString = state.parameters.getString(base.push(P_DEPOSIT_RULE), null); if (depositString == null) state.output.fatal(String.format("%s: missing required parameter '%s'.", this.getClass().getSimpleName(), base.push(P_DEPOSIT_RULE))); try { depositString = depositString.replace('-', '_'); depositRule = DepositRule.valueOf(depositString); } catch (final NullPointerException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } catch (final IllegalArgumentException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } assert(repOK()); } }
AntSystemUpdateRule implements UpdateRule { @Override public void setup(final EvolutionState state, final Parameter base) { assert(state != null); assert(base != null); decayRate = state.parameters.getDouble(base.push(P_DECAY_RATE), null); if (decayRate < 0.0 || decayRate >= 1.0 || Double.isInfinite(decayRate) || Double.isNaN(decayRate)) state.output.fatal(String.format("%s: '%s' parameter is set to '%f,' but must be on the interval [0,1).", this.getClass().getSimpleName(), base.push(P_DECAY_RATE), decayRate)); q = state.parameters.exists(base.push(P_Q), null) ? state.parameters.getDouble(base.push(P_Q), null) : 1.0; if (q <= 0.0) state.output.fatal(String.format("%s: parameter '%s' has a value of %f, but must be positive.", this.getClass().getSimpleName(), base.push(P_Q), q)); String depositString = state.parameters.getString(base.push(P_DEPOSIT_RULE), null); if (depositString == null) state.output.fatal(String.format("%s: missing required parameter '%s'.", this.getClass().getSimpleName(), base.push(P_DEPOSIT_RULE))); try { depositString = depositString.replace('-', '_'); depositRule = DepositRule.valueOf(depositString); } catch (final NullPointerException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } catch (final IllegalArgumentException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } assert(repOK()); }  }
AntSystemUpdateRule implements UpdateRule { @Override public void setup(final EvolutionState state, final Parameter base) { assert(state != null); assert(base != null); decayRate = state.parameters.getDouble(base.push(P_DECAY_RATE), null); if (decayRate < 0.0 || decayRate >= 1.0 || Double.isInfinite(decayRate) || Double.isNaN(decayRate)) state.output.fatal(String.format("%s: '%s' parameter is set to '%f,' but must be on the interval [0,1).", this.getClass().getSimpleName(), base.push(P_DECAY_RATE), decayRate)); q = state.parameters.exists(base.push(P_Q), null) ? state.parameters.getDouble(base.push(P_Q), null) : 1.0; if (q <= 0.0) state.output.fatal(String.format("%s: parameter '%s' has a value of %f, but must be positive.", this.getClass().getSimpleName(), base.push(P_Q), q)); String depositString = state.parameters.getString(base.push(P_DEPOSIT_RULE), null); if (depositString == null) state.output.fatal(String.format("%s: missing required parameter '%s'.", this.getClass().getSimpleName(), base.push(P_DEPOSIT_RULE))); try { depositString = depositString.replace('-', '_'); depositRule = DepositRule.valueOf(depositString); } catch (final NullPointerException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } catch (final IllegalArgumentException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } assert(repOK()); }  @Override void setup(final EvolutionState state, final Parameter base); double getDecayRate(); DepositRule getDepositRule(); double getQ(); @Override void updatePheromones(final EvolutionState state, final PheromoneTable pheromones, final List individuals); final boolean repOK(); }
AntSystemUpdateRule implements UpdateRule { @Override public void setup(final EvolutionState state, final Parameter base) { assert(state != null); assert(base != null); decayRate = state.parameters.getDouble(base.push(P_DECAY_RATE), null); if (decayRate < 0.0 || decayRate >= 1.0 || Double.isInfinite(decayRate) || Double.isNaN(decayRate)) state.output.fatal(String.format("%s: '%s' parameter is set to '%f,' but must be on the interval [0,1).", this.getClass().getSimpleName(), base.push(P_DECAY_RATE), decayRate)); q = state.parameters.exists(base.push(P_Q), null) ? state.parameters.getDouble(base.push(P_Q), null) : 1.0; if (q <= 0.0) state.output.fatal(String.format("%s: parameter '%s' has a value of %f, but must be positive.", this.getClass().getSimpleName(), base.push(P_Q), q)); String depositString = state.parameters.getString(base.push(P_DEPOSIT_RULE), null); if (depositString == null) state.output.fatal(String.format("%s: missing required parameter '%s'.", this.getClass().getSimpleName(), base.push(P_DEPOSIT_RULE))); try { depositString = depositString.replace('-', '_'); depositRule = DepositRule.valueOf(depositString); } catch (final NullPointerException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } catch (final IllegalArgumentException e) { state.output.fatal(String.format("%s: invalid value '%s' found for parameter '%s'. Allowed values are %s.", this.getClass().getSimpleName(), depositString, base.push(P_DEPOSIT_RULE), Arrays.asList(DepositRule.values()))); } assert(repOK()); }  @Override void setup(final EvolutionState state, final Parameter base); double getDecayRate(); DepositRule getDepositRule(); double getQ(); @Override void updatePheromones(final EvolutionState state, final PheromoneTable pheromones, final List individuals); final boolean repOK(); final static String P_DECAY_RATE; final static String P_DEPOSIT_RULE; final static String P_Q; }