use eoExceptions everywhere
This commit is contained in:
parent
75ac37b02a
commit
eba2e14950
127 changed files with 524 additions and 418 deletions
|
|
@ -59,7 +59,7 @@ edoFileSnapshot::edoFileSnapshot(std::string dirname,
|
||||||
|
|
||||||
if ( (res == -1) || (res == 127) )
|
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
|
// now make sure there is a dir without any genXXX file in it
|
||||||
|
|
@ -112,8 +112,8 @@ eoMonitor& edoFileSnapshot::operator()(void)
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
std::string str = "edoFileSnapshot: Could not open " + _currentFileName;
|
// std::string str = "edoFileSnapshot: Could not open " + _currentFileName;
|
||||||
throw std::runtime_error(str);
|
throw eoFileError(_currentFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _saveFilenames )
|
if ( _saveFilenames )
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <stdexcept> // std::runtime_error
|
#include <stdexcept> // std::runtime_error
|
||||||
#include "eoObject.h" // eoObject
|
#include "eoObject.h" // eoObject
|
||||||
#include "eoPersistent.h" // eoPersistent
|
#include "eoPersistent.h" // eoPersistent
|
||||||
|
#include "eoExceptions.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@defgroup Core Core components
|
@defgroup Core Core components
|
||||||
|
|
@ -73,13 +74,14 @@ public:
|
||||||
/// Return fitness value.
|
/// Return fitness value.
|
||||||
const Fitness& fitness() const {
|
const Fitness& fitness() const {
|
||||||
if (invalid())
|
if (invalid())
|
||||||
throw std::runtime_error("invalid fitness");
|
throw eoInvalidFitnessError("Cannot retrieve unevaluated fitness");
|
||||||
return repFitness;
|
return repFitness;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked
|
/// Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked
|
||||||
Fitness& fitnessReference() {
|
Fitness& fitnessReference() {
|
||||||
if (invalid()) throw std::runtime_error("invalid fitness");
|
if (invalid())
|
||||||
|
throw eoInvalidFitnessError("Cannot retrieve unevaluated fitness reference");
|
||||||
return repFitness;
|
return repFitness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +122,7 @@ public:
|
||||||
* The read and print methods should be compatible and have the same format.
|
* The read and print methods should be compatible and have the same format.
|
||||||
* In principle, format is "plain": they just print a number
|
* In principle, format is "plain": they just print a number
|
||||||
* @param _is a std::istream.
|
* @param _is a std::istream.
|
||||||
* @throw runtime_std::exception If a valid object can't be read.
|
* @throw eoInvalidFitnessError If a valid object can't be read.
|
||||||
*/
|
*/
|
||||||
virtual void readFrom(std::istream& _is) {
|
virtual void readFrom(std::istream& _is) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public:
|
||||||
Fitness fitness () const
|
Fitness fitness () const
|
||||||
{
|
{
|
||||||
if (invalid ())
|
if (invalid ())
|
||||||
throw std::runtime_error ("invalid fitness in PO.h");
|
throw eoInvalidFitnessError("invalid fitness in PO.h");
|
||||||
return repFitness;
|
return repFitness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ public:
|
||||||
Fitness best () const
|
Fitness best () const
|
||||||
{
|
{
|
||||||
if (invalid ())
|
if (invalid ())
|
||||||
throw std::runtime_error ("invalid best fitness in PO.h");
|
throw eoInvalidFitnessError("invalid best fitness in PO.h");
|
||||||
return bestFitness;
|
return bestFitness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
|
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
|
||||||
throw std::runtime_error(stmp.c_str());
|
throw eoException(stmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
_state.storeFunctor(select);
|
_state.storeFunctor(select);
|
||||||
|
|
@ -260,7 +260,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Sorry, only deterministic tournament available at the moment");
|
throw eoException("Sorry, only deterministic tournament available at the moment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptReplace = new eoMGGReplacement<EOT>(-surviveParents, tSize);
|
ptReplace = new eoMGGReplacement<EOT>(-surviveParents, tSize);
|
||||||
|
|
@ -341,7 +341,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF
|
||||||
}
|
}
|
||||||
else // no replacement recognized
|
else // no replacement recognized
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Invalid replacement type " + replacementParam.first);
|
throw eoException("Invalid replacement type " + replacementParam.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptReplace = & make_general_replacement<EOT>(
|
ptReplace = & make_general_replacement<EOT>(
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
||||||
else // parameter passed by user as DetTour(T)
|
else // parameter passed by user as DetTour(T)
|
||||||
nicheSize = atof(ppSelect.second[0].c_str());
|
nicheSize = atof(ppSelect.second[0].c_str());
|
||||||
if (_dist == NULL) // no distance
|
if (_dist == NULL) // no distance
|
||||||
throw std::runtime_error("You didn't specify a distance when calling make_algo_scalar and using sharing");
|
throw eoException("You didn't specify a distance when calling make_algo_scalar and using sharing");
|
||||||
select = new eoSharingSelect<EOT>(nicheSize, *_dist);
|
select = new eoSharingSelect<EOT>(nicheSize, *_dist);
|
||||||
}
|
}
|
||||||
else if (ppSelect.first == std::string("StochTour"))
|
else if (ppSelect.first == std::string("StochTour"))
|
||||||
|
|
@ -206,7 +206,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
|
std::string stmp = std::string("Invalid selection: ") + ppSelect.first;
|
||||||
throw std::runtime_error(stmp.c_str());
|
throw eoException(stmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
_state.storeFunctor(select);
|
_state.storeFunctor(select);
|
||||||
|
|
@ -282,7 +282,7 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string stmp = std::string("Invalid replacement: ") + ppReplace.first;
|
std::string stmp = std::string("Invalid replacement: ") + ppReplace.first;
|
||||||
throw std::runtime_error(stmp.c_str());
|
throw eoException(stmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
_state.storeFunctor(replace);
|
_state.storeFunctor(replace);
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
|
||||||
|
|
||||||
// now check that there is at least one!
|
// now check that there is at least one!
|
||||||
if (!continuator)
|
if (!continuator)
|
||||||
throw std::runtime_error("You MUST provide a stopping criterion");
|
throw eoException("You MUST provide a stopping criterion");
|
||||||
// OK, it's there: store in the eoState
|
// OK, it's there: store in the eoState
|
||||||
_state.storeFunctor(continuator);
|
_state.storeFunctor(continuator);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
|
||||||
{
|
{
|
||||||
p = atof(_ppReduce.second[0].c_str());
|
p = atof(_ppReduce.second[0].c_str());
|
||||||
if ( (p<=0.5) || (p>1) )
|
if ( (p<=0.5) || (p>1) )
|
||||||
throw std::runtime_error("Stochastic tournament size should be in [0.5,1]");
|
throw eoException("Stochastic tournament size should be in [0.5,1]");
|
||||||
}
|
}
|
||||||
|
|
||||||
ptReduce = new eoStochTournamentTruncate<EOT>(p);
|
ptReduce = new eoStochTournamentTruncate<EOT>(p);
|
||||||
|
|
@ -110,7 +110,7 @@ eoReduce<EOT> & decode_reduce(eoParamParamType & _ppReduce, eoState & _state)
|
||||||
}
|
}
|
||||||
else // no known reduction entered
|
else // no known reduction entered
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Unknown reducer: " + _ppReduce.first);
|
throw eoException("Unknown reducer: " + _ppReduce.first);
|
||||||
}
|
}
|
||||||
// all done, stores and return a reference
|
// all done, stores and return a reference
|
||||||
_state.storeFunctor(ptReduce);
|
_state.storeFunctor(ptReduce);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
{
|
{
|
||||||
// First checks that no other eoCtrlCContinue does exist
|
// First checks that no other eoCtrlCContinue does exist
|
||||||
if (existCtrlCContinue)
|
if (existCtrlCContinue)
|
||||||
throw std::runtime_error("A signal handler for Ctrl C is already defined!\n");
|
throw eoParamException("A signal handler for Ctrl C is already defined!\n");
|
||||||
|
|
||||||
#ifndef _WINDOWS
|
#ifndef _WINDOWS
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
|
|
|
||||||
|
|
@ -261,8 +261,8 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
unsigned pSize = _pop.size();
|
unsigned pSize = _pop.size();
|
||||||
offspring.clear(); // new offspring
|
offspring.clear(); // new offspring
|
||||||
|
|
||||||
|
|
@ -273,17 +273,17 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
|
||||||
replace(_pop, offspring); // after replace, the new pop. is in _pop
|
replace(_pop, offspring); // after replace, the new pop. is in _pop
|
||||||
|
|
||||||
if (pSize > _pop.size())
|
if (pSize > _pop.size())
|
||||||
throw std::runtime_error("Population shrinking!");
|
throw eoException("Population shrinking!");
|
||||||
else if (pSize < _pop.size())
|
else if (pSize < _pop.size())
|
||||||
throw std::runtime_error("Population growing!");
|
throw eoException("Population growing!");
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch (std::exception& e)
|
// catch (std::exception& e)
|
||||||
{
|
// {
|
||||||
std::string s = e.what();
|
// std::string s = e.what();
|
||||||
s.append( " in eoEasyEA");
|
// s.append( " in eoEasyEA");
|
||||||
throw std::runtime_error( s );
|
// throw std::runtime_error( s );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
while ( continuator( _pop ) );
|
while ( continuator( _pop ) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,8 @@ public:
|
||||||
/// Apply a few iteration of flight to the population (=swarm).
|
/// Apply a few iteration of flight to the population (=swarm).
|
||||||
virtual void operator () (eoPop < POT > &_pop)
|
virtual void operator () (eoPop < POT > &_pop)
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// initializes the topology, velocity, best particle(s)
|
// initializes the topology, velocity, best particle(s)
|
||||||
init();
|
init();
|
||||||
do
|
do
|
||||||
|
|
@ -154,13 +154,13 @@ public:
|
||||||
}
|
}
|
||||||
while (continuator (_pop));
|
while (continuator (_pop));
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch (std::exception & e)
|
// catch (std::exception & e)
|
||||||
{
|
// {
|
||||||
std::string s = e.what ();
|
// std::string s = e.what ();
|
||||||
s.append (" in eoEasyPSO");
|
// s.append (" in eoEasyPSO");
|
||||||
throw std::runtime_error (s);
|
// throw std::runtime_error (s);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,8 @@ protected:
|
||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if ( !_of.is_open() ) {
|
if ( !_of.is_open() ) {
|
||||||
std::string str = "Error, eoEvalDump could not open: " + _filename;
|
// std::string str = "Error, eoEvalDump could not open: " + _filename;
|
||||||
throw std::runtime_error( str );
|
throw eoFileError( _filename );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// here, in release mode, we assume that the file could be opened
|
// here, in release mode, we assume that the file could be opened
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,69 @@ protected:
|
||||||
const std::string _msg;
|
const std::string _msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class eoInvalidFitnessError : public eoException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
eoInvalidFitnessError(std::string msg = "Invalid fitness") : eoException(msg) {}
|
||||||
|
~eoInvalidFitnessError() throw() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class eoPopSizeException : public eoException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
eoPopSizeException(size_t size, std::string msg = "") :
|
||||||
|
eoException(),
|
||||||
|
_size(size),
|
||||||
|
_msg(msg)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual std::string message() const throw()
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Bad population size: " << _size;
|
||||||
|
if(_msg != "") {
|
||||||
|
oss << ", " << _msg;
|
||||||
|
}
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
~eoPopSizeException() throw() {}
|
||||||
|
protected:
|
||||||
|
const size_t _size;
|
||||||
|
const std::string _msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class eoPopSizeChangeException : public eoPopSizeException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
eoPopSizeChangeException(size_t size_from, size_t size_to, std::string msg="") :
|
||||||
|
eoPopSizeException(0),
|
||||||
|
_size_from(size_from),
|
||||||
|
_size_to(size_to),
|
||||||
|
_msg(msg)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual std::string message() const throw()
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Population size changed from " << _size_from << " to " << _size_to;
|
||||||
|
if(_msg != "") {
|
||||||
|
oss << ", " << _msg;
|
||||||
|
}
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
~eoPopSizeChangeException() throw() {}
|
||||||
|
protected:
|
||||||
|
const size_t _size_from;
|
||||||
|
const size_t _size_to;
|
||||||
|
const std::string _msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Base class for exceptions which need to stop the algorithm to be handled
|
/** Base class for exceptions which need to stop the algorithm to be handled
|
||||||
*
|
*
|
||||||
* (like stopping criterion or numerical errors).
|
* (like stopping criterion or numerical errors).
|
||||||
|
|
@ -110,7 +173,7 @@ public:
|
||||||
virtual std::string message() const throw()
|
virtual std::string message() const throw()
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "STOP because the maximum number of allowed seconds has been reached ("
|
msg << "The maximum number of allowed seconds has been reached ("
|
||||||
<< _elapsed << ")";
|
<< _elapsed << ")";
|
||||||
return msg.str();
|
return msg.str();
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +203,7 @@ public:
|
||||||
virtual std::string message() const throw()
|
virtual std::string message() const throw()
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << " the maximum number of evaluation has been reached ("
|
msg << "The maximum number of evaluation has been reached ("
|
||||||
<< _threshold << ").";
|
<< _threshold << ").";
|
||||||
return msg.str();
|
return msg.str();
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +289,7 @@ public:
|
||||||
_cmd(cmd), _has_pipe(false), _err_code(-1), _output("")
|
_cmd(cmd), _has_pipe(false), _err_code(-1), _output("")
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
eoSystemError(std::string cmd, int err_code, std::string output) :
|
eoSystemError(std::string cmd, int err_code, std::string output = "") :
|
||||||
eoException(),
|
eoException(),
|
||||||
_cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output)
|
_cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output)
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -234,10 +297,12 @@ public:
|
||||||
virtual std::string message() const throw()
|
virtual std::string message() const throw()
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "System call: `" << _cmd << "` error";
|
ss << "System call: `" << _cmd << "` ended with error";
|
||||||
if(_has_pipe) {
|
if(_has_pipe) {
|
||||||
ss << " code #" << _err_code
|
ss << " code #" << _err_code;
|
||||||
<< " with the following output:" << std::endl << _output;
|
if(_output != "") {
|
||||||
|
ss << " with the following output:" << std::endl << _output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
@ -251,4 +316,24 @@ protected:
|
||||||
const std::string _output;
|
const std::string _output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class eoFileError : public eoSystemError
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
eoFileError(std::string filename) :
|
||||||
|
eoSystemError(""),
|
||||||
|
_filename(filename)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual std::string message() const throw()
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Could not open file: " << _filename;
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string _filename;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // __eoExceptions_h__
|
#endif // __eoExceptions_h__
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for ( unsigned i = 0; i < _eo1.size(); i++ ) {
|
for ( unsigned i = 0; i < _eo1.size(); i++ ) {
|
||||||
|
|
@ -109,7 +109,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
@ -155,7 +155,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
bool hasChanged = false;
|
bool hasChanged = false;
|
||||||
for (unsigned i=0; i<_eo1.size(); i++)
|
for (unsigned i=0; i<_eo1.size(); i++)
|
||||||
|
|
@ -199,7 +199,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
bool hasChanged = false;
|
bool hasChanged = false;
|
||||||
unsigned where = eo::rng.random(_eo1.size()-1);
|
unsigned where = eo::rng.random(_eo1.size()-1);
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
@ -146,7 +146,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
bool hasChanged = false;
|
bool hasChanged = false;
|
||||||
for (unsigned i=0; i<_eo1.size(); i++)
|
for (unsigned i=0; i<_eo1.size(); i++)
|
||||||
|
|
@ -191,7 +191,7 @@ public :
|
||||||
if (_eo1.size() != _eo2.size())
|
if (_eo1.size() != _eo2.size())
|
||||||
{
|
{
|
||||||
string s = "Operand size don't match in " + className();
|
string s = "Operand size don't match in " + className();
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
bool hasChanged = false;
|
bool hasChanged = false;
|
||||||
unsigned where = eo::rng.random(_eo1.size()-1);
|
unsigned where = eo::rng.random(_eo1.size()-1);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
if (_offspring.size() != toKeep)
|
if (_offspring.size() != toKeep)
|
||||||
{
|
{
|
||||||
std::cerr << "Les tailles " << _offspring.size() << " " << toKeep << std::endl;
|
std::cerr << "Les tailles " << _offspring.size() << " " << toKeep << std::endl;
|
||||||
throw std::runtime_error("eoG3Replacement: wrong number of remaining offspring");
|
throw eoException("eoG3Replacement: wrong number of remaining offspring");
|
||||||
}
|
}
|
||||||
// and put back into _parents
|
// and put back into _parents
|
||||||
plus(_offspring, _parents);
|
plus(_offspring, _parents);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include "eoSTLFunctor.h"
|
#include "eoSTLFunctor.h"
|
||||||
#include "utils/eoRndGenerators.h"
|
#include "utils/eoRndGenerators.h"
|
||||||
#include "utils/rnd_generators.h" // for shuffle method
|
#include "utils/rnd_generators.h" // for shuffle method
|
||||||
|
#include "eoExceptions.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,7 +135,7 @@ typedef typename EOT::AtomType AtomType;
|
||||||
: offset(_minSize), extent(_maxSize - _minSize), init(_init)
|
: offset(_minSize), extent(_maxSize - _minSize), init(_init)
|
||||||
{
|
{
|
||||||
if (_minSize >= _maxSize)
|
if (_minSize >= _maxSize)
|
||||||
throw std::logic_error("eoInitVariableLength: minSize larger or equal to maxSize");
|
throw eoException("eoInitVariableLength: minSize larger or equal to maxSize");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public:
|
||||||
if (neighborhoodSize >= _pop.size()){
|
if (neighborhoodSize >= _pop.size()){
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append (" Invalid neighborhood size in eoLinearTopology ");
|
s.append (" Invalid neighborhood size in eoLinearTopology ");
|
||||||
throw std::runtime_error (s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned howManyNeighborhood=_pop.size()/ neighborhoodSize;
|
unsigned howManyNeighborhood=_pop.size()/ neighborhoodSize;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
unsigned toKeep = temp.size(); // how many to keep from merged populations
|
unsigned toKeep = temp.size(); // how many to keep from merged populations
|
||||||
// minimal check
|
// minimal check
|
||||||
if (toKeep < 2)
|
if (toKeep < 2)
|
||||||
throw std::runtime_error("Not enough parents killed in eoMGGReplacement");
|
throw eoException("Not enough parents killed in eoMGGReplacement");
|
||||||
|
|
||||||
// select best offspring
|
// select best offspring
|
||||||
typename eoPop<EOT>::iterator it = _offspring.it_best_element();
|
typename eoPop<EOT>::iterator it = _offspring.it_best_element();
|
||||||
|
|
|
||||||
|
|
@ -67,13 +67,13 @@ public :
|
||||||
if (_interpret_as_rate)
|
if (_interpret_as_rate)
|
||||||
{
|
{
|
||||||
if ( (_rate<0) || (_rate>1) )
|
if ( (_rate<0) || (_rate>1) )
|
||||||
throw std::logic_error("eoElitism: rate shoud be in [0,1]");
|
throw eoParamException("eoElitism: rate shoud be in [0,1]");
|
||||||
rate = _rate;
|
rate = _rate;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_rate<0)
|
if (_rate<0)
|
||||||
throw std::logic_error("Negative number of offspring in eoElitism!");
|
throw eoParamException("Negative number of offspring in eoElitism!");
|
||||||
combien = (unsigned int)_rate;
|
combien = (unsigned int)_rate;
|
||||||
if (combien != _rate)
|
if (combien != _rate)
|
||||||
eo::log << eo::warnings << "Warning: Number of guys to merge in eoElitism was rounded" << std::endl;
|
eo::log << eo::warnings << "Warning: Number of guys to merge in eoElitism was rounded" << std::endl;
|
||||||
|
|
@ -91,7 +91,7 @@ public :
|
||||||
combienLocal = combien;
|
combienLocal = combien;
|
||||||
|
|
||||||
if (combienLocal > _pop.size())
|
if (combienLocal > _pop.size())
|
||||||
throw std::logic_error("Elite larger than population");
|
throw eoException("Elite larger than population");
|
||||||
|
|
||||||
std::vector<const EOT*> result;
|
std::vector<const EOT*> result;
|
||||||
_pop.nth_element(combienLocal, result);
|
_pop.nth_element(combienLocal, result);
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ private :
|
||||||
// Check whether the derived class was nice
|
// Check whether the derived class was nice
|
||||||
if (niche_count.size() != fronts[i].size())
|
if (niche_count.size() != fronts[i].size())
|
||||||
{
|
{
|
||||||
throw std::logic_error("eoNDSorting: niche and front should have the same size");
|
throw eoException("eoNDSorting: niche and front should have the same size");
|
||||||
}
|
}
|
||||||
|
|
||||||
double max_niche = *std::max_element(niche_count.begin(), niche_count.end());
|
double max_niche = *std::max_element(niche_count.begin(), niche_count.end());
|
||||||
|
|
@ -322,7 +322,7 @@ private :
|
||||||
// Check whether the derived class was nice
|
// Check whether the derived class was nice
|
||||||
if (niche_count.size() != current_front.size())
|
if (niche_count.size() != current_front.size())
|
||||||
{
|
{
|
||||||
throw std::logic_error("eoNDSorting: niche and front should have the same size");
|
throw eoException("eoNDSorting: niche and front should have the same size");
|
||||||
}
|
}
|
||||||
|
|
||||||
double max_niche = *std::max_element(niche_count.begin(), niche_count.end());
|
double max_niche = *std::max_element(niche_count.begin(), niche_count.end());
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class eoOneToOneBreeder: public eoBreed<EOT>
|
||||||
// check: only one offspring?
|
// check: only one offspring?
|
||||||
unsigned posEnd = popit.tellp();
|
unsigned posEnd = popit.tellp();
|
||||||
if (posEnd != pos)
|
if (posEnd != pos)
|
||||||
throw std::runtime_error("Operator can only generate a SINGLE offspring in eoOneToOneBreeder");
|
throw eoException("Operator can only generate a SINGLE offspring in eoOneToOneBreeder");
|
||||||
|
|
||||||
// do the tournament between parent and offspring
|
// do the tournament between parent and offspring
|
||||||
eval(leOffspring); // first need to evaluate the offspring
|
eval(leOffspring); // first need to evaluate the offspring
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ Authors:
|
||||||
#include "eoPersistent.h"
|
#include "eoPersistent.h"
|
||||||
#include "eoInit.h"
|
#include "eoInit.h"
|
||||||
#include "utils/rnd_generators.h" // for shuffle method
|
#include "utils/rnd_generators.h" // for shuffle method
|
||||||
|
#include "eoExceptions.h"
|
||||||
|
|
||||||
/** A std::vector of EO object, to be used in all algorithms
|
/** A std::vector of EO object, to be used in all algorithms
|
||||||
* (selectors, operators, replacements, ...).
|
* (selectors, operators, replacements, ...).
|
||||||
|
|
@ -108,7 +109,7 @@ class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
|
||||||
unsigned oldSize = size();
|
unsigned oldSize = size();
|
||||||
if (_newPopSize < oldSize)
|
if (_newPopSize < oldSize)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("New size smaller than old size in pop.append");
|
throw eoPopSizeChangeException(oldSize, _newPopSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_newPopSize == oldSize)
|
if (_newPopSize == oldSize)
|
||||||
|
|
@ -222,7 +223,7 @@ class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
|
||||||
typename eoPop<EOT>::const_iterator it = std::max_element(begin(), end());
|
typename eoPop<EOT>::const_iterator it = std::max_element(begin(), end());
|
||||||
#endif
|
#endif
|
||||||
if( it == end() )
|
if( it == end() )
|
||||||
throw std::runtime_error("eoPop<EOT>: Empty population, when calling best_element().");
|
throw eoPopSizeException(this->size());
|
||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public:
|
||||||
eoProportionalSelect(const eoPop<EOT>& /*pop*/ = eoPop<EOT>())
|
eoProportionalSelect(const eoPop<EOT>& /*pop*/ = eoPop<EOT>())
|
||||||
{
|
{
|
||||||
if (minimizing_fitness<EOT>())
|
if (minimizing_fitness<EOT>())
|
||||||
throw std::logic_error("eoProportionalSelect: minimizing fitness");
|
throw eoException("eoProportionalSelect: minimizing fitness");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(const eoPop<EOT>& _pop)
|
void setup(const eoPop<EOT>& _pop)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append (" min > max in eoRandomRealWeightUp");
|
s.append (" min > max in eoRandomRealWeightUp");
|
||||||
throw std::runtime_error (s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
if (_eo == &(*it))
|
if (_eo == &(*it))
|
||||||
return it-_pop.begin();
|
return it-_pop.begin();
|
||||||
}
|
}
|
||||||
throw std::runtime_error("Not found in eoLinearRanking");
|
throw eoException("Not found in eoLinearRanking");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* COmputes the ranked fitness: fitnesses range in [m,M]
|
/* COmputes the ranked fitness: fitnesses range in [m,M]
|
||||||
|
|
@ -74,7 +74,7 @@ public:
|
||||||
unsigned int pSizeMinusOne = pSize-1;
|
unsigned int pSizeMinusOne = pSize-1;
|
||||||
|
|
||||||
if (pSize <= 1)
|
if (pSize <= 1)
|
||||||
throw std::runtime_error("Cannot do ranking with population of size <= 1");
|
throw eoPopSizeException(pSize,"cannot do ranking with population of size <= 1");
|
||||||
|
|
||||||
// value() refers to the std::vector of worthes (we're in an eoParamvalue)
|
// value() refers to the std::vector of worthes (we're in an eoParamvalue)
|
||||||
value().resize(pSize);
|
value().resize(pSize);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ template <class EOT> class eoTruncate : public eoReduce<EOT>
|
||||||
if (_newgen.size() == _newsize)
|
if (_newgen.size() == _newsize)
|
||||||
return;
|
return;
|
||||||
if (_newgen.size() < _newsize)
|
if (_newgen.size() < _newsize)
|
||||||
throw std::logic_error("eoTruncate: Cannot truncate to a larger size!\n");
|
throw eoException("eoTruncate: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
_newgen.sort();
|
_newgen.sort();
|
||||||
_newgen.resize(_newsize);
|
_newgen.resize(_newsize);
|
||||||
|
|
@ -74,7 +74,7 @@ template <class EOT> class eoRandomReduce : public eoReduce<EOT>
|
||||||
if (_newgen.size() == _newsize)
|
if (_newgen.size() == _newsize)
|
||||||
return;
|
return;
|
||||||
if (_newgen.size() < _newsize)
|
if (_newgen.size() < _newsize)
|
||||||
throw std::logic_error("eoRandomReduce: Cannot truncate to a larger size!\n");
|
throw eoException("eoRandomReduce: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
// shuffle the population, then trucate
|
// shuffle the population, then trucate
|
||||||
_newgen.shuffle();
|
_newgen.shuffle();
|
||||||
|
|
@ -123,7 +123,7 @@ public:
|
||||||
if (presentSize == _newsize)
|
if (presentSize == _newsize)
|
||||||
return;
|
return;
|
||||||
if (presentSize < _newsize)
|
if (presentSize < _newsize)
|
||||||
throw std::logic_error("eoTruncate: Cannot truncate to a larger size!\n");
|
throw eoException("eoTruncate: Cannot truncate to a larger size!\n");
|
||||||
std::vector<EPpair> scores(presentSize);
|
std::vector<EPpair> scores(presentSize);
|
||||||
for (unsigned i=0; i<presentSize; i++)
|
for (unsigned i=0; i<presentSize; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -186,7 +186,7 @@ class eoLinearTruncate : public eoReduce<EOT>
|
||||||
if (oldSize == _newsize)
|
if (oldSize == _newsize)
|
||||||
return;
|
return;
|
||||||
if (oldSize < _newsize)
|
if (oldSize < _newsize)
|
||||||
throw std::logic_error("eoLinearTruncate: Cannot truncate to a larger size!\n");
|
throw eoException("eoLinearTruncate: Cannot truncate to a larger size!\n");
|
||||||
for (unsigned i=0; i<oldSize - _newsize; i++)
|
for (unsigned i=0; i<oldSize - _newsize; i++)
|
||||||
{
|
{
|
||||||
typename eoPop<EOT>::iterator it = _newgen.it_worse_element();
|
typename eoPop<EOT>::iterator it = _newgen.it_worse_element();
|
||||||
|
|
@ -224,7 +224,7 @@ public:
|
||||||
if (oldSize == _newsize)
|
if (oldSize == _newsize)
|
||||||
return;
|
return;
|
||||||
if (oldSize < _newsize)
|
if (oldSize < _newsize)
|
||||||
throw std::logic_error("eoDetTournamentTruncate: Cannot truncate to a larger size!\n");
|
throw eoException("eoDetTournamentTruncate: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
|
|
||||||
// Now OK to erase some losers
|
// Now OK to erase some losers
|
||||||
|
|
@ -280,7 +280,7 @@ public:
|
||||||
if (oldSize == _newsize)
|
if (oldSize == _newsize)
|
||||||
return;
|
return;
|
||||||
if (oldSize < _newsize)
|
if (oldSize < _newsize)
|
||||||
throw std::logic_error("eoStochTournamentTruncate: Cannot truncate to a larger size!\n");
|
throw eoException("eoStochTournamentTruncate: Cannot truncate to a larger size!\n");
|
||||||
// Now OK to erase some losers
|
// Now OK to erase some losers
|
||||||
for (unsigned i=0; i<oldSize - _newsize; i++)
|
for (unsigned i=0; i<oldSize - _newsize; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class eoReduceMerge : public eoReplacement<EOT>
|
||||||
void operator()(eoPop<EOT>& _parents, eoPop<EOT>& _offspring)
|
void operator()(eoPop<EOT>& _parents, eoPop<EOT>& _offspring)
|
||||||
{
|
{
|
||||||
if (_parents.size() < _offspring.size())
|
if (_parents.size() < _offspring.size())
|
||||||
throw std::logic_error("eoReduceMerge: More offspring than parents!\n");
|
throw eoPopSizeChangeException(_parents.size(), _offspring.size(),"more offspring than parents!");
|
||||||
reduce(_parents, _parents.size() - _offspring.size());
|
reduce(_parents, _parents.size() - _offspring.size());
|
||||||
merge(_offspring, _parents);
|
merge(_offspring, _parents);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public:
|
||||||
// then the offspring
|
// then the offspring
|
||||||
unsigned reducedOffspringSize = howManyReducedOffspring(offSize);
|
unsigned reducedOffspringSize = howManyReducedOffspring(offSize);
|
||||||
if (!reducedOffspringSize)
|
if (!reducedOffspringSize)
|
||||||
throw std::runtime_error("No offspring left after reduction!");
|
throw eoPopSizeException(reducedOffspringSize,"no offspring left after reduction!");
|
||||||
if (reducedOffspringSize != offSize) // need reduction
|
if (reducedOffspringSize != offSize) // need reduction
|
||||||
reduceOffspring(_offspring, reducedOffspringSize);
|
reduceOffspring(_offspring, reducedOffspringSize);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
return ;
|
return ;
|
||||||
unsigned newsize = popSize - eliminated;
|
unsigned newsize = popSize - eliminated;
|
||||||
if (newsize < 0)
|
if (newsize < 0)
|
||||||
throw std::logic_error("eoTruncateSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoTruncateSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
_newgen.nth_element(newsize);
|
_newgen.nth_element(newsize);
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ public:
|
||||||
return ;
|
return ;
|
||||||
long newsize = static_cast<long>(popSize) - static_cast<long>(eliminated);
|
long newsize = static_cast<long>(popSize) - static_cast<long>(eliminated);
|
||||||
if (newsize < 0)
|
if (newsize < 0)
|
||||||
throw std::logic_error("eoLinearTruncateSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoLinearTruncateSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
_eliminated.reserve(_eliminated.size()+eliminated); //in case not empty?
|
_eliminated.reserve(_eliminated.size()+eliminated); //in case not empty?
|
||||||
for (unsigned i=0; i<eliminated; i++)
|
for (unsigned i=0; i<eliminated; i++)
|
||||||
|
|
@ -143,7 +143,7 @@ public:
|
||||||
return ;
|
return ;
|
||||||
unsigned newsize = popSize - eliminated;
|
unsigned newsize = popSize - eliminated;
|
||||||
if (newsize < 0)
|
if (newsize < 0)
|
||||||
throw std::logic_error("eoRandomSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoRandomSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
_newgen.shuffle();
|
_newgen.shuffle();
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ public:
|
||||||
return ;
|
return ;
|
||||||
unsigned newsize = popSize - eliminated;
|
unsigned newsize = popSize - eliminated;
|
||||||
if (newsize < 0)
|
if (newsize < 0)
|
||||||
throw std::logic_error("eoLinearRandomSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoLinearRandomSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
_eliminated.reserve(_eliminated.size()+eliminated); //in case not empty?
|
_eliminated.reserve(_eliminated.size()+eliminated); //in case not empty?
|
||||||
for (unsigned i=0; i<eliminated; i++)
|
for (unsigned i=0; i<eliminated; i++)
|
||||||
|
|
@ -234,7 +234,7 @@ public:
|
||||||
return ;
|
return ;
|
||||||
unsigned newsize = popSize - eliminated;
|
unsigned newsize = popSize - eliminated;
|
||||||
if (newsize < 0)
|
if (newsize < 0)
|
||||||
throw std::logic_error("eoDetTournamentTruncateSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoDetTournamentTruncateSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
|
|
||||||
_eliminated.reserve(_eliminated.size()+eliminated); //in case not empty?
|
_eliminated.reserve(_eliminated.size()+eliminated); //in case not empty?
|
||||||
|
|
@ -291,7 +291,7 @@ public:
|
||||||
unsigned newSize = oldSize - _eliminated.size();
|
unsigned newSize = oldSize - _eliminated.size();
|
||||||
unsigned eliminated = howMany(popSize);
|
unsigned eliminated = howMany(popSize);
|
||||||
if (newSize < 0)
|
if (newSize < 0)
|
||||||
throw std::logic_error("eoStochTournamentTruncateSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoStochTournamentTruncateSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
end of old version */
|
end of old version */
|
||||||
|
|
||||||
|
|
@ -301,7 +301,7 @@ end of old version */
|
||||||
return ;
|
return ;
|
||||||
unsigned newsize = popSize - eliminated;
|
unsigned newsize = popSize - eliminated;
|
||||||
if (newsize < 0)
|
if (newsize < 0)
|
||||||
throw std::logic_error("eoDetTournamentTruncateSplit: Cannot truncate to a larger size!\n");
|
throw eoException("eoDetTournamentTruncateSplit: Cannot truncate to a larger size!\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public:
|
||||||
{
|
{
|
||||||
// First checks that no other eoSIGContinue does exist
|
// First checks that no other eoSIGContinue does exist
|
||||||
if (existSIGContinue)
|
if (existSIGContinue)
|
||||||
throw std::runtime_error("A signal handler is already defined!\n");
|
throw eoParamException("A signal handler is already defined!\n");
|
||||||
|
|
||||||
#ifndef _WINDOWS
|
#ifndef _WINDOWS
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
if ( objectTypeStr == "eoRandomSelect" ) {
|
if ( objectTypeStr == "eoRandomSelect" ) {
|
||||||
selectPtr = new eoRandomSelect<EOT>( rate );
|
selectPtr = new eoRandomSelect<EOT>( rate );
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error( "Incorrect selector type" );
|
throw eoException( "Incorrect selector type" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectPtr;
|
return selectPtr;
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ protected:
|
||||||
std::vector<typename EOT::Fitness> fitness;
|
std::vector<typename EOT::Fitness> fitness;
|
||||||
void check_sync(unsigned index, const EOT& _eo) {
|
void check_sync(unsigned index, const EOT& _eo) {
|
||||||
if (fitness[index] != _eo.fitness()) {
|
if (fitness[index] != _eo.fitness()) {
|
||||||
throw std::runtime_error("eoSelectFromWorth: fitnesses are not in sync");
|
throw eoException("eoSelectFromWorth: fitnesses are not in sync");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ template <class EOT> class eoEliteSequentialSelect: public eoSelectOne<EOT>
|
||||||
unsigned int ibest = 0;
|
unsigned int ibest = 0;
|
||||||
const EOT * best = eoPters[0];
|
const EOT * best = eoPters[0];
|
||||||
if (_pop.size() == 1)
|
if (_pop.size() == 1)
|
||||||
throw std::runtime_error("Trying eoEliteSequentialSelect with only one individual!");
|
throw eoException("Trying eoEliteSequentialSelect with only one individual!");
|
||||||
for (unsigned i=1; i<_pop.size(); i++)
|
for (unsigned i=1; i<_pop.size(); i++)
|
||||||
if (*eoPters[i]>*best)
|
if (*eoPters[i]>*best)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#ifndef eoSharing_h
|
#ifndef eoSharing_h
|
||||||
#define eoSharing_h
|
#define eoSharing_h
|
||||||
|
|
||||||
|
#include "eoExceptions.h"
|
||||||
#include "eoPerf2Worth.h"
|
#include "eoPerf2Worth.h"
|
||||||
#include "utils/eoDistance.h"
|
#include "utils/eoDistance.h"
|
||||||
|
|
||||||
|
|
@ -100,7 +101,7 @@ public:
|
||||||
unsigned i, j,
|
unsigned i, j,
|
||||||
pSize=_pop.size();
|
pSize=_pop.size();
|
||||||
if (pSize <= 1)
|
if (pSize <= 1)
|
||||||
throw std::runtime_error("Apptempt to do sharing with population of size 1");
|
throw eoPopSizeException(pSize, "attempt to do sharing with population of size 1");
|
||||||
value().resize(pSize);
|
value().resize(pSize);
|
||||||
std::vector<double> sim(pSize); // to hold the similarities
|
std::vector<double> sim(pSize); // to hold the similarities
|
||||||
dMatrix distMatrix(pSize); // to hold the distances
|
dMatrix distMatrix(pSize); // to hold the distances
|
||||||
|
|
|
||||||
|
|
@ -73,21 +73,21 @@ template<class EOT> class eoSimpleEDA: public eoEDA<EOT>
|
||||||
eoPop<EOT> pop(popSize, _distrib);
|
eoPop<EOT> pop(popSize, _distrib);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
apply<EOT>(_distrib, pop); // re-init. of _pop from distrib
|
apply<EOT>(_distrib, pop); // re-init. of _pop from distrib
|
||||||
|
|
||||||
apply<EOT>(eval, pop); // eval of current population
|
apply<EOT>(eval, pop); // eval of current population
|
||||||
|
|
||||||
update(_distrib, pop); // updates distrib from _pop
|
update(_distrib, pop); // updates distrib from _pop
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch (std::exception& e)
|
// catch (std::exception& e)
|
||||||
{
|
// {
|
||||||
std::string s = e.what();
|
// std::string s = e.what();
|
||||||
s.append( " in eoSimpleEDA");
|
// s.append( " in eoSimpleEDA");
|
||||||
throw std::runtime_error( s );
|
// throw std::runtime_error( s );
|
||||||
}
|
// }
|
||||||
} while ( continuator( pop ) );
|
} while ( continuator( pop ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public:
|
||||||
else{
|
else{
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append (" Invalid indice in eoSocialNeighborhood ");
|
s.append (" Invalid indice in eoSocialNeighborhood ");
|
||||||
throw std::runtime_error (s);
|
throw eoException(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
eoStochasticUniversalSelect(const eoPop<EOT>& pop = eoPop<EOT>())
|
eoStochasticUniversalSelect(const eoPop<EOT>& pop = eoPop<EOT>())
|
||||||
{
|
{
|
||||||
if (minimizing_fitness<EOT>())
|
if (minimizing_fitness<EOT>())
|
||||||
throw std::logic_error("eoStochasticUniversalSelect: minimizing fitness");
|
throw eoException("eoStochasticUniversalSelect: minimizing fitness");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(const eoPop<EOT>& _pop)
|
void setup(const eoPop<EOT>& _pop)
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ public:
|
||||||
// carefull, we can have a rate of 1 if we want to kill all remaining
|
// carefull, we can have a rate of 1 if we want to kill all remaining
|
||||||
unsigned nbDie = std::min(howmanyDie(pSize), pSize-nbSurvive);
|
unsigned nbDie = std::min(howmanyDie(pSize), pSize-nbSurvive);
|
||||||
if (nbDie > nbRemaining)
|
if (nbDie > nbRemaining)
|
||||||
throw std::logic_error("eoDeterministicSurviveAndDie: Too many to kill!\n");
|
throw eoException("eoDeterministicSurviveAndDie: Too many to kill!\n");
|
||||||
|
|
||||||
if (!nbDie)
|
if (!nbDie)
|
||||||
{
|
{
|
||||||
|
|
@ -169,7 +169,7 @@ public:
|
||||||
|
|
||||||
unsigned survivorSize = luckyOffspring.size() + luckyParents.size();
|
unsigned survivorSize = luckyOffspring.size() + luckyParents.size();
|
||||||
if (survivorSize > pSize)
|
if (survivorSize > pSize)
|
||||||
throw std::logic_error("eoGeneralReplacement: More survivors than parents!\n");
|
throw eoPopSizeChangeException(survivorSize, pSize, "more survivors than parents!");
|
||||||
|
|
||||||
plus(_parents, _offspring); // all that remain in _offspring
|
plus(_parents, _offspring); // all that remain in _offspring
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ template<class Chrom> class eoSwapMutation: public eoMonOp<Chrom>
|
||||||
{
|
{
|
||||||
// consistency check
|
// consistency check
|
||||||
if(howManySwaps < 1)
|
if(howManySwaps < 1)
|
||||||
throw std::runtime_error("Invalid number of swaps in eoSwapMutation");
|
throw eoException("Invalid number of swaps in eoSwapMutation");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The class name.
|
/// The class name.
|
||||||
|
|
|
||||||
|
|
@ -181,8 +181,8 @@ public:
|
||||||
virtual void operator () (eoPop < POT > &_pop)
|
virtual void operator () (eoPop < POT > &_pop)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// initializes the topology, velocity, best particle(s)
|
// initializes the topology, velocity, best particle(s)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
@ -206,13 +206,13 @@ public:
|
||||||
}
|
}
|
||||||
while (continuator (_pop));
|
while (continuator (_pop));
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch (std::exception & e)
|
// catch (std::exception & e)
|
||||||
{
|
// {
|
||||||
std::string s = e.what ();
|
// std::string s = e.what ();
|
||||||
s.append (" in eoSyncEasyPSO");
|
// s.append (" in eoSyncEasyPSO");
|
||||||
throw std::runtime_error (s);
|
// throw std::runtime_error (s);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ public:
|
||||||
{
|
{
|
||||||
// minimal check
|
// minimal check
|
||||||
if (updateFactor>=1)
|
if (updateFactor>=1)
|
||||||
throw std::runtime_error("Update factor must be < 1 in eoOneFifthMutation");
|
throw eoParamException("Update factor must be < 1 in eoOneFifthMutation");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The class name */
|
/** The class name */
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class eoRealInitBounded : public eoInit<EOT>
|
||||||
eoRealInitBounded(eoRealVectorBounds & _bounds):bounds(_bounds)
|
eoRealInitBounded(eoRealVectorBounds & _bounds):bounds(_bounds)
|
||||||
{
|
{
|
||||||
if (!bounds.isBounded())
|
if (!bounds.isBounded())
|
||||||
throw std::runtime_error("Needs bounded bounds to initialize a std::vector<double>");
|
throw eoException("Needs bounded bounds to initialize a std::vector<double>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** simply passes the argument to the uniform method of the bounds */
|
/** simply passes the argument to the uniform method of the bounds */
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ template<class EOT> class eoUniformMutation: public eoMonOp<EOT>
|
||||||
{
|
{
|
||||||
// sanity check ?
|
// sanity check ?
|
||||||
if (_eo.size() != bounds.size())
|
if (_eo.size() != bounds.size())
|
||||||
throw std::runtime_error("Invalid size of indi in eoUniformMutation");
|
throw eoException("Invalid size of indi in eoUniformMutation");
|
||||||
|
|
||||||
for (unsigned lieu=0; lieu<_eo.size(); lieu++)
|
for (unsigned lieu=0; lieu<_eo.size(); lieu++)
|
||||||
if (rng.flip(p_change[lieu]))
|
if (rng.flip(p_change[lieu]))
|
||||||
|
|
@ -213,7 +213,7 @@ template<class EOT> class eoDetUniformMutation: public eoMonOp<EOT>
|
||||||
{
|
{
|
||||||
// sanity check ?
|
// sanity check ?
|
||||||
if (_eo.size() != bounds.size())
|
if (_eo.size() != bounds.size())
|
||||||
throw std::runtime_error("Invalid size of indi in eoDetUniformMutation");
|
throw eoException("Invalid size of indi in eoDetUniformMutation");
|
||||||
for (unsigned i=0; i<no; i++)
|
for (unsigned i=0; i<no; i++)
|
||||||
{
|
{
|
||||||
unsigned lieu = rng.random(_eo.size());
|
unsigned lieu = rng.random(_eo.size());
|
||||||
|
|
@ -357,7 +357,7 @@ template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
|
||||||
bounds(eoDummyVectorNoBounds), alpha(_alpha), range(1+2*_alpha)
|
bounds(eoDummyVectorNoBounds), alpha(_alpha), range(1+2*_alpha)
|
||||||
{
|
{
|
||||||
if (_alpha < 0)
|
if (_alpha < 0)
|
||||||
throw std::runtime_error("BLX coefficient should be positive");
|
throw eoParamException("BLX coefficient should be positive");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -373,7 +373,7 @@ template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
|
||||||
bounds(_bounds), alpha(_alpha), range(1+2*_alpha)
|
bounds(_bounds), alpha(_alpha), range(1+2*_alpha)
|
||||||
{
|
{
|
||||||
if (_alpha < 0)
|
if (_alpha < 0)
|
||||||
throw std::runtime_error("BLX coefficient should be positive");
|
throw eoParamException("BLX coefficient should be positive");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The class name.
|
/// The class name.
|
||||||
|
|
|
||||||
|
|
@ -51,34 +51,34 @@
|
||||||
|
|
||||||
// Algo
|
// Algo
|
||||||
///////
|
///////
|
||||||
eoAlgo<eoEsSimple<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsSimple<double> >& _eval, eoContinue<eoEsSimple<double> >& _continue, eoGenOp<eoEsSimple<double> >& _op, eoDistance<eoEsSimple<double> >* _dist)
|
eoAlgo<eoEsSimple<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsSimple<double> >& _eval, eoContinue<eoEsSimple<double> >& _continue, eoGenOp<eoEsSimple<double> >& _op, eoDistance<eoEsSimple<double> >* /*_dist*/)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoAlgo<eoEsSimple<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsSimple<eoMinimizingFitness> >& _eval, eoContinue<eoEsSimple<eoMinimizingFitness> >& _continue, eoGenOp<eoEsSimple<eoMinimizingFitness> >& _op, eoDistance<eoEsSimple<eoMinimizingFitness> >* _dist)
|
eoAlgo<eoEsSimple<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsSimple<eoMinimizingFitness> >& _eval, eoContinue<eoEsSimple<eoMinimizingFitness> >& _continue, eoGenOp<eoEsSimple<eoMinimizingFitness> >& _op, eoDistance<eoEsSimple<eoMinimizingFitness> >* /*_dist*/)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
eoAlgo<eoEsStdev<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsStdev<double> >& _eval, eoContinue<eoEsStdev<double> >& _continue, eoGenOp<eoEsStdev<double> >& _op, eoDistance<eoEsStdev<double> >* _dist)
|
eoAlgo<eoEsStdev<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsStdev<double> >& _eval, eoContinue<eoEsStdev<double> >& _continue, eoGenOp<eoEsStdev<double> >& _op, eoDistance<eoEsStdev<double> >* /*_dist*/)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoAlgo<eoEsStdev<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsStdev<eoMinimizingFitness> >& _eval, eoContinue<eoEsStdev<eoMinimizingFitness> >& _continue, eoGenOp<eoEsStdev<eoMinimizingFitness> >& _op, eoDistance<eoEsStdev<eoMinimizingFitness> >* _dist)
|
eoAlgo<eoEsStdev<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsStdev<eoMinimizingFitness> >& _eval, eoContinue<eoEsStdev<eoMinimizingFitness> >& _continue, eoGenOp<eoEsStdev<eoMinimizingFitness> >& _op, eoDistance<eoEsStdev<eoMinimizingFitness> >* /*_dist*/)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
eoAlgo<eoEsFull<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsFull<double> >& _eval, eoContinue<eoEsFull<double> >& _continue, eoGenOp<eoEsFull<double> >& _op, eoDistance<eoEsFull<double> >* _dist)
|
eoAlgo<eoEsFull<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsFull<double> >& _eval, eoContinue<eoEsFull<double> >& _continue, eoGenOp<eoEsFull<double> >& _op, eoDistance<eoEsFull<double> >* /*_dist*/)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoAlgo<eoEsFull<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsFull<eoMinimizingFitness> >& _eval, eoContinue<eoEsFull<eoMinimizingFitness> >& _continue, eoGenOp<eoEsFull<eoMinimizingFitness> >& _op, eoDistance<eoEsFull<eoMinimizingFitness> >* _dist)
|
eoAlgo<eoEsFull<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoEsFull<eoMinimizingFitness> >& _eval, eoContinue<eoEsFull<eoMinimizingFitness> >& _continue, eoGenOp<eoEsFull<eoMinimizingFitness> >& _op, eoDistance<eoEsFull<eoMinimizingFitness> >* /*_dist*/)
|
||||||
{
|
{
|
||||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ eoEsChromInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
|
||||||
is >> sigma;
|
is >> sigma;
|
||||||
// minimum check
|
// minimum check
|
||||||
if(sigma < 0)
|
if(sigma < 0)
|
||||||
throw std::runtime_error("Negative sigma in make_genotype");
|
throw eoException("Negative sigma in make_genotype");
|
||||||
if(to_scale)
|
if(to_scale)
|
||||||
init = new eoEsChromInit<EOT>(boundsParam.value(), sigma, to_scale);
|
init = new eoEsChromInit<EOT>(boundsParam.value(), sigma, to_scale);
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
if (v.size() == 2) // a min and a max for all variables
|
if (v.size() == 2) // a min and a max for all variables
|
||||||
ptBounds = new eoRealVectorBounds(vecSize, v[0], v[1]);
|
ptBounds = new eoRealVectorBounds(vecSize, v[0], v[1]);
|
||||||
else // no time now
|
else // no time now
|
||||||
throw std::runtime_error("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
|
throw eoException("Sorry, only unique bounds for all variables implemented at the moment. Come back later");
|
||||||
// we need to give ownership of this pointer to somebody
|
// we need to give ownership of this pointer to somebody
|
||||||
/////////// end of temporary code
|
/////////// end of temporary code
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'o', "Genetic Operators");
|
'o', "Genetic Operators");
|
||||||
|
|
||||||
if (operatorParam.value() != std::string("SGA"))
|
if (operatorParam.value() != std::string("SGA"))
|
||||||
throw std::runtime_error("Sorry, only SGA-like operator available right now\n");
|
throw eoException("Sorry, only SGA-like operator available right now\n");
|
||||||
|
|
||||||
// now we read Pcross and Pmut,
|
// now we read Pcross and Pmut,
|
||||||
// the relative weights for all crossovers -> proportional choice
|
// the relative weights for all crossovers -> proportional choice
|
||||||
|
|
@ -138,14 +138,14 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'C', "Genetic Operators" );
|
'C', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
eoValueParam<double>& pMutParam
|
eoValueParam<double>& pMutParam
|
||||||
= _parser.getORcreateParam(0.1, "pMut", "Probability of Mutation",
|
= _parser.getORcreateParam(0.1, "pMut", "Probability of Mutation",
|
||||||
'M', "Genetic Operators" );
|
'M', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
// the crossovers
|
// the crossovers
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
@ -156,7 +156,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
's', "Genetic Operators" );
|
's', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (segmentRateParam.value() < 0) )
|
if ( (segmentRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid segmentRate");
|
throw eoParamException("Invalid segmentRate");
|
||||||
|
|
||||||
eoValueParam<double>& arithmeticRateParam
|
eoValueParam<double>& arithmeticRateParam
|
||||||
= _parser.getORcreateParam(double(2.0), "arithmeticRate",
|
= _parser.getORcreateParam(double(2.0), "arithmeticRate",
|
||||||
|
|
@ -164,7 +164,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'A', "Genetic Operators" );
|
'A', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (arithmeticRateParam.value() < 0) )
|
if ( (arithmeticRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid arithmeticRate");
|
throw eoParamException("Invalid arithmeticRate");
|
||||||
|
|
||||||
// minimum check
|
// minimum check
|
||||||
bool bCross = true;
|
bool bCross = true;
|
||||||
|
|
@ -202,14 +202,14 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'e', "Genetic Operators" );
|
'e', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (epsilonParam.value() < 0) )
|
if ( (epsilonParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid epsilon");
|
throw eoParamException("Invalid epsilon");
|
||||||
|
|
||||||
eoValueParam<double> & uniformMutRateParam
|
eoValueParam<double> & uniformMutRateParam
|
||||||
= _parser.getORcreateParam(1.0, "uniformMutRate",
|
= _parser.getORcreateParam(1.0, "uniformMutRate",
|
||||||
"Relative rate for uniform mutation", 'u', "Genetic Operators" );
|
"Relative rate for uniform mutation", 'u', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (uniformMutRateParam.value() < 0) )
|
if ( (uniformMutRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid uniformMutRate");
|
throw eoParamException("Invalid uniformMutRate");
|
||||||
|
|
||||||
eoValueParam<double> & detMutRateParam
|
eoValueParam<double> & detMutRateParam
|
||||||
= _parser.getORcreateParam(1.0, "detMutRate",
|
= _parser.getORcreateParam(1.0, "detMutRate",
|
||||||
|
|
@ -217,7 +217,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'd', "Genetic Operators" );
|
'd', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (detMutRateParam.value() < 0) )
|
if ( (detMutRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid detMutRate");
|
throw eoParamException("Invalid detMutRate");
|
||||||
|
|
||||||
eoValueParam<double> & normalMutRateParam
|
eoValueParam<double> & normalMutRateParam
|
||||||
= _parser.getORcreateParam(1.0, "normalMutRate",
|
= _parser.getORcreateParam(1.0, "normalMutRate",
|
||||||
|
|
@ -225,7 +225,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'd', "Genetic Operators" );
|
'd', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (normalMutRateParam.value() < 0) )
|
if ( (normalMutRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid normalMutRate");
|
throw eoParamException("Invalid normalMutRate");
|
||||||
// and the sigma
|
// and the sigma
|
||||||
eoValueParam<double> & sigmaParam
|
eoValueParam<double> & sigmaParam
|
||||||
= _parser.getORcreateParam(1.0, "sigma",
|
= _parser.getORcreateParam(1.0, "sigma",
|
||||||
|
|
@ -233,7 +233,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
'S', "Genetic Operators" );
|
'S', "Genetic Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (sigmaParam.value() < 0) )
|
if ( (sigmaParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid sigma");
|
throw eoParamException("Invalid sigma");
|
||||||
|
|
||||||
// minimum check
|
// minimum check
|
||||||
bool bMut = true;
|
bool bMut = true;
|
||||||
|
|
@ -243,7 +243,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
bMut = false;
|
bMut = false;
|
||||||
}
|
}
|
||||||
if (!bCross && !bMut)
|
if (!bCross && !bMut)
|
||||||
throw std::runtime_error("No operator called in SGA operator definition!!!");
|
throw eoException("No operator called in SGA operator definition!!!");
|
||||||
|
|
||||||
// Create the CombinedMonOp
|
// Create the CombinedMonOp
|
||||||
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;
|
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'o', "Variation Operators");
|
'o', "Variation Operators");
|
||||||
|
|
||||||
if (operatorParam.value() != std::string("SGA"))
|
if (operatorParam.value() != std::string("SGA"))
|
||||||
throw std::runtime_error("Sorry, only SGA-like operator available right now\n");
|
throw eoException("Sorry, only SGA-like operator available right now\n");
|
||||||
|
|
||||||
// now we read Pcross and Pmut,
|
// now we read Pcross and Pmut,
|
||||||
// and create the eoGenOp that is exactly
|
// and create the eoGenOp that is exactly
|
||||||
|
|
@ -99,14 +99,14 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'C', "Variation Operators" );
|
'C', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
eoValueParam<double>& pMutParam
|
eoValueParam<double>& pMutParam
|
||||||
= _parser.getORcreateParam(1.0, "pMut", "Probability of Mutation",
|
= _parser.getORcreateParam(1.0, "pMut", "Probability of Mutation",
|
||||||
'M', "Variation Operators" );
|
'M', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
|
|
||||||
// crossover
|
// crossover
|
||||||
|
|
@ -140,7 +140,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
ptObjAtomCross = new eoDoubleIntermediate;
|
ptObjAtomCross = new eoDoubleIntermediate;
|
||||||
else if (crossObjParam.value() == std::string("none"))
|
else if (crossObjParam.value() == std::string("none"))
|
||||||
ptObjAtomCross = new eoBinCloneOp<double>;
|
ptObjAtomCross = new eoBinCloneOp<double>;
|
||||||
else throw std::runtime_error("Invalid Object variable crossover type");
|
else throw eoException("Invalid Object variable crossover type");
|
||||||
|
|
||||||
if (crossStdevParam.value() == std::string("discrete"))
|
if (crossStdevParam.value() == std::string("discrete"))
|
||||||
ptStdevAtomCross = new eoDoubleExchange;
|
ptStdevAtomCross = new eoDoubleExchange;
|
||||||
|
|
@ -148,7 +148,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
ptStdevAtomCross = new eoDoubleIntermediate;
|
ptStdevAtomCross = new eoDoubleIntermediate;
|
||||||
else if (crossStdevParam.value() == std::string("none"))
|
else if (crossStdevParam.value() == std::string("none"))
|
||||||
ptStdevAtomCross = new eoBinCloneOp<double>;
|
ptStdevAtomCross = new eoBinCloneOp<double>;
|
||||||
else throw std::runtime_error("Invalid mutation strategy parameter crossover type");
|
else throw eoException("Invalid mutation strategy parameter crossover type");
|
||||||
|
|
||||||
// and build the indi Xover
|
// and build the indi Xover
|
||||||
if (crossTypeParam.value() == std::string("global"))
|
if (crossTypeParam.value() == std::string("global"))
|
||||||
|
|
@ -160,7 +160,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
);
|
);
|
||||||
ptCross = new eoBinGenOp<EOT>(crossTmp);
|
ptCross = new eoBinGenOp<EOT>(crossTmp);
|
||||||
}
|
}
|
||||||
else throw std::runtime_error("Invalide Object variable crossover type");
|
else throw eoException("Invalide Object variable crossover type");
|
||||||
|
|
||||||
// now that everything is OK, DON'T FORGET TO STORE MEMORY
|
// now that everything is OK, DON'T FORGET TO STORE MEMORY
|
||||||
_state.storeFunctor(ptObjAtomCross);
|
_state.storeFunctor(ptObjAtomCross);
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'o', "Variation Operators");
|
'o', "Variation Operators");
|
||||||
|
|
||||||
if (operatorParam.value() != std::string("SGA"))
|
if (operatorParam.value() != std::string("SGA"))
|
||||||
throw std::runtime_error("Sorry, only SGA-like operator available right now\n");
|
throw eoException("Sorry, only SGA-like operator available right now\n");
|
||||||
|
|
||||||
// now we read Pcross and Pmut,
|
// now we read Pcross and Pmut,
|
||||||
// the relative weights for all crossovers -> proportional choice
|
// the relative weights for all crossovers -> proportional choice
|
||||||
|
|
@ -103,7 +103,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'C', "Variation Operators" );
|
'C', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
eoValueParam<double>& pMutParam
|
eoValueParam<double>& pMutParam
|
||||||
= _parser.getORcreateParam(0.1, "pMut",
|
= _parser.getORcreateParam(0.1, "pMut",
|
||||||
|
|
@ -111,7 +111,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'M', "Variation Operators" );
|
'M', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
// the crossovers
|
// the crossovers
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
@ -122,7 +122,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'a', "Variation Operators" );
|
'a', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (alphaParam.value() < 0) )
|
if ( (alphaParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid BLX coefficient alpha");
|
throw eoParamException("Invalid BLX coefficient alpha");
|
||||||
|
|
||||||
|
|
||||||
eoValueParam<double>& segmentRateParam
|
eoValueParam<double>& segmentRateParam
|
||||||
|
|
@ -131,7 +131,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
's', "Variation Operators" );
|
's', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (segmentRateParam.value() < 0) )
|
if ( (segmentRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid segmentRate");
|
throw eoParamException("Invalid segmentRate");
|
||||||
|
|
||||||
eoValueParam<double>& hypercubeRateParam
|
eoValueParam<double>& hypercubeRateParam
|
||||||
= _parser.getORcreateParam(double(1.0), "hypercubeRate",
|
= _parser.getORcreateParam(double(1.0), "hypercubeRate",
|
||||||
|
|
@ -139,7 +139,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'A', "Variation Operators" );
|
'A', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (hypercubeRateParam.value() < 0) )
|
if ( (hypercubeRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid hypercubeRate");
|
throw eoParamException("Invalid hypercubeRate");
|
||||||
|
|
||||||
eoValueParam<double>& uxoverRateParam
|
eoValueParam<double>& uxoverRateParam
|
||||||
= _parser.getORcreateParam(double(1.0), "uxoverRate",
|
= _parser.getORcreateParam(double(1.0), "uxoverRate",
|
||||||
|
|
@ -147,7 +147,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'A', "Variation Operators" );
|
'A', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (uxoverRateParam.value() < 0) )
|
if ( (uxoverRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid uxoverRate");
|
throw eoParamException("Invalid uxoverRate");
|
||||||
|
|
||||||
// minimum check
|
// minimum check
|
||||||
bool bCross = true;
|
bool bCross = true;
|
||||||
|
|
@ -191,7 +191,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'e', "Variation Operators" );
|
'e', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (epsilonParam.value() < 0) )
|
if ( (epsilonParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid epsilon");
|
throw eoParamException("Invalid epsilon");
|
||||||
|
|
||||||
eoValueParam<double> & uniformMutRateParam
|
eoValueParam<double> & uniformMutRateParam
|
||||||
= _parser.getORcreateParam(1.0, "uniformMutRate",
|
= _parser.getORcreateParam(1.0, "uniformMutRate",
|
||||||
|
|
@ -199,7 +199,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'u', "Variation Operators" );
|
'u', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (uniformMutRateParam.value() < 0) )
|
if ( (uniformMutRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid uniformMutRate");
|
throw eoParamException("Invalid uniformMutRate");
|
||||||
|
|
||||||
eoValueParam<double> & detMutRateParam
|
eoValueParam<double> & detMutRateParam
|
||||||
= _parser.getORcreateParam(1.0, "detMutRate",
|
= _parser.getORcreateParam(1.0, "detMutRate",
|
||||||
|
|
@ -207,14 +207,14 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
'd', "Variation Operators" );
|
'd', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (detMutRateParam.value() < 0) )
|
if ( (detMutRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid detMutRate");
|
throw eoParamException("Invalid detMutRate");
|
||||||
|
|
||||||
eoValueParam<double> & normalMutRateParam
|
eoValueParam<double> & normalMutRateParam
|
||||||
= _parser.getORcreateParam(1.0, "normalMutRate",
|
= _parser.getORcreateParam(1.0, "normalMutRate",
|
||||||
"Relative rate for Gaussian mutation", 'd', "Variation Operators" );
|
"Relative rate for Gaussian mutation", 'd', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (normalMutRateParam.value() < 0) )
|
if ( (normalMutRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid normalMutRate");
|
throw eoParamException("Invalid normalMutRate");
|
||||||
|
|
||||||
eoValueParam<double> & sigmaParam
|
eoValueParam<double> & sigmaParam
|
||||||
= _parser.getORcreateParam(0.3, "sigma",
|
= _parser.getORcreateParam(0.3, "sigma",
|
||||||
|
|
@ -234,7 +234,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
|
||||||
bMut = false;
|
bMut = false;
|
||||||
}
|
}
|
||||||
if (!bCross && !bMut)
|
if (!bCross && !bMut)
|
||||||
throw std::runtime_error("No operator called in SGA operator definition!!!");
|
throw eoException("No operator called in SGA operator definition!!!");
|
||||||
|
|
||||||
// Create the CombinedMonOp
|
// Create the CombinedMonOp
|
||||||
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;
|
eoPropCombinedMonOp<EOT> *ptCombinedMonOp = NULL;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ eoDistribUpdater<EOT> & do_make_PBILupdate(eoParser & _parser, eoState& _state,
|
||||||
ptUpdate = new eoPBILAdditive<EOT>(LRBest, nbBest, tolerance, LRWorst, nbWorst);
|
ptUpdate = new eoPBILAdditive<EOT>(LRBest, nbBest, tolerance, LRWorst, nbWorst);
|
||||||
}
|
}
|
||||||
else
|
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
|
// done: don't forget to store the allocated pointers
|
||||||
_state.storeFunctor(ptUpdate);
|
_state.storeFunctor(ptUpdate);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
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"))
|
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,
|
// now we read Pcross and Pmut,
|
||||||
// the relative weights for all crossovers -> proportional choice
|
// 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" );
|
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
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" );
|
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||||
throw std::runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
// the crossovers
|
// 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" );
|
eoValueParam<double>& onePointRateParam = _parser.createParam(double(1.0), "onePointRate", "Relative rate for one point crossover", '1', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (onePointRateParam.value() < 0) )
|
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" );
|
eoValueParam<double>& twoPointsRateParam = _parser.createParam(double(1.0), "twoPointRate", "Relative rate for two point crossover", '2', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (twoPointsRateParam.value() < 0) )
|
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" );
|
eoValueParam<double>& uRateParam = _parser.createParam(double(2.0), "uRate", "Relative rate for uniform crossover", 'U', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (uRateParam.value() < 0) )
|
if ( (uRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid uRate");
|
throw eoParamException("Invalid uRate");
|
||||||
|
|
||||||
// minimum check
|
// minimum check
|
||||||
// bool bCross = true; // not used ?
|
// 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" );
|
eoValueParam<double> & pMutPerBitParam = _parser.createParam(0.01, "pMutPerBit", "Probability of flipping 1 bit in bit-flip mutation", 'b', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutPerBitParam.value() < 0) || (pMutPerBitParam.value() > 0.5) )
|
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" );
|
eoValueParam<double> & bitFlipRateParam = _parser.createParam(0.01, "bitFlipRate", "Relative rate for bit-flip mutation", 's', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (bitFlipRateParam.value() < 0) )
|
if ( (bitFlipRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid bitFlipRate");
|
throw eoParamException("Invalid bitFlipRate");
|
||||||
|
|
||||||
// oneBitFlip
|
// 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 eoParamException("Invalid oneBitRate");
|
||||||
|
|
||||||
// kBitFlip
|
// kBitFlip
|
||||||
eoValueParam<unsigned> & kBitParam = _parser.createParam((unsigned)1, "kBit", "Number of bit for deterministic k bit-flip mutation", 0, "Variation Operators" );
|
eoValueParam<unsigned> & kBitParam = _parser.createParam((unsigned)1, "kBit", "Number of bit for deterministic k bit-flip mutation", 0, "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( ! kBitParam.value() )
|
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" );
|
eoValueParam<double> & kBitRateParam = _parser.createParam(0.0, "kBitRate", "Relative rate for deterministic k bit-flip mutation", 0, "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (kBitRateParam.value() < 0) )
|
if ( (kBitRateParam.value() < 0) )
|
||||||
throw std::runtime_error("Invalid kBitRate");
|
throw eoParamException("Invalid kBitRate");
|
||||||
|
|
||||||
// minimum check
|
// minimum check
|
||||||
// bool bMut = true; // not used ?
|
// bool bMut = true; // not used ?
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
|
||||||
{
|
{
|
||||||
if(initializor.empty())
|
if(initializor.empty())
|
||||||
{
|
{
|
||||||
throw std::logic_error("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?");
|
throw eoException("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?");
|
||||||
}
|
}
|
||||||
// lets sort the initializor std::vector according to arity (so we can be sure the terminals are in front)
|
// lets sort the initializor std::vector according to arity (so we can be sure the terminals are in front)
|
||||||
// we use stable_sort so that if element i was in front of element j and they have the same arity i remains in front of j
|
// we use stable_sort so that if element i was in front of element j and they have the same arity i remains in front of j
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class eoStParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
|
||||||
{
|
{
|
||||||
if(_node.empty())
|
if(_node.empty())
|
||||||
{
|
{
|
||||||
throw std::logic_error("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?");
|
throw eoException("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ namespace eo
|
||||||
{
|
{
|
||||||
if ( _packetSize <= 0 )
|
if ( _packetSize <= 0 )
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Packet size should not be negative.");
|
throw eoException("Packet size should not be negative.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if( table )
|
if( table )
|
||||||
|
|
|
||||||
|
|
@ -115,13 +115,13 @@ PyEO& pop_getitem(eoPop<PyEO>& pop, boost::python::object key)
|
||||||
{
|
{
|
||||||
boost::python::extract<int> x(key);
|
boost::python::extract<int> x(key);
|
||||||
if (!x.check())
|
if (!x.check())
|
||||||
throw index_error("Slicing not allowed");
|
throw eoException("Slicing not allowed");
|
||||||
|
|
||||||
int i = x();
|
int i = x();
|
||||||
|
|
||||||
if (static_cast<unsigned>(i) >= pop.size())
|
if (static_cast<unsigned>(i) >= pop.size())
|
||||||
{
|
{
|
||||||
throw index_error("Index out of bounds");
|
throw eoException("Index out of bounds");
|
||||||
}
|
}
|
||||||
return pop[i];
|
return pop[i];
|
||||||
}
|
}
|
||||||
|
|
@ -130,13 +130,13 @@ void pop_setitem(eoPop<PyEO>& pop, boost::python::object key, PyEO& value)
|
||||||
{
|
{
|
||||||
boost::python::extract<int> x(key);
|
boost::python::extract<int> x(key);
|
||||||
if (!x.check())
|
if (!x.check())
|
||||||
throw index_error("Slicing not allowed");
|
throw eoException("Slicing not allowed");
|
||||||
|
|
||||||
int i = x();
|
int i = x();
|
||||||
|
|
||||||
if (static_cast<unsigned>(i) >= pop.size())
|
if (static_cast<unsigned>(i) >= pop.size())
|
||||||
{
|
{
|
||||||
throw index_error("Index out of bounds");
|
throw eoException("Index out of bounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
pop[i] = value;
|
pop[i] = value;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public :
|
||||||
{
|
{
|
||||||
if (which >= objective_info.size())
|
if (which >= objective_info.size())
|
||||||
{
|
{
|
||||||
throw index_error("Too few elements allocated, resize objectives first");
|
throw eoException("Too few elements allocated, resize objectives first");
|
||||||
}
|
}
|
||||||
|
|
||||||
objective_info[which] = value;
|
objective_info[which] = value;
|
||||||
|
|
@ -70,7 +70,7 @@ public :
|
||||||
boost::python::extract<double> x(object::operator[](i));
|
boost::python::extract<double> x(object::operator[](i));
|
||||||
|
|
||||||
if (!x.check())
|
if (!x.check())
|
||||||
throw std::runtime_error("PyFitness: does not contain doubles");
|
throw eoException("PyFitness: does not contain doubles");
|
||||||
return x();
|
return x();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public:
|
||||||
{
|
{
|
||||||
if (static_cast<unsigned>(i) >= vec.size())
|
if (static_cast<unsigned>(i) >= vec.size())
|
||||||
{
|
{
|
||||||
throw index_error("Index out of bounds");
|
throw eoException("Index out of bounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
return vec[i]->getValue();
|
return vec[i]->getValue();
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ const PyEO& popview_getitem(const std::vector<const PyEO*>& pop, int it)
|
||||||
{
|
{
|
||||||
unsigned item = unsigned(it);
|
unsigned item = unsigned(it);
|
||||||
if (item > pop.size())
|
if (item > pop.size())
|
||||||
throw index_error("too much");
|
throw eoException("too much");
|
||||||
|
|
||||||
return *pop[item];
|
return *pop[item];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ void setv< std::vector<double>, numeric::array >
|
||||||
{
|
{
|
||||||
extract<double> x(val[i]);
|
extract<double> x(val[i]);
|
||||||
if (!x.check())
|
if (!x.check())
|
||||||
throw std::runtime_error("double expected");
|
throw eoException("double expected");
|
||||||
|
|
||||||
v[i] = x();
|
v[i] = x();
|
||||||
}
|
}
|
||||||
|
|
@ -130,9 +130,9 @@ void setv< std::pair<double, double>, tuple >
|
||||||
extract<double> second(val[1]);
|
extract<double> second(val[1]);
|
||||||
|
|
||||||
if (!first.check())
|
if (!first.check())
|
||||||
throw std::runtime_error("doubles expected");
|
throw eoException("doubles expected");
|
||||||
if (!second.check())
|
if (!second.check())
|
||||||
throw std::runtime_error("doubles expected");
|
throw eoException("doubles expected");
|
||||||
|
|
||||||
p.value().first = first();
|
p.value().first = first();
|
||||||
p.value().second = second();
|
p.value().second = second();
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public :
|
||||||
|
|
||||||
virtual void operator()(const eoPop<EOT>& _pop) {
|
virtual void operator()(const eoPop<EOT>& _pop) {
|
||||||
if( whichFitnessTerm >= _pop[0].fitness().size() )
|
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;
|
double result =0.0;
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
|
|
@ -102,7 +102,7 @@ public:
|
||||||
|
|
||||||
virtual void operator()(const eoPop<EOT>& _pop) {
|
virtual void operator()(const eoPop<EOT>& _pop) {
|
||||||
if( whichFitnessTerm >= _pop[0].fitness().size() )
|
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];
|
value() = _pop.best_element().fitness()[whichFitnessTerm];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ public:
|
||||||
/** just to be sure the add method is not called further
|
/** just to be sure the add method is not called further
|
||||||
*/
|
*/
|
||||||
virtual void add(const eoParam& )
|
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:
|
private:
|
||||||
eoFDCStat<EOT> & FDCstat;
|
eoFDCStat<EOT> & FDCstat;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "eoFileMonitor.h"
|
#include "eoFileMonitor.h"
|
||||||
#include "compatibility.h"
|
#include "compatibility.h"
|
||||||
#include "eoParam.h"
|
#include "eoParam.h"
|
||||||
|
#include "../eoExceptions.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -36,8 +37,8 @@ void eoFileMonitor::printHeader()
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
string str = "eoFileMonitor could not open: " + filename;
|
// string str = "eoFileMonitor could not open: " + filename;
|
||||||
throw runtime_error(str);
|
throw eoFileError(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
printHeader(os);
|
printHeader(os);
|
||||||
|
|
@ -54,8 +55,8 @@ eoMonitor& eoFileMonitor::operator()(void)
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
string str = "eoFileMonitor could not write to: " + filename;
|
// string str = "eoFileMonitor could not write to: " + filename;
|
||||||
throw runtime_error(str);
|
throw eoFileError(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "eoMonitor.h"
|
#include "eoMonitor.h"
|
||||||
#include "../eoObject.h"
|
#include "../eoObject.h"
|
||||||
|
#include "../eoExceptions.h"
|
||||||
|
|
||||||
|
|
||||||
/** Prints statistics to file
|
/** Prints statistics to file
|
||||||
|
|
@ -75,8 +76,8 @@ public :
|
||||||
std::ofstream os (filename.c_str ());
|
std::ofstream os (filename.c_str ());
|
||||||
|
|
||||||
if (!os) {
|
if (!os) {
|
||||||
std::string str = "Error, eoFileMonitor could not open: " + filename;
|
// std::string str = "Error, eoFileMonitor could not open: " + filename;
|
||||||
throw std::runtime_error (str);
|
throw eoFileError(filename);
|
||||||
}
|
}
|
||||||
} // if ! keep
|
} // if ! keep
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public :
|
||||||
int res = system(s.c_str());
|
int res = system(s.c_str());
|
||||||
// test for (unlikely) errors
|
// test for (unlikely) errors
|
||||||
if ( (res==-1) || (res==127) )
|
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
|
// now make sure there is a dir without any genXXX file in it
|
||||||
if (res) // no dir present
|
if (res) // no dir present
|
||||||
{
|
{
|
||||||
|
|
@ -122,8 +122,8 @@ public :
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
std::string str = "eoFileSnapshot: Could not open " + currentFileName;
|
// std::string str = "eoFileSnapshot: Could not open " + currentFileName;
|
||||||
throw std::runtime_error(str);
|
throw eoFileError(currentFileName);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return operator()(os);
|
return operator()(os);
|
||||||
|
|
@ -151,7 +151,7 @@ public :
|
||||||
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
|
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
|
||||||
vv[i] = ptParam->value();
|
vv[i] = ptParam->value();
|
||||||
if (vv[i].size() != v.size())
|
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++)
|
for (unsigned k=0; k<v.size(); k++)
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +173,7 @@ public :
|
||||||
{
|
{
|
||||||
if (!dynamic_cast<const eoValueParam<std::vector<double> >*>(&_param))
|
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);
|
eoMonitor::add(_param);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "eoGnuplot.h"
|
#include "eoGnuplot.h"
|
||||||
|
#include "../eoExceptions.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned eoGnuplot::numWindow=0;
|
unsigned eoGnuplot::numWindow=0;
|
||||||
|
|
@ -82,7 +83,7 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
||||||
args[5] = 0;
|
args[5] = 0;
|
||||||
gpCom = PipeComOpenArgv( GNUPLOT_PROGRAM, args );
|
gpCom = PipeComOpenArgv( GNUPLOT_PROGRAM, args );
|
||||||
if(! gpCom )
|
if(! gpCom )
|
||||||
throw std::runtime_error("Cannot spawn gnuplot\n");
|
throw eoSystemError(GNUPLOT_PROGRAM);
|
||||||
else {
|
else {
|
||||||
PipeComSend( gpCom, "set grid\n" );
|
PipeComSend( gpCom, "set grid\n" );
|
||||||
PipeComSend( gpCom, _extra.c_str() );
|
PipeComSend( gpCom, _extra.c_str() );
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ void eoGnuplot1DMonitor::FirstPlot()
|
||||||
{
|
{
|
||||||
if (this->vec.size() < 2)
|
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
|
#ifdef HAVE_GNUPLOT
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ public:
|
||||||
{
|
{
|
||||||
unsigned int combloc = -count;
|
unsigned int combloc = -count;
|
||||||
if (_size<combloc)
|
if (_size<combloc)
|
||||||
throw std::runtime_error("Negative result in eoHowMany");
|
throw eoException("Negative result in eoHowMany");
|
||||||
return _size-combloc;
|
return _size-combloc;
|
||||||
}
|
}
|
||||||
return unsigned(count);
|
return unsigned(count);
|
||||||
|
|
@ -167,7 +167,7 @@ public:
|
||||||
|
|
||||||
// minimal check
|
// minimal check
|
||||||
if ( rate < 0.0 )
|
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 */
|
/** The unary - operator: reverses the computation */
|
||||||
|
|
@ -188,7 +188,7 @@ public:
|
||||||
{
|
{
|
||||||
rate = 1.0+_rate;
|
rate = 1.0+_rate;
|
||||||
if (rate < 0) // was < -1
|
if (rate < 0) // was < -1
|
||||||
throw std::logic_error("rate < -1 in eoHowMany!");
|
throw eoException("rate < -1 in eoHowMany!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -31,17 +31,17 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
|
||||||
std::string delim(",; ");
|
std::string delim(",; ");
|
||||||
std::string beginOrClose("[(])");
|
std::string beginOrClose("[(])");
|
||||||
if (!remove_leading(_value, delim)) // only delimiters were left
|
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
|
// look for opening char
|
||||||
size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b]
|
size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b]
|
||||||
if (posDeb >= _value.size()) // nothing left to read
|
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
|
// ending char: next {}() after posDeb
|
||||||
size_t posFin = _value.find_first_of(beginOrClose,posDeb+1);
|
size_t posFin = _value.find_first_of(beginOrClose,posDeb+1);
|
||||||
if (posFin >= _value.size()) // not found
|
if (posFin >= _value.size()) // not found
|
||||||
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
|
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
|
||||||
|
|
||||||
// the bounds
|
// the bounds
|
||||||
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
|
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
|
||||||
|
|
@ -51,7 +51,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
|
||||||
remove_leading(sBounds, delim);
|
remove_leading(sBounds, delim);
|
||||||
size_t posDelim = sBounds.find_first_of(delim);
|
size_t posDelim = sBounds.find_first_of(delim);
|
||||||
if (posDelim >= sBounds.size())
|
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;
|
bool minBounded=false, maxBounded=false;
|
||||||
long int minBound=0, maxBound=0;
|
long int minBound=0, maxBound=0;
|
||||||
|
|
@ -85,7 +85,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
|
||||||
if (minBounded && maxBounded)
|
if (minBounded && maxBounded)
|
||||||
{
|
{
|
||||||
if (maxBound <= minBound)
|
if (maxBound <= minBound)
|
||||||
throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor");
|
throw eoException("Syntax error in eoGeneralIntBounds Ctor");
|
||||||
locBound = new eoIntInterval(minBound, maxBound);
|
locBound = new eoIntInterval(minBound, maxBound);
|
||||||
}
|
}
|
||||||
else if (!minBounded && !maxBounded) // no bound at all
|
else if (!minBounded && !maxBounded) // no bound at all
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <stdexcept> // std::exceptions!
|
#include <stdexcept> // std::exceptions!
|
||||||
#include "eoRNG.h"
|
#include "eoRNG.h"
|
||||||
|
#include "../eoExceptions.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class eoIntBounds eoIntBounds.h es/eoIntBounds.h
|
\class eoIntBounds eoIntBounds.h es/eoIntBounds.h
|
||||||
|
|
@ -163,29 +164,29 @@ public:
|
||||||
|
|
||||||
virtual long int minimum() const
|
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
|
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
|
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
|
virtual double uniform(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(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
|
virtual long int random(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(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
|
// methods from eoPersistent
|
||||||
|
|
@ -199,7 +200,7 @@ public:
|
||||||
{
|
{
|
||||||
(void)_is;
|
(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)
|
repMinimum(_min), repMaximum(_max), repRange(_max-_min)
|
||||||
{
|
{
|
||||||
if (repRange<=0)
|
if (repRange<=0)
|
||||||
throw std::logic_error("Void range in eoIntBounds");
|
throw eoException("Void range in eoIntBounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
@ -328,7 +329,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_is;
|
(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
|
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
|
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
|
virtual double uniform(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(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
|
virtual long int random(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(void)_rng;
|
||||||
|
|
||||||
throw std::logic_error("Trying to generate uniform values in eoIntBelowBound");
|
throw eoException("Trying to generate uniform values in eoIntBelowBound");
|
||||||
}
|
}
|
||||||
|
|
||||||
// description
|
// description
|
||||||
|
|
@ -437,7 +438,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_is;
|
(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
|
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
|
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
|
virtual double uniform(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(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
|
virtual long int random(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(void)_rng;
|
||||||
|
|
||||||
throw std::logic_error("Trying to generate uniform values in eoIntAboveBound");
|
throw eoException("Trying to generate uniform values in eoIntAboveBound");
|
||||||
}
|
}
|
||||||
|
|
||||||
// description
|
// description
|
||||||
|
|
@ -545,7 +546,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_is;
|
(void)_is;
|
||||||
|
|
||||||
throw std::runtime_error("Should not use eoIntAboveBound::readFrom");
|
throw eoException("Should not use eoIntAboveBound::readFrom");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
eoMonitor& eoOStreamMonitor::operator()(void)
|
eoMonitor& eoOStreamMonitor::operator()(void)
|
||||||
{
|
{
|
||||||
if (!out) {
|
if (!out) {
|
||||||
std::string str = "eoOStreamMonitor: Could not write to the output stream";
|
// std::string str = "eoOStreamMonitor: Could not write to the output stream";
|
||||||
throw std::runtime_error(str);
|
throw eoFileError("output stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firsttime) {
|
if (firsttime) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../eoScalarFitness.h"
|
#include "../eoScalarFitness.h"
|
||||||
|
#include "../eoExceptions.h"
|
||||||
|
|
||||||
/** @defgroup Parameters Parameters management
|
/** @defgroup Parameters Parameters management
|
||||||
*
|
*
|
||||||
|
|
@ -385,14 +386,14 @@ inline void eoValueParam<std::vector<eoMinimizingFitness> >::setValue(const std:
|
||||||
template <>
|
template <>
|
||||||
inline std::string eoValueParam<std::vector<void*> >::getValue(void) const
|
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("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void eoValueParam<std::vector<void*> >::setValue(const std::string&)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
|
||||||
ifs.peek(); // check if it exists
|
ifs.peek(); // check if it exists
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
{
|
{
|
||||||
string msg = string("Could not open response file: ") + pts;
|
// string msg = string("Could not open response file: ") + pts;
|
||||||
throw runtime_error(msg);
|
throw eoFileError(pts);
|
||||||
}
|
}
|
||||||
// read - will be overwritten by command-line
|
// read - will be overwritten by command-line
|
||||||
readFrom(ifs);
|
readFrom(ifs);
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
|
||||||
|
|
||||||
size_t posFin = _value.find_first_of(std::string(closeChar));
|
size_t posFin = _value.find_first_of(std::string(closeChar));
|
||||||
if (posFin >= _value.size())
|
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
|
// y a-t-il un nbre devant
|
||||||
unsigned count = 1;
|
unsigned count = 1;
|
||||||
|
|
@ -110,7 +110,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
|
||||||
std::string sCount = _value.substr(0, posDeb);
|
std::string sCount = _value.substr(0, posDeb);
|
||||||
count = read_int(sCount);
|
count = read_int(sCount);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
throw std::runtime_error("Syntax error when reading bounds");
|
throw eoException("Syntax error when reading bounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
// the bounds
|
// the bounds
|
||||||
|
|
@ -121,7 +121,7 @@ void eoRealVectorBounds::readFrom(std::string _value)
|
||||||
remove_leading(sBounds, delim);
|
remove_leading(sBounds, delim);
|
||||||
size_t posDelim = sBounds.find_first_of(delim);
|
size_t posDelim = sBounds.find_first_of(delim);
|
||||||
if (posDelim >= sBounds.size())
|
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;
|
bool minBounded=false, maxBounded=false;
|
||||||
double minBound=0, maxBound=0;
|
double minBound=0, maxBound=0;
|
||||||
|
|
@ -192,17 +192,17 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
|
||||||
std::string delim(",; ");
|
std::string delim(",; ");
|
||||||
std::string beginOrClose("[(])");
|
std::string beginOrClose("[(])");
|
||||||
if (!remove_leading(_value, delim)) // only delimiters were left
|
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
|
// look for opening char
|
||||||
size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b]
|
size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b]
|
||||||
if (posDeb >= _value.size()) // nothing left to read
|
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
|
// ending char: next {}() after posDeb
|
||||||
size_t posFin = _value.find_first_of(beginOrClose,posDeb+1);
|
size_t posFin = _value.find_first_of(beginOrClose,posDeb+1);
|
||||||
if (posFin >= _value.size()) // not found
|
if (posFin >= _value.size()) // not found
|
||||||
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
|
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
|
||||||
|
|
||||||
// the bounds
|
// the bounds
|
||||||
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
|
std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1);
|
||||||
|
|
@ -212,7 +212,7 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
|
||||||
remove_leading(sBounds, delim);
|
remove_leading(sBounds, delim);
|
||||||
size_t posDelim = sBounds.find_first_of(delim);
|
size_t posDelim = sBounds.find_first_of(delim);
|
||||||
if (posDelim >= sBounds.size())
|
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;
|
bool minBounded=false, maxBounded=false;
|
||||||
double minBound=0, maxBound=0;
|
double minBound=0, maxBound=0;
|
||||||
|
|
@ -246,7 +246,7 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value)
|
||||||
if (minBounded && maxBounded)
|
if (minBounded && maxBounded)
|
||||||
{
|
{
|
||||||
if (maxBound <= minBound)
|
if (maxBound <= minBound)
|
||||||
throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor");
|
throw eoException("Syntax error in eoGeneralRealBounds Ctor");
|
||||||
locBound = new eoRealInterval(minBound, maxBound);
|
locBound = new eoRealInterval(minBound, maxBound);
|
||||||
}
|
}
|
||||||
else if (!minBounded && !maxBounded) // no bound at all
|
else if (!minBounded && !maxBounded) // no bound at all
|
||||||
|
|
|
||||||
|
|
@ -161,22 +161,22 @@ public:
|
||||||
|
|
||||||
virtual double minimum() const
|
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
|
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
|
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
|
virtual double uniform(eoRng & _rng = eo::rng) const
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(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
|
// methods from eoPersistent
|
||||||
|
|
@ -190,7 +190,7 @@ public:
|
||||||
{
|
{
|
||||||
(void)_is;
|
(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;
|
(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
|
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
|
virtual double range() const
|
||||||
{
|
{
|
||||||
throw std::logic_error("Trying to get range of eoRealBelowBound");
|
throw eoException("Trying to get range of eoRealBelowBound");
|
||||||
}
|
}
|
||||||
|
|
||||||
// random generators
|
// random generators
|
||||||
|
|
@ -372,7 +372,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(void)_rng;
|
||||||
|
|
||||||
throw std::logic_error("Trying to generate uniform values in eoRealBelowBound");
|
throw eoException("Trying to generate uniform values in eoRealBelowBound");
|
||||||
}
|
}
|
||||||
|
|
||||||
// description
|
// description
|
||||||
|
|
@ -417,7 +417,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_is;
|
(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
|
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
|
virtual double range() const
|
||||||
{
|
{
|
||||||
throw std::logic_error("Trying to get range of eoRealAboveBound");
|
throw eoException("Trying to get range of eoRealAboveBound");
|
||||||
}
|
}
|
||||||
|
|
||||||
// random generators
|
// random generators
|
||||||
|
|
@ -471,7 +471,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(void)_rng;
|
||||||
|
|
||||||
throw std::logic_error("Trying to generate uniform values in eoRealAboveBound");
|
throw eoException("Trying to generate uniform values in eoRealAboveBound");
|
||||||
}
|
}
|
||||||
|
|
||||||
// description
|
// description
|
||||||
|
|
@ -516,7 +516,7 @@ public :
|
||||||
{
|
{
|
||||||
(void)_is;
|
(void)_is;
|
||||||
|
|
||||||
throw std::runtime_error("Should not use eoRealAboveBound::readFrom");
|
throw eoException("Should not use eoRealAboveBound::readFrom");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ public:
|
||||||
eoRealBaseVectorBounds(), factor(1, _dim), ownedBounds(0)
|
eoRealBaseVectorBounds(), factor(1, _dim), ownedBounds(0)
|
||||||
{
|
{
|
||||||
if (_max-_min<=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);
|
eoRealBounds *ptBounds = new eoRealInterval(_min, _max);
|
||||||
// handle memory once
|
// handle memory once
|
||||||
ownedBounds.push_back(ptBounds);
|
ownedBounds.push_back(ptBounds);
|
||||||
|
|
@ -265,7 +265,7 @@ public:
|
||||||
factor(_min.size(), 1), ownedBounds(0)
|
factor(_min.size(), 1), ownedBounds(0)
|
||||||
{
|
{
|
||||||
if (_max.size() != _min.size())
|
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
|
// the bounds
|
||||||
eoRealBounds *ptBounds;
|
eoRealBounds *ptBounds;
|
||||||
for (unsigned i=0; i<_min.size(); i++)
|
for (unsigned i=0; i<_min.size(); i++)
|
||||||
|
|
@ -386,20 +386,20 @@ public:
|
||||||
// accessors
|
// accessors
|
||||||
virtual double minimum(unsigned)
|
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)
|
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)
|
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()
|
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
|
// random generators
|
||||||
|
|
@ -407,7 +407,7 @@ public:
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(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
|
// fills a std::vector with uniformly chosen variables in bounds
|
||||||
|
|
@ -415,7 +415,7 @@ public:
|
||||||
{
|
{
|
||||||
(void)_rng;
|
(void)_rng;
|
||||||
|
|
||||||
throw std::logic_error("No uniform distribution on eoRealVectorNoBounds");
|
throw eoException("No uniform distribution on eoRealVectorNoBounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#ifndef eoRndGenerators_h
|
#ifndef eoRndGenerators_h
|
||||||
#define eoRndGenerators_h
|
#define eoRndGenerators_h
|
||||||
|
|
||||||
|
#include "../eoExceptions.h"
|
||||||
#include "eoRNG.h"
|
#include "eoRNG.h"
|
||||||
#include "../eoFunctor.h"
|
#include "../eoFunctor.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
@ -80,7 +81,7 @@ template <class T = double> class eoUniformGenerator : public eoRndGenerator<T>
|
||||||
minim(_min), range(_max-_min), uniform(_rng)
|
minim(_min), range(_max-_min), uniform(_rng)
|
||||||
{
|
{
|
||||||
if (_min>_max)
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ public :
|
||||||
virtual void operator()(const std::vector<const EOT*>& _pop)
|
virtual void operator()(const std::vector<const EOT*>& _pop)
|
||||||
{
|
{
|
||||||
if (whichElement > _pop.size())
|
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());
|
doit(_pop, Fitness());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ void eoState::registerObject(eoPersistent& registrant)
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (!is)
|
||||||
{
|
{
|
||||||
string str = "Could not open file " + _filename;
|
// string str = "Could not open file " + _filename;
|
||||||
throw runtime_error(str);
|
throw eoFileError(_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
load(is);
|
load(is);
|
||||||
|
|
@ -96,8 +96,8 @@ void eoState::load(std::istream& is)
|
||||||
|
|
||||||
if (is.fail())
|
if (is.fail())
|
||||||
{
|
{
|
||||||
string str = "Error while reading stream";
|
// string str = "Error while reading stream";
|
||||||
throw runtime_error(str);
|
throw eoFileError("stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
while(! is.eof())
|
while(! is.eof())
|
||||||
|
|
@ -127,7 +127,7 @@ void eoState::load(std::istream& is)
|
||||||
while (getline(is, str))
|
while (getline(is, str))
|
||||||
{
|
{
|
||||||
if (is.eof())
|
if (is.eof())
|
||||||
throw runtime_error("No section in load file");
|
throw eoException("No section in load file");
|
||||||
if (is_section(str, name))
|
if (is_section(str, name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -154,8 +154,8 @@ void eoState::save(const string& filename) const
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
string msg = "Could not open file: " + filename + " for writing!";
|
// string msg = "Could not open file: " + filename + " for writing!";
|
||||||
throw runtime_error(msg);
|
throw eoFileError(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(os);
|
save(os);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ template <class T = double> class eoUniformInit : public eoInit<T>
|
||||||
minim(_min), range(_max-_min), uniform(_rng)
|
minim(_min), range(_max-_min), uniform(_rng)
|
||||||
{
|
{
|
||||||
if (_min>_max)
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ bool testDirRes(std::string _dirName, bool _erase=true)
|
||||||
// test for (unlikely) errors
|
// test for (unlikely) errors
|
||||||
if ( (res==-1) || (res==127) )
|
if ( (res==-1) || (res==127) )
|
||||||
{
|
{
|
||||||
s = "Problem executing test of dir " + _dirName;
|
// s = "Problem executing test of dir " + _dirName;
|
||||||
throw runtime_error(s);
|
throw eoSystemError(s,res);
|
||||||
}
|
}
|
||||||
// now make sure there is a dir without any file in it - or quit
|
// now make sure there is a dir without any file in it - or quit
|
||||||
if (res) // no dir present
|
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!
|
// WARNING: bug if dir exists and is empty; this says it is not!
|
||||||
// shoudl use scandir instead - no time now :-((( MS Aug. 01
|
// shoudl use scandir instead - no time now :-((( MS Aug. 01
|
||||||
s = "Dir " + _dirName + " is not empty";
|
s = "Dir " + _dirName + " is not empty";
|
||||||
throw runtime_error(s);
|
throw eoException(s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#ifndef eoRND_GENERATORS_H
|
#ifndef eoRND_GENERATORS_H
|
||||||
#define eoRND_GENERATORS_H
|
#define eoRND_GENERATORS_H
|
||||||
|
|
||||||
|
#include "../eoExceptions.h"
|
||||||
#include "eoRNG.h"
|
#include "eoRNG.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
@ -56,7 +57,7 @@ template <class T = double> class uniform_generator
|
||||||
minim(_min), range(_max-_min), uniform(_rng)
|
minim(_min), range(_max-_min), uniform(_rng)
|
||||||
{
|
{
|
||||||
if (_min>_max)
|
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)); }
|
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)
|
minim(_min), range(_max-_min), random(_rng)
|
||||||
{
|
{
|
||||||
if (_min>_max)
|
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)); }
|
T operator()(void) { return (T) (minim + random.random(range)); }
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ double sum_fitness(It begin, It end)
|
||||||
{
|
{
|
||||||
double v = static_cast<double>(begin->fitness());
|
double v = static_cast<double>(begin->fitness());
|
||||||
if (v < 0.0)
|
if (v < 0.0)
|
||||||
throw std::logic_error("sum_fitness: negative fitness value encountered");
|
throw eoInvalidFitnessError("sum_fitness: negative fitness value encountered");
|
||||||
sum += v;
|
sum += v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ public :
|
||||||
|
|
||||||
performance_type performance(void) const
|
performance_type performance(void) const
|
||||||
{
|
{
|
||||||
if(!valid_performance) throw runtime_error("no performance");
|
if(!valid_performance) throw eoException("no performance");
|
||||||
return Traits::get_performance(rep_fitness);
|
return Traits::get_performance(rep_fitness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,8 +145,8 @@ public :
|
||||||
|
|
||||||
worth_type worth(void) const
|
worth_type worth(void) const
|
||||||
{
|
{
|
||||||
if(!valid_worth) throw runtime_error("no worth");
|
if(!valid_worth) throw eoException("no worth");
|
||||||
if(!Traits::needs_mapping) throw runtime_error("no mapping");
|
if(!Traits::needs_mapping) throw eoException("no mapping");
|
||||||
return Traits::get_worth(rep_fitness);
|
return Traits::get_worth(rep_fitness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,14 +236,14 @@ public :
|
||||||
{
|
{
|
||||||
if (!fitness_traits::needs_mapping)
|
if (!fitness_traits::needs_mapping)
|
||||||
{
|
{
|
||||||
throw runtime_error("eoPop: no scaling needed, yet a scaling function is defined");
|
throw eoException("eoPop: no scaling needed, yet a scaling function is defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
(*p2w)(*this);
|
(*p2w)(*this);
|
||||||
}
|
}
|
||||||
else if (fitness_traits::needs_mapping)
|
else if (fitness_traits::needs_mapping)
|
||||||
{
|
{
|
||||||
throw runtime_error("eoPop: no scaling function attached to the population, while one was certainly called for");
|
throw eoException("eoPop: no scaling function attached to the population, while one was certainly called for");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ class Experiment : public eoserial::Persistent
|
||||||
} else if( distribName == "exponential" ) {
|
} else if( distribName == "exponential" ) {
|
||||||
_distribution = & exponentialDistribution;
|
_distribution = & exponentialDistribution;
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error("When unpacking experience, no distribution found.");
|
throw eoException("When unpacking experience, no distribution found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
eoserial::unpackObject( *obj, "distribution", *_distribution );
|
eoserial::unpackObject( *obj, "distribution", *_distribution );
|
||||||
|
|
@ -503,7 +503,7 @@ int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
if( isChosenDistrib )
|
if( isChosenDistrib )
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Only one distribution can be chosen during a launch!");
|
throw eoException("Only one distribution can be chosen during a launch!");
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
isChosenDistrib = true;
|
isChosenDistrib = true;
|
||||||
|
|
@ -517,7 +517,7 @@ int main( int argc, char** argv )
|
||||||
|
|
||||||
if( !isChosenDistrib )
|
if( !isChosenDistrib )
|
||||||
{
|
{
|
||||||
throw std::runtime_error("No distribution chosen. One distribution should be chosen.");
|
throw eoException("No distribution chosen. One distribution should be chosen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Experiment e( pdistrib, size, packet_size, worker_print_waiting_time, seed, fileName );
|
Experiment e( pdistrib, size, packet_size, worker_print_waiting_time, seed, fileName );
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ int main(int argc, char** argv)
|
||||||
// eo::log << eo::setlevel( eo::debug );
|
// eo::log << eo::setlevel( eo::debug );
|
||||||
Node::init( argc, argv );
|
Node::init( argc, argv );
|
||||||
if( Node::comm().size() != 7 ) {
|
if( Node::comm().size() != 7 ) {
|
||||||
throw std::runtime_error("World size should be 7.");
|
throw eoException("World size should be 7.");
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializableVector< SerializableBase<int> > v;
|
SerializableVector< SerializableBase<int> > v;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
const int ALL = Node::comm().size();
|
const int ALL = Node::comm().size();
|
||||||
if( ALL < 3 ) {
|
if( ALL < 3 ) {
|
||||||
throw std::runtime_error("Needs at least 3 processes to be launched!");
|
throw eoException("Needs at least 3 processes to be launched!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests are auto described thanks to member "description"
|
// Tests are auto described thanks to member "description"
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoRealVectorBounds& _
|
||||||
|
|
||||||
if (lambda_rate.value() < 1.0f)
|
if (lambda_rate.value() < 1.0f)
|
||||||
{
|
{
|
||||||
throw logic_error("lambda_rate must be larger than 1 in a comma strategy");
|
throw eoParamException("lambda_rate must be larger than 1 in a comma strategy");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ void init(eoPop<Dummy> & _pop, unsigned _pSize)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error("init pop with 0 size");
|
throw eoPopSizeException(_pSize,"init pop with 0 size");
|
||||||
}
|
}
|
||||||
for (unsigned i=0; i<_pSize; i++)
|
for (unsigned i=0; i<_pSize; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ bool check_permutation(const Chrom & _chrom)
|
||||||
std::cout << " Error: Wrong permutation !" << std::endl;
|
std::cout << " Error: Wrong permutation !" << std::endl;
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append( " Wrong permutation in t-eoInitPermutation");
|
s.append( " Wrong permutation in t-eoInitPermutation");
|
||||||
throw std::runtime_error( s );
|
throw eoException( s );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ bool check_permutation(const Chrom& _chrom){
|
||||||
std::cout << " Error: Wrong permutation !" << std::endl;
|
std::cout << " Error: Wrong permutation !" << std::endl;
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append( " Wrong permutation in t-eoShiftMutation");
|
s.append( " Wrong permutation in t-eoShiftMutation");
|
||||||
throw std::runtime_error( s );
|
throw eoException( s );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ void testSelectMany(eoSelect<EOT> & _select, std::string _name)
|
||||||
{
|
{
|
||||||
unsigned trouve = isInPop<Dummy>(offspring[i], parents);
|
unsigned trouve = isInPop<Dummy>(offspring[i], parents);
|
||||||
if (trouve == parents.size()) // pas trouve
|
if (trouve == parents.size()) // pas trouve
|
||||||
throw std::runtime_error("Pas trouve ds parents");
|
throw eoException("Pas trouve ds parents");
|
||||||
nb[trouve]++;
|
nb[trouve]++;
|
||||||
}
|
}
|
||||||
// dump to file so you can plot using gnuplot - dir name is hardcoded!
|
// dump to file so you can plot using gnuplot - dir name is hardcoded!
|
||||||
|
|
@ -149,7 +149,7 @@ eoValueParam<unsigned> tournamentSizeParam = parser.createParam(unsigned(2), "to
|
||||||
parentsOrg[pSize-1].fitness(10*pSize);
|
parentsOrg[pSize-1].fitness(10*pSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Invalid fitness Type"+fitnessType);
|
throw eoInvalidFitnessError("Invalid fitness Type"+fitnessType);
|
||||||
|
|
||||||
std::cout << "Initial parents (odd)\n" << parentsOrg << std::endl;
|
std::cout << "Initial parents (odd)\n" << parentsOrg << std::endl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ void testSelectMany(eoSelect<EOT> & _select, std::string _name)
|
||||||
{
|
{
|
||||||
unsigned trouve = isInPop<Dummy>(offspring[i], parents);
|
unsigned trouve = isInPop<Dummy>(offspring[i], parents);
|
||||||
if (trouve == parents.size()) // pas trouve
|
if (trouve == parents.size()) // pas trouve
|
||||||
throw std::runtime_error("Pas trouve ds parents");
|
throw eoException("Pas trouve ds parents");
|
||||||
nb[trouve]++;
|
nb[trouve]++;
|
||||||
}
|
}
|
||||||
// dump to file so you can plot using gnuplot - dir name is hardcoded!
|
// dump to file so you can plot using gnuplot - dir name is hardcoded!
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ bool check_permutation(const Chrom& _chrom){
|
||||||
std::cout << " Error: Wrong permutation !" << std::endl;
|
std::cout << " Error: Wrong permutation !" << std::endl;
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append( " Wrong permutation in t-eoShiftMutation");
|
s.append( " Wrong permutation in t-eoShiftMutation");
|
||||||
throw std::runtime_error( s );
|
throw eoException( s );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ bool check_permutation(const Chrom& _chrom){
|
||||||
std::cout << " Error: Wrong permutation !" << std::endl;
|
std::cout << " Error: Wrong permutation !" << std::endl;
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append( " Wrong permutation in t-eoShiftMutation");
|
s.append( " Wrong permutation in t-eoShiftMutation");
|
||||||
throw std::runtime_error( s );
|
throw eoException( s );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ bool check_permutation(const Chrom& _chrom){
|
||||||
std::cout << " Error: Wrong permutation !" << std::endl;
|
std::cout << " Error: Wrong permutation !" << std::endl;
|
||||||
std::string s;
|
std::string s;
|
||||||
s.append( " Wrong permutation in t-eoShiftMutation");
|
s.append( " Wrong permutation in t-eoShiftMutation");
|
||||||
throw std::runtime_error( s );
|
throw eoException( s );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,12 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||||
throw runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||||
throw runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
|
|
||||||
// the crossover - with probability pCross
|
// the crossover - with probability pCross
|
||||||
|
|
|
||||||
|
|
@ -215,12 +215,12 @@ try {
|
||||||
double pCross = parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ).value();
|
double pCross = parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ).value();
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCross < 0) || (pCross > 1) )
|
if ( (pCross < 0) || (pCross > 1) )
|
||||||
throw runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
double pMut = parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ).value();
|
double pMut = parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ).value();
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMut < 0) || (pMut > 1) )
|
if ( (pMut < 0) || (pMut > 1) )
|
||||||
throw runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
// now create the generalOp
|
// now create the generalOp
|
||||||
eoSGAGenOp<Indi> op(cross, pCross, mut, pMut);
|
eoSGAGenOp<Indi> op(cross, pCross, mut, pMut);
|
||||||
|
|
@ -827,7 +827,7 @@ eoContinue<Indi> & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu
|
||||||
|
|
||||||
// now check that there is at least one!
|
// now check that there is at least one!
|
||||||
if (!continuator)
|
if (!continuator)
|
||||||
throw runtime_error("You MUST provide a stopping criterion");
|
throw eoException("You MUST provide a stopping criterion");
|
||||||
// OK, it's there: store in the eoState
|
// OK, it's there: store in the eoState
|
||||||
_state.storeFunctor(continuator);
|
_state.storeFunctor(continuator);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,12 @@ try
|
||||||
double pCross = parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ).value();
|
double pCross = parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ).value();
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCross < 0) || (pCross > 1) )
|
if ( (pCross < 0) || (pCross > 1) )
|
||||||
throw runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
double pMut = parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ).value();
|
double pMut = parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ).value();
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMut < 0) || (pMut > 1) )
|
if ( (pMut < 0) || (pMut > 1) )
|
||||||
throw runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
// now create the generalOp
|
// now create the generalOp
|
||||||
eoSGAGenOp<Indi> op(cross, pCross, mut, pMut);
|
eoSGAGenOp<Indi> op(cross, pCross, mut, pMut);
|
||||||
|
|
@ -278,7 +278,7 @@ try
|
||||||
// first check the directory (and creates it if not exists already):
|
// first check the directory (and creates it if not exists already):
|
||||||
if (fileMyStructStat || plotMyStructStat)
|
if (fileMyStructStat || plotMyStructStat)
|
||||||
if (! testDirRes(dirName, true) )
|
if (! testDirRes(dirName, true) )
|
||||||
throw runtime_error("Problem with resDir");
|
throw eoParamException("Problem with resDir");
|
||||||
|
|
||||||
// should we write it to a file ?
|
// should we write it to a file ?
|
||||||
if (fileMyStructStat)
|
if (fileMyStructStat)
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,12 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
||||||
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
eoValueParam<double>& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
|
||||||
throw runtime_error("Invalid pCross");
|
throw eoParamException("Invalid pCross");
|
||||||
|
|
||||||
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
eoValueParam<double>& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" );
|
||||||
// minimum check
|
// minimum check
|
||||||
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
|
||||||
throw runtime_error("Invalid pMut");
|
throw eoParamException("Invalid pMut");
|
||||||
|
|
||||||
|
|
||||||
// the crossover - with probability pCross
|
// the crossover - with probability pCross
|
||||||
|
|
|
||||||
|
|
@ -263,8 +263,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
if (!os) {
|
if (!os) {
|
||||||
std::string str = "moVectorMonitor: Could not open " + _filename;
|
// std::string str = "moVectorMonitor: Could not open " + _filename;
|
||||||
throw std::runtime_error(str);
|
throw eoFileError(_filename);;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < size(); i++) {
|
for (unsigned int i = 0; i < size(); i++) {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public:
|
||||||
int pos = _is.tellg();
|
int pos = _is.tellg();
|
||||||
_is >> fitness_str;
|
_is >> fitness_str;
|
||||||
if (fitness_str == "INVALID") {
|
if (fitness_str == "INVALID") {
|
||||||
throw std::runtime_error("invalid fitness");
|
throw eoInvalidFitnessError("invalid fitness");
|
||||||
} else {
|
} else {
|
||||||
Fitness repFit;
|
Fitness repFit;
|
||||||
_is.seekg(pos);
|
_is.seekg(pos);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue