32 #ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_OPERATORS_CROSSOVER_SBX_H 33 #define SHARK_ALGORITHMS_DIRECT_SEARCH_OPERATORS_CROSSOVER_SBX_H 41 template<
typename Po
intType>
49 void init( RealVector
const& lower, RealVector
const& upper ) {
60 template<
class randomType,
typename Indiv
idualType>
65 for(
unsigned int i = 0; i < point1.size(); i++ ) {
72 if( point2[i] < point1[i] ) {
82 if( std::abs(y2 - y1) < 1E-7 )
continue;
85 double beta1 = 1 + 2 * (y1 -
m_lower( i )) / (y2 - y1);
86 double beta2 = 1 + 2 * (
m_upper( i ) - y2) / (y2 - y1);
87 double expp =
m_nc + 1.;
89 double alpha1 = 2. - std::pow(beta1 , -expp);
90 double alpha2 = 2. - std::pow(beta2 , -expp);
95 if( u > 1. / alpha1 ) {
96 alpha1 = 1. / (2. - alpha1);
98 if( u > 1. / alpha2 ) {
99 alpha2 = 1. / (2. - alpha2);
101 betaQ1 = std::pow( alpha1, 1.0/expp );
102 betaQ2 = std::pow( alpha2, 1.0/expp );
105 point1[i] = 0.5 * ((y1 + y2) - betaQ1 * (y2 - y1));
106 point2[i] = 0.5 * ((y1 + y2) + betaQ2 * (y2 - y1));
112 point1[i] = std::max( point1[i],
m_lower( i ) );
113 point1[i] = std::min( point1[i],
m_upper( i ) );
114 point2[i] = std::max( point2[i],
m_lower( i ) );
115 point2[i] = std::min( point2[i],
m_upper( i ) );
124 template<
typename Archive>
125 void serialize( Archive & archive,
const unsigned int version ) {
126 archive & BOOST_SERIALIZATION_NVP(
m_nc );
127 archive & BOOST_SERIALIZATION_NVP(
m_prob );
128 archive & BOOST_SERIALIZATION_NVP(
m_upper );
129 archive & BOOST_SERIALIZATION_NVP(
m_lower );