use eoExceptions everywhere

This commit is contained in:
Johann Dreo 2020-03-27 00:21:52 +01:00
commit eba2e14950
127 changed files with 524 additions and 418 deletions

View file

@ -69,7 +69,7 @@ eoDistribUpdater<EOT> & do_make_PBILupdate(eoParser & _parser, eoState& _state,
ptUpdate = new eoPBILAdditive<EOT>(LRBest, nbBest, tolerance, LRWorst, nbWorst);
}
else
throw std::runtime_error("Only PBIL additive update rule available at the moment");
throw eoException("Only PBIL additive update rule available at the moment");
// done: don't forget to store the allocated pointers
_state.storeFunctor(ptUpdate);

View file

@ -78,7 +78,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
eoValueParam<std::string>& operatorParam = _parser.createParam(std::string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators");
if (operatorParam.value() != std::string("SGA"))
throw std::runtime_error("Only SGA-like operator available right now\n");
throw eoException("Only SGA-like operator available right now\n");
// now we read Pcross and Pmut,
// the relative weights for all crossovers -> proportional choice
@ -89,12 +89,12 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
// minimum check
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
throw std::runtime_error("Invalid pCross");
throw eoParamException("Invalid pCross");
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
// minimum check
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
throw std::runtime_error("Invalid pMut");
throw eoParamException("Invalid pMut");
// the crossovers
/////////////////
@ -102,17 +102,17 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
eoValueParam<double>& onePointRateParam = _parser.createParam(double(1.0), "onePointRate", "Relative rate for one point crossover", '1', "Variation Operators" );
// minimum check
if ( (onePointRateParam.value() < 0) )
throw std::runtime_error("Invalid onePointRate");
throw eoParamException("Invalid onePointRate");
eoValueParam<double>& twoPointsRateParam = _parser.createParam(double(1.0), "twoPointRate", "Relative rate for two point crossover", '2', "Variation Operators" );
// minimum check
if ( (twoPointsRateParam.value() < 0) )
throw std::runtime_error("Invalid twoPointsRate");
throw eoParamException("Invalid twoPointsRate");
eoValueParam<double>& uRateParam = _parser.createParam(double(2.0), "uRate", "Relative rate for uniform crossover", 'U', "Variation Operators" );
// minimum check
if ( (uRateParam.value() < 0) )
throw std::runtime_error("Invalid uRate");
throw eoParamException("Invalid uRate");
// minimum check
// bool bCross = true; // not used ?
@ -149,29 +149,29 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init
eoValueParam<double> & pMutPerBitParam = _parser.createParam(0.01, "pMutPerBit", "Probability of flipping 1 bit in bit-flip mutation", 'b', "Variation Operators" );
// minimum check
if ( (pMutPerBitParam.value() < 0) || (pMutPerBitParam.value() > 0.5) )
throw std::runtime_error("Invalid pMutPerBit");
throw eoParamException("Invalid pMutPerBit");
eoValueParam<double> & bitFlipRateParam = _parser.createParam(0.01, "bitFlipRate", "Relative rate for bit-flip mutation", 's', "Variation Operators" );
// minimum check
if ( (bitFlipRateParam.value() < 0) )
throw std::runtime_error("Invalid bitFlipRate");
throw eoParamException("Invalid bitFlipRate");
// oneBitFlip
eoValueParam<double> & oneBitRateParam = _parser.createParam(0.01, "oneBitRate", "Relative rate for deterministic bit-flip mutation", 'd', "Variation Operators" );
// minimum check
if ( (oneBitRateParam.value() < 0) )
throw std::runtime_error("Invalid oneBitRate");
throw eoParamException("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");
throw eoParamException("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");
throw eoParamException("Invalid kBitRate");
// minimum check
// bool bMut = true; // not used ?