32 #ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_OPERATORS_MUTATION_POLYNOMIALMUTATION_H 33 #define SHARK_ALGORITHMS_DIRECT_SEARCH_OPERATORS_MUTATION_POLYNOMIALMUTATION_H 50 template<
typename Function>
51 void init(
const Function & f ) {
52 m_prob = 1./f.numberOfVariables();
53 if(!f.isConstrained()){
57 else if (f.hasConstraintHandler() && f.getConstraintHandler().isBoxConstrained()) {
59 ConstraintHandler
const& handler =
static_cast<ConstraintHandler const&
>(f.getConstraintHandler());
65 throw SHARKEXCEPTION(
"[PolynomialMutator::init] Algorithm does only allow box constraints");
73 template<
typename Indiv
idualType>
75 double delta, deltaQ, expp, u = 0.;
79 for(
unsigned int i = 0; i < point.size(); i++ ) {
81 if( Rng::coinToss(
m_prob ) ) {
82 u = Rng::uni( 0., 1. );
94 delta = ::pow(delta , expp);
98 deltaQ = 2. * u + (1 - 2. * u) * delta;
99 deltaQ = ::pow(deltaQ, expp) - 1. ;
101 deltaQ = 2. - 2. * u + 2. * (u - .5) * delta;
102 deltaQ = 1. - ::pow(deltaQ , expp);
123 template<
typename Archive>
124 void serialize( Archive & archive,
const unsigned int version ) {
125 archive & BOOST_SERIALIZATION_NVP(
m_nm );
126 archive & BOOST_SERIALIZATION_NVP(
m_prob );
127 archive & BOOST_SERIALIZATION_NVP(
m_upper );
128 archive & BOOST_SERIALIZATION_NVP(
m_lower );