List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats POPULATION_LIMIT_NOT_POSITIVE
LocalizedFormats POPULATION_LIMIT_NOT_POSITIVE
To view the source code for org.apache.commons.math3.exception.util LocalizedFormats POPULATION_LIMIT_NOT_POSITIVE.
Click Source Link
From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation.java
/** * Creates a new ListPopulation instance. * <p>//from w w w . j a va 2 s . c o m * 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); }
From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation.java
/** * Sets the maximal population size./* w w w .java 2 s. co m*/ * @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; }