fix even more warnings and reduce some tests runtimes

tested under gcc and clang
This commit is contained in:
Johann Dreo 2020-04-28 17:41:50 +02:00
commit 9d3c848dfb
9 changed files with 29 additions and 26 deletions

View file

@ -54,7 +54,7 @@ public:
* distrib.mean, pop.best_element);
* @endcode
*/
edoEstimatorAdaptiveEdit<D>(
edoEstimatorAdaptiveEdit(
D& distrib,
std::function<P()> getter,
std::function<void(P)> setter

View file

@ -65,9 +65,9 @@ int main(int ac, char** av)
std::string section("Algorithm parameters");
unsigned int r_max = parser.createParam((unsigned int)100, "run-number", "Number of run", 'r', section).value(); // r
unsigned int r_max = parser.createParam((unsigned int)10, "run-number", "Number of run", 'r', section).value(); // r
unsigned int p_min = parser.createParam((unsigned int)10, "population-min", "Population min", 'p', section).value(); // p
unsigned int p_max = parser.createParam((unsigned int)1000, "population-max", "Population max", 'P', section).value(); // P
unsigned int p_max = parser.createParam((unsigned int)100, "population-max", "Population max", 'P', section).value(); // P
unsigned int p_step = parser.createParam((unsigned int)50, "population-step", "Population step", 't', section).value(); // t
unsigned int s_size = parser.createParam((unsigned int)2, "dimension-size", "Dimension size", 'd', section).value(); // d

View file

@ -38,11 +38,11 @@ public:
virtual void put(unsigned _oneIndice)=0;
virtual bool contains(unsigned _oneIndice)=0;
virtual bool contains(unsigned _oneIndice) const =0;
virtual unsigned size()=0;
virtual unsigned size() const =0;
virtual unsigned get(unsigned _index)=0;
virtual unsigned get(unsigned _index) const =0;
virtual POT & best()=0;

View file

@ -56,7 +56,7 @@ public:
* particle whose indice is _oneIndice")
* @param _oneIndice - The indice of the particle in its population.
*/
bool contains(unsigned _oneIndice)
bool contains(unsigned _oneIndice) const
{
for (unsigned i=0;i< indicesList.size();i++)
{
@ -77,7 +77,7 @@ public:
/**
* Return the size of the neighborhood.
*/
unsigned size()
unsigned size() const
{
return indicesList.size();
@ -87,7 +87,7 @@ public:
* Return the "_index-th" particle of the neighborhood.
* Throw an exception if its not contained in the neighborhood.
*/
unsigned get(unsigned _index)
unsigned get(unsigned _index) const
{
if (_index < size())
return indicesList[_index];

View file

@ -28,11 +28,12 @@
#ifndef eoRndGenerators_h
#define eoRndGenerators_h
#include <stdexcept>
#include <cassert>
#include "../eoExceptions.h"
#include "eoRNG.h"
#include "../eoFunctor.h"
#include <stdexcept>
/** @defgroup Random Random number generation
*
@ -80,7 +81,8 @@ template <class T = double> class eoUniformGenerator : public eoRndGenerator<T>
eoUniformGenerator(T _min, T _max, eoRng& _rng = rng) :
minim(_min), range(_max-_min), uniform(_rng)
{
if (_min>_max)
assert(_min < _max);
if (_min > _max)
throw eoException("Min is greater than Max in uniform_generator");
}

View file

@ -71,7 +71,7 @@ std::pair< eoAlgo<Particle>*, eoPop<Particle>* >
auto& random_pos = store.pack< eoInitFixedLength<Particle> >(dim, gen_pos);
auto pop = new eoPop<Particle>();
pop->append(100, random_pos); // pop size
pop->append(10, random_pos); // pop size
auto& gen_minus = store.pack< eoUniformGenerator<double> >(-0.05, 0.05);
auto& random_velo = store.pack< eoVelocityInitFixedLength<Particle> >(dim, gen_minus);
@ -89,7 +89,7 @@ std::pair< eoAlgo<Particle>*, eoPop<Particle>* >
auto& flight = store.pack< eoStandardFlight<Particle> >();
auto& cont_gen = store.pack< eoGenContinue<Particle> >(50);
auto& cont_gen = store.pack< eoGenContinue<Particle> >(10);
auto& cont = store.pack< eoCombinedContinue<Particle> >(cont_gen);
auto& checkpoint = store.pack< eoCheckPoint<Particle> >(cont);
@ -122,7 +122,7 @@ int main(int /*argc*/, char** /*argv*/)
// Evaluation of a forged algo on the sub-problem
eoBooleanGenerator gen(0.5);
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/500, gen);
eoInitFixedLength<Bits> onemax_init(/*bitstring size=*/50, gen);
eoEvalFoundryEA<Particle,Bits> eval_foundry(foundry,
onemax_init, /*pop_size=*/ 10,
onemax_eval, /*penalization=*/ 0);

View file

@ -42,15 +42,16 @@ int main() {
eoUniformGenerator<double> u2(0.003, 0.05 );
eoUniformGenerator<unsigned long> u3( 10000U, 10000000U);
try
{ // throws an error
eoUniformGenerator<unsigned long> utest( 10000000U, 10000U);
throw; // if this succeeds something is wrong, make sure that that is noticed
}
catch (std::logic_error& e)
{
std::cout << e.what() << std::endl;
}
// Test replaced by an assert
// try
// { // throws an error
// eoUniformGenerator<unsigned long> utest( 10000000U, 10000U);
// throw; // if this succeeds something is wrong, make sure that that is noticed
// }
// catch (std::logic_error& e)
// {
// std::cout << e.what() << std::endl;
// }
std::ofstream os("t-eoRandom.out");

View file

@ -40,7 +40,7 @@ int main_function(int /*argc*/, char **/*argv*/)
topology.setup(pop);
std::cout<<"\n\n\nPopulation :\n\n"<<pop;
std::cout<<"\n\nNeighborhood :\n\n";
topology.printOn();
topology.printOn(std::cout);
int k = NEIGHBORHOOD_SIZE/2;
for(unsigned i=0;i<pop.size();i++)
{