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

@ -1,3 +1,5 @@
#include "eoExceptions.h"
template<template <class> class EOAlgo, class EOT, class Policy>
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, const eoEasyEA_tag&)
{
@ -16,8 +18,8 @@ void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, co
do
{
try
{
// try
// {
unsigned pSize = _pop.size();
this->offspring.clear(); // new offspring
this->breed(_pop, this->offspring);
@ -27,17 +29,17 @@ void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, co
this->replace(_pop, this->offspring); // after replace, the new pop. is in _pop
if (pSize > _pop.size())
throw std::runtime_error("Population shrinking!");
throw eoPopSizeChangeException(_pop.size(), pSize, "Population shrinking!");
else if (pSize < _pop.size())
throw std::runtime_error("Population growing!");
throw eoPopSizeChangeException(_pop.size(), pSize, "Population growing!");
}
catch (std::exception& e)
{
std::string s = e.what();
s.append( " in eoEasyEA");
throw std::runtime_error( s );
}
// }
// catch (std::exception& e)
// {
// std::string s = e.what();
// s.append( " in eoEasyEA");
// throw std::runtime_error( s );
// }
}
while (this->continuator( _pop ) );
}

View file

@ -1,8 +1,8 @@
template<template <class> class EOAlgo, class EOT, class Policy>
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, const eoEasyPSO_tag&)
{
try
{
// try
// {
// initializes the topology, velocity, best particle(s)
this->init();
do
@ -25,11 +25,11 @@ void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, co
this->velocity.updateNeighborhood(_pop[idx],idx);
} while (this->continuator (_pop));
}
catch (std::exception & e)
{
std::string s = e.what ();
s.append (" in eoEasyPSO");
throw std::runtime_error (s);
}
// }
// catch (std::exception & e)
// {
// std::string s = e.what ();
// s.append (" in eoEasyPSO");
// throw std::runtime_error (s);
// }
}

View file

@ -1,8 +1,8 @@
template<template <class> class EOAlgo, class EOT, class Policy>
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, const eoSyncEasyPSO_tag&)
{
try
{
// try
// {
// initializes the topology, velocity, best particle(s)
this->init();
@ -26,11 +26,11 @@ void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, co
} while (this->continuator(_pop));
}
catch (std::exception & e)
{
std::string s = e.what ();
s.append (" in eoSyncEasyPSO");
throw std::runtime_error (s);
}
// }
// catch (std::exception & e)
// {
// std::string s = e.what ();
// s.append (" in eoSyncEasyPSO");
// throw std::runtime_error (s);
// }
}