SuPReMo  0.1.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Optimiser Class Referenceabstract

#include <Optimiser.h>

Inheritance diagram for Optimiser:
Inheritance graph
[legend]

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 ()
 
PrecisionTypeGetBestPoint ()
 
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< ObjectiveFunctionobjectiveFunction
 Shared pointer to the objective function. More...
 
PrecisionTypegradient
 The array xi in numerical recipes. More...
 
PrecisionTypecurrentPoint
 The current point, p in numerical recipes. More...
 
PrecisionTypebestPoint
 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...
 

Detailed Description

Base class that defines the basic optimiser functionality. Has to be derived and implemented into a working optimiser class.

Member Typedef Documentation

◆ PrecisionType

typedef float Optimiser::PrecisionType

Constructor & Destructor Documentation

◆ Optimiser()

Optimiser::Optimiser ( )

Constructor

◆ ~Optimiser()

Optimiser::~Optimiser ( )
virtual

Destructor

Member Function Documentation

◆ GetBestObjectiveFunctionValue()

Optimiser::PrecisionType Optimiser::GetBestObjectiveFunctionValue ( )

Return the best objecitve function value

◆ GetBestPoint()

Optimiser::PrecisionType * Optimiser::GetBestPoint ( )

Return the pointer to the point which resulted in the best functcion value.

◆ GetInitialObjectiveFunctionValue()

Optimiser::PrecisionType Optimiser::GetInitialObjectiveFunctionValue ( )

Return the initial objecitve function value

◆ Initialise()

virtual void Optimiser::Initialise ( )
pure virtual

Initialise the optimiser. Needs to be implemented by inheriting class.

Implemented in ConjugateGradientOptimiser.

◆ MoveCurrentPointAlongGradient()

void Optimiser::MoveCurrentPointAlongGradient ( PrecisionType  stepSize)
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} \]

Todo:
Make parallel

◆ Optimise()

virtual void Optimiser::Optimise ( PrecisionType startingPoint)
pure virtual

Initiate the optimisation

Parameters
startingPointPoint where to start the optimisation from. Can be null-pointer to start form zero.

Implemented in ConjugateGradientOptimiser.

◆ PerformLineSearch()

void Optimiser::PerformLineSearch ( PrecisionType  maxLength,
PrecisionType  smallLength,
PrecisionType startLength 
)
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.

Parameters
maxLengthThe maximum size to which the line-search steps are limited.
smallLengthThe length below which no more line-search steps are performed.
startLengthThe initial step-size. Will be updated with the total stpe size which can be utilised for consecutive line-searches (i.e. with updated gradients).

◆ ResetCurrentIterationNumber()

void Optimiser::ResetCurrentIterationNumber ( )

Set the current iteration number to zero.

◆ SetMaxIterations()

void Optimiser::SetMaxIterations ( unsigned int  maxIterations)
inline

Set the number of iterations

Parameters
maxIterationsThe maximum number of iterations performed.

◆ SetObjectiveFunction()

void Optimiser::SetObjectiveFunction ( std::shared_ptr< ObjectiveFunction > &  objectiveFunctionIn)

Set the objective function which is to be optimised

Parameters
objectiveFunctionInShared pointer to the objective function

◆ SetOutputIntermediateGradientFolder()

void Optimiser::SetOutputIntermediateGradientFolder ( const std::string &  outputFolderIn,
const std::string &  outPrefix 
)
inline

◆ SetPreviouslyEvaluatedObjectiveFunctionValue()

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.

Member Data Documentation

◆ bestObjectiveFunctionValue

PrecisionType Optimiser::bestObjectiveFunctionValue
protected

The best objective function value achieved.

◆ bestPoint

PrecisionType* Optimiser::bestPoint
protected

The best point achieved, p in numerical recipes.

◆ currentIterationNumber

unsigned int Optimiser::currentIterationNumber
protected

Tracker of the current iteration number.

◆ currentObjectiveFunctionValue

PrecisionType Optimiser::currentObjectiveFunctionValue
protected

The current objective function value corresponding to the current iteration.

◆ currentPoint

PrecisionType* Optimiser::currentPoint
protected

The current point, p in numerical recipes.

◆ gradient

PrecisionType* Optimiser::gradient
protected

The array xi in numerical recipes.

◆ initialObjectiveFunctionValue

PrecisionType Optimiser::initialObjectiveFunctionValue
protected

The objective function value at the starting point of the optimisation.

◆ maxLineSearchStepSize

PrecisionType Optimiser::maxLineSearchStepSize
protected

The maximum step size used for the line-search. Has to be initialised in derived class.

◆ maxNumberOfIterations

unsigned int Optimiser::maxNumberOfIterations
protected

The maximum number of allowed iterations.

◆ maxNumberOfLineIterations

const unsigned int Optimiser::maxNumberOfLineIterations
protected

The maximum number of iterations used for the line-serach along the gradient.

◆ minLineSearchStepSize

PrecisionType Optimiser::minLineSearchStepSize
protected

The minimum step size used for the line-search. Has to be initialised in derived class.

◆ numberOfDOFs

unsigned int Optimiser::numberOfDOFs
protected

The number of degrees of freedom.

◆ numberOfIterationsPerformed

unsigned int Optimiser::numberOfIterationsPerformed
protected

The total number of iterations performed.

◆ objectiveFunction

std::shared_ptr<ObjectiveFunction> Optimiser::objectiveFunction
protected

Shared pointer to the objective function.

◆ outputIntermediateGradientFolder

std::string Optimiser::outputIntermediateGradientFolder
protected

Folder to which the intermediated objective function gradients will be saved.

◆ outputIntermediateGradientPrefix

std::string Optimiser::outputIntermediateGradientPrefix
protected

String holding additional information to differentiate the output from different levels.

◆ preEvaluatedObjectiveFunctionValue

PrecisionType Optimiser::preEvaluatedObjectiveFunctionValue
protected

A pre-calculated objective function value that will be used during the optimisation if usePreEvaluatedEvaluatedObjectiveFunctionValue is set to true.

◆ usePreEvaluatedEvaluatedObjectiveFunctionValue

bool Optimiser::usePreEvaluatedEvaluatedObjectiveFunctionValue
protected

Indicator if the first objective function value calculation can be skipped.


The documentation for this class was generated from the following files: