fix even more warnings and reduce some tests runtimes
tested under gcc and clang
This commit is contained in:
parent
ddb261348c
commit
9d3c848dfb
9 changed files with 29 additions and 26 deletions
|
|
@ -54,7 +54,7 @@ public:
|
||||||
* distrib.mean, pop.best_element);
|
* distrib.mean, pop.best_element);
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
edoEstimatorAdaptiveEdit<D>(
|
edoEstimatorAdaptiveEdit(
|
||||||
D& distrib,
|
D& distrib,
|
||||||
std::function<P()> getter,
|
std::function<P()> getter,
|
||||||
std::function<void(P)> setter
|
std::function<void(P)> setter
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ int main(int ac, char** av)
|
||||||
|
|
||||||
std::string section("Algorithm parameters");
|
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_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 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
|
unsigned int s_size = parser.createParam((unsigned int)2, "dimension-size", "Dimension size", 'd', section).value(); // d
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ public:
|
||||||
|
|
||||||
virtual void put(unsigned _oneIndice)=0;
|
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;
|
virtual POT & best()=0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
* particle whose indice is _oneIndice")
|
* particle whose indice is _oneIndice")
|
||||||
* @param _oneIndice - The indice of the particle in its population.
|
* @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++)
|
for (unsigned i=0;i< indicesList.size();i++)
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Return the size of the neighborhood.
|
* Return the size of the neighborhood.
|
||||||
*/
|
*/
|
||||||
unsigned size()
|
unsigned size() const
|
||||||
{
|
{
|
||||||
return indicesList.size();
|
return indicesList.size();
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ public:
|
||||||
* Return the "_index-th" particle of the neighborhood.
|
* Return the "_index-th" particle of the neighborhood.
|
||||||
* Throw an exception if its not contained in the neighborhood.
|
* Throw an exception if its not contained in the neighborhood.
|
||||||
*/
|
*/
|
||||||
unsigned get(unsigned _index)
|
unsigned get(unsigned _index) const
|
||||||
{
|
{
|
||||||
if (_index < size())
|
if (_index < size())
|
||||||
return indicesList[_index];
|
return indicesList[_index];
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,12 @@
|
||||||
|
|
||||||
#ifndef eoRndGenerators_h
|
#ifndef eoRndGenerators_h
|
||||||
#define eoRndGenerators_h
|
#define eoRndGenerators_h
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include "../eoExceptions.h"
|
#include "../eoExceptions.h"
|
||||||
#include "eoRNG.h"
|
#include "eoRNG.h"
|
||||||
#include "../eoFunctor.h"
|
#include "../eoFunctor.h"
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
/** @defgroup Random Random number generation
|
/** @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) :
|
eoUniformGenerator(T _min, T _max, eoRng& _rng = rng) :
|
||||||
minim(_min), range(_max-_min), uniform(_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");
|
throw eoException("Min is greater than Max in uniform_generator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,8 @@ void eoState::load(std::istream& is)
|
||||||
if (is_section(str, name))
|
if (is_section(str, name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
removeComment(str, getCommentString());
|
removeComment(str, getCommentString());
|
||||||
fullstring += str + "\n";
|
fullstring += str + "\n";
|
||||||
}
|
}
|
||||||
std::istringstream the_stream(fullstring);
|
std::istringstream the_stream(fullstring);
|
||||||
object->readFrom(the_stream);
|
object->readFrom(the_stream);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ std::pair< eoAlgo<Particle>*, eoPop<Particle>* >
|
||||||
auto& random_pos = store.pack< eoInitFixedLength<Particle> >(dim, gen_pos);
|
auto& random_pos = store.pack< eoInitFixedLength<Particle> >(dim, gen_pos);
|
||||||
|
|
||||||
auto pop = new eoPop<Particle>();
|
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& gen_minus = store.pack< eoUniformGenerator<double> >(-0.05, 0.05);
|
||||||
auto& random_velo = store.pack< eoVelocityInitFixedLength<Particle> >(dim, gen_minus);
|
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& 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& cont = store.pack< eoCombinedContinue<Particle> >(cont_gen);
|
||||||
|
|
||||||
auto& checkpoint = store.pack< eoCheckPoint<Particle> >(cont);
|
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
|
// Evaluation of a forged algo on the sub-problem
|
||||||
eoBooleanGenerator gen(0.5);
|
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,
|
eoEvalFoundryEA<Particle,Bits> eval_foundry(foundry,
|
||||||
onemax_init, /*pop_size=*/ 10,
|
onemax_init, /*pop_size=*/ 10,
|
||||||
onemax_eval, /*penalization=*/ 0);
|
onemax_eval, /*penalization=*/ 0);
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,16 @@ int main() {
|
||||||
eoUniformGenerator<double> u2(0.003, 0.05 );
|
eoUniformGenerator<double> u2(0.003, 0.05 );
|
||||||
eoUniformGenerator<unsigned long> u3( 10000U, 10000000U);
|
eoUniformGenerator<unsigned long> u3( 10000U, 10000000U);
|
||||||
|
|
||||||
try
|
// Test replaced by an assert
|
||||||
{ // throws an error
|
// try
|
||||||
eoUniformGenerator<unsigned long> utest( 10000000U, 10000U);
|
// { // throws an error
|
||||||
throw; // if this succeeds something is wrong, make sure that that is noticed
|
// eoUniformGenerator<unsigned long> utest( 10000000U, 10000U);
|
||||||
}
|
// throw; // if this succeeds something is wrong, make sure that that is noticed
|
||||||
catch (std::logic_error& e)
|
// }
|
||||||
{
|
// catch (std::logic_error& e)
|
||||||
std::cout << e.what() << std::endl;
|
// {
|
||||||
}
|
// std::cout << e.what() << std::endl;
|
||||||
|
// }
|
||||||
|
|
||||||
std::ofstream os("t-eoRandom.out");
|
std::ofstream os("t-eoRandom.out");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ int main_function(int /*argc*/, char **/*argv*/)
|
||||||
topology.setup(pop);
|
topology.setup(pop);
|
||||||
std::cout<<"\n\n\nPopulation :\n\n"<<pop;
|
std::cout<<"\n\n\nPopulation :\n\n"<<pop;
|
||||||
std::cout<<"\n\nNeighborhood :\n\n";
|
std::cout<<"\n\nNeighborhood :\n\n";
|
||||||
topology.printOn();
|
topology.printOn(std::cout);
|
||||||
int k = NEIGHBORHOOD_SIZE/2;
|
int k = NEIGHBORHOOD_SIZE/2;
|
||||||
for(unsigned i=0;i<pop.size();i++)
|
for(unsigned i=0;i<pop.size();i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue