ITK  5.4.0
Insight Toolkit
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members

#include <itkSingleValuedVnlCostFunctionAdaptor.h>

Detailed Description

This class is an Adaptor that allows to pass itk::SingleValuedCostFunctions to vnl_optimizers expecting a vnl_cost_function.

This class returns a single valued.

Definition at line 37 of file itkSingleValuedVnlCostFunctionAdaptor.h.

+ Inheritance diagram for itk::SingleValuedVnlCostFunctionAdaptor:
+ Collaboration diagram for itk::SingleValuedVnlCostFunctionAdaptor:

Public Types

using DerivativeType = SingleValuedCostFunction::DerivativeType
 
using InternalDerivativeType = vnl_vector< double >
 
using InternalMeasureType = double
 
using InternalParametersType = vnl_vector< double >
 
using MeasureType = SingleValuedCostFunction::MeasureType
 
using ParametersType = SingleValuedCostFunction::ParametersType
 
using ScalesType = Array< double >
 

Public Member Functions

unsigned long AddObserver (const EventObject &event, Command *) const
 
void compute (const InternalParametersType &x, InternalMeasureType *fun, InternalDerivativeType *g) override
 
void ConvertExternalToInternalGradient (const DerivativeType &input, InternalDerivativeType &output) const
 
InternalMeasureType f (const InternalParametersType &inparameters) override
 
const ParametersTypeGetCachedCurrentParameters () const
 
const DerivativeTypeGetCachedDerivative () const
 
const MeasureTypeGetCachedValue () const
 
const SingleValuedCostFunctionGetCostFunction () const
 
bool GetNegateCostFunction () const
 
void gradf (const InternalParametersType &inparameters, InternalDerivativeType &gradient) override
 
void NegateCostFunctionOff ()
 
void NegateCostFunctionOn ()
 
void SetCostFunction (SingleValuedCostFunction *costFunction)
 
void SetNegateCostFunction (bool flag)
 
void SetScales (const ScalesType &scales)
 
 SingleValuedVnlCostFunctionAdaptor (unsigned int spaceDimension)
 

Protected Member Functions

void ReportIteration (const EventObject &event) const
 

Private Member Functions

virtual const ScalesTypeGetInverseScales () const
 

Private Attributes

ParametersType m_CachedCurrentParameters {}
 
DerivativeType m_CachedDerivative {}
 
MeasureType m_CachedValue {}
 
SingleValuedCostFunction::Pointer m_CostFunction {}
 
ScalesType m_InverseScales {}
 
bool m_NegateCostFunction {}
 
Object::Pointer m_Reporter {}
 
bool m_ScalesInitialized {}
 

Member Typedef Documentation

◆ DerivativeType

Derivatives of the SingleValuedCostFunction

Definition at line 53 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ InternalDerivativeType

InternalGradientType type alias.

Definition at line 47 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ InternalMeasureType

InternalMeasureType type alias.

Definition at line 44 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ InternalParametersType

InternalParametersType type alias.

Definition at line 41 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ MeasureType

Type of the SingleValuedCostFunction value

Definition at line 56 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ ParametersType

Parameters of the SingleValuedCostFunction

Definition at line 50 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ ScalesType

Scales type alias

Definition at line 59 of file itkSingleValuedVnlCostFunctionAdaptor.h.

Constructor & Destructor Documentation

◆ SingleValuedVnlCostFunctionAdaptor()

itk::SingleValuedVnlCostFunctionAdaptor::SingleValuedVnlCostFunctionAdaptor ( unsigned int  spaceDimension)

Constructor with size

Member Function Documentation

◆ AddObserver()

unsigned long itk::SingleValuedVnlCostFunctionAdaptor::AddObserver ( const EventObject event,
Command  
) const

This AddObserver method allows to simulate that this class derives from an itkObject for the purpose of reporting iteration events. The goal of this method is to allow ITK-vnl optimizer adaptors to get iteration events despite the fact that VNL does not provide callbacks.

◆ compute()

void itk::SingleValuedVnlCostFunctionAdaptor::compute ( const InternalParametersType x,
InternalMeasureType fun,
InternalDerivativeType g 
)
override

Delegate computation of value and gradient to the costFunction.

◆ ConvertExternalToInternalGradient()

void itk::SingleValuedVnlCostFunctionAdaptor::ConvertExternalToInternalGradient ( const DerivativeType input,
InternalDerivativeType output 
) const

Convert external derivative measures into internal type

◆ f()

InternalMeasureType itk::SingleValuedVnlCostFunctionAdaptor::f ( const InternalParametersType inparameters)
override

Delegate computation of the value to the CostFunction.

◆ GetCachedCurrentParameters()

const ParametersType& itk::SingleValuedVnlCostFunctionAdaptor::GetCachedCurrentParameters ( ) const

◆ GetCachedDerivative()

const DerivativeType& itk::SingleValuedVnlCostFunctionAdaptor::GetCachedDerivative ( ) const

◆ GetCachedValue()

const MeasureType& itk::SingleValuedVnlCostFunctionAdaptor::GetCachedValue ( ) const

Return the value of the last evaluation to the value of the cost function. Note that this method DOES NOT triggers a computation of the function or the derivatives, it only returns previous values. Therefore the values here are only valid after you invoke the f() or gradf() methods.

◆ GetCostFunction()

const SingleValuedCostFunction* itk::SingleValuedVnlCostFunctionAdaptor::GetCostFunction ( ) const
inline

Get the CostFunction deriving from SingleValuedCostFunction

Definition at line 73 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ GetInverseScales()

virtual const ScalesType& itk::SingleValuedVnlCostFunctionAdaptor::GetInverseScales ( ) const
privatevirtual

Get current parameters scaling.

◆ GetNegateCostFunction()

bool itk::SingleValuedVnlCostFunctionAdaptor::GetNegateCostFunction ( ) const

◆ gradf()

void itk::SingleValuedVnlCostFunctionAdaptor::gradf ( const InternalParametersType inparameters,
InternalDerivativeType gradient 
)
override

Delegate computation of the gradient to the costFunction.

◆ NegateCostFunctionOff()

void itk::SingleValuedVnlCostFunctionAdaptor::NegateCostFunctionOff ( )
inline

Definition at line 118 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ NegateCostFunctionOn()

void itk::SingleValuedVnlCostFunctionAdaptor::NegateCostFunctionOn ( )
inline

Definition at line 113 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ ReportIteration()

void itk::SingleValuedVnlCostFunctionAdaptor::ReportIteration ( const EventObject event) const
protected

This method is intended to be called by the derived classes in order to notify of an iteration event to any Command/Observers

◆ SetCostFunction()

void itk::SingleValuedVnlCostFunctionAdaptor::SetCostFunction ( SingleValuedCostFunction costFunction)
inline

Set the CostFunction deriving from SingleValuedCostFunction

Definition at line 66 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ SetNegateCostFunction()

void itk::SingleValuedVnlCostFunctionAdaptor::SetNegateCostFunction ( bool  flag)

Set/Get Negate cost function. The purpose of this boolean flag is to make possible to take certain VNL optimizers that are only minimizers, and use them for maximizing functions. When the boolean flag is set to true, the values returned by GetValue in the internal ITK cost function will be multiplied by -1 before returning it in the f() function. Similar operations will be done for the gradf() and compute() methods. When the boolean flag is set to false, then the values returned by the ITK cost function will be passed unchanged to the VNL optimizers.

◆ SetScales()

void itk::SingleValuedVnlCostFunctionAdaptor::SetScales ( const ScalesType scales)

Set current parameters scaling.

Member Data Documentation

◆ m_CachedCurrentParameters

ParametersType itk::SingleValuedVnlCostFunctionAdaptor::m_CachedCurrentParameters {}
mutableprivate

Definition at line 161 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_CachedDerivative

DerivativeType itk::SingleValuedVnlCostFunctionAdaptor::m_CachedDerivative {}
mutableprivate

Definition at line 160 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_CachedValue

MeasureType itk::SingleValuedVnlCostFunctionAdaptor::m_CachedValue {}
mutableprivate

Definition at line 159 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_CostFunction

SingleValuedCostFunction::Pointer itk::SingleValuedVnlCostFunctionAdaptor::m_CostFunction {}
private

Definition at line 153 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_InverseScales

ScalesType itk::SingleValuedVnlCostFunctionAdaptor::m_InverseScales {}
private

Definition at line 155 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_NegateCostFunction

bool itk::SingleValuedVnlCostFunctionAdaptor::m_NegateCostFunction {}
private

Definition at line 156 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_Reporter

Object::Pointer itk::SingleValuedVnlCostFunctionAdaptor::m_Reporter {}
private

Definition at line 157 of file itkSingleValuedVnlCostFunctionAdaptor.h.

◆ m_ScalesInitialized

bool itk::SingleValuedVnlCostFunctionAdaptor::m_ScalesInitialized {}
private

Definition at line 154 of file itkSingleValuedVnlCostFunctionAdaptor.h.


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