本文整理汇总了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 (< 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);
}
示例2: setPopulationLimit
/**
* Sets the maximal population size.
* @param populationLimit maximal population size.
* @throws NotPositiveException if the population limit is not a positive number (< 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;
}