Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#RANDOMKEY_MUTATION_WRONG_CLASS
The following examples show how to use
org.apache.commons.math3.exception.util.LocalizedFormats#RANDOMKEY_MUTATION_WRONG_CLASS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 2
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 3
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a * {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 4
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 5
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a * {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 6
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 7
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }
Example 8
Source File: RandomKeyMutation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * @throws MathIllegalArgumentException if <code>original</code> is not a {@link RandomKey} instance */ public Chromosome mutate(final Chromosome original) throws MathIllegalArgumentException { if (!(original instanceof RandomKey<?>)) { throw new MathIllegalArgumentException(LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS, original.getClass().getSimpleName()); } RandomKey<?> originalRk = (RandomKey<?>) original; List<Double> repr = originalRk.getRepresentation(); int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size()); List<Double> newRepr = new ArrayList<Double> (repr); newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble()); return originalRk.newFixedLengthChromosome(newRepr); }