Loading...
Searching...
No Matches
itkCMAEvolutionStrategyOptimizer.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkCMAEvolutionStrategyOptimizer_h
#define itkCMAEvolutionStrategyOptimizer_h
#include "itkScaledSingleValuedNonLinearOptimizer.h"
#include <vector>
#include <utility>
#include <deque>
#include "itkArray.h"
#include "itkArray2D.h"
#include "itkMersenneTwisterRandomVariateGenerator.h"
#include <vnl/vnl_diag_matrix.h>
namespace itk
{
class CMAEvolutionStrategyOptimizer : public ScaledSingleValuedNonLinearOptimizer
{
public:
ITK_DISALLOW_COPY_AND_MOVE(CMAEvolutionStrategyOptimizer);
using Self = CMAEvolutionStrategyOptimizer;
using Superclass = ScaledSingleValuedNonLinearOptimizer;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(CMAEvolutionStrategyOptimizer, ScaledSingleValuedNonLinearOptimizer);
using Superclass::ParametersType;
using Superclass::DerivativeType;
using Superclass::CostFunctionType;
using Superclass::ScaledCostFunctionType;
using Superclass::MeasureType;
using Superclass::ScalesType;
enum StopConditionType
{
MetricError,
MaximumNumberOfIterations,
PositionToleranceMin,
PositionToleranceMax,
ValueTolerance,
ZeroStepLength,
Unknown
};
void
StartOptimization() override;
virtual void
ResumeOptimization();
virtual void
StopOptimization();
itkGetConstMacro(CurrentIteration, unsigned long);
itkGetConstMacro(CurrentValue, MeasureType);
itkGetConstReferenceMacro(StopCondition, StopConditionType);
itkGetConstMacro(CurrentSigma, double);
itkGetConstMacro(CurrentMinimumD, double);
itkGetConstMacro(CurrentMaximumD, double);
virtual double
GetCurrentStepLength() const
{
return this->GetCurrentSigma() * this->GetCurrentMaximumD();
}
itkGetConstReferenceMacro(CurrentScaledStep, ParametersType);
itkGetConstMacro(MaximumNumberOfIterations, unsigned long);
itkSetClampMacro(MaximumNumberOfIterations, unsigned long, 1, NumericTraits<unsigned long>::max());
itkSetMacro(PopulationSize, unsigned int);
itkGetConstMacro(PopulationSize, unsigned int);
itkSetMacro(NumberOfParents, unsigned int);
itkGetConstMacro(NumberOfParents, unsigned int);
itkSetClampMacro(InitialSigma, double, NumericTraits<double>::min(), NumericTraits<double>::max());
itkGetConstMacro(InitialSigma, double);
itkSetClampMacro(MaximumDeviation, double, 0.0, NumericTraits<double>::max());
itkGetConstMacro(MaximumDeviation, double);
itkSetClampMacro(MinimumDeviation, double, 0.0, NumericTraits<double>::max());
itkGetConstMacro(MinimumDeviation, double);
itkSetMacro(UseDecayingSigma, bool);
itkGetConstMacro(UseDecayingSigma, bool);
itkSetClampMacro(SigmaDecayA, double, 0.0, NumericTraits<double>::max());
itkGetConstMacro(SigmaDecayA, double);
itkSetClampMacro(SigmaDecayAlpha, double, 0.0, 1.0);
itkGetConstMacro(SigmaDecayAlpha, double);
itkSetMacro(UseCovarianceMatrixAdaptation, bool);
itkGetConstMacro(UseCovarianceMatrixAdaptation, bool);
itkSetStringMacro(RecombinationWeightsPreset);
itkGetStringMacro(RecombinationWeightsPreset);
itkSetMacro(UpdateBDPeriod, unsigned int);
itkGetConstMacro(UpdateBDPeriod, unsigned int);
itkSetMacro(PositionToleranceMin, double);
itkGetConstMacro(PositionToleranceMin, double);
itkSetMacro(PositionToleranceMax, double);
itkGetConstMacro(PositionToleranceMax, double);
itkSetMacro(ValueTolerance, double);
itkGetConstMacro(ValueTolerance, double);
protected:
using RecombinationWeightsType = Array<double>;
using EigenValueMatrixType = vnl_diag_matrix<double>;
using CovarianceMatrixType = vnl_matrix<double>;
using ParameterContainerType = std::vector<ParametersType>;
using MeasureHistoryType = std::deque<MeasureType>;
using MeasureIndexPairType = std::pair<MeasureType, unsigned int>;
using MeasureContainerType = std::vector<MeasureIndexPairType>;
using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
RandomGeneratorType::Pointer m_RandomGenerator{ RandomGeneratorType::GetInstance() };
MeasureType m_CurrentValue{ 0.0 };
unsigned long m_CurrentIteration{ 0 };
StopConditionType m_StopCondition{ Unknown };
bool m_Stop{ false };
bool m_UseCovarianceMatrixAdaptation{ true };
unsigned int m_PopulationSize{ 0 };
unsigned int m_NumberOfParents{ 0 };
unsigned int m_UpdateBDPeriod{ 1 };
double m_EffectiveMu{ 0.0 };
double m_ConjugateEvolutionPathConstant{ 0.0 };
double m_SigmaDampingConstant{ 0.0 };
double m_CovarianceMatrixAdaptationConstant{ 0.0 };
double m_EvolutionPathConstant{ 0.0 };
double m_CovarianceMatrixAdaptationWeight{ 0.0 };
double m_ExpectationNormNormalDistribution{ 0.0 };
RecombinationWeightsType m_RecombinationWeights{};
unsigned long m_HistoryLength{ 0 };
double m_CurrentSigma{ 0.0 };
double m_CurrentMinimumD{ 1.0 };
double m_CurrentMaximumD{ 1.0 };
bool m_Heaviside{ false };
ParameterContainerType m_SearchDirs{};
ParameterContainerType m_NormalizedSearchDirs{};
MeasureContainerType m_CostFunctionValues{};
ParametersType m_CurrentScaledStep{};
ParametersType m_CurrentNormalizedStep{};
ParametersType m_EvolutionPath{};
ParametersType m_ConjugateEvolutionPath{};
MeasureHistoryType m_MeasureHistory{};
CovarianceMatrixType m_C{};
CovarianceMatrixType m_B{};
EigenValueMatrixType m_D{};
CMAEvolutionStrategyOptimizer();
~CMAEvolutionStrategyOptimizer() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;
virtual void
InitializeConstants();
virtual void
InitializeProgressVariables();
virtual void
InitializeBCD();
virtual void
GenerateOffspring();
virtual void
SortCostFunctionValues();
virtual void
AdvanceOneStep();
virtual void
UpdateConjugateEvolutionPath();
virtual void
UpdateHeaviside();
virtual void
UpdateEvolutionPath();
virtual void
UpdateC();
virtual void
UpdateSigma();
virtual void
UpdateBD();
virtual void
FixNumericalErrors();
virtual bool
TestConvergence(bool firstCheck);
private:
unsigned long m_MaximumNumberOfIterations{ 100 };
bool m_UseDecayingSigma{ false };
double m_InitialSigma{ 1.0 };
double m_SigmaDecayA{ 50 };
double m_SigmaDecayAlpha{ 0.602 };
std::string m_RecombinationWeightsPreset{ "superlinear" };
double m_MaximumDeviation{ std::numeric_limits<double>::max() };
double m_MinimumDeviation{ 0.0 };
double m_PositionToleranceMax{ 1e8 };
double m_PositionToleranceMin{ 1e-12 };
double m_ValueTolerance{ 1e-12 };
};
} // end namespace itk
#endif //#ifndef itkCMAEvolutionStrategyOptimizer_h
itk::CMAEvolutionStrategyOptimizer::m_RandomGenerator
RandomGeneratorType::Pointer m_RandomGenerator
Definition itkCMAEvolutionStrategyOptimizer.h:240
itk::CMAEvolutionStrategyOptimizer::m_PopulationSize
unsigned int m_PopulationSize
Definition itkCMAEvolutionStrategyOptimizer.h:256
itk::CMAEvolutionStrategyOptimizer::m_UpdateBDPeriod
unsigned int m_UpdateBDPeriod
Definition itkCMAEvolutionStrategyOptimizer.h:258
itk::CMAEvolutionStrategyOptimizer::RecombinationWeightsType
Array< double > RecombinationWeightsType
Definition itkCMAEvolutionStrategyOptimizer.h:228
itk::CMAEvolutionStrategyOptimizer::UpdateSigma
virtual void UpdateSigma()
itk::CMAEvolutionStrategyOptimizer::GetCurrentStepLength
virtual double GetCurrentStepLength() const
Definition itkCMAEvolutionStrategyOptimizer.h:110
itk::CMAEvolutionStrategyOptimizer::m_SigmaDampingConstant
double m_SigmaDampingConstant
Definition itkCMAEvolutionStrategyOptimizer.h:268
itk::CMAEvolutionStrategyOptimizer::m_ValueTolerance
double m_ValueTolerance
Definition itkCMAEvolutionStrategyOptimizer.h:438
itk::CMAEvolutionStrategyOptimizer::m_MeasureHistory
MeasureHistoryType m_MeasureHistory
Definition itkCMAEvolutionStrategyOptimizer.h:309
itk::CMAEvolutionStrategyOptimizer::m_Stop
bool m_Stop
Definition itkCMAEvolutionStrategyOptimizer.h:252
itk::CMAEvolutionStrategyOptimizer::ResumeOptimization
virtual void ResumeOptimization()
itk::CMAEvolutionStrategyOptimizer::m_CurrentMaximumD
double m_CurrentMaximumD
Definition itkCMAEvolutionStrategyOptimizer.h:288
itk::CMAEvolutionStrategyOptimizer::Superclass
ScaledSingleValuedNonLinearOptimizer Superclass
Definition itkCMAEvolutionStrategyOptimizer.h:55
itk::CMAEvolutionStrategyOptimizer::m_Heaviside
bool m_Heaviside
Definition itkCMAEvolutionStrategyOptimizer.h:291
itk::CMAEvolutionStrategyOptimizer::m_EvolutionPathConstant
double m_EvolutionPathConstant
Definition itkCMAEvolutionStrategyOptimizer.h:272
itk::CMAEvolutionStrategyOptimizer::m_D
EigenValueMatrixType m_D
Definition itkCMAEvolutionStrategyOptimizer.h:316
itk::CMAEvolutionStrategyOptimizer::UpdateEvolutionPath
virtual void UpdateEvolutionPath()
itk::CMAEvolutionStrategyOptimizer::m_CurrentIteration
unsigned long m_CurrentIteration
Definition itkCMAEvolutionStrategyOptimizer.h:246
itk::CMAEvolutionStrategyOptimizer::InitializeBCD
virtual void InitializeBCD()
itk::CMAEvolutionStrategyOptimizer::m_MaximumDeviation
double m_MaximumDeviation
Definition itkCMAEvolutionStrategyOptimizer.h:434
itk::CMAEvolutionStrategyOptimizer::SortCostFunctionValues
virtual void SortCostFunctionValues()
itk::CMAEvolutionStrategyOptimizer::m_UseDecayingSigma
bool m_UseDecayingSigma
Definition itkCMAEvolutionStrategyOptimizer.h:429
itk::CMAEvolutionStrategyOptimizer::EigenValueMatrixType
vnl_diag_matrix< double > EigenValueMatrixType
Definition itkCMAEvolutionStrategyOptimizer.h:229
itk::CMAEvolutionStrategyOptimizer::m_SearchDirs
ParameterContainerType m_SearchDirs
Definition itkCMAEvolutionStrategyOptimizer.h:294
itk::CMAEvolutionStrategyOptimizer::RandomGeneratorType
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
Definition itkCMAEvolutionStrategyOptimizer.h:237
itk::CMAEvolutionStrategyOptimizer::m_ExpectationNormNormalDistribution
double m_ExpectationNormNormalDistribution
Definition itkCMAEvolutionStrategyOptimizer.h:276
itk::CMAEvolutionStrategyOptimizer::m_UseCovarianceMatrixAdaptation
bool m_UseCovarianceMatrixAdaptation
Definition itkCMAEvolutionStrategyOptimizer.h:255
itk::CMAEvolutionStrategyOptimizer::m_CurrentNormalizedStep
ParametersType m_CurrentNormalizedStep
Definition itkCMAEvolutionStrategyOptimizer.h:302
itk::CMAEvolutionStrategyOptimizer::~CMAEvolutionStrategyOptimizer
~CMAEvolutionStrategyOptimizer() override=default
itk::CMAEvolutionStrategyOptimizer::m_StopCondition
StopConditionType m_StopCondition
Definition itkCMAEvolutionStrategyOptimizer.h:249
itk::CMAEvolutionStrategyOptimizer::Pointer
SmartPointer< Self > Pointer
Definition itkCMAEvolutionStrategyOptimizer.h:56
itk::CMAEvolutionStrategyOptimizer::StopConditionType
StopConditionType
Definition itkCMAEvolutionStrategyOptimizer.h:70
itk::CMAEvolutionStrategyOptimizer::ValueTolerance
@ ValueTolerance
Definition itkCMAEvolutionStrategyOptimizer.h:75
itk::CMAEvolutionStrategyOptimizer::ZeroStepLength
@ ZeroStepLength
Definition itkCMAEvolutionStrategyOptimizer.h:76
itk::CMAEvolutionStrategyOptimizer::MetricError
@ MetricError
Definition itkCMAEvolutionStrategyOptimizer.h:71
itk::CMAEvolutionStrategyOptimizer::PositionToleranceMax
@ PositionToleranceMax
Definition itkCMAEvolutionStrategyOptimizer.h:74
itk::CMAEvolutionStrategyOptimizer::PositionToleranceMin
@ PositionToleranceMin
Definition itkCMAEvolutionStrategyOptimizer.h:73
itk::CMAEvolutionStrategyOptimizer::MaximumNumberOfIterations
@ MaximumNumberOfIterations
Definition itkCMAEvolutionStrategyOptimizer.h:72
itk::CMAEvolutionStrategyOptimizer::Unknown
@ Unknown
Definition itkCMAEvolutionStrategyOptimizer.h:77
itk::CMAEvolutionStrategyOptimizer::InitializeConstants
virtual void InitializeConstants()
itk::CMAEvolutionStrategyOptimizer::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(CMAEvolutionStrategyOptimizer)
itk::CMAEvolutionStrategyOptimizer::m_SigmaDecayAlpha
double m_SigmaDecayAlpha
Definition itkCMAEvolutionStrategyOptimizer.h:432
itk::CMAEvolutionStrategyOptimizer::UpdateHeaviside
virtual void UpdateHeaviside()
itk::CMAEvolutionStrategyOptimizer::MeasureIndexPairType
std::pair< MeasureType, unsigned int > MeasureIndexPairType
Definition itkCMAEvolutionStrategyOptimizer.h:234
itk::CMAEvolutionStrategyOptimizer::CovarianceMatrixType
vnl_matrix< double > CovarianceMatrixType
Definition itkCMAEvolutionStrategyOptimizer.h:230
itk::CMAEvolutionStrategyOptimizer::m_MaximumNumberOfIterations
unsigned long m_MaximumNumberOfIterations
Definition itkCMAEvolutionStrategyOptimizer.h:428
itk::CMAEvolutionStrategyOptimizer::GetCurrentMaximumD
virtual double GetCurrentMaximumD() const
itk::CMAEvolutionStrategyOptimizer::m_NumberOfParents
unsigned int m_NumberOfParents
Definition itkCMAEvolutionStrategyOptimizer.h:257
itk::CMAEvolutionStrategyOptimizer::GenerateOffspring
virtual void GenerateOffspring()
itk::CMAEvolutionStrategyOptimizer::m_B
CovarianceMatrixType m_B
Definition itkCMAEvolutionStrategyOptimizer.h:314
itk::CMAEvolutionStrategyOptimizer::ParameterContainerType
std::vector< ParametersType > ParameterContainerType
Definition itkCMAEvolutionStrategyOptimizer.h:231
itk::CMAEvolutionStrategyOptimizer::m_CurrentValue
MeasureType m_CurrentValue
Definition itkCMAEvolutionStrategyOptimizer.h:243
itk::CMAEvolutionStrategyOptimizer::CMAEvolutionStrategyOptimizer
CMAEvolutionStrategyOptimizer()
itk::CMAEvolutionStrategyOptimizer::m_CostFunctionValues
MeasureContainerType m_CostFunctionValues
Definition itkCMAEvolutionStrategyOptimizer.h:298
itk::CMAEvolutionStrategyOptimizer::m_RecombinationWeightsPreset
std::string m_RecombinationWeightsPreset
Definition itkCMAEvolutionStrategyOptimizer.h:433
itk::CMAEvolutionStrategyOptimizer::m_EffectiveMu
double m_EffectiveMu
Definition itkCMAEvolutionStrategyOptimizer.h:264
itk::CMAEvolutionStrategyOptimizer::m_C
CovarianceMatrixType m_C
Definition itkCMAEvolutionStrategyOptimizer.h:312
itk::CMAEvolutionStrategyOptimizer::m_HistoryLength
unsigned long m_HistoryLength
Definition itkCMAEvolutionStrategyOptimizer.h:280
itk::CMAEvolutionStrategyOptimizer::m_MinimumDeviation
double m_MinimumDeviation
Definition itkCMAEvolutionStrategyOptimizer.h:435
itk::CMAEvolutionStrategyOptimizer::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkCMAEvolutionStrategyOptimizer.h:57
itk::CMAEvolutionStrategyOptimizer::InitializeProgressVariables
virtual void InitializeProgressVariables()
itk::CMAEvolutionStrategyOptimizer::GetCurrentSigma
virtual double GetCurrentSigma() const
itk::CMAEvolutionStrategyOptimizer::m_CurrentScaledStep
ParametersType m_CurrentScaledStep
Definition itkCMAEvolutionStrategyOptimizer.h:300
itk::CMAEvolutionStrategyOptimizer::Self
CMAEvolutionStrategyOptimizer Self
Definition itkCMAEvolutionStrategyOptimizer.h:54
itk::CMAEvolutionStrategyOptimizer::MeasureContainerType
std::vector< MeasureIndexPairType > MeasureContainerType
Definition itkCMAEvolutionStrategyOptimizer.h:235
itk::CMAEvolutionStrategyOptimizer::TestConvergence
virtual bool TestConvergence(bool firstCheck)
itk::CMAEvolutionStrategyOptimizer::m_ConjugateEvolutionPath
ParametersType m_ConjugateEvolutionPath
Definition itkCMAEvolutionStrategyOptimizer.h:306
itk::CMAEvolutionStrategyOptimizer::m_NormalizedSearchDirs
ParameterContainerType m_NormalizedSearchDirs
Definition itkCMAEvolutionStrategyOptimizer.h:296
itk::CMAEvolutionStrategyOptimizer::MeasureHistoryType
std::deque< MeasureType > MeasureHistoryType
Definition itkCMAEvolutionStrategyOptimizer.h:232
itk::CMAEvolutionStrategyOptimizer::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::CMAEvolutionStrategyOptimizer::m_ConjugateEvolutionPathConstant
double m_ConjugateEvolutionPathConstant
Definition itkCMAEvolutionStrategyOptimizer.h:266
itk::CMAEvolutionStrategyOptimizer::m_EvolutionPath
ParametersType m_EvolutionPath
Definition itkCMAEvolutionStrategyOptimizer.h:304
itk::CMAEvolutionStrategyOptimizer::m_CovarianceMatrixAdaptationWeight
double m_CovarianceMatrixAdaptationWeight
Definition itkCMAEvolutionStrategyOptimizer.h:274
itk::CMAEvolutionStrategyOptimizer::AdvanceOneStep
virtual void AdvanceOneStep()
itk::CMAEvolutionStrategyOptimizer::m_RecombinationWeights
RecombinationWeightsType m_RecombinationWeights
Definition itkCMAEvolutionStrategyOptimizer.h:278
itk::CMAEvolutionStrategyOptimizer::m_PositionToleranceMax
double m_PositionToleranceMax
Definition itkCMAEvolutionStrategyOptimizer.h:436
itk::CMAEvolutionStrategyOptimizer::StopOptimization
virtual void StopOptimization()
itk::CMAEvolutionStrategyOptimizer::UpdateC
virtual void UpdateC()
itk::CMAEvolutionStrategyOptimizer::UpdateConjugateEvolutionPath
virtual void UpdateConjugateEvolutionPath()
itk::CMAEvolutionStrategyOptimizer::m_SigmaDecayA
double m_SigmaDecayA
Definition itkCMAEvolutionStrategyOptimizer.h:431
itk::CMAEvolutionStrategyOptimizer::m_InitialSigma
double m_InitialSigma
Definition itkCMAEvolutionStrategyOptimizer.h:430
itk::CMAEvolutionStrategyOptimizer::m_CurrentMinimumD
double m_CurrentMinimumD
Definition itkCMAEvolutionStrategyOptimizer.h:286
itk::CMAEvolutionStrategyOptimizer::m_CurrentSigma
double m_CurrentSigma
Definition itkCMAEvolutionStrategyOptimizer.h:283
itk::CMAEvolutionStrategyOptimizer::m_CovarianceMatrixAdaptationConstant
double m_CovarianceMatrixAdaptationConstant
Definition itkCMAEvolutionStrategyOptimizer.h:270
itk::CMAEvolutionStrategyOptimizer::FixNumericalErrors
virtual void FixNumericalErrors()
itk::CMAEvolutionStrategyOptimizer::StartOptimization
void StartOptimization() override
itk::CMAEvolutionStrategyOptimizer::m_PositionToleranceMin
double m_PositionToleranceMin
Definition itkCMAEvolutionStrategyOptimizer.h:437
itk::CMAEvolutionStrategyOptimizer::UpdateBD
virtual void UpdateBD()
itk::ScaledSingleValuedNonLinearOptimizer::ScaledSingleValuedNonLinearOptimizer
ScaledSingleValuedNonLinearOptimizer()
itk::ScaledSingleValuedNonLinearOptimizer::ScalesType
NonLinearOptimizer::ScalesType ScalesType
Definition itkScaledSingleValuedNonLinearOptimizer.h:85
itk::ScaledSingleValuedNonLinearOptimizer::ScaledCostFunctionType
ScaledSingleValuedCostFunction ScaledCostFunctionType
Definition itkScaledSingleValuedNonLinearOptimizer.h:86
itkScaledSingleValuedNonLinearOptimizer.h
itk
Definition itkAdvancedImageToImageMetric.h:43

Generated on 1768596610 for elastix by 1.15.0 |