WebCab Optimization
v2.6
(J2EE Edition)

com.webcab.ejb.math.optimization.unidimensional
Class AccelBracketing

java.lang.Object
  |
  +--com.webcab.ejb.math.optimization.unidimensional.BracketingAlgorithm
        |
        +--com.webcab.ejb.math.optimization.unidimensional.AccelBracketing
All Implemented Interfaces:
Serializable

public class AccelBracketing
extends BracketingAlgorithm

A simple acceleration bracketing algorithm which can be applied to any general unidimensional function which is implemented via the interface UniDimensionalFunction.

Further Details

This is a general bracketing algorithm and can be it can be applied to any continuous function. The voldg, oldg, and g fields of the result are guaranteed to respect the following condition: voldg < oldg && oldg > or voldg < oldg && oldg < g. This means that, if the function is continuous then certainly a local maximum (in the first case) or minimum (in the second case) is between a and c.

The second point is taken as x + mindist, or the closest point x1 that makes the condition f(x) != f(x1) valid. The third point is found by taking accelerated steps until there is a sense change.

See Also:
The base class of the bracketing algorithms., A bracketing algorithm for differentiable functions., An alternative bracketing algorithm for generic unidimensional functions which are implemented by the use of the interface {@link UniDimensionalFunction}., Serialized Form

Constructor Summary
AccelBracketing()
           
 
Method Summary
protected  Bracket extend(Bracket br, UniDimensionalFunction f, double bparam, int extreme_type)
          Expands the bracketing interval until it surely contains at least one extremum of the given type.
protected  Bracket find_initial(double x, UniDimensionalFunction f, double mindist)
          Finds an initial, reasonable large interval, which can be subsequently enlarged by extend.
 
Methods inherited from class com.webcab.ejb.math.optimization.unidimensional.BracketingAlgorithm
bracketBidir, bracketUnidir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccelBracketing

public AccelBracketing()
Method Detail

find_initial

protected Bracket find_initial(double x,
                               UniDimensionalFunction f,
                               double mindist)
                        throws InvalidUniDimensionalFunctionException
Finds an initial, reasonable large interval, which can be subsequently enlarged by extend. The algorithm initially sets the b point of the bracket to x + mindist. If f(x + mindist) == f(x) the interval is increased until f(x + interval_width) != f(x).

Specified by:
find_initial in class BracketingAlgorithm
Parameters:
x - the starting point
f - the function. May implement UniDimensionalFunction or Derivative.
mindist - The first try for the b parameter in the bracket is x + mindist. The value for this should be of the same order with the tolerance or less. If this is too large, it is possible to skip over one or more extrema. If it is very small, it is probable that the algorithm will make many iterations until different function values are found.
Returns:
a bracket with points a and b set; a ;lt b; oldg = f(b); voldg = f(a); a == x. If the algorithm cannot find a bracket such that f(a) != f(b), the function is probably constant and a null reference is returned.
Throws:
InvalidUniDimensionalFunctionException - thrown if the users function returns invalid values like infinity or NaN.

extend

protected Bracket extend(Bracket br,
                         UniDimensionalFunction f,
                         double bparam,
                         int extreme_type)
                  throws InvalidUniDimensionalFunctionException,
                         UniDimensionalException
Expands the bracketing interval until it surely contains at least one extremum of the given type. Obs.: the extreme type must be consistent with the bracket supplied i.e. if extreme_type is 1, so we search for a minimum, b must be less than a (unlike in AccelDerivBracketing equality is not permitted). If extreme_type is -1, a must be less than b. This is guaranteed if the bracket is set by the corresponding find_initial method.

Specified by:
extend in class BracketingAlgorithm
Parameters:
br - the bracket with points a and b set; a < b; oldg = f(b); voldg = f(a)
f - the function. If the function does not implement Derivative an UniDimensionalException will be thrown.
bparam - the acceleration factor for interval expansion. See Mathematical Documentation for a discussion on recommended acceleration factors. Good values are 1.5 for increased safety or 2 for fast results.
extreme_type - Specifies the type of extremum: 1 for minimum or -1 for maximum.
Returns:
a bracket with points a, b and c set; a < b < c; g = f(c); oldg = f(b); voldg = f(a). If an extrmum cannot be located a null reference is returned.
Throws:
InvalidUniDimensionalFunctionException - thrown if the user function returns invalid values like infinity or NaN.
UniDimensionalException

WebCab Optimization
v2.6
(J2EE Edition)