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

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

public class DownhillSimplexND
extends java.lang.Object
implements OptimizerNDContinuous

This optimizer uses the Nelder-Mead downhill simplex method to optimize a function. You can input an initial guess which may make optimizations faster. Otherwise, a default initial guess is supplied. Adapted from Numerical Recipes (Press), 3rd Edition.

Author:
Hanlin Wan

Constructor Summary
DownhillSimplexND()
          Default constructor
DownhillSimplexND(int maxIter)
          Constructor to set maximum number of iterations to run
 
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)
          Default initialize method.
 void initialize(OptimizableNDContinuous function, double[] center, double rad)
          Initializes the optimizer with a function and an initial guess.
 void logData(boolean turnOn, int maxSteps)
          Turns on logging for each iteration of the optimization.
 boolean optimize(boolean findMinima)
          Optimizes the function
 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

DownhillSimplexND

public DownhillSimplexND()
Default constructor


DownhillSimplexND

public DownhillSimplexND(int maxIter)
Constructor to set maximum number of iterations to run

Parameters:
maxIter - maximum number of iterations
Method Detail

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

initialize

public void initialize(OptimizableNDContinuous function,
                       double[] center,
                       double rad)
Initializes the optimizer with a function and an initial guess. Guessing incorrectly may affect the accuracy and/or speed of the calculated extrema.

Parameters:
function - your OptimizableNDContinuous function that is being optimized
center - the approximate location of the extrema
rad - approximate radius from center where the extrema lies

initialize

public void initialize(OptimizableNDContinuous function)
Default initialize method. It will supply an initial guess depending on the domain given.

Specified by:
initialize in interface OptimizerNDContinuous
Parameters:
function - your OptimizableNDContinuous function that is being optimized

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

getIterations

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

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

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