Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: Elixir_0025_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Creates a new ListPopulation instance.
 * <p>Note: the chromosomes of the specified list are added to the population.</p>
 * @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) {
    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);
}
 
Example 3
Source File: Math_34_ListPopulation_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Creates a new ListPopulation instance.
 * <p>Note: the chromosomes of the specified list are added to the population.</p>
 * @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) {
    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);
}
 
Example 4
Source File: Math_34_ListPopulation_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new ListPopulation instance.
 * <p>Note: the chromosomes of the specified list are added to the population.</p>
 * @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) {
    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);
}
 
Example 5
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new ListPopulation instance.
 * <p>Note: the chromosomes of the specified list are added to the population.</p>
 * @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) {
    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);
}
 
Example 6
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the list of chromosomes.
 * <p>
 * Note: this method removed 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);
}
 
Example 7
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
public void addChromosome(final Chromosome chromosome) {
    if (chromosomes.size() >= populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                                            chromosomes.size(), populationLimit, false);
    }
    this.chromosomes.add(chromosome);
}
 
Example 8
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the list of chromosomes.
 * <p>
 * Note: this method removed 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);
}
 
Example 9
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
}
 
Example 10
Source File: Math_34_ListPopulation_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * 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
 */
public void addChromosome(final Chromosome chromosome) {
    if (chromosomes.size() >= populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                                            chromosomes.size(), populationLimit, false);
    }
    this.chromosomes.add(chromosome);
}
 
Example 11
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 * @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);
}
 
Example 12
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
}
 
Example 13
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
}
 
Example 14
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the list of chromosomes.
 * <p>
 * Note: this method removed 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);
}
 
Example 15
Source File: Math_34_ListPopulation_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
public void addChromosome(final Chromosome chromosome) {
    if (chromosomes.size() >= populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                                            chromosomes.size(), populationLimit, false);
    }
    this.chromosomes.add(chromosome);
}
 
Example 16
Source File: ListPopulation.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
public void addChromosomes(final Collection<Chromosome> chromosomeColl) {
    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);
}
 
Example 17
Source File: Math_34_ListPopulation_s.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the list of chromosomes.
 * <p>Note: this method removed all existing chromosomes in the population and adds all chromosomes
 * of the specified list to the population.</p>
 * @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
 */
public void setChromosomes(final List<Chromosome> chromosomes) {
    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);
}
 
Example 18
Source File: Elixir_0025_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * 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
 */
public void addChromosome(final Chromosome chromosome) {
    if (chromosomes.size() >= populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                                            chromosomes.size(), populationLimit, false);
    }
    this.chromosomes.add(chromosome);
}
 
Example 19
Source File: Math_34_ListPopulation_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the list of chromosomes.
 * <p>Note: this method removed all existing chromosomes in the population and adds all chromosomes
 * of the specified list to the population.</p>
 * @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
 */
public void setChromosomes(final List<Chromosome> chromosomes) {
    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);
}
 
Example 20
Source File: Elixir_0025_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Sets the list of chromosomes.
 * <p>Note: this method removed all existing chromosomes in the population and adds all chromosomes
 * of the specified list to the population.</p>
 * @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
 */
public void setChromosomes(final List<Chromosome> chromosomes) {
    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);
}