use eoExceptions everywhere

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

View file

@ -133,7 +133,7 @@ class MOEO : public EO < MOEOObjectiveVector >
{
if ( invalidObjectiveVector() )
{
throw std::runtime_error("invalid objective vector in MOEO");
throw eoInvalidFitnessError("invalid objective vector in MOEO");
}
return objectiveVectorValue;
}
@ -197,7 +197,7 @@ class MOEO : public EO < MOEOObjectiveVector >
{
if ( invalidFitness() )
{
throw std::runtime_error("invalid fitness in MOEO");
throw eoInvalidFitnessError("invalid fitness in MOEO");
}
// const_cast< Fitness& >( fitnessValue ).embededDataEx = objectiveVectorValue;
@ -241,7 +241,7 @@ class MOEO : public EO < MOEOObjectiveVector >
{
if ( invalidDiversity() )
{
throw std::runtime_error("invalid diversity in MOEO");
throw eoInvalidFitnessError("invalid diversity in MOEO");
}
return diversityValue;
}

View file

@ -42,6 +42,8 @@
#include <stdexcept>
#include <vector>
#include <eoExceptions.h>
/**
* A traits class for moeoObjectiveVector to specify the number of objectives and which ones have to be minimized or maximized.
*/
@ -70,7 +72,7 @@ class moeoObjectiveVectorTraits
bObj = _bObjectives;
// in case the number of objectives and the min/max vector size don't match
if (nObj != bObj.size())
throw std::runtime_error("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup");
throw eoException("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup");
}
@ -81,7 +83,7 @@ class moeoObjectiveVectorTraits
{
// in case the number of objectives would not be assigned yet
if (! nObj)
throw std::runtime_error("Number of objectives not assigned in moeoObjectiveVectorTraits");
throw eoException("Number of objectives not assigned in moeoObjectiveVectorTraits");
return nObj;
}
@ -94,7 +96,7 @@ class moeoObjectiveVectorTraits
{
// in case there would be a wrong index
if (_i >= bObj.size())
throw std::runtime_error("Wrong index in moeoObjectiveVectorTraits");
throw eoException("Wrong index in moeoObjectiveVectorTraits");
return bObj[_i];
}

View file

@ -89,7 +89,7 @@ class moeoVector : public MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity
}
else
{
throw std::runtime_error("Size not initialized in moeoVector");
throw eoException("Size not initialized in moeoVector");
}
}
std::copy(_v.begin(), _v.end(), begin());