![]() |
SuPReMo
0.1.1
|
#include <Optimiser.h>
Public Types | |
typedef float | PrecisionType |
Public Member Functions | |
Optimiser () | |
virtual | ~Optimiser () |
void | SetObjectiveFunction (std::shared_ptr< ObjectiveFunction > &objectiveFunctionIn) |
virtual void | Optimise (PrecisionType *startingPoint)=0 |
virtual void | Initialise ()=0 |
PrecisionType | GetBestObjectiveFunctionValue () |
PrecisionType | GetInitialObjectiveFunctionValue () |
PrecisionType * | GetBestPoint () |
void | ResetCurrentIterationNumber () |
void | SetMaxIterations (unsigned int maxIterations) |
void | SetPreviouslyEvaluatedObjectiveFunctionValue (PrecisionType objectiveFunctionValue) |
void | SetOutputIntermediateGradientFolder (const std::string &outputFolderIn, const std::string &outPrefix) |
Protected Member Functions | |
void | MoveCurrentPointAlongGradient (PrecisionType stepSize) |
void | PerformLineSearch (PrecisionType maxLength, PrecisionType smallLength, PrecisionType &startLength) |
Protected Attributes | |
PrecisionType | currentObjectiveFunctionValue |
The current objective function value corresponding to the current iteration. More... | |
PrecisionType | bestObjectiveFunctionValue |
The best objective function value achieved. More... | |
PrecisionType | initialObjectiveFunctionValue |
The objective function value at the starting point of the optimisation. More... | |
unsigned int | currentIterationNumber |
Tracker of the current iteration number. More... | |
unsigned int | maxNumberOfIterations |
The maximum number of allowed iterations. More... | |
const unsigned int | maxNumberOfLineIterations |
The maximum number of iterations used for the line-serach along the gradient. More... | |
PrecisionType | maxLineSearchStepSize |
The maximum step size used for the line-search. Has to be initialised in derived class. More... | |
PrecisionType | minLineSearchStepSize |
The minimum step size used for the line-search. Has to be initialised in derived class. More... | |
unsigned int | numberOfIterationsPerformed |
The total number of iterations performed. More... | |
unsigned int | numberOfDOFs |
The number of degrees of freedom. More... | |
std::shared_ptr< ObjectiveFunction > | objectiveFunction |
Shared pointer to the objective function. More... | |
PrecisionType * | gradient |
The array xi in numerical recipes. More... | |
PrecisionType * | currentPoint |
The current point, p in numerical recipes. More... | |
PrecisionType * | bestPoint |
The best point achieved, p in numerical recipes. More... | |
PrecisionType | preEvaluatedObjectiveFunctionValue |
A pre-calculated objective function value that will be used during the optimisation if usePreEvaluatedEvaluatedObjectiveFunctionValue is set to true. More... | |
bool | usePreEvaluatedEvaluatedObjectiveFunctionValue |
Indicator if the first objective function value calculation can be skipped. More... | |
std::string | outputIntermediateGradientFolder |
Folder to which the intermediated objective function gradients will be saved. More... | |
std::string | outputIntermediateGradientPrefix |
String holding additional information to differentiate the output from different levels. More... | |
Base class that defines the basic optimiser functionality. Has to be derived and implemented into a working optimiser class.
typedef float Optimiser::PrecisionType |
Optimiser::Optimiser | ( | ) |
Constructor
|
virtual |
Destructor
Optimiser::PrecisionType Optimiser::GetBestObjectiveFunctionValue | ( | ) |
Return the best objecitve function value
Optimiser::PrecisionType * Optimiser::GetBestPoint | ( | ) |
Return the pointer to the point which resulted in the best functcion value.
Optimiser::PrecisionType Optimiser::GetInitialObjectiveFunctionValue | ( | ) |
Return the initial objecitve function value
|
pure virtual |
Initialise the optimiser. Needs to be implemented by inheriting class.
Implemented in ConjugateGradientOptimiser.
|
inlineprotected |
Move the current point so that it moves by step size from the best point into the direction of the gradient.
\[ \mathbf{p}_\mathrm{cur} = \mathbf{p}_\mathrm{best} + s \cdot \nabla\mathbf{f} \]
|
pure virtual |
Initiate the optimisation
startingPoint | Point where to start the optimisation from. Can be null-pointer to start form zero. |
Implemented in ConjugateGradientOptimiser.
|
protected |
Perform a line search. Walk along the gradient direction with increasing step sizes. If no more improvements are found, continue with halved step sizes until the minimum size was reached, or maximum number of maxNumberOfLineIterations was exceeded.
maxLength | The maximum size to which the line-search steps are limited. |
smallLength | The length below which no more line-search steps are performed. |
startLength | The initial step-size. Will be updated with the total stpe size which can be utilised for consecutive line-searches (i.e. with updated gradients). |
void Optimiser::ResetCurrentIterationNumber | ( | ) |
Set the current iteration number to zero.
|
inline |
Set the number of iterations
maxIterations | The maximum number of iterations performed. |
void Optimiser::SetObjectiveFunction | ( | std::shared_ptr< ObjectiveFunction > & | objectiveFunctionIn | ) |
Set the objective function which is to be optimised
objectiveFunctionIn | Shared pointer to the objective function |
|
inline |
void Optimiser::SetPreviouslyEvaluatedObjectiveFunctionValue | ( | PrecisionType | objectiveFunctionValue | ) |
Set a previously evaluated objective function value such that the first value calculation can be skipped during the optimisation. Note this value has to be the same as for the starting point of the optimisation. No additional checks are being performed internally.
|
protected |
The best objective function value achieved.
|
protected |
The best point achieved, p in numerical recipes.
|
protected |
Tracker of the current iteration number.
|
protected |
The current objective function value corresponding to the current iteration.
|
protected |
The current point, p in numerical recipes.
|
protected |
The array xi in numerical recipes.
|
protected |
The objective function value at the starting point of the optimisation.
|
protected |
The maximum step size used for the line-search. Has to be initialised in derived class.
|
protected |
The maximum number of allowed iterations.
|
protected |
The maximum number of iterations used for the line-serach along the gradient.
|
protected |
The minimum step size used for the line-search. Has to be initialised in derived class.
|
protected |
The number of degrees of freedom.
|
protected |
The total number of iterations performed.
|
protected |
Shared pointer to the objective function.
|
protected |
Folder to which the intermediated objective function gradients will be saved.
|
protected |
String holding additional information to differentiate the output from different levels.
|
protected |
A pre-calculated objective function value that will be used during the optimisation if usePreEvaluatedEvaluatedObjectiveFunctionValue is set to true.
|
protected |
Indicator if the first objective function value calculation can be skipped.