Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#INVALID_FIXED_LENGTH_CHROMOSOME

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#INVALID_FIXED_LENGTH_CHROMOSOME . 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: CycleCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if the chromosomes are not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 2
Source File: OrderedCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 3
Source File: OrderedCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 4
Source File: OrderedCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 5
Source File: HelloWorldExample.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void checkValidity(List<Character> repr) throws InvalidRepresentationException {
    for (char c : repr) {
        if (c < 32 || c > 126) {
            throw new InvalidRepresentationException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
        }
    }
}
 
Example 6
Source File: UniformCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 7
Source File: CycleCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if the chromosomes are not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 8
Source File: CycleCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if the chromosomes are not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 9
Source File: CycleCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if the chromosomes are not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 10
Source File: UniformCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second) {
    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 11
Source File: CycleCrossover.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws MathIllegalArgumentException if the chromosomes are not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked")
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 12
Source File: OnePointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs one point crossover. A random crossover point is selected and the
 * first part from each parent is copied to the corresponding child, and the
 * second parts are copied crosswise.
 *
 * Example:
 * -C- denotes a crossover point
 *                   -C-                                -C-
 * p1 = (1 0 1 0 0 1  | 0 1 1)    X    p2 = (0 1 1 0 1 0  | 1 1 1)
 *         \------------/ \-----/              \------------/ \-----/
 *            ||         (*)                       ||        (**)
 *            VV         (**)                      VV        (*)
 *      /------------\ /-----\              /------------\ /-----\
 * c1 = (1 0 1 0 0 1  | 1 1 1)    X    p2 = (0 1 1 0 1 0  | 0 1 1)
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *         not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second) {
    if (! (first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return crossover((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 13
Source File: NPointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs a N-point crossover. N random crossover points are selected and are used
 * to divide the parent chromosomes into segments. The segments are copied in alternate
 * order from the two parents to the corresponding child chromosomes.
 *
 * Example (2-point crossover):
 * <pre>
 * -C- denotes a crossover point
 *           -C-       -C-                         -C-        -C-
 * p1 = (1 0  | 1 0 0 1 | 0 1 1)    X    p2 = (0 1  | 1 0 1 0  | 1 1 1)
 *      \----/ \-------/ \-----/              \----/ \--------/ \-----/
 *        ||      (*)       ||                  ||      (**)       ||
 *        VV      (**)      VV                  VV      (*)        VV
 *      /----\ /--------\ /-----\             /----\ /--------\ /-----\
 * c1 = (1 0  | 1 0 1 0  | 0 1 1)    X   c2 = (0 1  | 1 0 0 1  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 14
Source File: NPointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs a N-point crossover. N random crossover points are selected and are used
 * to divide the parent chromosomes into segments. The segments are copied in alternate
 * order from the two parents to the corresponding child chromosomes.
 *
 * Example (2-point crossover):
 * <pre>
 * -C- denotes a crossover point
 *           -C-       -C-                         -C-        -C-
 * p1 = (1 0  | 1 0 0 1 | 0 1 1)    X    p2 = (0 1  | 1 0 1 0  | 1 1 1)
 *      \----/ \-------/ \-----/              \----/ \--------/ \-----/
 *        ||      (*)       ||                  ||      (**)       ||
 *        VV      (**)      VV                  VV      (*)        VV
 *      /----\ /--------\ /-----\             /----\ /--------\ /-----\
 * c1 = (1 0  | 1 0 1 0  | 0 1 1)    X   c2 = (0 1  | 1 0 0 1  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 15
Source File: OnePointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs one point crossover. A random crossover point is selected and the
 * first part from each parent is copied to the corresponding child, and the
 * second parts are copied crosswise.
 *
 * Example:
 * <pre>
 * -C- denotes a crossover point
 *                   -C-                                 -C-
 * p1 = (1 0 1 0 0 1  | 0 1 1)    X    p2 = (0 1 1 0 1 0  | 1 1 1)
 *      \------------/ \-----/              \------------/ \-----/
 *            ||         (*)                       ||        (**)
 *            VV         (**)                      VV        (*)
 *      /------------\ /-----\              /------------\ /-----\
 * c1 = (1 0 1 0 0 1  | 1 1 1)    X    c2 = (0 1 1 0 1 0  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (! (first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return crossover((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 16
Source File: OnePointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs one point crossover. A random crossover point is selected and the
 * first part from each parent is copied to the corresponding child, and the
 * second parts are copied crosswise.
 *
 * Example:
 * <pre>
 * -C- denotes a crossover point
 *                   -C-                                 -C-
 * p1 = (1 0 1 0 0 1  | 0 1 1)    X    p2 = (0 1 1 0 1 0  | 1 1 1)
 *      \------------/ \-----/              \------------/ \-----/
 *            ||         (*)                       ||        (**)
 *            VV         (**)                      VV        (*)
 *      /------------\ /-----\              /------------\ /-----\
 * c1 = (1 0 1 0 0 1  | 1 1 1)    X    c2 = (0 1 1 0 1 0  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *         not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second) {
    if (! (first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return crossover((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 17
Source File: OnePointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs one point crossover. A random crossover point is selected and the
 * first part from each parent is copied to the corresponding child, and the
 * second parts are copied crosswise.
 *
 * Example:
 * <pre>
 * -C- denotes a crossover point
 *                   -C-                                 -C-
 * p1 = (1 0 1 0 0 1  | 0 1 1)    X    p2 = (0 1 1 0 1 0  | 1 1 1)
 *      \------------/ \-----/              \------------/ \-----/
 *            ||         (*)                       ||        (**)
 *            VV         (**)                      VV        (*)
 *      /------------\ /-----\              /------------\ /-----\
 * c1 = (1 0 1 0 0 1  | 1 1 1)    X    c2 = (0 1 1 0 1 0  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (! (first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return crossover((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 18
Source File: OnePointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs one point crossover. A random crossover point is selected and the
 * first part from each parent is copied to the corresponding child, and the
 * second parts are copied crosswise.
 *
 * Example:
 * <pre>
 * -C- denotes a crossover point
 *                   -C-                                 -C-
 * p1 = (1 0 1 0 0 1  | 0 1 1)    X    p2 = (0 1 1 0 1 0  | 1 1 1)
 *      \------------/ \-----/              \------------/ \-----/
 *            ||         (*)                       ||        (**)
 *            VV         (**)                      VV        (*)
 *      /------------\ /-----\              /------------\ /-----\
 * c1 = (1 0 1 0 0 1  | 1 1 1)    X    c2 = (0 1 1 0 1 0  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (! (first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return crossover((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 19
Source File: NPointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs a N-point crossover. N random crossover points are selected and are used
 * to divide the parent chromosomes into segments. The segments are copied in alternate
 * order from the two parents to the corresponding child chromosomes.
 *
 * Example (2-point crossover):
 * <pre>
 * -C- denotes a crossover point
 *           -C-       -C-                         -C-        -C-
 * p1 = (1 0  | 1 0 0 1 | 0 1 1)    X    p2 = (0 1  | 1 0 1 0  | 1 1 1)
 *      \----/ \-------/ \-----/              \----/ \--------/ \-----/
 *        ||      (*)       ||                  ||      (**)       ||
 *        VV      (**)      VV                  VV      (*)        VV
 *      /----\ /--------\ /-----\             /----\ /--------\ /-----\
 * c1 = (1 0  | 1 0 1 0  | 0 1 1)    X   c2 = (0 1  | 1 0 0 1  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (!(first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return mate((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}
 
Example 20
Source File: OnePointCrossover.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Performs one point crossover. A random crossover point is selected and the
 * first part from each parent is copied to the corresponding child, and the
 * second parts are copied crosswise.
 *
 * Example:
 * <pre>
 * -C- denotes a crossover point
 *                   -C-                                 -C-
 * p1 = (1 0 1 0 0 1  | 0 1 1)    X    p2 = (0 1 1 0 1 0  | 1 1 1)
 *      \------------/ \-----/              \------------/ \-----/
 *            ||         (*)                       ||        (**)
 *            VV         (**)                      VV        (*)
 *      /------------\ /-----\              /------------\ /-----\
 * c1 = (1 0 1 0 0 1  | 1 1 1)    X    c2 = (0 1 1 0 1 0  | 0 1 1)
 * </pre>
 *
 * @param first first parent (p1)
 * @param second second parent (p2)
 * @return pair of two children (c1,c2)
 * @throws MathIllegalArgumentException iff one of the chromosomes is
 *   not an instance of {@link AbstractListChromosome}
 * @throws DimensionMismatchException if the length of the two chromosomes is different
 */
@SuppressWarnings("unchecked") // OK because of instanceof checks
public ChromosomePair crossover(final Chromosome first, final Chromosome second)
    throws DimensionMismatchException, MathIllegalArgumentException {

    if (! (first instanceof AbstractListChromosome<?> && second instanceof AbstractListChromosome<?>)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME);
    }
    return crossover((AbstractListChromosome<T>) first, (AbstractListChromosome<T>) second);
}