Class BracketSearchMinimizer.Solution
- java.lang.Object
-
- dev.nm.root.univariate.bracketsearch.BracketSearchMinimizer.Solution
-
- All Implemented Interfaces:
UnivariateMinimizer.Solution
,MinimizationSolution<Double>
- Direct Known Subclasses:
BrentMinimizer.Solution
,FibonaccMinimizer.Solution
,GoldenMinimizer.Solution
- Enclosing class:
- BracketSearchMinimizer
protected abstract class BracketSearchMinimizer.Solution extends Object implements UnivariateMinimizer.Solution
-
-
Field Summary
Fields Modifier and Type Field Description protected UnivariateRealFunction
f
protected double
fmin
the best minimum found so farprotected double
fnext
the next guess of the minimumprotected int
iter
the current iteration countprotected double
xl
the lower bound of the bracketing intervalprotected double
xmin
the best minimizer found so farprotected double
xnext
the next best guess of the minimizerprotected double
xu
the upper bound of the bracketing interval
-
Constructor Summary
Constructors Modifier Constructor Description protected
Solution(UnivariateRealFunction f)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
init(double xmin, double fmin)
Initializes the algorithm states with initial \(x_{min}\) and \(f_{min}\) before iterations.protected boolean
isBracketing(double xl, double x, double xu)
Check whether [xl, xu] is bracketing x.protected abstract boolean
isMinFound()
the convergence criterionDouble
minimizer()
Get the minimizer (solution) to the minimization problem.double
minimum()
Get the (approximate) minimum found.double
search(double lower, double initial, double upper)
Search for a minimum within the interval [lower, upper].protected void
updateStates()
Update the bracketing interval and the best min found so far.protected abstract double
xnext()
Compute the next best estimate within the bracketing interval.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dev.nm.root.univariate.UnivariateMinimizer.Solution
search
-
-
-
-
Field Detail
-
f
protected UnivariateRealFunction f
-
fmin
protected double fmin
the best minimum found so far
-
fnext
protected double fnext
the next guess of the minimum
-
xl
protected double xl
the lower bound of the bracketing interval
-
xu
protected double xu
the upper bound of the bracketing interval
-
xmin
protected double xmin
the best minimizer found so far
-
xnext
protected double xnext
the next best guess of the minimizer
-
iter
protected int iter
the current iteration count
-
-
Constructor Detail
-
Solution
protected Solution(UnivariateRealFunction f)
-
-
Method Detail
-
init
protected void init(double xmin, double fmin)
Initializes the algorithm states with initial \(x_{min}\) and \(f_{min}\) before iterations. The function value of the initial minimum point is evaluated in this class. If the subclass algorithm needs the computed function value, it can override this method to avoid an unnecessary evaluation. By default, the implementation is empty. If the subclass algorithm does not need to initialize states from the function value, no overriding is needed.- Parameters:
xmin
- the initial minimum pointfmin
- the function value of the initial minimum point
-
isMinFound
protected abstract boolean isMinFound()
the convergence criterion- Returns:
true
if the current min value is considered to have converged within a threshold
-
xnext
protected abstract double xnext()
Compute the next best estimate within the bracketing interval. A particular univariate minimization algorithm implements the logic in this method.- Returns:
- the next best guess of the minimizer
-
search
public double search(double lower, double initial, double upper)
Description copied from interface:UnivariateMinimizer.Solution
Search for a minimum within the interval [lower, upper].- Specified by:
search
in interfaceUnivariateMinimizer.Solution
- Parameters:
lower
- the lower bound for the bracketing interval which contains a minimuminitial
- an initial guessupper
- the upper bound for the bracketing interval which contains a minimum- Returns:
- an approximate minimizer
-
updateStates
protected void updateStates()
Update the bracketing interval and the best min found so far.
-
isBracketing
protected boolean isBracketing(double xl, double x, double xu)
Check whether [xl, xu] is bracketing x.- Parameters:
xl
- the lower bound of the bracketing intervalx
- a guess of the minimizerxu
- the upper bound of the bracketing interval- Returns:
true
if fx < fl && fx < fu
-
minimum
public double minimum()
Description copied from interface:MinimizationSolution
Get the (approximate) minimum found.- Specified by:
minimum
in interfaceMinimizationSolution<Double>
- Returns:
- the (approximate) minimum found
-
minimizer
public Double minimizer()
Description copied from interface:MinimizationSolution
Get the minimizer (solution) to the minimization problem.- Specified by:
minimizer
in interfaceMinimizationSolution<Double>
- Returns:
- the minimizer
-
-