org.apache.commons.math3.exception.NumberIsTooLargeException Java Examples
The following examples show how to use
org.apache.commons.math3.exception.NumberIsTooLargeException.
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: Math_22_UniformRealDistribution_t.java From coming with MIT License | 6 votes |
/** * Creates a uniform distribution. * * @param rng Random number generator. * @param lower Lower bound of this distribution (inclusive). * @param upper Upper bound of this distribution (exclusive). * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NumberIsTooLargeException if {@code lower >= upper}. * @since 3.1 */ public UniformRealDistribution(RandomGenerator rng, double lower, double upper, double inverseCumAccuracy) throws NumberIsTooLargeException { super(rng); if (lower >= upper) { throw new NumberIsTooLargeException( LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND, lower, upper, false); } this.lower = lower; this.upper = upper; solverAbsoluteAccuracy = inverseCumAccuracy; }
Example #2
Source File: Math_34_ListPopulation_s.java From coming with MIT License | 6 votes |
/** * 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 (< 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: Nopol2017_0064_t.java From coming with MIT License | 6 votes |
/** * Samples the specified univariate real function on the specified interval. * <br/> * The interval is divided equally into {@code n} sections and sample points * are taken from {@code min} to {@code max - (max - min) / n}; therefore * {@code f} is not sampled at the upper bound {@code max}. * * @param f Function to be sampled * @param min Lower bound of the interval (included). * @param max Upper bound of the interval (excluded). * @param n Number of sample points. * @return the array of samples. * @throws NumberIsTooLargeException if the lower bound {@code min} is * greater than, or equal to the upper bound {@code max}. * @throws NotStrictlyPositiveException if the number of sample points * {@code n} is negative. */ public static double[] sample(UnivariateFunction f, double min, double max, int n) { if (n <= 0) { throw new NotStrictlyPositiveException( LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, Integer.valueOf(n)); } if (min >= max) { throw new NumberIsTooLargeException(min, max, false); } final double[] s = new double[n]; final double h = (max - min) / n; for (int i = 0; i < n; i++) { s[i] = f.value(min + i * h); } return s; }
Example #4
Source File: Math_34_ListPopulation_t.java From coming with MIT License | 6 votes |
/** * 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 (< 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: Math_22_UniformRealDistribution_s.java From coming with MIT License | 6 votes |
/** * Creates a uniform distribution. * * @param rng Random number generator. * @param lower Lower bound of this distribution (inclusive). * @param upper Upper bound of this distribution (exclusive). * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NumberIsTooLargeException if {@code lower >= upper}. * @since 3.1 */ public UniformRealDistribution(RandomGenerator rng, double lower, double upper, double inverseCumAccuracy) throws NumberIsTooLargeException { super(rng); if (lower >= upper) { throw new NumberIsTooLargeException( LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND, lower, upper, false); } this.lower = lower; this.upper = upper; solverAbsoluteAccuracy = inverseCumAccuracy; }
Example #6
Source File: Elixir_0025_t.java From coming with MIT License | 6 votes |
/** * 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 (< 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 #7
Source File: JGenProg2017_0058_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #8
Source File: JGenProg2017_0088_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #9
Source File: jMutRepair_008_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #10
Source File: JGenProg2017_0088_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #11
Source File: jMutRepair_0024_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #12
Source File: JGenProg2015_003_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #13
Source File: Math_34_ListPopulation_s.java From coming with MIT License | 5 votes |
/** * 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 #14
Source File: Elixir_0025_s.java From coming with MIT License | 5 votes |
/** * 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 #15
Source File: jMutRepair_0033_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #16
Source File: Math_34_ListPopulation_t.java From coming with MIT License | 5 votes |
/** * 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 #17
Source File: Elixir_0020_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #18
Source File: Math_34_ListPopulation_t.java From coming with MIT License | 5 votes |
/** * 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 #19
Source File: JGenProg2017_00110_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #20
Source File: JGenProg2017_0019_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #21
Source File: JGenProg2017_0019_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #22
Source File: JGenProg2017_00130_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #23
Source File: JGenProg2017_00130_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #24
Source File: Math_10_DSCompiler_t.java From coming with MIT License | 5 votes |
/** Get the index of a partial derivative in an array. * @param parameters number of free parameters * @param order derivation order * @param sizes sizes array * @param orders derivation orders with respect to each parameter * (the lenght of this array must match the number of parameters) * @return index of the partial derivative * @exception NumberIsTooLargeException if sum of derivation orders is larger * than the instance limits */ private static int getPartialDerivativeIndex(final int parameters, final int order, final int[][] sizes, final int ... orders) throws NumberIsTooLargeException { // the value is obtained by diving into the recursive Dan Kalman's structure // this is theorem 2 of his paper, with recursion replaced by iteration int index = 0; int m = order; int ordersSum = 0; for (int i = parameters - 1; i >= 0; --i) { // derivative order for current free parameter int derivativeOrder = orders[i]; // safety check ordersSum += derivativeOrder; if (ordersSum > order) { throw new NumberIsTooLargeException(ordersSum, order, true); } while (derivativeOrder-- > 0) { // as long as we differentiate according to current free parameter, // we have to skip the value part and dive into the derivative part // so we add the size of the value part to the base index index += sizes[i][m--]; } } return index; }
Example #25
Source File: Cardumen_00256_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #26
Source File: Cardumen_0036_t.java From coming with MIT License | 5 votes |
/** * Creates a new hypergeometric distribution. * * @param rng Random number generator. * @param populationSize Population size. * @param numberOfSuccesses Number of successes in the population. * @param sampleSize Sample size. * @throws NotPositiveException if {@code numberOfSuccesses < 0}. * @throws NotStrictlyPositiveException if {@code populationSize <= 0}. * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize}, * or {@code sampleSize > populationSize}. * @since 3.1 */ public HypergeometricDistribution(RandomGenerator rng, int populationSize, int numberOfSuccesses, int sampleSize) throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException { super(rng); if (populationSize <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE, populationSize); } if (numberOfSuccesses < 0) { throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES, numberOfSuccesses); } if (sampleSize < 0) { throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } if (numberOfSuccesses > populationSize) { throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE, numberOfSuccesses, populationSize, true); } if (sampleSize > populationSize) { throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE, sampleSize, populationSize, true); } this.numberOfSuccesses = numberOfSuccesses; this.populationSize = populationSize; this.sampleSize = sampleSize; }
Example #27
Source File: Elixir_0025_s.java From coming with MIT License | 5 votes |
/** * 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 #28
Source File: Cardumen_0036_s.java From coming with MIT License | 5 votes |
/** * Creates a new hypergeometric distribution. * * @param rng Random number generator. * @param populationSize Population size. * @param numberOfSuccesses Number of successes in the population. * @param sampleSize Sample size. * @throws NotPositiveException if {@code numberOfSuccesses < 0}. * @throws NotStrictlyPositiveException if {@code populationSize <= 0}. * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize}, * or {@code sampleSize > populationSize}. * @since 3.1 */ public HypergeometricDistribution(RandomGenerator rng, int populationSize, int numberOfSuccesses, int sampleSize) throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException { super(rng); if (populationSize <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE, populationSize); } if (numberOfSuccesses < 0) { throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES, numberOfSuccesses); } if (sampleSize < 0) { throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } if (numberOfSuccesses > populationSize) { throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE, numberOfSuccesses, populationSize, true); } if (sampleSize > populationSize) { throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE, sampleSize, populationSize, true); } this.numberOfSuccesses = numberOfSuccesses; this.populationSize = populationSize; this.sampleSize = sampleSize; }
Example #29
Source File: Arja_00123_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example #30
Source File: Cardumen_00212_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> */ public double cumulativeProbability(int x0, int x1) throws NumberIsTooLargeException { if (x1 < x0) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }