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

@ -63,7 +63,7 @@ public :
virtual void operator()(const eoPop<EOT>& _pop) {
if( whichFitnessTerm >= _pop[0].fitness().size() )
throw std::logic_error("Fitness term requested out of range");
throw eoException("Fitness term requested out of range");
double result =0.0;
unsigned count = 0;
@ -102,7 +102,7 @@ public:
virtual void operator()(const eoPop<EOT>& _pop) {
if( whichFitnessTerm >= _pop[0].fitness().size() )
throw std::logic_error("Fitness term requested out of range");
throw eoException("Fitness term requested out of range");
value() = _pop.best_element().fitness()[whichFitnessTerm];
}

View file

@ -135,7 +135,7 @@ public:
/** just to be sure the add method is not called further
*/
virtual void add(const eoParam& )
{ throw std::runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); }
{ throw eoException("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); }
private:
eoFDCStat<EOT> & FDCstat;

View file

@ -10,6 +10,7 @@
#include "eoFileMonitor.h"
#include "compatibility.h"
#include "eoParam.h"
#include "../eoExceptions.h"
using namespace std;
@ -36,8 +37,8 @@ void eoFileMonitor::printHeader()
if (!os)
{
string str = "eoFileMonitor could not open: " + filename;
throw runtime_error(str);
// string str = "eoFileMonitor could not open: " + filename;
throw eoFileError(filename);
}
printHeader(os);
@ -54,8 +55,8 @@ eoMonitor& eoFileMonitor::operator()(void)
if (!os)
{
string str = "eoFileMonitor could not write to: " + filename;
throw runtime_error(str);
// string str = "eoFileMonitor could not write to: " + filename;
throw eoFileError(filename);
}
if (

View file

@ -33,6 +33,7 @@
#include "eoMonitor.h"
#include "../eoObject.h"
#include "../eoExceptions.h"
/** Prints statistics to file
@ -75,8 +76,8 @@ public :
std::ofstream os (filename.c_str ());
if (!os) {
std::string str = "Error, eoFileMonitor could not open: " + filename;
throw std::runtime_error (str);
// std::string str = "Error, eoFileMonitor could not open: " + filename;
throw eoFileError(filename);
}
} // if ! keep
}

View file

@ -67,7 +67,7 @@ public :
int res = system(s.c_str());
// test for (unlikely) errors
if ( (res==-1) || (res==127) )
throw std::runtime_error("Problem executing test of dir in eoFileSnapshot");
throw eoSystemError(s, res);
// now make sure there is a dir without any genXXX file in it
if (res) // no dir present
{
@ -122,8 +122,8 @@ public :
if (!os)
{
std::string str = "eoFileSnapshot: Could not open " + currentFileName;
throw std::runtime_error(str);
// std::string str = "eoFileSnapshot: Could not open " + currentFileName;
throw eoFileError(currentFileName);;
}
return operator()(os);
@ -151,7 +151,7 @@ public :
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
vv[i] = ptParam->value();
if (vv[i].size() != v.size())
throw std::runtime_error("Dimension error in eoSnapshotMonitor");
throw eoException("Dimension error in eoSnapshotMonitor");
}
for (unsigned k=0; k<v.size(); k++)
{
@ -173,7 +173,7 @@ public :
{
if (!dynamic_cast<const eoValueParam<std::vector<double> >*>(&_param))
{
throw std::logic_error(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName());
throw eoException(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName());
}
eoMonitor::add(_param);
}

View file

@ -29,6 +29,7 @@
#include <stdexcept>
#include "eoGnuplot.h"
#include "../eoExceptions.h"
unsigned eoGnuplot::numWindow=0;
@ -82,7 +83,7 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
args[5] = 0;
gpCom = PipeComOpenArgv( GNUPLOT_PROGRAM, args );
if(! gpCom )
throw std::runtime_error("Cannot spawn gnuplot\n");
throw eoSystemError(GNUPLOT_PROGRAM);
else {
PipeComSend( gpCom, "set grid\n" );
PipeComSend( gpCom, _extra.c_str() );

View file

@ -61,7 +61,7 @@ void eoGnuplot1DMonitor::FirstPlot()
{
if (this->vec.size() < 2)
{
throw std::runtime_error("Must have some stats to plot!\n");
throw eoException("Must have some stats to plot!\n");
}
#ifdef HAVE_GNUPLOT
std::ostringstream os;

View file

@ -119,7 +119,7 @@ public:
{
unsigned int combloc = -count;
if (_size<combloc)
throw std::runtime_error("Negative result in eoHowMany");
throw eoException("Negative result in eoHowMany");
return _size-combloc;
}
return unsigned(count);
@ -167,7 +167,7 @@ public:
// minimal check
if ( rate < 0.0 )
throw std::runtime_error("Negative rate read in eoHowMany::readFrom");
throw eoException("Negative rate read in eoHowMany::readFrom");
}
/** The unary - operator: reverses the computation */
@ -188,7 +188,7 @@ public:
{
rate = 1.0+_rate;
if (rate < 0) // was < -1
throw std::logic_error("rate < -1 in eoHowMany!");
throw eoException("rate < -1 in eoHowMany!");
}
}
else

View file

@ -31,17 +31,17 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
std::string delim(",; ");
std::string beginOrClose("[(])");
if (!remove_leading(_value, delim)) // only delimiters were left
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
// look for opening char
size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b]
if (posDeb >= _value.size()) // nothing left to read
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
// ending char: next {}() after posDeb
size_t posFin = _value.find_first_of(beginOrClose,posDeb+1);
if (posFin >= _value.size()) // not found
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
// the bounds
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
@ -51,7 +51,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
remove_leading(sBounds, delim);
size_t posDelim = sBounds.find_first_of(delim);
if (posDelim >= sBounds.size())
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
bool minBounded=false, maxBounded=false;
long int minBound=0, maxBound=0;
@ -85,7 +85,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
if (minBounded && maxBounded)
{
if (maxBound <= minBound)
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
locBound = new eoIntInterval(minBound, maxBound);
}
else if (!minBounded && !maxBounded) // no bound at all

View file

@ -29,6 +29,7 @@
#include <stdexcept> // std::exceptions!
#include "eoRNG.h"
#include "../eoExceptions.h"
/**
\class eoIntBounds eoIntBounds.h es/eoIntBounds.h
@ -163,29 +164,29 @@ public:
virtual long int minimum() const
{
throw std::logic_error("Trying to get minimum of unbounded eoIntBounds");
throw eoException("Trying to get minimum of unbounded eoIntBounds");
}
virtual long int maximum() const
{
throw std::logic_error("Trying to get maximum of unbounded eoIntBounds");
throw eoException("Trying to get maximum of unbounded eoIntBounds");
}
virtual long int range() const
{
throw std::logic_error("Trying to get range of unbounded eoIntBounds");
throw eoException("Trying to get range of unbounded eoIntBounds");
}
virtual double uniform(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in unbounded eoIntBounds");
throw eoException("Trying to generate uniform values in unbounded eoIntBounds");
}
virtual long int random(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in unbounded eoIntBounds");
throw eoException("Trying to generate uniform values in unbounded eoIntBounds");
}
// methods from eoPersistent
@ -199,7 +200,7 @@ public:
{
(void)_is;
throw std::runtime_error("Should not use eoIntBounds::readFrom");
throw eoException("Should not use eoIntBounds::readFrom");
}
/**
@ -244,7 +245,7 @@ public :
repMinimum(_min), repMaximum(_max), repRange(_max-_min)
{
if (repRange<=0)
throw std::logic_error("Void range in eoIntBounds");
throw eoException("Void range in eoIntBounds");
}
// accessors
@ -328,7 +329,7 @@ public :
{
(void)_is;
throw std::runtime_error("Should not use eoIntInterval::readFrom");
throw eoException("Should not use eoIntInterval::readFrom");
}
/**
@ -374,25 +375,25 @@ public :
virtual long int maximum() const
{
throw std::logic_error("Trying to get maximum of eoIntBelowBound");
throw eoException("Trying to get maximum of eoIntBelowBound");
}
virtual long int range() const
{
throw std::logic_error("Trying to get range of eoIntBelowBound");
throw eoException("Trying to get range of eoIntBelowBound");
}
virtual double uniform(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in eoIntBelowBound");
throw eoException("Trying to generate uniform values in eoIntBelowBound");
}
virtual long int random(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in eoIntBelowBound");
throw eoException("Trying to generate uniform values in eoIntBelowBound");
}
// description
@ -437,7 +438,7 @@ public :
{
(void)_is;
throw std::runtime_error("Should not use eoIntBelowBound::readFrom");
throw eoException("Should not use eoIntBelowBound::readFrom");
}
/**
@ -482,25 +483,25 @@ public :
virtual long int minimum() const
{
throw std::logic_error("Trying to get minimum of eoIntAboveBound");
throw eoException("Trying to get minimum of eoIntAboveBound");
}
virtual long int range() const
{
throw std::logic_error("Trying to get range of eoIntAboveBound");
throw eoException("Trying to get range of eoIntAboveBound");
}
virtual double uniform(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in eoIntAboveBound");
throw eoException("Trying to generate uniform values in eoIntAboveBound");
}
virtual long int random(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in eoIntAboveBound");
throw eoException("Trying to generate uniform values in eoIntAboveBound");
}
// description
@ -545,7 +546,7 @@ public :
{
(void)_is;
throw std::runtime_error("Should not use eoIntAboveBound::readFrom");
throw eoException("Should not use eoIntAboveBound::readFrom");
}
/**

View file

@ -19,8 +19,8 @@
eoMonitor& eoOStreamMonitor::operator()(void)
{
if (!out) {
std::string str = "eoOStreamMonitor: Could not write to the output stream";
throw std::runtime_error(str);
// std::string str = "eoOStreamMonitor: Could not write to the output stream";
throw eoFileError("output stream");
}
if (firsttime) {

View file

@ -34,6 +34,7 @@
#include <string>
#include <vector>
#include "../eoScalarFitness.h"
#include "../eoExceptions.h"
/** @defgroup Parameters Parameters management
*
@ -385,14 +386,14 @@ inline void eoValueParam<std::vector<eoMinimizingFitness> >::setValue(const std:
template <>
inline std::string eoValueParam<std::vector<void*> >::getValue(void) const
{
throw std::runtime_error("I cannot getValue for a std::vector<EOT*>");
throw eoException("I cannot getValue for a std::vector<EOT*>");
return std::string("");
}
template <>
inline void eoValueParam<std::vector<void*> >::setValue(const std::string&)
{
throw std::runtime_error("I cannot setValue for a std::vector<EOT*>");
throw eoException("I cannot setValue for a std::vector<EOT*>");
return;
}

View file

@ -96,8 +96,8 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
ifs.peek(); // check if it exists
if (!ifs)
{
string msg = string("Could not open response file: ") + pts;
throw runtime_error(msg);
// string msg = string("Could not open response file: ") + pts;
throw eoFileError(pts);
}
// read - will be overwritten by command-line
readFrom(ifs);

View file

@ -101,7 +101,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
size_t posFin = _value.find_first_of(std::string(closeChar));
if (posFin >= _value.size())
throw std::runtime_error("Syntax error when reading bounds");
throw eoException("Syntax error when reading bounds");
// y a-t-il un nbre devant
unsigned count = 1;
@ -110,7 +110,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
std::string sCount = _value.substr(0, posDeb);
count = read_int(sCount);
if (count <= 0)
throw std::runtime_error("Syntax error when reading bounds");
throw eoException("Syntax error when reading bounds");
}
// the bounds
@ -121,7 +121,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
remove_leading(sBounds, delim);
size_t posDelim = sBounds.find_first_of(delim);
if (posDelim >= sBounds.size())
throw std::runtime_error("Syntax error when reading bounds");
throw eoException("Syntax error when reading bounds");
bool minBounded=false, maxBounded=false;
double minBound=0, maxBound=0;
@ -192,17 +192,17 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
std::string delim(",; ");
std::string beginOrClose("[(])");
if (!remove_leading(_value, delim)) // only delimiters were left
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
// look for opening char
size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b]
if (posDeb >= _value.size()) // nothing left to read
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
// ending char: next {}() after posDeb
size_t posFin = _value.find_first_of(beginOrClose,posDeb+1);
if (posFin >= _value.size()) // not found
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
// the bounds
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
@ -212,7 +212,7 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
remove_leading(sBounds, delim);
size_t posDelim = sBounds.find_first_of(delim);
if (posDelim >= sBounds.size())
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
bool minBounded=false, maxBounded=false;
double minBound=0, maxBound=0;
@ -246,7 +246,7 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
if (minBounded && maxBounded)
{
if (maxBound <= minBound)
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
locBound = new eoRealInterval(minBound, maxBound);
}
else if (!minBounded && !maxBounded) // no bound at all

View file

@ -161,22 +161,22 @@ public:
virtual double minimum() const
{
throw std::logic_error("Trying to get minimum of unbounded eoRealBounds");
throw eoException("Trying to get minimum of unbounded eoRealBounds");
}
virtual double maximum() const
{
throw std::logic_error("Trying to get maximum of unbounded eoRealBounds");
throw eoException("Trying to get maximum of unbounded eoRealBounds");
}
virtual double range() const
{
throw std::logic_error("Trying to get range of unbounded eoRealBounds");
throw eoException("Trying to get range of unbounded eoRealBounds");
}
virtual double uniform(eoRng & _rng = eo::rng) const
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in unbounded eoRealBounds");
throw eoException("Trying to generate uniform values in unbounded eoRealBounds");
}
// methods from eoPersistent
@ -190,7 +190,7 @@ public:
{
(void)_is;
throw std::runtime_error("Should not use eoRealBounds::readFrom");
throw eoException("Should not use eoRealBounds::readFrom");
}
/**
@ -315,7 +315,7 @@ public :
{
(void)_is;
throw std::runtime_error("Should not use eoRealInterval::readFrom");
throw eoException("Should not use eoRealInterval::readFrom");
}
/**
@ -360,11 +360,11 @@ public :
virtual double maximum() const
{
throw std::logic_error("Trying to get maximum of eoRealBelowBound");
throw eoException("Trying to get maximum of eoRealBelowBound");
}
virtual double range() const
{
throw std::logic_error("Trying to get range of eoRealBelowBound");
throw eoException("Trying to get range of eoRealBelowBound");
}
// random generators
@ -372,7 +372,7 @@ public :
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in eoRealBelowBound");
throw eoException("Trying to generate uniform values in eoRealBelowBound");
}
// description
@ -417,7 +417,7 @@ public :
{
(void)_is;
throw std::runtime_error("Should not use eoRealBelowBound::readFrom");
throw eoException("Should not use eoRealBelowBound::readFrom");
}
/**
@ -459,11 +459,11 @@ public :
virtual double minimum() const
{
throw std::logic_error("Trying to get minimum of eoRealAboveBound");
throw eoException("Trying to get minimum of eoRealAboveBound");
}
virtual double range() const
{
throw std::logic_error("Trying to get range of eoRealAboveBound");
throw eoException("Trying to get range of eoRealAboveBound");
}
// random generators
@ -471,7 +471,7 @@ public :
{
(void)_rng;
throw std::logic_error("Trying to generate uniform values in eoRealAboveBound");
throw eoException("Trying to generate uniform values in eoRealAboveBound");
}
// description
@ -516,7 +516,7 @@ public :
{
(void)_is;
throw std::runtime_error("Should not use eoRealAboveBound::readFrom");
throw eoException("Should not use eoRealAboveBound::readFrom");
}
/**

View file

@ -250,7 +250,7 @@ public:
eoRealBaseVectorBounds(), factor(1, _dim), ownedBounds(0)
{
if (_max-_min<=0)
throw std::logic_error("Void range in eoRealVectorBounds");
throw eoException("Void range in eoRealVectorBounds");
eoRealBounds *ptBounds = new eoRealInterval(_min, _max);
// handle memory once
ownedBounds.push_back(ptBounds);
@ -265,7 +265,7 @@ public:
factor(_min.size(), 1), ownedBounds(0)
{
if (_max.size() != _min.size())
throw std::logic_error("Dimensions don't match in eoRealVectorBounds");
throw eoException("Dimensions don't match in eoRealVectorBounds");
// the bounds
eoRealBounds *ptBounds;
for (unsigned i=0; i<_min.size(); i++)
@ -386,20 +386,20 @@ public:
// accessors
virtual double minimum(unsigned)
{
throw std::logic_error("Trying to get minimum of eoRealVectorNoBounds");
throw eoException("Trying to get minimum of eoRealVectorNoBounds");
}
virtual double maximum(unsigned)
{
throw std::logic_error("Trying to get maximum of eoRealVectorNoBounds");
throw eoException("Trying to get maximum of eoRealVectorNoBounds");
}
virtual double range(unsigned)
{
throw std::logic_error("Trying to get range of eoRealVectorNoBounds");
throw eoException("Trying to get range of eoRealVectorNoBounds");
}
virtual double averageRange()
{
throw std::logic_error("Trying to get average range of eoRealVectorNoBounds");
throw eoException("Trying to get average range of eoRealVectorNoBounds");
}
// random generators
@ -407,7 +407,7 @@ public:
{
(void)_rng;
throw std::logic_error("No uniform distribution on eoRealVectorNoBounds");
throw eoException("No uniform distribution on eoRealVectorNoBounds");
}
// fills a std::vector with uniformly chosen variables in bounds
@ -415,7 +415,7 @@ public:
{
(void)_rng;
throw std::logic_error("No uniform distribution on eoRealVectorNoBounds");
throw eoException("No uniform distribution on eoRealVectorNoBounds");
}
};

View file

@ -29,6 +29,7 @@
#ifndef eoRndGenerators_h
#define eoRndGenerators_h
#include "../eoExceptions.h"
#include "eoRNG.h"
#include "../eoFunctor.h"
#include <stdexcept>
@ -80,7 +81,7 @@ template <class T = double> class eoUniformGenerator : public eoRndGenerator<T>
minim(_min), range(_max-_min), uniform(_rng)
{
if (_min>_max)
throw std::logic_error("Min is greater than Max in uniform_generator");
throw eoException("Min is greater than Max in uniform_generator");
}
/**

View file

@ -251,7 +251,7 @@ public :
virtual void operator()(const std::vector<const EOT*>& _pop)
{
if (whichElement > _pop.size())
throw std::logic_error("fitness requested of element outside of pop");
throw eoException("fitness requested of element outside of pop");
doit(_pop, Fitness());
}

View file

@ -69,7 +69,7 @@ void eoState::registerObject(eoPersistent& registrant)
}
else
{
throw logic_error("Interval error: object already present in the state");
throw eoException("Interval error: object already present in the state");
}
}
@ -79,8 +79,8 @@ void eoState::load(const string& _filename)
if (!is)
{
string str = "Could not open file " + _filename;
throw runtime_error(str);
// string str = "Could not open file " + _filename;
throw eoFileError(_filename);
}
load(is);
@ -96,8 +96,8 @@ void eoState::load(std::istream& is)
if (is.fail())
{
string str = "Error while reading stream";
throw runtime_error(str);
// string str = "Error while reading stream";
throw eoFileError("stream");
}
while(! is.eof())
@ -127,7 +127,7 @@ void eoState::load(std::istream& is)
while (getline(is, str))
{
if (is.eof())
throw runtime_error("No section in load file");
throw eoException("No section in load file");
if (is_section(str, name))
break;
@ -154,8 +154,8 @@ void eoState::save(const string& filename) const
if (!os)
{
string msg = "Could not open file: " + filename + " for writing!";
throw runtime_error(msg);
// string msg = "Could not open file: " + filename + " for writing!";
throw eoFileError(filename);
}
save(os);

View file

@ -82,7 +82,7 @@ template <class T = double> class eoUniformInit : public eoInit<T>
minim(_min), range(_max-_min), uniform(_rng)
{
if (_min>_max)
throw std::logic_error("Min is greater than Max in uniform_generator");
throw eoParamException("Min is greater than Max in uniform_generator");
}
/**

View file

@ -85,8 +85,8 @@ bool testDirRes(std::string _dirName, bool _erase=true)
// test for (unlikely) errors
if ( (res==-1) || (res==127) )
{
s = "Problem executing test of dir " + _dirName;
throw runtime_error(s);
// s = "Problem executing test of dir " + _dirName;
throw eoSystemError(s,res);
}
// now make sure there is a dir without any file in it - or quit
if (res) // no dir present
@ -108,7 +108,7 @@ bool testDirRes(std::string _dirName, bool _erase=true)
// WARNING: bug if dir exists and is empty; this says it is not!
// shoudl use scandir instead - no time now :-((( MS Aug. 01
s = "Dir " + _dirName + " is not empty";
throw runtime_error(s);
throw eoException(s);
return true;
}

View file

@ -31,6 +31,7 @@
#ifndef eoRND_GENERATORS_H
#define eoRND_GENERATORS_H
#include "../eoExceptions.h"
#include "eoRNG.h"
#include <stdexcept>
@ -56,7 +57,7 @@ template <class T = double> class uniform_generator
minim(_min), range(_max-_min), uniform(_rng)
{
if (_min>_max)
throw std::logic_error("Min is greater than Max in uniform_generator");
throw eoParamException("Min is greater than Max in uniform_generator");
}
T operator()(void) { return minim+static_cast<T>(uniform.uniform(range)); }
@ -99,7 +100,7 @@ template <class T = uint32_t> class random_generator
minim(_min), range(_max-_min), random(_rng)
{
if (_min>_max)
throw std::logic_error("Min is greater than Max in random_generator");
throw eoParamException("Min is greater than Max in random_generator");
}
T operator()(void) { return (T) (minim + random.random(range)); }

View file

@ -89,7 +89,7 @@ double sum_fitness(It begin, It end)
{
double v = static_cast<double>(begin->fitness());
if (v < 0.0)
throw std::logic_error("sum_fitness: negative fitness value encountered");
throw eoInvalidFitnessError("sum_fitness: negative fitness value encountered");
sum += v;
}