* ga/make_op: added kbit flip mutation, disabled by default
This commit is contained in:
parent
1809120d34
commit
29e31fb6df
1 changed files with 17 additions and 0 deletions
|
|
@ -156,11 +156,23 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
|
||||||
if ( (bitFlipRateParam.value() < 0) )
|
if ( (bitFlipRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid bitFlipRate");
|
throw std::runtime_error("Invalid bitFlipRate");
|
||||||
|
|
||||||
|
// oneBitFlip
|
||||||
eoValueParam<double> & oneBitRateParam = _parser.createParam(0.01, "oneBitRate", "Relative rate for deterministic bit-flip mutation", 'd', "Variation Operators" );
|
eoValueParam<double> & oneBitRateParam = _parser.createParam(0.01, "oneBitRate", "Relative rate for deterministic bit-flip mutation", 'd', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (oneBitRateParam.value() < 0) )
|
if ( (oneBitRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid oneBitRate");
|
throw std::runtime_error("Invalid oneBitRate");
|
||||||
|
|
||||||
|
// kBitFlip
|
||||||
|
eoValueParam<unsigned> & kBitParam = _parser.createParam((unsigned)1, "kBit", "Number of bit for deterministic k bit-flip mutation", 0, "Variation Operators" );
|
||||||
|
// minimum check
|
||||||
|
if ( ! kBitParam.value() )
|
||||||
|
throw std::runtime_error("Invalid kBit");
|
||||||
|
|
||||||
|
eoValueParam<double> & kBitRateParam = _parser.createParam(0.0, "kBitRate", "Relative rate for deterministic k bit-flip mutation", 0, "Variation Operators" );
|
||||||
|
// minimum check
|
||||||
|
if ( (kBitRateParam.value() < 0) )
|
||||||
|
throw std::runtime_error("Invalid kBitRate");
|
||||||
|
|
||||||
// minimum check
|
// minimum check
|
||||||
// bool bMut = true; // not used ?
|
// bool bMut = true; // not used ?
|
||||||
if (bitFlipRateParam.value()+oneBitRateParam.value()==0)
|
if (bitFlipRateParam.value()+oneBitRateParam.value()==0)
|
||||||
|
|
@ -184,6 +196,11 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
|
||||||
_state.storeFunctor(ptMon);
|
_state.storeFunctor(ptMon);
|
||||||
ptCombinedMonOp->add(*ptMon, oneBitRateParam.value());
|
ptCombinedMonOp->add(*ptMon, oneBitRateParam.value());
|
||||||
|
|
||||||
|
// mutate exactly k bit per individual
|
||||||
|
ptMon = new eoDetBitFlip<EOT>(kBitParam.value());
|
||||||
|
_state.storeFunctor(ptMon);
|
||||||
|
ptCombinedMonOp->add(*ptMon, kBitRateParam.value());
|
||||||
|
|
||||||
_state.storeFunctor(ptCombinedMonOp);
|
_state.storeFunctor(ptCombinedMonOp);
|
||||||
|
|
||||||
// now build the eoGenOp:
|
// now build the eoGenOp:
|
||||||
|
|
|
||||||
Reference in a new issue