Class DerivativeLineMultiOptimizer
java.lang.Object
com.irurueta.numerical.optimization.Optimizer
com.irurueta.numerical.optimization.MultiOptimizer
com.irurueta.numerical.optimization.DerivativeLineMultiOptimizer
- Direct Known Subclasses:
DerivativeConjugateGradientMultiOptimizer
Class to find a minimum on a multidimensional function along a given line
of input values. The difference between this abstract class and
LineMultiOptimizer is that subclasses of this class will use the function
gradient information. By using gradient information, typically convergence is
faster, although, if gradient does not have a closed expression, then a
GradientEstimator will be needed in the gradient listener provided to this
class. Notice that a GradientEstimator might estimate gradients with a
certain error, so depending on the function topology, LineMultiOptimizer
subclasses might obtain greater accuracy than subclasses of this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DerivativeBrentSingleOptimizer
Internal optimizer to find a minimum of a function along a line of input values.private DirectionalDerivativeEvaluator
Class in charge of evaluating a function through a given line.protected GradientFunctionEvaluatorListener
Listener to evaluate the function's gradient.private int
Number of dimensions on function being evaluated.protected double[]
n-dimensional point containing a minimum in a given line.protected double[]
Direction to make the search.Fields inherited from class com.irurueta.numerical.optimization.MultiOptimizer
fmin, listener, resultAvailable, xmin
Fields inherited from class com.irurueta.numerical.optimization.Optimizer
iterationCompletedListener, locked
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Empty constructor.protected
DerivativeLineMultiOptimizer
(MultiDimensionFunctionEvaluatorListener listener, GradientFunctionEvaluatorListener gradientListener, double[] point, double[] direction) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
Returns direction to start looking for a minimum.Returns gradient listener.double[]
Returns start point where algorithm will be started.private void
internalSetStartPointAndDirection
(double[] point, double[] direction) Internal method to set start point and direction to start the search for a local minimum.boolean
Returns boolean indicating whether direction has already been provided and is ready for retrieval.boolean
Returns boolean indicating whether the gradient listener has been provided and is available for retrieval.boolean
isReady()
Returns boolean indicating whether this instance is considered to be ready to start the estimation of a minimum.boolean
Returns boolean indicating whether start point has already been provided and is ready for retrieval.protected double
linmin()
Searches for a minimum along a given line of input values.void
setGradientListener
(GradientFunctionEvaluatorListener gradientListener) Sets gradient listener.void
setStartPointAndDirection
(double[] point, double[] direction) Internal method to set start point and direction to start the search for a local minimum.Methods inherited from class com.irurueta.numerical.optimization.MultiOptimizer
getEvaluationAtResult, getListener, getResult, isListenerAvailable, isResultAvailable, setListener
Methods inherited from class com.irurueta.numerical.optimization.Optimizer
getOnIterationCompletedListener, isLocked, minimize, setOnIterationCompletedListener
-
Field Details
-
p
protected double[] pn-dimensional point containing a minimum in a given line. -
xi
protected double[] xiDirection to make the search. -
n
private int nNumber of dimensions on function being evaluated. -
gradientListener
Listener to evaluate the function's gradient. If the function's gradient is not know (e.g. does not have a closed expression), then a GradientEstimator might be used inside the listener implementation. -
evaluator
Class in charge of evaluating a function through a given line. -
dbrent
Internal optimizer to find a minimum of a function along a line of input values. Hence, input is converted to a single dimension using a DirectionalEvaluator.
-
-
Constructor Details
-
DerivativeLineMultiOptimizer
protected DerivativeLineMultiOptimizer()Empty constructor. -
DerivativeLineMultiOptimizer
protected DerivativeLineMultiOptimizer(MultiDimensionFunctionEvaluatorListener listener, GradientFunctionEvaluatorListener gradientListener, double[] point, double[] direction) Constructor.- Parameters:
listener
- Listener to evaluate a multi-dimension function.gradientListener
- Listener to evaluate the function's gradient.point
- Start point where algorithm will be started. Start point should be close to the local minimum to be found. Provided array must have a length equal to the number of dimensions of the function being evaluated, otherwise and exception will be raised when searching for the minimum.direction
- Direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.- Throws:
IllegalArgumentException
- Raised if provided point and direction don't have the same length.
-
-
Method Details
-
isStartPointAvailable
public boolean isStartPointAvailable()Returns boolean indicating whether start point has already been provided and is ready for retrieval.- Returns:
- True if available, false otherwise.
-
getStartPoint
Returns start point where algorithm will be started. Start point should be close to the local minimum to be found.- Returns:
- Start point where algorithm will be started.
- Throws:
NotAvailableException
- Raised if start point has not yet been provided and is not available.
-
isDirectionAvailable
public boolean isDirectionAvailable()Returns boolean indicating whether direction has already been provided and is ready for retrieval.- Returns:
- True if available, false otherwise.
-
getDirection
Returns direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.- Returns:
- Direction to start looking for a minimum.
- Throws:
NotAvailableException
- Raised if direction has not yet been provided and is not available.
-
internalSetStartPointAndDirection
private void internalSetStartPointAndDirection(double[] point, double[] direction) Internal method to set start point and direction to start the search for a local minimum. This method does not check whether this instance is locked.- Parameters:
point
- Start point where algorithm will be started. Start point should be close to the local minimum to be found. Provided array must have a length equal to the number of dimensions of the function being evaluated, otherwise and exception will be raised when searching for the minimum.direction
- Direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.- Throws:
IllegalArgumentException
- Raised if provided point and direction don't have the same length.
-
setStartPointAndDirection
Internal method to set start point and direction to start the search for a local minimum.- Parameters:
point
- Start point where algorithm will be started. Start point should be close to the local minimum to be found. Provided array must have a length equal to the number of dimensions of the function being evaluated, otherwise and exception will be raised when searching for the minimum.direction
- Direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.- Throws:
LockedException
- Raised if this instance is locked.IllegalArgumentException
- Raised if provided point and direction don't have the same length.
-
isReady
public boolean isReady()Returns boolean indicating whether this instance is considered to be ready to start the estimation of a minimum. This instance is considered to be ready once a listener, gradient listener, start point and direction are provided.- Overrides:
isReady
in classMultiOptimizer
- Returns:
- True if this instance is ready, false otherwise.
-
getGradientListener
Returns gradient listener. The gradient listener is used to evaluate the function's gradient. If the function's gradient is not know (e.g. does not have a closed expression), then a GradientEstimator might be used inside the listener implementation.- Returns:
- Gradient listener.
- Throws:
NotAvailableException
- Raised if gradient listener is not available for retrieval.
-
setGradientListener
public void setGradientListener(GradientFunctionEvaluatorListener gradientListener) throws LockedException Sets gradient listener. The gradient listener is used to evaluate the function's gradient. If the function's gradient is not know (e.g. does not have a closed expression), then a GradientEstimator might be used inside the listener implementation.- Parameters:
gradientListener
- Gradient listener.- Throws:
LockedException
- Raised if this instance is locked.
-
isGradientListenerAvailable
public boolean isGradientListenerAvailable()Returns boolean indicating whether the gradient listener has been provided and is available for retrieval.- Returns:
- True if available, false otherwise.
-
linmin
protected double linmin()Searches for a minimum along a given line of input values. The line being searched is obtained by using a start point and direction.- Returns:
- Returns function evaluation at minimum that has been found.
-