List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE
LocalizedFormats LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE
To view the source code for org.apache.commons.math3.exception.util LocalizedFormats LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE.
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 . ja va2s . 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
/** * Add a {@link Collection} of chromosomes to this {@link Population}. * @param chromosomeColl a {@link Collection} of chromosomes * @throws NumberIsTooLargeException if the population would exceed the population limit when * adding this chromosome/*from w w w.ja va2 s. c o m*/ * @since 3.1 */ public void addChromosomes(final Collection<Chromosome> chromosomeColl) throws NumberIsTooLargeException { if (chromosomes.size() + chromosomeColl.size() > populationLimit) { throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE, chromosomes.size(), populationLimit, false); } this.chromosomes.addAll(chromosomeColl); }
From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation.java
/** * Sets the list of chromosomes.//from w w w . j a va 2s . c om * <p> * Note: this method removes all existing chromosomes in the population and adds all chromosomes * of the specified list to the population. * * @param chromosomes the list of chromosomes * @throws NullArgumentException if the list of chromosomes is {@code null} * @throws NumberIsTooLargeException if the list of chromosomes exceeds the population limit * @deprecated use {@link #addChromosomes(Collection)} instead */ @Deprecated public void setChromosomes(final List<Chromosome> chromosomes) throws NullArgumentException, NumberIsTooLargeException { if (chromosomes == null) { throw new NullArgumentException(); } if (chromosomes.size() > populationLimit) { throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE, chromosomes.size(), populationLimit, false); } this.chromosomes.clear(); this.chromosomes.addAll(chromosomes); }
From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation.java
/** * Add the given chromosome to the population. * * @param chromosome the chromosome to add. * @throws NumberIsTooLargeException if the population would exceed the {@code populationLimit} after * adding this chromosome//w w w. j a v a 2 s. c om */ public void addChromosome(final Chromosome chromosome) throws NumberIsTooLargeException { if (chromosomes.size() >= populationLimit) { throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE, chromosomes.size(), populationLimit, false); } this.chromosomes.add(chromosome); }