/** * Constructor with default {@link BrentSolver line search solver} and * {@link IdentityPreconditioner preconditioner}. * * @param updateFormula formula to use for updating the β parameter, * must be one of {@link ConjugateGradientFormula#FLETCHER_REEVES} or {@link * ConjugateGradientFormula#POLAK_RIBIERE}. * @param checker Convergence checker. */ public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula, ConvergenceChecker<PointValuePair> checker) { this(updateFormula, checker, new BrentSolver(), new IdentityPreconditioner()); }
TooManyEvaluationsException, NumberIsTooLargeException { double min = getMin(); double max = getMax(); final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); double yInitial = computeObjectiveValue(initial); if (FastMath.abs(yInitial) <= functionValueAccuracy) { return initial; double yMin = computeObjectiveValue(min); if (FastMath.abs(yMin) <= functionValueAccuracy) { return min; return brent(min, initial, yMin, yInitial); double yMax = computeObjectiveValue(max); if (FastMath.abs(yMax) <= functionValueAccuracy) { return max; return brent(initial, max, yInitial, yMax);
double e = d; final double t = getAbsoluteAccuracy(); final double eps = getRelativeAccuracy(); b -= tol; fb = computeObjectiveValue(b); if ((fb > 0 && fc > 0) || (fb <= 0 && fc <= 0)) {
/** * Brent's algo Copied from AlgoRootInterval.java. */ public final static double calcSingleRoot(GeoFunction f, double left, double right) { BrentSolver rootFinder = new BrentSolver(); if (!f.isDefined()) { return Double.NaN; } double root = Double.NaN; Function fun = f.getFunction(); try { // Brent's method root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, left, right); } catch (Exception e) { try { // Let's try again by searching for a valid domain first double[] borders = RealRootUtil.getDefinedInterval(fun, left, right); root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, borders[0], borders[1]); } catch (Exception ex) { root = Double.NaN; } // try-catch } // try-catch return root; }
BrentSolver rootFinder = new BrentSolver(); rate = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, min, max);
TooManyEvaluationsException, NumberIsTooLargeException { double min = getMin(); double max = getMax(); final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); double yInitial = computeObjectiveValue(initial); if (Math.abs(yInitial) <= functionValueAccuracy) { return initial; double yMin = computeObjectiveValue(min); if (Math.abs(yMin) <= functionValueAccuracy) { return min; return brent(min, initial, yMin, yInitial); double yMax = computeObjectiveValue(max); if (Math.abs(yMax) <= functionValueAccuracy) { return max; return brent(initial, max, yInitial, yMax);
/** * Convenience method to find a zero of a univariate real function. A default * solver is used. * * @param function Function. * @param x0 Lower bound for the interval. * @param x1 Upper bound for the interval. * @param absoluteAccuracy Accuracy to be used by the solver. * @return a value where the function is zero. * @throws NoBracketingException if the function has the same sign at the * endpoints. * @throws NullArgumentException if {@code function} is {@code null}. */ public static double solve(UnivariateFunction function, double x0, double x1, double absoluteAccuracy) throws NullArgumentException, NoBracketingException { if (function == null) { throw new NullArgumentException(LocalizedFormats.FUNCTION); } final UnivariateSolver solver = new BrentSolver(absoluteAccuracy); return solver.solve(Integer.MAX_VALUE, function, x0, x1); }
double e = d; final double t = getAbsoluteAccuracy(); final double eps = getRelativeAccuracy(); b -= tol; fb = computeObjectiveValue(b); if ((fb > 0 && fc > 0) || (fb <= 0 && fc <= 0)) {
rootFinder = new BrentSolver(); root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, min, max); root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, borders[0], borders[1]);
TooManyEvaluationsException, NumberIsTooLargeException { double min = getMin(); double max = getMax(); final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); double yInitial = computeObjectiveValue(initial); if (FastMath.abs(yInitial) <= functionValueAccuracy) { return initial; double yMin = computeObjectiveValue(min); if (FastMath.abs(yMin) <= functionValueAccuracy) { return min; return brent(min, initial, yMin, yInitial); double yMax = computeObjectiveValue(max); if (FastMath.abs(yMax) <= functionValueAccuracy) { return max; return brent(initial, max, yInitial, yMax);
/** * Convenience method to find a zero of a univariate real function. A default * solver is used. * * @param function Function. * @param x0 Lower bound for the interval. * @param x1 Upper bound for the interval. * @return a value where the function is zero. * @throws NoBracketingException if the function has the same sign at the * endpoints. * @throws NullArgumentException if {@code function} is {@code null}. */ public static double solve(UnivariateFunction function, double x0, double x1) throws NullArgumentException, NoBracketingException { if (function == null) { throw new NullArgumentException(LocalizedFormats.FUNCTION); } final UnivariateSolver solver = new BrentSolver(); return solver.solve(Integer.MAX_VALUE, function, x0, x1); }
double e = d; final double t = getAbsoluteAccuracy(); final double eps = getRelativeAccuracy(); b -= tol; fb = computeObjectiveValue(b); if ((fb > 0 && fc > 0) || (fb <= 0 && fc <= 0)) {
double root = Double.NaN; if (rootFinderBrent == null) { rootFinderBrent = new BrentSolver(Kernel.STANDARD_PRECISION); root = rootFinderBrent.solve(MAX_ITERATIONS, fun, startX - step, startX + step, startX); root = rootFinderBrent.solve(MAX_ITERATIONS, fun, borders[0], borders[1], startX); if (checkRoot(fun, root)) {
/** * Constructor with default {@link BrentSolver line search solver} and * {@link IdentityPreconditioner preconditioner}. * * @param updateFormula formula to use for updating the β parameter, * must be one of {@link ConjugateGradientFormula#FLETCHER_REEVES} or {@link * ConjugateGradientFormula#POLAK_RIBIERE}. * @param checker Convergence checker. */ public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula, ConvergenceChecker<PointValuePair> checker) { this(updateFormula, checker, new BrentSolver(), new IdentityPreconditioner()); }
/** * Convenience method to find a zero of a univariate real function. A default * solver is used. * * @param function Function. * @param x0 Lower bound for the interval. * @param x1 Upper bound for the interval. * @return a value where the function is zero. * @throws NoBracketingException if the function has the same sign at the * endpoints. * @throws NullArgumentException if {@code function} is {@code null}. */ public static double solve(UnivariateFunction function, double x0, double x1) throws NullArgumentException, NoBracketingException { if (function == null) { throw new NullArgumentException(LocalizedFormats.FUNCTION); } final UnivariateSolver solver = new BrentSolver(); return solver.solve(Integer.MAX_VALUE, function, x0, x1); }
/** * Convenience method to find a zero of a univariate real function. A default * solver is used. * * @param function Function. * @param x0 Lower bound for the interval. * @param x1 Upper bound for the interval. * @param absoluteAccuracy Accuracy to be used by the solver. * @return a value where the function is zero. * @throws NoBracketingException if the function has the same sign at the * endpoints. * @throws NullArgumentException if {@code function} is {@code null}. */ public static double solve(UnivariateFunction function, double x0, double x1, double absoluteAccuracy) throws NullArgumentException, NoBracketingException { if (function == null) { throw new NullArgumentException(LocalizedFormats.FUNCTION); } final UnivariateSolver solver = new BrentSolver(absoluteAccuracy); return solver.solve(Integer.MAX_VALUE, function, x0, x1); }
/** * Convenience method to find a zero of a univariate real function. A default * solver is used. * * @param function Function. * @param x0 Lower bound for the interval. * @param x1 Upper bound for the interval. * @return a value where the function is zero. * @throws NoBracketingException if the function has the same sign at the * endpoints. * @throws NullArgumentException if {@code function} is {@code null}. */ public static double solve(UnivariateFunction function, double x0, double x1) throws NullArgumentException, NoBracketingException { if (function == null) { throw new NullArgumentException(LocalizedFormats.FUNCTION); } final UnivariateSolver solver = new BrentSolver(); return solver.solve(Integer.MAX_VALUE, function, x0, x1); }
/** * Convenience method to find a zero of a univariate real function. A default * solver is used. * * @param function Function. * @param x0 Lower bound for the interval. * @param x1 Upper bound for the interval. * @param absoluteAccuracy Accuracy to be used by the solver. * @return a value where the function is zero. * @throws NoBracketingException if the function has the same sign at the * endpoints. * @throws NullArgumentException if {@code function} is {@code null}. */ public static double solve(UnivariateFunction function, double x0, double x1, double absoluteAccuracy) throws NullArgumentException, NoBracketingException { if (function == null) { throw new NullArgumentException(LocalizedFormats.FUNCTION); } final UnivariateSolver solver = new BrentSolver(absoluteAccuracy); return solver.solve(Integer.MAX_VALUE, function, x0, x1); }
int ncat = 0; RpFunction func = null; UnivariateSolver solver = new BrentSolver(1.0e-12, 1.0e-8); HashMap<String, Double> unsortedMap = new HashMap<String, Double>();
solver = new BisectionSolver(); } else if (method.equals("Brent")) { solver = new BrentSolver();