use eoExceptions everywhere
This commit is contained in:
parent
75ac37b02a
commit
eba2e14950
127 changed files with 524 additions and 418 deletions
|
|
@ -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 ) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,6 @@ void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& pop)
|
|||
template<template <class> class EOAlgo, class EOT, class Policy>
|
||||
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& pop, const error_tag&)
|
||||
{
|
||||
throw std::runtime_error("This is not a valid algorithm");
|
||||
throw eoException("This is not a valid algorithm");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include <eo>
|
||||
|
||||
paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filename)
|
||||
{
|
||||
std::ifstream f(filename);
|
||||
|
|
@ -73,7 +75,7 @@ paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filenam
|
|||
|
||||
//for each vector non empty, if the size is not equal to the others, error
|
||||
if(lineVector.size() != size && !lineVector.empty())
|
||||
throw std::runtime_error("Mistake in the topology, line " + std::to_string(_matrix.size()+1) );
|
||||
throw eoException("Mistake in the topology, line " + std::to_string(_matrix.size()+1) );
|
||||
|
||||
if(!lineVector.empty())
|
||||
_matrix.push_back(lineVector);
|
||||
|
|
@ -82,13 +84,13 @@ paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filenam
|
|||
//for each vector, verify if the size is equal to the size of the final matrix
|
||||
for(auto& line : _matrix)
|
||||
if(line.size() != _matrix.size())
|
||||
throw std::runtime_error("Mistake in the topology, matrix is not squared" );
|
||||
throw eoException("Mistake in the topology, matrix is not squared" );
|
||||
|
||||
f.close () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Error occured while reading the topology file " + filename);
|
||||
throw eoFileError(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include <eo>
|
||||
|
||||
paradiseo::smp::CustomStochasticTopology::CustomStochasticTopology(std::string filename)
|
||||
{
|
||||
std::ifstream f(filename);
|
||||
|
|
@ -78,7 +80,7 @@ paradiseo::smp::CustomStochasticTopology::CustomStochasticTopology(std::string f
|
|||
|
||||
// For each vector non empty, if the size is not equal to the others, error
|
||||
if(lineVector.size() != size && !lineVector.empty())
|
||||
throw std::runtime_error("Mistake in the topology, line "+ std::to_string(_matrix.size()+1) );
|
||||
throw eoException("Mistake in the topology, line "+ std::to_string(_matrix.size()+1) );
|
||||
|
||||
if(!lineVector.empty())
|
||||
_matrix.push_back(lineVector);
|
||||
|
|
@ -87,13 +89,13 @@ paradiseo::smp::CustomStochasticTopology::CustomStochasticTopology(std::string f
|
|||
// For each vector, verify if the size is equal to the size of the final matrix
|
||||
for(auto& line : _matrix)
|
||||
if(line.size() != _matrix.size())
|
||||
throw std::runtime_error("Mistake in the topology, matrix is not square" );
|
||||
throw eoException("Mistake in the topology, matrix is not square" );
|
||||
|
||||
f.close () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Error occured while reading the topology file " + filename);
|
||||
throw eoFileError(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue