nr.minimizer
Class VecMinimizerImp

java.lang.Object
  extended by nr.minimizer.VecMinimizerImp
All Implemented Interfaces:
VecMinimizer
Direct Known Subclasses:
Brent, NelderMeadMinimizer

public abstract class VecMinimizerImp
extends java.lang.Object
implements VecMinimizer

Simple implementation of a VecMinimizer. The constructor takes a #nr.ScalarFunction and epsilon is used to create a vector, such that if the trial minimum is changed less than that vector in each component, the algorithm has converged. The concrete implementation needs to implement doMinimize.

Author:
Daniel Wachsstock

Field Summary
 int MAXFUNCTIONEVAL
          The maximum number of times to evaluate the function before throwing #nr.DidNotConvergeException
 
Constructor Summary
VecMinimizerImp(ScalarFunction f)
          create a new instance of VecMinimizerImp.
 
Method Summary
 double getEpsilon()
          return the relative accuracy parameter
 double minimize(Vec x)
          minimize.
 int numFuncEvals()
          the number of function evaluations it took to converge to the minimum.
 void setEpsilon(double epsilon)
          set the desired relative accuracy parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXFUNCTIONEVAL

public final int MAXFUNCTIONEVAL
The maximum number of times to evaluate the function before throwing #nr.DidNotConvergeException

See Also:
Constant Field Values
Constructor Detail

VecMinimizerImp

public VecMinimizerImp(ScalarFunction f)
create a new instance of VecMinimizerImp.

Parameters:
f - the ScalarFunction to minimize
Method Detail

minimize

public double minimize(Vec x)
minimize.

Specified by:
minimize in interface VecMinimizer
Parameters:
x - the initial guess; epsilon*x is the convergence criterion. x will be changed to the minimum of the initial function.
Returns:
the value of the function at the minimum.
Throws:
DidNotConvergeException - if the algorithm could not find the minimum

getEpsilon

public double getEpsilon()
Description copied from interface: VecMinimizer
return the relative accuracy parameter

Specified by:
getEpsilon in interface VecMinimizer

setEpsilon

public void setEpsilon(double epsilon)
Description copied from interface: VecMinimizer
set the desired relative accuracy parameter. Each implementation decides how to interpret this, if at all

Specified by:
setEpsilon in interface VecMinimizer

numFuncEvals

public int numFuncEvals()
Description copied from interface: VecMinimizer
the number of function evaluations it took to converge to the minimum.

Specified by:
numFuncEvals in interface VecMinimizer
Returns:
the number of function evaluations.