edu.jhu.bme.smile.commons.optimize
Class LineSearchND

java.lang.Object
  extended by edu.jhu.bme.smile.commons.optimize.LineSearchND
All Implemented Interfaces:
OptimizerNDContinuous

public class LineSearchND
extends java.lang.Object
implements OptimizerNDContinuous

Uses 1D optimizers to optimize an ND function. It optimizes in one dimension at a time. Once the extrema has been found in one dimension, it goes onto the next dimension and optimizes that one. It keeps changing dimensions until all of them converge to one extrema.

Author:
Hanlin Wan

Constructor Summary
LineSearchND()
          Default constructor.
LineSearchND(Optimizer1DContinuous alg)
          Constructor to specify what 1D optimizer to use.
LineSearchND(Optimizer1DContinuous alg, int maxIter)
          Constructor to specify optimizer and maximum iterations
 
Method Summary
 double[] getExtrema()
          Gets the extrema that was found
 int getIterations()
          Gets the number of iterations done.
 java.util.ArrayList<double[]> getLog()
          Gets the logged data
 void initialize(OptimizableNDContinuous function)
          Initialize the optimizer with the ND function.
 void initialize(OptimizableNDContinuous function, double[] init)
          Initialize the optimizer with the ND function.
 void logData(boolean turnOn, int maxSteps)
          Turns on logging for each iteration of the optimization.
 boolean optimize(boolean findMinima)
          Optimizes the function
 void setTolerance(double t)
          Sets the tolerance.
 java.lang.String statusMessage()
          Gets the status message from the optimizing process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineSearchND

public LineSearchND()
Default constructor. Uses BrentMethod1D as the default method


LineSearchND

public LineSearchND(Optimizer1DContinuous alg)
Constructor to specify what 1D optimizer to use.

Parameters:
alg - your Optimizer1DContinuous algorithm

LineSearchND

public LineSearchND(Optimizer1DContinuous alg,
                    int maxIter)
Constructor to specify optimizer and maximum iterations

Parameters:
alg - your Optimizer1DContinuous algorithm
maxIter - maximum number of iterations
Method Detail

setTolerance

public void setTolerance(double t)
Sets the tolerance.

Parameters:
t - tolerance

logData

public void logData(boolean turnOn,
                    int maxSteps)
Turns on logging for each iteration of the optimization.

Parameters:
turnOn - true if logging, false if not
maxSteps - maximum number of steps to log

getLog

public java.util.ArrayList<double[]> getLog()
Gets the logged data

Returns:
array of logged data

getExtrema

public double[] getExtrema()
Gets the extrema that was found

Specified by:
getExtrema in interface OptimizerNDContinuous
Returns:
the extrema array of where the extrema is

getIterations

public int getIterations()
Gets the number of iterations done.

Specified by:
getIterations in interface OptimizerNDContinuous
Returns:
number of iterations

initialize

public void initialize(OptimizableNDContinuous function)
Initialize the optimizer with the ND function.

Specified by:
initialize in interface OptimizerNDContinuous
Parameters:
function - your OptimizableNDContinuous function

initialize

public void initialize(OptimizableNDContinuous function,
                       double[] init)
Initialize the optimizer with the ND function. Sets your initial starting point.

Parameters:
function - your OptimizableNDContinuous function
init - starting point

optimize

public boolean optimize(boolean findMinima)
Optimizes the function

Specified by:
optimize in interface OptimizerNDContinuous
Parameters:
findMinima - true if you want to find the minimum, false if you want to find the maximum
Returns:
true if extrema was found successfully, false otherwise

statusMessage

public java.lang.String statusMessage()
Gets the status message from the optimizing process

Specified by:
statusMessage in interface OptimizerNDContinuous
Returns:
string of the status message