public class ConjugateGradient extends java.lang.Object implements Optimizer
Modifier and Type | Class and Description |
---|---|
static class |
ConjugateGradient.ProgressLevel
Enumeration of the different levels of output
|
static class |
ConjugateGradient.Update
Enumeration of the different update methods
|
Optimizer.OptimizerException
Constructor and Description |
---|
ConjugateGradient()
Constructor that uses default values for rigour (1e-7), update method
(BEALE_SORENSON_HESTENES_STIEFEL) and output (none)
|
ConjugateGradient(ConjugateGradient.ProgressLevel progressLevel)
Constructor that uses the given output level but default values for rigour (1e-7)
and update method (BEALE_SORENSON_HESTENES_STIEFEL)
|
ConjugateGradient(ConjugateGradient.Update update)
Constructor that uses the givemn update method and default values for rigour (1e-7)
and output (none)
|
ConjugateGradient(ConjugateGradient.Update update,
ConjugateGradient.ProgressLevel progressLevel)
Constructor that uses the given update method
(BEALE_SORENSON_HESTENES_STIEFEL) and output (none) but
the default values for rigour (1e-7),
|
ConjugateGradient(double tol)
Constructor that uses the given value for rigour and default values for update method
(BEALE_SORENSON_HESTENES_STIEFEL) and output (none)
|
ConjugateGradient(double tol,
ConjugateGradient.ProgressLevel progressLevel)
Constructor that uses the given tolerance and output level but the default
update method (BEALE_SORENSON_HESTENES_STIEFEL)
|
ConjugateGradient(double tol,
ConjugateGradient.Update update)
Constructor that uses the given tolerance and update method but
the default output (none)
|
ConjugateGradient(double tol,
ConjugateGradient.Update update,
ConjugateGradient.ProgressLevel progressLevel)
Constructor that uses the given values for rigour, update method
and output
|
Modifier and Type | Method and Description |
---|---|
<R extends Likelihood> |
maximise(Optimizable<R> c,
Parameters p)
Maximises the likelihood, logging to screen.
|
<R extends Likelihood> |
maximise(Optimizable<R> c,
Parameters p,
java.io.File log)
Maximises the likelihood, logging to a file.
|
<R extends Likelihood> |
restart(Optimizable<R> l,
java.io.File checkPoint)
Maximises the likelihood starting from a checkpoint file (see
Optimizer.setCheckPointFile(java.io.File) ,
logging to the screen. |
<R extends Likelihood> |
restart(Optimizable<R> 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).
|
void |
setMaximumRunTime(int num,
java.util.concurrent.TimeUnit unit)
Set a maximum time the optimiser should run for
|
public ConjugateGradient()
public ConjugateGradient(double tol)
tol
- The toelrance to usepublic ConjugateGradient(ConjugateGradient.Update update)
update
- The update method to usepublic ConjugateGradient(double tol, ConjugateGradient.Update update)
tol
- The tolerance to useupdate
- The update method to usepublic ConjugateGradient(ConjugateGradient.ProgressLevel progressLevel)
progressLevel
- The output level to usepublic ConjugateGradient(double tol, ConjugateGradient.ProgressLevel progressLevel)
tol
- The tolerance to useprogressLevel
- The output level to usepublic ConjugateGradient(ConjugateGradient.Update update, ConjugateGradient.ProgressLevel progressLevel)
update
- the update methodprogressLevel
- The output level to usepublic ConjugateGradient(double tol, ConjugateGradient.Update update, ConjugateGradient.ProgressLevel progressLevel)
tol
- The tolerance to useupdate
- The update method to useprogressLevel
- The output level to usepublic <R extends Likelihood> R maximise(Optimizable<R> c, Parameters p) throws GeneralException
Optimizer
maximise
in interface Optimizer
R
- The type returned by the calculatorc
- The likelihood calculatorp
- The parameters to maximise. Parameters are modified.GeneralException
- When there is a problem in finding an optimisable solution.public <R extends Likelihood> R maximise(Optimizable<R> c, Parameters p, java.io.File log) throws GeneralException
Optimizer
maximise
in interface Optimizer
R
- The type returned by the calculatorc
- The likelihood calculatorp
- The parameters to maximise. Parameters are modified.log
- The log fileGeneralException
- When there is a problem in finding an optimisable solutionpublic <R extends Likelihood> R restart(Optimizable<R> l, java.io.File checkPoint) throws GeneralException
Optimizer
Optimizer.setCheckPointFile(java.io.File)
,
logging to the screen. Logging level should be set in the constructor of implementing classes.restart
in interface Optimizer
R
- The type returned by the calculatorl
- The likelihood calculatorcheckPoint
- The checkpoint fileGeneralException
- When there is a problem in finding an optimisable solutionpublic <R extends Likelihood> R restart(Optimizable<R> l, java.io.File checkPoint, java.io.File log) throws GeneralException
Optimizer
Optimizer.setCheckPointFile(java.io.File)
,
logging to a file. Logging level should be set in the constructor of implementing classes.restart
in interface Optimizer
R
- The type returned by the calculatorl
- The likelihood calculatorcheckPoint
- The checkpoint filelog
- The log fileGeneralException
- When there is a problem in finding an optimisable solutionpublic void setCheckPointFile(java.io.File checkPoint) throws Optimizer.OptimizerException
Optimizer
Optimizer.setCheckPointFrequency(int, java.util.concurrent.TimeUnit)
).
This checkpoint file can then be used to restart the optimiser from this
state. Can be useful if optimisation is likely to take a long and the
process could be stopped for some reason.setCheckPointFile
in interface Optimizer
checkPoint
- The chekpoint file.Optimizer.OptimizerException
- Thrown if the optomiser
does not implement checkpoints.public void setCheckPointFrequency(int num, java.util.concurrent.TimeUnit unit) throws Optimizer.OptimizerException
Optimizer
setCheckPointFrequency
in interface Optimizer
num
- The number of time units that should pass between checkpoint
writes.unit
- The time unitOptimizer.OptimizerException
- Thrown if the optomiser
does not implement checkpoints.public void setMaximumRunTime(int num, java.util.concurrent.TimeUnit unit) throws Optimizer.OptimizerException
Optimizer
setMaximumRunTime
in interface Optimizer
num
- The number of time units that should pass between checkpoint
writes.unit
- The time unitOptimizer.OptimizerException
- Thrown if the optimiser
does not implement a maximum run time.