/** {@inheritDoc} */ public void trigger(int max) throws MaxCountExceededException { throw new MaxCountExceededException(max); } });
/** * Construct the exception with a specific context. * * @param specific Specific context pattern. * @param max Maximum. * @param args Additional arguments. */ public MaxCountExceededException(Localizable specific, Number max, Object ... args) { getContext().addMessage(specific, max, args); this.max = max; }
/** * Increment the evaluation count by one. * Method {@link #computeObjectiveValue(double)} calls this method internally. * It is provided for subclasses that do not exclusively use * {@code computeObjectiveValue} to solve the function. * See e.g. {@link AbstractUnivariateDifferentiableSolver}. * * @throws TooManyEvaluationsException when the allowed number of function * evaluations has been exhausted. */ protected void incrementEvaluationCount() throws TooManyEvaluationsException { try { evaluations.increment(); } catch (MaxCountExceededException e) { throw new TooManyEvaluationsException(e.getMax()); } } }
/** {@inheritDoc} */ @Override public void writeExternal(final ObjectOutput out) throws IOException { try { // save the local attributes finalizeStep(); } catch (MaxCountExceededException mcee) { final IOException ioe = new IOException(mcee.getLocalizedMessage()); ioe.initCause(mcee); throw ioe; } final int dimension = (currentState == null) ? -1 : currentState.length; out.writeInt(dimension); for (int i = 0; i < dimension; ++i) { out.writeDouble(yDotKLast[0][i]); out.writeDouble(yDotKLast[1][i]); out.writeDouble(yDotKLast[2][i]); } // save the state of the base class super.writeExternal(out); }
public static boolean allEigenvaluesAreSmallerThanOneInModulus(TetradMatrix mat) { double[] realEigenvalues = new double[0]; double[] imagEigenvalues = new double[0]; try { EigenDecomposition dec = new EigenDecomposition(mat.getRealMatrix()); realEigenvalues = dec.getRealEigenvalues(); imagEigenvalues = dec.getImagEigenvalues(); } catch (MaxCountExceededException e) { e.printStackTrace(); } for (int i = 0; i < realEigenvalues.length; i++) { double realEigenvalue = realEigenvalues[i]; double imagEigenvalue = imagEigenvalues[i]; System.out.println("Real eigenvalues are : " + realEigenvalue + " and imag part : " + imagEigenvalue); double modulus = Math.sqrt(Math.pow(realEigenvalue, 2) + Math.pow(imagEigenvalue, 2)); if (modulus >= 1.0) { return false; } } return true; }
final IOException ioe = new IOException(mcee.getLocalizedMessage()); ioe.initCause(mcee); throw ioe;
/** * Increment the iterations counter by 1. * @exception MaxCountExceededException if the maximal number of iterations is exceeded */ protected void incrementIterationsCounter() throws MaxCountExceededException { if (++iterations > maxIterations) { throw new MaxCountExceededException(maxIterations); } }
/** * Compute the objective function value. * * @param point Point at which the objective function must be evaluated. * @return the objective function value at the specified point. * @throws TooManyEvaluationsException if the maximal number of evaluations is * exceeded. */ protected double[] computeObjectiveValue(double[] point) { try { evaluations.incrementCount(); } catch (MaxCountExceededException e) { throw new TooManyEvaluationsException(e.getMax()); } return function.value(point); }
/** * Construct the exception with a specific context. * * @param specific Specific context pattern. * @param max Maximum. * @param args Additional arguments. */ public MaxCountExceededException(Localizable specific, Number max, Object ... args) { getContext().addMessage(specific, max, args); this.max = max; }
/** {@inheritDoc} */ @Override public void writeExternal(final ObjectOutput out) throws IOException { try { // save the local attributes finalizeStep(); } catch (MaxCountExceededException mcee) { final IOException ioe = new IOException(mcee.getLocalizedMessage()); ioe.initCause(mcee); throw ioe; } final int dimension = (currentState == null) ? -1 : currentState.length; out.writeInt(dimension); for (int i = 0; i < dimension; ++i) { out.writeDouble(yDotKLast[0][i]); out.writeDouble(yDotKLast[1][i]); out.writeDouble(yDotKLast[2][i]); } // save the state of the base class super.writeExternal(out); }
/** {@inheritDoc} */ public void trigger(int max) throws MaxCountExceededException { throw new MaxCountExceededException(max); } };
/** * Compute the objective function value. * * @param point Point at which the objective function must be evaluated. * @return the objective function value at specified point. * @throws TooManyEvaluationsException if the maximal number of evaluations * is exceeded. */ protected double computeObjectiveValue(double point) { try { evaluations.incrementCount(); } catch (MaxCountExceededException e) { throw new TooManyEvaluationsException(e.getMax()); } return function.value(point); }
/** * Construct the exception with a specific context. * * @param specific Specific context pattern. * @param max Maximum. * @param args Additional arguments. */ public MaxCountExceededException(Localizable specific, Number max, Object ... args) { getContext().addMessage(specific, max, args); this.max = max; }
final IOException ioe = new IOException(mcee.getLocalizedMessage()); ioe.initCause(mcee); throw ioe;
/** * Replace {@code i}-th facet of the microsphere. * Method for initializing the microsphere facets. * * @param normal Facet's normal vector. * @param copy Whether to copy the given array. * @throws DimensionMismatchException if the length of {@code n} * does not match the space dimension. * @throws MaxCountExceededException if the method has been called * more times than the size of the sphere. */ protected void add(double[] normal, boolean copy) { if (microsphere.size() >= size) { throw new MaxCountExceededException(size); } if (normal.length > dimension) { throw new DimensionMismatchException(normal.length, dimension); } microsphere.add(new Facet(copy ? normal.clone() : normal)); microsphereData.add(new FacetData(0d, 0d)); }
/** * Compute the objective function value. * * @param point Point at which the objective function must be evaluated. * @return the objective function value at specified point. * @throws TooManyEvaluationsException if the maximal number of function * evaluations is exceeded. */ protected double computeObjectiveValue(final double point) throws TooManyEvaluationsException { try { evaluations.increment(); } catch (MaxCountExceededException e) { throw new TooManyEvaluationsException(e.getMax()); } return function.value(point); }
throw new MaxCountExceededException(maxIterations); } else if (Double.isInfinite(sum)) { ret = 1.0;
/** * @param f Function. * @param x Argument. * @return {@code f(x)} * @throws TooManyEvaluationsException if the maximal number of evaluations is * exceeded. */ private double eval(UnivariateFunction f, double x) { try { evaluations.incrementCount(); } catch (MaxCountExceededException e) { throw new TooManyEvaluationsException(e.getMax()); } return f.value(x); } }
throw new MaxCountExceededException(LocalizedFormats.NON_CONVERGENT_CONTINUED_FRACTION, maxIterations, x);
/** * @param f Function. * @param x Argument. * @return {@code f(x)} * @throws TooManyEvaluationsException if the maximal number of evaluations is * exceeded. */ private double eval(UnivariateFunction f, double x) { try { evaluations.increment(); } catch (MaxCountExceededException e) { throw new TooManyEvaluationsException(e.getMax()); } return f.value(x); } }