本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME属性的具体用法?Java LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME怎么用?Java LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.INVALID_FIXED_LENGTH_CHROMOSOME属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: crossover
/**
* {@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);
}
示例2: crossover
/**
* {@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);
}
示例3: crossover
/**
* 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);
}
示例4: crossover
/**
* 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);
}