32 #ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_CMA_CHROMOSOME_H 33 #define SHARK_ALGORITHMS_DIRECT_SEARCH_CMA_CHROMOSOME_H 67 std::size_t searchSpaceDimension,
68 double successThreshold,
69 double initialStepSize
71 : m_stepSize( initialStepSize )
72 , m_covarianceMatrixLearningRate( 0 )
73 , m_successThreshold(successThreshold)
75 m_mutationDistribution.
resize( searchSpaceDimension );
76 m_evolutionPath.resize( searchSpaceDimension );
77 m_lastStep.resize( searchSpaceDimension );
78 m_lastZ.resize( searchSpaceDimension );
80 m_targetSuccessProbability = 1.0 / ( 5.0 + 1/2.0 );
82 m_stepSizeDampingFactor = 1.0 + searchSpaceDimension / 2.;
84 m_evolutionPathLearningRate = 2.0 / (2.0 + searchSpaceDimension);
85 m_covarianceMatrixLearningRate = 2.0 / (
sqr(searchSpaceDimension) + 6.);
86 m_covarianceMatrixUnlearningRate = 0.4/( std::pow(searchSpaceDimension, 1.6 )+1. );
102 m_stepSize *= ::exp( 1./m_stepSizeDampingFactor * (m_successProbability - m_targetSuccessProbability) / (1-m_targetSuccessProbability) );
105 if( m_successProbability < m_successThreshold ) {
107 noalias(m_evolutionPath) += std::sqrt( evolutionpathUpdateWeight ) *
m_lastStep;
108 rankOneUpdate(1 - m_covarianceMatrixLearningRate,m_covarianceMatrixLearningRate,m_evolutionPath);
125 m_stepSize *= ::exp( 1./m_stepSizeDampingFactor * (m_successProbability - m_targetSuccessProbability) / (1-m_targetSuccessProbability) );
127 if(offspringSuccess !=
Failure)
return;
129 if( m_successProbability < m_successThreshold ) {
131 double stepNormSqr = norm_sqr( m_lastZ );
134 if( stepNormSqr > 1 && 1 < m_covarianceMatrixUnlearningRate*(2*stepNormSqr-1) ){
135 rate = 1.0/(2*stepNormSqr-1);
138 rankOneUpdate(1+rate,-rate,m_lastStep);
150 template<
typename Archive>
151 void serialize( Archive & archive,
const unsigned int version ) {
153 archive & BOOST_SERIALIZATION_NVP( m_mutationDistribution );
156 archive & BOOST_SERIALIZATION_NVP( m_evolutionPath );
157 archive & BOOST_SERIALIZATION_NVP( m_lastStep );
159 archive & BOOST_SERIALIZATION_NVP( m_stepSize );
160 archive & BOOST_SERIALIZATION_NVP( m_stepSizeDampingFactor );
161 archive & BOOST_SERIALIZATION_NVP( m_stepSizeLearningRate );
162 archive & BOOST_SERIALIZATION_NVP( m_successProbability );
163 archive & BOOST_SERIALIZATION_NVP( m_targetSuccessProbability );
164 archive & BOOST_SERIALIZATION_NVP( m_successThreshold);
165 archive & BOOST_SERIALIZATION_NVP( m_evolutionPathLearningRate );
166 archive & BOOST_SERIALIZATION_NVP( m_covarianceMatrixLearningRate );
167 archive & BOOST_SERIALIZATION_NVP( m_covarianceMatrixUnlearningRate );
174 void rankOneUpdate(
double alpha,
double beta, RealVector
const& v){
186 1 - m_covarianceMatrixLearningRate+evolutionpathUpdateWeight,
187 m_covarianceMatrixLearningRate,