Example usage for org.apache.commons.math3.exception.util LocalizedFormats MUTATION_RATE

List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats MUTATION_RATE

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util LocalizedFormats MUTATION_RATE.

Prototype

LocalizedFormats MUTATION_RATE

To view the source code for org.apache.commons.math3.exception.util LocalizedFormats MUTATION_RATE.

Click Source Link

Usage

From source file:eu.tsp.sal.SensorGeneticAlgorithm.java

/**
 * Create a new genetic algorithm.//w  w  w  . ja v  a  2s  . co  m
 * @param crossoverPolicy The {@link CrossoverPolicy}
 * @param crossoverRate The crossover rate as a percentage (0-1 inclusive)
 * @param mutationPolicy The {@link MutationPolicy}
 * @param mutationRate The mutation rate as a percentage (0-1 inclusive)
 * @param selectionPolicy The {@link SelectionPolicy}
 * @throws OutOfRangeException if the crossover or mutation rate is outside the [0, 1] range
 */
public SensorGeneticAlgorithm(final CrossoverPolicy crossoverPolicy, final double crossoverRate,
        final MutationPolicy mutationPolicy, final double mutationRate, final SelectionPolicy selectionPolicy)
        throws OutOfRangeException {

    if (crossoverRate < 0 || crossoverRate > 1) {
        throw new OutOfRangeException(LocalizedFormats.CROSSOVER_RATE, crossoverRate, 0, 1);
    }
    if (mutationRate < 0 || mutationRate > 1) {
        throw new OutOfRangeException(LocalizedFormats.MUTATION_RATE, mutationRate, 0, 1);
    }
    this.crossoverPolicy = crossoverPolicy;
    this.crossoverRate = crossoverRate;
    this.mutationPolicy = mutationPolicy;
    this.mutationRate = mutationRate;
    this.selectionPolicy = selectionPolicy;
}

From source file:sos.base.util.genetic.SOSGeneticAlgorithm.java

/**
 * Create a new genetic algorithm.//from w  w  w  .  j a v a2 s . c  o  m
 * 
 * @param crossoverPolicy
 *            The {@link CrossoverPolicy}
 * @param crossoverRate
 *            The crossover rate as a percentage (0-1 inclusive)
 * @param mutationPolicy
 *            The {@link MutationPolicy}
 * @param mutationRate
 *            The mutation rate as a percentage (0-1 inclusive)
 * @param selectionPolicy
 *            The {@link SelectionPolicy}
 * @throws OutOfRangeException
 *             if the crossover or mutation rate is outside the [0, 1] range
 */
public SOSGeneticAlgorithm(final CrossoverPolicy crossoverPolicy, final double crossoverRate,
        final MutationPolicy mutationPolicy, final double mutationRate, final SelectionPolicy selectionPolicy,
        final SOSSelectionPolicy sosSelect) throws OutOfRangeException {

    this.sosSelect = sosSelect;
    if (crossoverRate < 0 || crossoverRate > 1) {
        throw new OutOfRangeException(LocalizedFormats.CROSSOVER_RATE, crossoverRate, 0, 1);
    }
    if (mutationRate < 0 || mutationRate > 1) {
        throw new OutOfRangeException(LocalizedFormats.MUTATION_RATE, mutationRate, 0, 1);
    }
    this.crossoverPolicy = crossoverPolicy;
    this.crossoverRate = crossoverRate;
    this.mutationPolicy = mutationPolicy;
    this.mutationRate = mutationRate;
    this.selectionPolicy = selectionPolicy;
}