Removed a few dsp files and changed saving/loading eoPops a bit.
This commit is contained in:
parent
33803be4cd
commit
4f1bcfa292
33 changed files with 59 additions and 2767 deletions
|
|
@ -60,7 +60,7 @@ class eoFixedLength : public EO<FitT>, public std::vector<GeneType>
|
|||
|
||||
os << size() << ' ';
|
||||
|
||||
std::copy(begin(), end(), ostream_iterator<double>(os));
|
||||
std::copy(begin(), end(), ostream_iterator<double>(os, " "));
|
||||
}
|
||||
|
||||
/// reading...
|
||||
|
|
|
|||
|
|
@ -90,24 +90,6 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
|
|||
///
|
||||
~eoPop() {};
|
||||
|
||||
/** @name Methods from eoObject */
|
||||
//@{
|
||||
/**
|
||||
* Read object. The EOT class must have a ctor from a stream;
|
||||
in this case, a strstream is used.
|
||||
* @param _is A istream.
|
||||
|
||||
*/
|
||||
virtual void readFrom(istream& _is)
|
||||
{
|
||||
while( _is )
|
||||
{
|
||||
EOT thisEOT;
|
||||
thisEOT.readFrom( _is );
|
||||
push_back( thisEOT );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
sort the population. Use this member to sort in order
|
||||
of descending Fitness, so the first individual is the best!
|
||||
|
|
@ -166,10 +148,33 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
|
|||
* Write object. It's called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A ostream.
|
||||
*/
|
||||
virtual void printOn(ostream& _os) const {
|
||||
copy( begin(), end(), ostream_iterator<EOT>( _os, "\n") );
|
||||
virtual void printOn(ostream& _os) const
|
||||
{
|
||||
_os << size() << '\n';
|
||||
copy( begin(), end(), ostream_iterator<EOT>( _os, "\n") );
|
||||
};
|
||||
|
||||
/** @name Methods from eoObject */
|
||||
//@{
|
||||
/**
|
||||
* Read object. The EOT class must have a ctor from a stream;
|
||||
in this case, a strstream is used.
|
||||
* @param _is A istream.
|
||||
|
||||
*/
|
||||
virtual void readFrom(istream& _is)
|
||||
{
|
||||
size_t sz;
|
||||
_is >> sz;
|
||||
|
||||
resize(sz);
|
||||
|
||||
for (size_t i = 0; i < sz; ++i)
|
||||
{
|
||||
operator[](i).readFrom( _is );
|
||||
}
|
||||
}
|
||||
|
||||
/** Inherited from eoObject. Returns the class name.
|
||||
@see eoObject
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -75,10 +75,13 @@ class eoScalarFitness
|
|||
};
|
||||
|
||||
/**
|
||||
Typedefs for fitness comparison,
|
||||
Typedefs for fitness comparison, Maximizing Fitness compares with less,
|
||||
and minimizing fitness compares with greater. This because we want ordinary
|
||||
fitness values (doubles) to be equivalent with Maximizing Fitness, and
|
||||
comparing with less is the default behaviour.
|
||||
*/
|
||||
typedef eoScalarFitness<double, std::greater<double> > eoMaximizingFitness;
|
||||
typedef eoScalarFitness<double, std::less<double> > eoMinimizingFitness;
|
||||
typedef eoScalarFitness<double, std::less<double> > eoMaximizingFitness;
|
||||
typedef eoScalarFitness<double, std::greater<double> > eoMinimizingFitness;
|
||||
|
||||
template <class F, class Cmp>
|
||||
std::ostream& operator<<(std::ostream& os, const eoScalarFitness<F, Cmp>& f)
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ class eoEsFull : public eoFixedLength<Fit, double>
|
|||
eoFixedLength<Fit,double>::printOn(os);
|
||||
|
||||
os << ' ';
|
||||
std::copy(stdevs.begin(), stdevs.end(), std::ostream_iterator<double>(os));
|
||||
std::copy(stdevs.begin(), stdevs.end(), std::ostream_iterator<double>(os, " "));
|
||||
|
||||
os << ' ';
|
||||
|
||||
std::copy(correlations.begin(), correlations.end(), std::ostream_iterator<double>(os));
|
||||
std::copy(correlations.begin(), correlations.end(), std::ostream_iterator<double>(os, " "));
|
||||
|
||||
os << ' ';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class eoEsStdev : public eoFixedLength<Fit, double>
|
|||
eoFixedLength<Fit,double>::printOn(os);
|
||||
|
||||
os << ' ';
|
||||
std::copy(stdevs.begin(), stdevs.end(), std::ostream_iterator<double>(os));
|
||||
std::copy(stdevs.begin(), stdevs.end(), std::ostream_iterator<double>(os, " "));
|
||||
|
||||
os << ' ';
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue