gov.sandia.cognition.learning.algorithm.root
Class RootBracketExpander

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
          extended by gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm<ResultType>
              extended by gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner<Evaluator<Double,Double>,LineBracket>
                  extended by gov.sandia.cognition.learning.algorithm.root.RootBracketExpander
All Implemented Interfaces:
AnytimeAlgorithm<LineBracket>, IterativeAlgorithm, StoppableAlgorithm, AnytimeBatchLearner<Evaluator<Double,Double>,LineBracket>, BatchLearner<Evaluator<Double,Double>,LineBracket>, RootBracketer, CloneableSerializable, Serializable, Cloneable

public class RootBracketExpander
extends AbstractAnytimeBatchLearner<Evaluator<Double,Double>,LineBracket>
implements RootBracketer

The root-bracketing expansion algorithm. This function repeatedly expands a root bracket about an initial guess until it finds a region where it can be demonstrated that the function makes a zero-crossing (root). The algorithm can fail on functions where the function "kisses" zero, or has a "notch" type look.

Since:
3.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Field Summary
static double DEFAULT_INITIAL_GUESS
          Default initial guess, 0.0
static int DEFAULT_MAX_ITERATIONS
          Default max iterations, 100
static double SCALE_FACTOR
          Default scale factor on expansion, the golden ratio, 1.618034
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
data, keepGoing
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
maxIterations
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
DEFAULT_ITERATION, iteration
 
Constructor Summary
RootBracketExpander()
          Creates a new instance of RootBracketExpander
 
Method Summary
protected  void cleanupAlgorithm()
          Called to clean up the learning algorithm's state after learning has finished.
 LineBracket getBracket()
          Getter for bracket.
 double getInitialGuess()
          Getter for initialGuess.
 LineBracket getResult()
          Gets the current result of the algorithm.
protected  boolean initializeAlgorithm()
          Called to initialize the learning algorithm's state based on the data that is stored in the data field.
 boolean isResultValid()
          Indicates whether or not the algorithm results are in a consistent state or not.
protected  void setBracket(LineBracket bracket)
          Setter for bracket.
 void setInitialGuess(double initialGuess)
          Sets the initial guess of the root location.
protected  boolean step()
          Called to take a single step of the learning algorithm.
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
clone, getData, getKeepGoing, learn, setData, setKeepGoing, stop
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
getMaxIterations, setMaxIterations
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 
Methods inherited from interface gov.sandia.cognition.algorithm.AnytimeAlgorithm
getMaxIterations, setMaxIterations
 
Methods inherited from interface gov.sandia.cognition.algorithm.IterativeAlgorithm
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
 
Methods inherited from interface gov.sandia.cognition.algorithm.StoppableAlgorithm
stop
 

Field Detail

SCALE_FACTOR

public static final double SCALE_FACTOR
Default scale factor on expansion, the golden ratio, 1.618034

See Also:
Constant Field Values

DEFAULT_MAX_ITERATIONS

public static final int DEFAULT_MAX_ITERATIONS
Default max iterations, 100

See Also:
Constant Field Values

DEFAULT_INITIAL_GUESS

public static final double DEFAULT_INITIAL_GUESS
Default initial guess, 0.0

See Also:
Constant Field Values
Constructor Detail

RootBracketExpander

public RootBracketExpander()
Creates a new instance of RootBracketExpander

Method Detail

initializeAlgorithm

protected boolean initializeAlgorithm()
Description copied from class: AbstractAnytimeBatchLearner
Called to initialize the learning algorithm's state based on the data that is stored in the data field. The return value indicates if the algorithm can be run or not based on the initialization.

Specified by:
initializeAlgorithm in class AbstractAnytimeBatchLearner<Evaluator<Double,Double>,LineBracket>
Returns:
True if the learning algorithm can be run and false if it cannot.

step

protected boolean step()
Description copied from class: AbstractAnytimeBatchLearner
Called to take a single step of the learning algorithm.

Specified by:
step in class AbstractAnytimeBatchLearner<Evaluator<Double,Double>,LineBracket>
Returns:
True if another step can be taken and false it the algorithm should halt.

cleanupAlgorithm

protected void cleanupAlgorithm()
Description copied from class: AbstractAnytimeBatchLearner
Called to clean up the learning algorithm's state after learning has finished.

Specified by:
cleanupAlgorithm in class AbstractAnytimeBatchLearner<Evaluator<Double,Double>,LineBracket>

getResult

public LineBracket getResult()
Description copied from interface: AnytimeAlgorithm
Gets the current result of the algorithm.

Specified by:
getResult in interface AnytimeAlgorithm<LineBracket>
Returns:
Current result of the algorithm.

isResultValid

public boolean isResultValid()
Description copied from interface: StoppableAlgorithm
Indicates whether or not the algorithm results are in a consistent state or not. A StoppableAlgorithm may not always be able to stop in a manner that makes its results valid. This method is used to check whether the results are in a consistent state or not.

Specified by:
isResultValid in interface StoppableAlgorithm
Overrides:
isResultValid in class AbstractAnytimeAlgorithm<LineBracket>
Returns:
True if the results of the algorithm are in valid state and false if they are not valid.

getInitialGuess

public double getInitialGuess()
Getter for initialGuess.

Returns:
Initial guess of the root's location.

setInitialGuess

public void setInitialGuess(double initialGuess)
Description copied from interface: RootBracketer
Sets the initial guess of the root location.

Specified by:
setInitialGuess in interface RootBracketer
Parameters:
initialGuess - Initial guess of the root location.

getBracket

public LineBracket getBracket()
Getter for bracket.

Returns:
Bracket on the root location.

setBracket

protected void setBracket(LineBracket bracket)
Setter for bracket.

Parameters:
bracket - Bracket on the root location.