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

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

public class LineSearchNDDifferentiable
extends java.lang.Object
implements OptimizerNDContinuousDifferentiable

Uses Diffentiable 1D optimizers to optimize a Differentiable 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
LineSearchNDDifferentiable()
          Default constructor.
LineSearchNDDifferentiable(Optimizer1DContinuousDifferentiable alg)
          Constructor to specify what 1D optimizer to use.
LineSearchNDDifferentiable(Optimizer1DContinuousDifferentiable alg, int maxIter)
          Contructor 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(OptimizableNDContinuousDifferentiable function)
          Initialize the optimizer with the Differentiable ND function
 void initialize(OptimizableNDContinuousDifferentiable function, double[] init)
          Initialize the optimizer with the ND Differentiable 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

LineSearchNDDifferentiable

public LineSearchNDDifferentiable()
Default constructor. Uses NewtonMethod1D as the default method


LineSearchNDDifferentiable

public LineSearchNDDifferentiable(Optimizer1DContinuousDifferentiable alg)
Constructor to specify what 1D optimizer to use.

Parameters:
alg - your Optimizer1DContinuousDifferentiable algorithm

LineSearchNDDifferentiable

public LineSearchNDDifferentiable(Optimizer1DContinuousDifferentiable alg,
                                  int maxIter)
Contructor to specify optimizer and maximum iterations

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

setTolerance

public void setTolerance(double t)
Sets the tolerance. Default is 1e-5.

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 OptimizerNDContinuousDifferentiable
Returns:
the extrema array of where the extrema is

getIterations

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

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

initialize

public void initialize(OptimizableNDContinuousDifferentiable function)
Initialize the optimizer with the Differentiable ND function

Specified by:
initialize in interface OptimizerNDContinuousDifferentiable
Parameters:
function - your OptimizableNDContinuousDifferentiable function

initialize

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

Parameters:
function - your OptimizableNDContinuousDifferentiable function
init - starting point

optimize

public boolean optimize(boolean findMinima)
Optimizes the function

Specified by:
optimize in interface OptimizerNDContinuousDifferentiable
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 OptimizerNDContinuousDifferentiable
Returns:
string of the status message