Optimizers
Class GoldenSection

java.lang.Object
  extended by Optimizers.GoldenSection
All Implemented Interfaces:
Optimizer

public class GoldenSection
extends java.lang.Object
implements Optimizer

Implements a golden section search for parameter optimisation. Each parameter is optimised in turn until the difference in likelihood falls below a set value. This value starts high and slowly decreased so as to not waste time highly optomizing one parameter while other parameters may be highly sub-optimal.

The amount of logging can be controlled as can the rigor used (the difference in likelihood when the search stops).

Version:
1.0

Nested Class Summary
static class GoldenSection.ProgressLevel
          Enumeration of the different levels of output
 
Nested classes/interfaces inherited from interface Optimizers.Optimizer
Optimizer.OptimizerException
 
Constructor Summary
GoldenSection()
          Constructor that uses default parameters for rigor and output level
GoldenSection(double rigor)
          Constructor which allows a user defined rigor
GoldenSection(double rigor, GoldenSection.ProgressLevel progresslevel)
          Constructor which allows a user defined rigor and output level
GoldenSection(GoldenSection.ProgressLevel progresslevel)
          Constrcutor which allows a user define output level
 
Method Summary
 Likelihood maximise(Calculator l, Parameters params)
          Maximises the likelihood, logging to screen.
 Likelihood maximise(Calculator l, Parameters params, java.io.File log)
          Maximises the likelihood, logging to a file.
 Likelihood restart(Calculator l, java.io.File checkPoint)
          Maximises the likelihood starting from a checkpoint file (see Optimizer.setCheckPointFile(java.io.File), logging to the screen.
 Likelihood restart(Calculator l, java.io.File checkPoint, java.io.File log)
          Maximises the likelihood starting from a checkpoint file (see Optimizer.setCheckPointFile(java.io.File), logging to a file.
 void setCheckPointFile(java.io.File checkPoint)
          Sets a checkpoint file.
 void setCheckPointFrequency(int num, java.util.concurrent.TimeUnit unit)
          Sets how often a checkpoint is saved (if a file has been set).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GoldenSection

public GoldenSection()
Constructor that uses default parameters for rigor and output level


GoldenSection

public GoldenSection(GoldenSection.ProgressLevel progresslevel)
Constrcutor which allows a user define output level

Parameters:
progresslevel - The output level

GoldenSection

public GoldenSection(double rigor)
Constructor which allows a user defined rigor

Parameters:
rigor - Rigor to be used

GoldenSection

public GoldenSection(double rigor,
                     GoldenSection.ProgressLevel progresslevel)
Constructor which allows a user defined rigor and output level

Parameters:
rigor - Rigor to be used
progresslevel - The output level
Method Detail

maximise

public Likelihood maximise(Calculator l,
                           Parameters params)
                    throws RateCategory.RateException,
                           Model.ModelException,
                           TreeException,
                           Parameters.ParameterException,
                           Parameters.ParameterException,
                           OutputException
Description copied from interface: Optimizer
Maximises the likelihood, logging to screen. Logging level sould be set in the constructor of implementing classes.

Specified by:
maximise in interface Optimizer
Parameters:
l - The likelihood calculator
params - The parameters to maximise. Parameters are modified.
Returns:
The maximised likelihood (in a structure that includes most intermediate likelihoods).
Throws:
RateCategory.RateException - Thrown if there is an issue with a rate category in the model (e.g. a badly formatted rate).
Model.ModelException - Thrown if there is a problem with the model (e.g. the rate categories differ in their states)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)
OutputException - Thrown if unable to write a checkpoint file

maximise

public Likelihood maximise(Calculator l,
                           Parameters params,
                           java.io.File log)
                    throws RateCategory.RateException,
                           Model.ModelException,
                           TreeException,
                           Parameters.ParameterException,
                           Parameters.ParameterException,
                           OutputException
Description copied from interface: Optimizer
Maximises the likelihood, logging to a file. Logging level sould be set in the constructor of implementing classes.

Specified by:
maximise in interface Optimizer
Parameters:
l - The likelihood calculator
params - The parameters to maximise. Parameters are modified.
log - The log file
Returns:
The maximised likelihood (in a structure that includes most intermediate likelihoods).
Throws:
RateCategory.RateException - Thrown if there is an issue with a rate category in the model (e.g. a badly formatted rate).
Model.ModelException - Thrown if there is a problem with the model (e.g. the rate categories differ in their states)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)
OutputException - Thrown if unable to write a checkpoint file

restart

public Likelihood restart(Calculator l,
                          java.io.File checkPoint)
                   throws RateCategory.RateException,
                          Model.ModelException,
                          TreeException,
                          Parameters.ParameterException,
                          Parameters.ParameterException,
                          InputException,
                          OutputException,
                          Optimizer.OptimizerException
Description copied from interface: Optimizer
Maximises the likelihood starting from a checkpoint file (see Optimizer.setCheckPointFile(java.io.File), logging to the screen. Logging level sould be set in the constructor of implementing classes.

Specified by:
restart in interface Optimizer
Parameters:
l - The likelihood calculator
checkPoint - The checkpoint file
Returns:
The maximised likelihood (in a structure that includes most intermediate likelihoods).
Throws:
RateCategory.RateException - Thrown if there is an issue with a rate category in the model (e.g. a badly formatted rate).
Model.ModelException - Thrown if there is a problem with the model (e.g. the rate categories differ in their states)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)
InputException - Thrown if there is a problem with the checkpoint file
OutputException - Thrown if unable to write a checkpoint file
Optimizer.OptimizerException - Thrown if optomizer is unable to restart from a checkpoint file

restart

public Likelihood restart(Calculator l,
                          java.io.File checkPoint,
                          java.io.File log)
                   throws RateCategory.RateException,
                          Model.ModelException,
                          TreeException,
                          Parameters.ParameterException,
                          Parameters.ParameterException,
                          InputException,
                          OutputException,
                          Optimizer.OptimizerException
Description copied from interface: Optimizer
Maximises the likelihood starting from a checkpoint file (see Optimizer.setCheckPointFile(java.io.File), logging to a file. Logging level sould be set in the constructor of implementing classes.

Specified by:
restart in interface Optimizer
Parameters:
l - The likelihood calculator
checkPoint - The checkpoint file
log - The log file
Returns:
The maximised likelihood (in a structure that includes most intermediate likelihoods).
Throws:
RateCategory.RateException - Thrown if there is an issue with a rate category in the model (e.g. a badly formatted rate).
Model.ModelException - Thrown if there is a problem with the model (e.g. the rate categories differ in their states)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)
InputException - Thrown if there is a problem with the checkpoint file
OutputException - Thrown if unable to write a checkpoint file
Optimizer.OptimizerException - Thrown if optomizer is unable to restart from a checkpoint file

setCheckPointFile

public void setCheckPointFile(java.io.File checkPoint)
                       throws Optimizer.OptimizerException
Description copied from interface: Optimizer
Sets a checkpoint file. If set will write a checkpoint file of the optimizers state at regular intervals (set by Optimizer.setCheckPointFrequency(int, java.util.concurrent.TimeUnit)). This checkpoint file can then be used to restart the optimizer from this state. Can be useful if optimization is likely to take a long and the process could be stopped for some reason.

Specified by:
setCheckPointFile in interface Optimizer
Parameters:
checkPoint - The chekpoint file.
Throws:
Optimizer.OptimizerException - Thrown if the optomizer does not implement checkpoints.

setCheckPointFrequency

public void setCheckPointFrequency(int num,
                                   java.util.concurrent.TimeUnit unit)
                            throws Optimizer.OptimizerException
Description copied from interface: Optimizer
Sets how often a checkpoint is saved (if a file has been set).

Specified by:
setCheckPointFrequency in interface Optimizer
Parameters:
num - The number of time units that should pass between checkpoint writes.
unit - The time unit
Throws:
Optimizer.OptimizerException - Thrown if the optomizer does not implement checkpoints.