当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE属性代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE属性的具体用法?Java LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE怎么用?Java LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.exception.util.LocalizedFormats的用法示例。


在下文中一共展示了LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ListPopulation

/**
 * Creates a new ListPopulation instance.
 * <p>
 * Note: the chromosomes of the specified list are added to the population.
 *
 * @param chromosomes list of chromosomes to be added to the population
 * @param populationLimit maximal size of the population
 * @throws NullArgumentException if the list of chromosomes is {@code null}
 * @throws NotPositiveException if the population limit is not a positive number (&lt; 1)
 * @throws NumberIsTooLargeException if the list of chromosomes exceeds the population limit
 */
public ListPopulation(final List<Chromosome> chromosomes, final int populationLimit)
    throws NullArgumentException, NotPositiveException, NumberIsTooLargeException {

    if (chromosomes == null) {
        throw new NullArgumentException();
    }
    if (populationLimit <= 0) {
        throw new NotPositiveException(LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE, populationLimit);
    }
    if (chromosomes.size() > populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                                            chromosomes.size(), populationLimit, false);
    }
    this.populationLimit = populationLimit;
    this.chromosomes = new ArrayList<Chromosome>(populationLimit);
    this.chromosomes.addAll(chromosomes);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:ListPopulation.java

示例2: setPopulationLimit

/**
 * Sets the maximal population size.
 * @param populationLimit maximal population size.
 * @throws NotPositiveException if the population limit is not a positive number (&lt; 1)
 * @throws NumberIsTooSmallException if the new population size is smaller than the current number
 *   of chromosomes in the population
 */
public void setPopulationLimit(final int populationLimit) throws NotPositiveException, NumberIsTooSmallException {
    if (populationLimit <= 0) {
        throw new NotPositiveException(LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE, populationLimit);
    }
    if (populationLimit < chromosomes.size()) {
        throw new NumberIsTooSmallException(populationLimit, chromosomes.size(), true);
    }
    this.populationLimit = populationLimit;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:16,代码来源:ListPopulation.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。