Changed all variables named howmany into combien (French for how many)
because of a silly problem on Solaris (howmany seems to be some macro???)
This commit is contained in:
parent
28c6b9a285
commit
64990a1ac4
3 changed files with 22 additions and 23 deletions
|
|
@ -55,18 +55,18 @@ class eoInitFixedLength: public eoInit<EOT>
|
||||||
|
|
||||||
typedef typename EOT::AtomType AtomType;
|
typedef typename EOT::AtomType AtomType;
|
||||||
|
|
||||||
eoInitFixedLength(unsigned _howmany, eoRndGenerator<AtomType>& _generator)
|
eoInitFixedLength(unsigned _combien, eoRndGenerator<AtomType>& _generator)
|
||||||
: howmany(_howmany), generator(_generator) {}
|
: combien(_combien), generator(_generator) {}
|
||||||
|
|
||||||
void operator()(EOT& chrom)
|
void operator()(EOT& chrom)
|
||||||
{
|
{
|
||||||
chrom.resize(howmany);
|
chrom.resize(combien);
|
||||||
std::generate(chrom.begin(), chrom.end(), generator);
|
std::generate(chrom.begin(), chrom.end(), generator);
|
||||||
chrom.invalidate();
|
chrom.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private :
|
private :
|
||||||
unsigned howmany;
|
unsigned combien;
|
||||||
/// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics
|
/// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics
|
||||||
eoSTLF<AtomType> generator;
|
eoSTLF<AtomType> generator;
|
||||||
};
|
};
|
||||||
|
|
@ -87,8 +87,7 @@ class eoInitVariableLength: public eoInit<EOT>
|
||||||
|
|
||||||
void operator()(EOT& chrom)
|
void operator()(EOT& chrom)
|
||||||
{
|
{
|
||||||
unsigned howmany = offset + rng.random(extent);
|
chrom.resize(offset + rng.random(extent));
|
||||||
chrom.resize(howmany);
|
|
||||||
generate(chrom.begin(), chrom.end(), generator);
|
generate(chrom.begin(), chrom.end(), generator);
|
||||||
chrom.invalidate();
|
chrom.invalidate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ template <class EOT> class eoElitism : public eoMerge<EOT>
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
eoElitism(double _rate, bool _interpret_as_rate = true):
|
eoElitism(double _rate, bool _interpret_as_rate = true):
|
||||||
rate(0), howmany(0)
|
rate(0), combien(0)
|
||||||
{
|
{
|
||||||
if (_interpret_as_rate)
|
if (_interpret_as_rate)
|
||||||
{
|
{
|
||||||
|
|
@ -68,27 +68,27 @@ public :
|
||||||
{
|
{
|
||||||
if (_rate<0)
|
if (_rate<0)
|
||||||
throw std::logic_error("Negative number of offspring in eoElitism!");
|
throw std::logic_error("Negative number of offspring in eoElitism!");
|
||||||
howmany = (unsigned int)_rate;
|
combien = (unsigned int)_rate;
|
||||||
if (howmany != _rate)
|
if (combien != _rate)
|
||||||
cout << "Warning: Number of guys to merge in eoElitism was rounded";
|
cout << "Warning: Number of guys to merge in eoElitism was rounded";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const eoPop<EOT>& _pop, eoPop<EOT>& _offspring)
|
void operator()(const eoPop<EOT>& _pop, eoPop<EOT>& _offspring)
|
||||||
{
|
{
|
||||||
if ((howmany == 0) && (rate == 0.0))
|
if ((combien == 0) && (rate == 0.0))
|
||||||
return;
|
return;
|
||||||
unsigned howmanyLocal;
|
unsigned combienLocal;
|
||||||
if (howmany == 0) // rate is specified
|
if (combien == 0) // rate is specified
|
||||||
howmanyLocal = (unsigned int) (rate * _pop.size());
|
combienLocal = (unsigned int) (rate * _pop.size());
|
||||||
else
|
else
|
||||||
howmanyLocal = howmany;
|
combienLocal = combien;
|
||||||
|
|
||||||
if (howmanyLocal > _pop.size())
|
if (combienLocal > _pop.size())
|
||||||
throw std::logic_error("Elite larger than population");
|
throw std::logic_error("Elite larger than population");
|
||||||
|
|
||||||
vector<const EOT*> result;
|
vector<const EOT*> result;
|
||||||
_pop.nth_element(howmanyLocal, result);
|
_pop.nth_element(combienLocal, result);
|
||||||
|
|
||||||
for (size_t i = 0; i < result.size(); ++i)
|
for (size_t i = 0; i < result.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +98,7 @@ public :
|
||||||
|
|
||||||
private :
|
private :
|
||||||
double rate;
|
double rate;
|
||||||
unsigned howmany;
|
unsigned combien;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class eoHowMany
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
eoHowMany(double _rate, bool _interpret_as_rate = true):
|
eoHowMany(double _rate, bool _interpret_as_rate = true):
|
||||||
rate(0), howmany(0)
|
rate(0), combien(0)
|
||||||
{
|
{
|
||||||
if (_interpret_as_rate)
|
if (_interpret_as_rate)
|
||||||
{
|
{
|
||||||
|
|
@ -50,27 +50,27 @@ public:
|
||||||
{
|
{
|
||||||
if (_rate<0)
|
if (_rate<0)
|
||||||
throw std::logic_error("Negative number in eoHowMany!");
|
throw std::logic_error("Negative number in eoHowMany!");
|
||||||
howmany = (unsigned int)_rate;
|
combien = (unsigned int)_rate;
|
||||||
if (howmany != _rate)
|
if (combien != _rate)
|
||||||
cout << "Warning: Number was rounded in eoHowMany";
|
cout << "Warning: Number was rounded in eoHowMany";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int operator()(unsigned int _size)
|
unsigned int operator()(unsigned int _size)
|
||||||
{
|
{
|
||||||
if (howmany == 0)
|
if (combien == 0)
|
||||||
{
|
{
|
||||||
if (rate == 0.0)
|
if (rate == 0.0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return (unsigned int) (rate * _size);
|
return (unsigned int) (rate * _size);
|
||||||
}
|
}
|
||||||
return howmany;
|
return combien;
|
||||||
}
|
}
|
||||||
|
|
||||||
private :
|
private :
|
||||||
double rate;
|
double rate;
|
||||||
unsigned howmany;
|
unsigned combien;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue