bpp-core3  3.0.0
bpp::FunctionStopCondition Class Reference

Stop condition on function value. More...

#include <Bpp/Numeric/Function/OptimizationStopCondition.h>

+ Inheritance diagram for bpp::FunctionStopCondition:
+ Collaboration diagram for bpp::FunctionStopCondition:

Public Member Functions

 FunctionStopCondition (const OptimizerInterface *optimizer)
 
 FunctionStopCondition (const OptimizerInterface *optimizer, double tolerance)
 
 FunctionStopCondition (const OptimizerInterface *optimizer, int burnin)
 
 FunctionStopCondition (const OptimizerInterface *optimizer, double tolerance, int burnin)
 
virtual ~FunctionStopCondition ()
 
FunctionStopConditionclone () const
 Create a copy of this object and send a pointer to it. More...
 
void init ()
 Initialize the condition. More...
 
bool isToleranceReached () const
 Tell if the we reached the desired tolerance with a given new set of estimates. More...
 
double getCurrentTolerance () const
 Get the current tolerance. More...
 
const OptimizerInterfacegetOptimizer () const
 
void setOptimizer (const OptimizerInterface *optimizer)
 Set the optimizer attached to this instance. More...
 
void setTolerance (double tolerance)
 Set the tolerance parameter. More...
 
double getTolerance () const
 Get the tolerance parameter. More...
 
virtual void resetCounter ()
 
virtual void setBurnin (int burnin)
 
virtual int getBurnin () const
 

Protected Attributes

const OptimizerInterfaceoptimizer_
 
double tolerance_
 
double callCount_
 Count the number of times the isToleranceReached() function has been called. More...
 
int burnin_
 

Private Attributes

double lastFunctionValue_
 The last value of the function. More...
 
double newFunctionValue_
 The new value of the function. More...
 

Detailed Description

Stop condition on function value.

This stops the optimization when $|f\left(\left\{\lambda_{i,t}\right\}\right)-f\left(\left\{\lambda_{i,t-1}\right\}\right)| \leq \mbox{tolerance}$, where $f\left(\left\{\lambda_{i, t}\right\}\right)$ is the value of the function given the parameter values at iteration $t$, and $f\left(\left\{\lambda_{i, t-1}\right\}\right)$ is the value of the function given the parameter velues at iteration $t-1$.

Definition at line 234 of file OptimizationStopCondition.h.

Constructor & Destructor Documentation

◆ FunctionStopCondition() [1/4]

FunctionStopCondition::FunctionStopCondition ( const OptimizerInterface optimizer)

Definition at line 133 of file OptimizationStopCondition.cpp.

References init().

◆ FunctionStopCondition() [2/4]

FunctionStopCondition::FunctionStopCondition ( const OptimizerInterface optimizer,
double  tolerance 
)

Definition at line 142 of file OptimizationStopCondition.cpp.

References init().

◆ FunctionStopCondition() [3/4]

FunctionStopCondition::FunctionStopCondition ( const OptimizerInterface optimizer,
int  burnin 
)

Definition at line 152 of file OptimizationStopCondition.cpp.

References init().

◆ FunctionStopCondition() [4/4]

FunctionStopCondition::FunctionStopCondition ( const OptimizerInterface optimizer,
double  tolerance,
int  burnin 
)

Definition at line 162 of file OptimizationStopCondition.cpp.

References init().

◆ ~FunctionStopCondition()

FunctionStopCondition::~FunctionStopCondition ( )
virtual

Definition at line 173 of file OptimizationStopCondition.cpp.

Member Function Documentation

◆ clone()

FunctionStopCondition* bpp::FunctionStopCondition::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::OptimizationStopCondition.

Definition at line 260 of file OptimizationStopCondition.h.

◆ getBurnin()

virtual int bpp::AbstractOptimizationStopCondition::getBurnin ( ) const
inlinevirtualinherited

Definition at line 177 of file OptimizationStopCondition.h.

◆ getCurrentTolerance()

double FunctionStopCondition::getCurrentTolerance ( ) const
virtual

Get the current tolerance.

This is computed from the last check performed. Initially, it is equal to the tolerance parameter.

Returns
The current tolerance achieved.

Implements bpp::OptimizationStopCondition.

Definition at line 202 of file OptimizationStopCondition.cpp.

References bpp::AbstractOptimizationStopCondition::burnin_, bpp::AbstractOptimizationStopCondition::callCount_, lastFunctionValue_, newFunctionValue_, and bpp::AbstractOptimizationStopCondition::tolerance_.

◆ getOptimizer()

const OptimizerInterface* bpp::AbstractOptimizationStopCondition::getOptimizer ( ) const
inlinevirtualinherited
Returns
The optimizer to which this instance belongs to.

Implements bpp::OptimizationStopCondition.

Definition at line 163 of file OptimizationStopCondition.h.

◆ getTolerance()

double bpp::AbstractOptimizationStopCondition::getTolerance ( ) const
inlinevirtualinherited

Get the tolerance parameter.

Returns
The tolerance parameter.

Implements bpp::OptimizationStopCondition.

Definition at line 169 of file OptimizationStopCondition.h.

Referenced by bpp::GoldenSectionSearch::GSSStopCondition::isToleranceReached().

◆ init()

◆ isToleranceReached()

bool FunctionStopCondition::isToleranceReached ( ) const
virtual

Tell if the we reached the desired tolerance with a given new set of estimates.

The new parameter list is compared to the last estimates, and the lastParameterEstimates list is actulaized with the newParameters list.

Returns
True if the tolerance level is reached.

Implements bpp::OptimizationStopCondition.

Definition at line 189 of file OptimizationStopCondition.cpp.

References bpp::AbstractOptimizationStopCondition::burnin_, bpp::AbstractOptimizationStopCondition::callCount_, bpp::OptimizerInterface::getFunctionValue(), lastFunctionValue_, newFunctionValue_, bpp::AbstractOptimizationStopCondition::optimizer_, and bpp::AbstractOptimizationStopCondition::tolerance_.

◆ resetCounter()

virtual void bpp::AbstractOptimizationStopCondition::resetCounter ( )
inlinevirtualinherited

Definition at line 173 of file OptimizationStopCondition.h.

◆ setBurnin()

virtual void bpp::AbstractOptimizationStopCondition::setBurnin ( int  burnin)
inlinevirtualinherited

Definition at line 175 of file OptimizationStopCondition.h.

◆ setOptimizer()

void bpp::AbstractOptimizationStopCondition::setOptimizer ( const OptimizerInterface optimizer)
inlinevirtualinherited

Set the optimizer attached to this instance.

Parameters
optimizerThe optimizer to which this instance belongs to.

Implements bpp::OptimizationStopCondition.

Definition at line 165 of file OptimizationStopCondition.h.

◆ setTolerance()

void bpp::AbstractOptimizationStopCondition::setTolerance ( double  tolerance)
inlinevirtualinherited

Set the tolerance parameter.

Parameters
toleranceThe tolerance parameter.

Implements bpp::OptimizationStopCondition.

Definition at line 167 of file OptimizationStopCondition.h.

Member Data Documentation

◆ burnin_

◆ callCount_

◆ lastFunctionValue_

double bpp::FunctionStopCondition::lastFunctionValue_
mutableprivate

The last value of the function.

This is used by the isToleranceReached() method.

Definition at line 243 of file OptimizationStopCondition.h.

Referenced by getCurrentTolerance(), and isToleranceReached().

◆ newFunctionValue_

double bpp::FunctionStopCondition::newFunctionValue_
mutableprivate

The new value of the function.

This is used by the isToleranceReached() method.

Definition at line 250 of file OptimizationStopCondition.h.

Referenced by getCurrentTolerance(), init(), and isToleranceReached().

◆ optimizer_

◆ tolerance_


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