Removed "using namespace std" statements from header files in EO -- "std::" identifier were added where necessary.

This commit is contained in:
okoenig 2003-02-27 19:28:07 +00:00
commit 86fa476c67
263 changed files with 2009 additions and 1976 deletions

View file

@ -27,7 +27,7 @@
#ifndef _EO1D_H
#define _EO1D_H
#include <iostream> // for ostream
#include <iostream> // for std::ostream
// EO Includes
#include <EO.h>
@ -59,7 +59,7 @@ least, a copy ctor, assignment operators,
\deprecated
As eo1d provides a so-called 'fat' interface, it might be wiser to
use eoFixedLength or eoVariableLength instead, that derive from
vector and list respectively and (important) redirect the less than
std::vector and std::list respectively and (important) redirect the less than
comparison operator to EO rather than the STL variants.
@see eoFixedLength eoVariableLength
@ -80,15 +80,15 @@ public:
/** Ctor using a random number generator and with an specified size
@param _rndGen Random number generator
@param _size lineal dimension of the eo1d
@param _ID An ID string, preferably unique
@param _ID An ID std::string, preferably unique
*/
eo1d( unsigned _size, eoRnd<T>& _rndGen, const string& _ID = "");
eo1d( unsigned _size, eoRnd<T>& _rndGen, const std::string& _ID = "");
/** Ctor from a istream. It just passes the stream to EO, subclasses should
/** Ctor from a std::istream. It just passes the stream to EO, subclasses should
have to implement this.
@param _is the input stream
*/
eo1d( istream& _is): EO<fitnessT>(){ readFrom(is); }
eo1d( std::istream& _is): EO<fitnessT>(){ readFrom(is); }
/// Copy ctor
eo1d( const eo1d& _eo )
@ -108,7 +108,7 @@ public:
@param _i index of the gene, which is the minimal unit. Must be
an unsigned less than #length()#
@return what's inside the gene, with the correct type
@exception out_of_range if _i > size()
@std::exception out_of_range if _i > size()
*/
virtual T getGene( unsigned _i ) const = 0;
@ -117,7 +117,7 @@ public:
* for T must be defined .
@param _i index
@return what's inside the gene, with the correct type
@exception out_of_range if _i > size()
@std::exception out_of_range if _i > size()
*/
virtual void setGene( unsigned _i, const T& _value ) = 0;
@ -143,10 +143,10 @@ public:
/**
* Read object. Theoretically, the length is known in advance. All objects
* Should call base class
* @param _s A istream.
* @throw runtime_exception If a valid object can't be read.
* @param _s A std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(istream& _s) {
virtual void readFrom(std::istream& _s) {
for ( unsigned i = 0; i < length(); i ++ ) {
T tmp;
@ -160,8 +160,8 @@ public:
/** Print itself: inherited from eoObject implementation.
Instance from base classes are processed in
base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/
virtual void printOn( ostream& _s ) const{
@param _s the std::ostream in which things are written*/
virtual void printOn( std::ostream& _s ) const{
for ( unsigned i = 0; i < length(); i ++ ) {
_s << getGene( i ) << " ";
}
@ -170,7 +170,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eo1d";};
std::string className() const {return "eo1d";};
//@}
@ -184,11 +184,11 @@ public:
/* Ctor using a random number generator and with an specified size
@param _rndGen Random number generator
@param _size lineal dimension of the eo1d
@param _ID An ID string, preferably unique
@param _ID An ID std::string, preferably unique
*/
template< class T, class fitnessT>
eo1d<T,fitnessT>::eo1d<T,fitnessT>( unsigned _size, eoRnd<T>& _rndGen,
const string& _ID )
const std::string& _ID )
:EO<fitnessT> ( _ID ) {
for ( unsigned i = 0; i < _size; i ++ ) {
insertGene( i, _rndGen() );

View file

@ -27,7 +27,7 @@
#ifndef _EO1DWDISTANCE_H
#define _EO1DWDISTANCE_H
#include <iostream> // for ostream
#include <iostream> // for std::ostream
// EO Includes
#include <eo1d.h>
@ -58,7 +58,7 @@ public:
@param _i index of the gene, which is the minimal unit. Must be
an unsigned less than #length()#
@return what's inside the gene, with the correct type
@exception out_of_range if _i > size()
@std::exception out_of_range if _i > size()
*/
virtual T getGene( unsigned _i ) const {
return innereo1d.getGene( _i );
@ -69,7 +69,7 @@ public:
* for T must be defined .
@param _i index
@return what's inside the gene, with the correct type
@exception out_of_range if _i > size()
@std::exception out_of_range if _i > size()
*/
virtual void setGene( unsigned _i, const T& _value ) {
innereo1d.setGene( _i, _value);
@ -118,7 +118,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eo1dWDistance";};
std::string className() const {return "eo1dWDistance";};
//@}

View file

@ -39,7 +39,7 @@ Description.....: Implementation of a 2-dimensional chromosome.
#ifndef _EO2D_H
#define _EO2D_H
#include <iostream> // for ostream
#include <iostream> // for std::ostream
#include <vector>
// EO Includes
@ -81,18 +81,18 @@ public:
@param _rows Initial number of rows
@param _columns Initial number of columns
@param _rndGen Random "T-type" generator
@param _ID An ID string, preferably unique
@param _ID An ID std::string, preferably unique
*/
eo2d( const unsigned _rows,
const unsigned _columns,
eoRnd<T>& _rndGen,
const string& _ID = "");
const std::string& _ID = "");
/** Ctor from an istream. It just passes the stream to EO, subclasses should
/** Ctor from an std::istream. It just passes the stream to EO, subclasses should
have to implement this.
@param _is the input stream
*/
eo2d( istream& _is): EO<fitnessT>( _is ){};
eo2d( std::istream& _is): EO<fitnessT>( _is ){};
/// Copy ctor
eo2d( const eo2d& _eo )
@ -112,8 +112,8 @@ public:
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
@return what's inside the gene, with the correct type
@exception out_of_range if _r >=numOfRows()
@exception out_of_range if _c >=numOfCols()
@std::exception out_of_range if _r >=numOfRows()
@std::exception out_of_range if _c >=numOfCols()
*/
virtual T getGene( const unsigned _r,
const unsigned _j ) const = 0;
@ -124,8 +124,8 @@ public:
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
@return what's inside the gene, with the correct type
@exception out_of_range if _r >=numOfRows()
@exception out_of_range if _c >=numOfCols()
@std::exception out_of_range if _r >=numOfRows()
@std::exception out_of_range if _c >=numOfCols()
*/
virtual void setGene( const unsigned _r,
const unsigned _c,
@ -136,16 +136,16 @@ public:
* Obviously, changes number of rows.
@param _r Position where the new row will be inserted.
@param _val Vector containing the new values to be inserted.
@exception invalid_argument If _val has not numOfCols() components.
@exception out_of_range If _r is greater than numOfRows()
@std::exception invalid_argument If _val has not numOfCols() components.
@std::exception out_of_range If _r is greater than numOfRows()
*/
virtual void insertRow( const unsigned _r,
const vector<T>& _val ) = 0;
const std::vector<T>& _val ) = 0;
/** Eliminates the row at position _r; all the other genes will
be shifted up.
@param _r Number of he row to be deleted.
@exception out_of_range if _r >=numOfRows()
@std::exception out_of_range if _r >=numOfRows()
*/
virtual void deleteRow( const unsigned _r ) = 0;
@ -154,15 +154,15 @@ public:
* Obviously, changes number of cols.
@param _r Position where the new column will be inserted.
@param _val Vector containing the new values to be inserted.
@exception invalid_argument if _val has not numOfRows() components.
@std::exception invalid_argument if _val has not numOfRows() components.
*/
virtual void insertCol( const unsigned _c,
const vector<T>& _val ) = 0;
const std::vector<T>& _val ) = 0;
/** Eliminates the column at position _c; all the other columns will
be shifted left.
@param _c Number of he column to be deleted.
@exception out_of_range if _c >=numOfCols()
@std::exception out_of_range if _c >=numOfCols()
*/
virtual void deleteCol( const unsigned _c ) = 0;
@ -177,10 +177,10 @@ public:
/**
* Read object. Theoretically, the length is known in advance. All objects
* Should call base class
* @param _s A istream.
* @throw runtime_exception If a valid object can't be read.
* @param _s A std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(istream& _s) {
virtual void readFrom(std::istream& _s) {
for ( unsigned r = 0; r < numOfRows(); ++r ) {
for ( unsigned c = 0; c < numOfCols(); ++c ) {
@ -196,8 +196,8 @@ public:
/** Print itself: inherited from eoObject implementation.
Instance from base classes are processed in
base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/
virtual void printOn( ostream& _s ) const{
@param _s the std::ostream in which things are written*/
virtual void printOn( std::ostream& _s ) const{
for ( unsigned r = 0; r < numOfRows(); ++r ) {
for ( unsigned c = 0; c < numOfCols(); ++c ) {
_s << getGene( r,c ) << " ";
@ -208,7 +208,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eo2d";};
std::string className() const {return "eo2d";};
//@}
@ -223,13 +223,13 @@ public:
@param _rows Initial number of rows
@param _columns Initial number of columns
@param _rndGen Random "T-type" generator
@param _ID An ID string, preferably unique
@param _ID An ID std::string, preferably unique
*/
template< class T, class fitnessT>
eo2d<T,fitnessT>::eo2d<T,fitnessT>( const unsigned _rows,
const unsigned _columns,
eoRnd<T>& _rndGen,
const string& _ID = "")
const std::string& _ID = "")
:EO<fitnessT> ( _ID ) {
for ( unsigned r = 0; r < _rows; ++r ) {
for ( unsigned c = 0; c < _cols; ++c ) {

View file

@ -5,14 +5,14 @@ File............: eo2dVector.h
Author..........: Geneura Team (this file: Victor Rivas, vrivas@ujaen.es)
Date............: 29-Sep-1999, at Fac. of Sciences, Univ. of Granada (Spain)
Description.....: Implementation of a 2-dimensional chromosome usign STL
vectors.
std::vectors.
================ Modif. 1 ================
Author........:
Date..........:
Description...:
QUEDA: Operador de asignación, lectura desde istream, escritura a ostream
QUEDA: Operador de asignación, lectura desde std::istream, escritura a std::ostream
-----------------------------------------------------------------------------
*/
//-----------------------------------------------------------------------------
@ -42,20 +42,20 @@ QUEDA: Operador de asignaci
#define _eo2dVector_H
// STL libraries
#include <vector> // For vector<int>
#include <vector> // For std::vector<int>
#include <stdexcept>
#include <strstream>
#include <iostream.h>
#include <ostream.h>
#include <eo2d.h>
#include <eoRnd.h>
/** Adaptor that turns an STL vector of vectror into an EO
/** Adaptor that turns an STL std::vector of vectror into an EO
with the same gene type as the type with which
the vector of vector has been instantiated.
the std::vector of std::vector has been instantiated.
*/
template <class T, class fitnessT>
class eo2dVector: public eo2d<T, fitnessT>, public vector< vector<T> > {
class eo2dVector: public eo2d<T, fitnessT>, public std::vector< std::vector<T> > {
public:
typedef T Type ;
@ -72,7 +72,7 @@ public:
eo2dVector( const unsigned _rows = 0,
const unsigned _cols = 0,
T _val = T() )
: eo2d<T, fitnessT>(), vector< vector<T> >( _rows, vector<T>( _cols, _val ) ){};
: eo2d<T, fitnessT>(), std::vector< std::vector<T> >( _rows, std::vector<T>( _cols, _val ) ){};
/** Ctor using a random number generator.
@param _rows Number of rows.
@ -83,23 +83,23 @@ public:
const unsigned _cols,
eoRnd<T>& _rnd );
/** Ctor from a istream. The T class should accept reading from a istream. It doesn't read fitness,
/** Ctor from a std::istream. The T class should accept reading from a std::istream. It doesn't read fitness,
which is supposed to be dynamic and dependent on environment.
@param _is the input stream; should have all values in a single line, separated by whitespace
*/
//eo2dVector( istream& _is);
//eo2dVector( std::istream& _is);
/// copy ctor
eo2dVector( const eo2dVector & _eo )
: eo2d<T, fitnessT>( _eo ), vector< vector<T> >( _eo ){ };
: eo2d<T, fitnessT>( _eo ), std::vector< std::vector<T> >( _eo ){ };
/// Assignment operator
/*
const eo2dVector& operator =( const eo2dVector & _eo ) {
if ( this != &_eo ){
eo2d<T, fitnessT>::operator=( _eo );
vector< <vector<T> >::operator=( _eo );
std::vector< <std::vector<T> >::operator=( _eo );
}
return *this;
}
@ -113,21 +113,21 @@ public:
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
@return what's inside the gene, with the correct type
@exception out_of_range if _r >=numOfRows()
@exception out_of_range if _c >=numOfCols()
@std::exception out_of_range if _r >=numOfRows()
@std::exception out_of_range if _c >=numOfCols()
*/
virtual T getGene( const unsigned _r,
const unsigned _c ) const {
if ( _r >= numOfRows() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::getGene: row out of range. "
<< "It should be <" << numOfRows() << '\0' << endl;
<< "It should be <" << numOfRows() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
if ( _c >= numOfCols() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::getGene: column out of range. "
<< "It should be <" << numOfCols() << '\0' << endl;
<< "It should be <" << numOfCols() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
return (*this)[_r][_c];
@ -138,22 +138,22 @@ public:
@param _r Index for rows. Must be an unsigned less than #numOfRows()#
@param _c Index for columns. Must be an unsigned less than #numOfCols()#
@return what's inside the gene, with the correct type
@exception out_of_range if _r >=numOfRows()
@exception out_of_range if _c >=numOfCols()
@std::exception out_of_range if _r >=numOfRows()
@std::exception out_of_range if _c >=numOfCols()
*/
virtual void setGene( const unsigned _r,
const unsigned _c,
const T& _value ) {
if ( _r >= numOfRows() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::setGene: row out of range. "
<< "It should be <" << numOfRows() << '\0' << endl;
<< "It should be <" << numOfRows() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
if ( _c >= numOfCols() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::setGene: column out of range. "
<< "It should be <" << numOfCols() << '\0' << endl;
<< "It should be <" << numOfCols() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
(*this)[_r][_c]=_value;
@ -166,47 +166,47 @@ public:
* Obviously, changes number of rows.
@param _r Position where the new row will be inserted.
@param _val Vector containing the new values to be inserted.
@exception invalid_argument If _val has not numOfCols() components.
@exception out_of_range If _r is greater than numOfRows()
@std::exception invalid_argument If _val has not numOfCols() components.
@std::exception out_of_range If _r is greater than numOfRows()
*/
virtual void insertRow( const unsigned _r,
const vector<T>& _val ) {
const std::vector<T>& _val ) {
// Test errors.
if ( _r > numOfRows() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::insertRow: row out of range. "
<< "It should be <=" << numOfRows() << '\0' << endl;
<< "It should be <=" << numOfRows() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
if ( _val.size() != numOfCols() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::insertRow: "
<< "Incorrect number of values to be added. "
<< "It should be ==" << numOfCols() << '\0' << endl;
<< "It should be ==" << numOfCols() << '\0' << std::endl;
throw invalid_argument( msg.str() );
}
// Insert the row.
vector< vector<T> >::iterator ite = begin()+_r;
std::vector< std::vector<T> >::iterator ite = begin()+_r;
insert( ite, _val );
};
/** Eliminates the row at position _r; all the other genes will
be shifted up.
@param _r Number of he row to be deleted.
@exception out_of_range if _r >=numOfRows()
@std::exception out_of_range if _r >=numOfRows()
*/
virtual void deleteRow( const unsigned _r ) {
// Test error.
if ( _r >= numOfRows() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::deleteRow: "
<< "Row out of range. "
<< "It should be <" << numOfRows() << '\0' << endl;
<< "It should be <" << numOfRows() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
// Delete row.
vector< vector<T> >::iterator ite = this->begin()+_r;
std::vector< std::vector<T> >::iterator ite = this->begin()+_r;
this->erase( ite );
};
@ -215,30 +215,30 @@ public:
* Obviously, changes number of cols.
@param _r Position where the new column will be inserted.
@param _val Vector containing the new values to be inserted.
@exception invalid_argument if _val has not numOfRows() components.
@std::exception invalid_argument if _val has not numOfRows() components.
*/
virtual void insertCol( const unsigned _c,
const vector<T>& _val ) {
const std::vector<T>& _val ) {
// Test errors.
if ( _c > numOfCols() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::insertCol: "
<< "Column out of range. "
<< "It should be >=" << numOfCols() << '\0' << endl;
<< "It should be >=" << numOfCols() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
if ( _val.size() != numOfRows() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::insertCol: "
<< "Incorrect number of values to be added. "
<< "It should be ==" << numOfRows() << '\0' << endl;
<< "It should be ==" << numOfRows() << '\0' << std::endl;
throw invalid_argument( msg.str() );
}
// Insert column.
for( unsigned r=0; r<numOfRows(); ++r ) {
vector<vector<T> >::iterator it1 = begin()+r;
vector<T>::iterator it2 = (*it1).begin()+_c;
std::vector<std::vector<T> >::iterator it1 = begin()+r;
std::vector<T>::iterator it2 = (*it1).begin()+_c;
(*it1).insert( it2, _val[r] );
};
}
@ -246,21 +246,21 @@ public:
/** Eliminates the column at position _c; all the other columns will
be shifted left.
@param _c Number of he column to be deleted.
@exception out_of_range if _c >=numOfCols()
@std::exception out_of_range if _c >=numOfCols()
*/
virtual void deleteCol( const unsigned _c ) {
// Test error.
if ( _c >= numOfCols() ) {
ostrstream msg;
std::ostrstream msg;
msg << "ERROR in eo2dVector::deleteCol: "
<< "Column out of range. "
<< "It should be <" << numOfCols() << '\0' << endl;
<< "It should be <" << numOfCols() << '\0' << std::endl;
throw out_of_range( msg.str() );
}
// Delete columns.
for( unsigned r=0; r<numOfRows(); ++r ) {
vector<vector<T> >::iterator it1 = begin()+r;
vector<T>::iterator it2 = (*it1).begin()+_c;
std::vector<std::vector<T> >::iterator it1 = begin()+r;
std::vector<T>::iterator it2 = (*it1).begin()+_c;
(*it1).erase( it2 );
}
};
@ -283,7 +283,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eo2dVector";};
std::string className() const {return "eo2dVector";};
//@}
};
@ -297,9 +297,9 @@ template <class T, class fitnessT>
eo2dVector<T,fitnessT>::eo2dVector( const unsigned _rows,
const unsigned _cols,
eoRnd<T>& _rnd )
: eo2d<T, fitnessT>(), vector< vector<T> >( _rows, vector<T>( _cols, T() ) ){
for ( vector< vector<T> >::iterator i = begin(); i != end(); ++i ) {
for( vector<T>::iterator j=(*i).begin(); j!= (*i).end(); ++j ) {
: eo2d<T, fitnessT>(), std::vector< std::vector<T> >( _rows, std::vector<T>( _cols, T() ) ){
for ( std::vector< std::vector<T> >::iterator i = begin(); i != end(); ++i ) {
for( std::vector<T>::iterator j=(*i).begin(); j!= (*i).end(); ++j ) {
*j = _rnd();
}
}
@ -307,8 +307,8 @@ eo2dVector<T,fitnessT>::eo2dVector( const unsigned _rows,
//_____________________________________________________________________________
/*template <class T, class fitnessT>
eoVector<T,fitnessT>::eoVector( istream& _is)
: eo1d<T, fitnessT>(), vector<T>( ){
eoVector<T,fitnessT>::eoVector( std::istream& _is)
: eo1d<T, fitnessT>(), std::vector<T>( ){
while (_is ) {
T tmp;
_is >> tmp;
@ -320,12 +320,12 @@ eoVector<T,fitnessT>::eoVector( istream& _is)
//_____________________________________________________________________________
template <class T, class fitnessT>
ostream& operator<<( ostream& _os, const eo2dVector<T,fitnessT>& _eo) {
std::ostream& operator<<( std::ostream& _os, const eo2dVector<T,fitnessT>& _eo) {
for( unsigned i=0; i<_eo.numOfRows(); ++i ) {
for( unsigned j=0; j<_eo.numOfCols(); ++j ) {
_os << _eo.getGene( i,j ) << " ";
}
_os << endl;
_os << std::endl;
}
return _os;
};

View file

@ -48,7 +48,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoAtomBitFlip";};
std::string className() const {return "eoAtomBitFlip";};
//@}
};

View file

@ -56,7 +56,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoAtomCreep";};
virtual std::string className() const {return "eoAtomCreep";};
//@}
};

View file

@ -52,7 +52,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoAtomRandom";};
std::string className() const {return "eoAtomRandom";};
//@}
private:

View file

@ -5,7 +5,7 @@
Abstract population insertion operator, which is used by the eoGeneralOps
to insert the results in the (intermediate) population. This file also
contains the definitions of a derived classes that implements a back inserter,
probably the only efficient inserter for populations of type vector.
probably the only efficient inserter for populations of type std::vector.
(c) Maarten Keijzer (mkeijzer@mad.scientist.com) and GeNeura Team, 1999, 2000
@ -49,7 +49,7 @@ class eoBackInserter : public eoPopInserter<EOT>
return *this;
}
string className(void) const { return "eoBackInserter"; }
std::string className(void) const { return "eoBackInserter"; }
};

View file

@ -24,9 +24,9 @@
//-----------------------------------------------------------------------------
#include <iostream> // ostream, istream
#include <iostream> // std::ostream, std::istream
#include <functional> // bind2nd
#include <string> // string
#include <string> // std::string
#include <eoFixedLength.h>
@ -39,7 +39,7 @@
/** eoBin: implementation of binary chromosome.
\class eoBin eoBin.h ga/eoBin.h
\ingroup bitstring
* based on STL's bit_vector (vector<bool>).
* based on STL's bit_std::vector (std::vector<bool>).
*/
template <class F> class eoBin: public eoFixedLength<F, bool>
{
@ -47,33 +47,33 @@ template <class F> class eoBin: public eoFixedLength<F, bool>
/**
* (Default) Constructor.
* @param size Size of the binary string.
* @param size Size of the binary std::string.
*/
eoBin(unsigned size = 0, bool value = false):
eoVector<bool,F>(size, value) {}
/// My class name.
string className() const
std::string className() const
{
return "eoBin";
}
/**
* To print me on a stream.
* @param os The ostream.
* @param os The std::ostream.
*/
void printOn(ostream& os) const
void printOn(std::ostream& os) const
{
copy(begin(), end(), ostream_iterator<bool>(os));
copy(begin(), end(), std::ostream_iterator<bool>(os));
}
/**
* To read me from a stream.
* @param is The istream.
* @param is The std::istream.
*/
void readFrom(istream& is)
void readFrom(std::istream& is)
{
string bits;
std::string bits;
is >> bits;
if (is)
{

View file

@ -28,7 +28,7 @@
//-----------------------------------------------------------------------------
#include <vector> // vector
#include <vector> // std::vector
#include <utils/eoRNG.h>
#include <eoOp.h> // eoOp, eoMonOp, eoBinOp
#include <eoPop.h> // eoPop
@ -103,7 +103,7 @@ template<class Chrom> class eoBreeder: public eoTransform<EOT>
};
/// The class name.
string className() const { return "eoBreeder"; }
std::string className() const { return "eoBreeder"; }
private:
eoOpSelector<Chrom>& opSel;

View file

@ -63,7 +63,7 @@ template <class EOT> class eoElitism : public eoCopyElite<EOT>
if (howmany > _pop.size())
throw logical_error("Elite larger than population");
vector<const EOT*> result;
std::vector<const EOT*> result;
_pop.nth_element(howmany, result);
for (int i = 0; i < result.size(); ++i)

View file

@ -48,7 +48,7 @@ template <class EOT> class eoDetTournament: public eoSelectOne<EOT>
eoDetTournament(unsigned _Tsize = 2 ):eoSelectOne<EOT>(), Tsize(_Tsize) {
// consistency check
if (Tsize < 2) {
cout << "Warning, Tournament size should be >= 2\nAdjusted\n";
std::cout << "Warning, Tournament size should be >= 2\nAdjusted\n";
Tsize = 2;
}
}

View file

@ -61,7 +61,7 @@ public :
return *this;
}
string className(void) const { return "eoDetTournamentInserter"; }
std::string className(void) const { return "eoDetTournamentInserter"; }
private :
unsigned t_size;

View file

@ -56,7 +56,7 @@ class eoDistance {
virtual double distance( const EOT& ) const = 0;
/// Returns classname
virtual string className() const { return "eoDistance"; }
virtual std::string className() const { return "eoDistance"; }
};

View file

@ -62,7 +62,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoDup";};
virtual std::string className() const {return "eoDup";};
//@}
};

View file

@ -27,17 +27,17 @@
#define _eoESCHROM_H
// STL libraries
#include <vector> // For vector<>
#include <vector> // For std::vector<>
#include <stdexcept>
#include <strstream>
#include <iostream> // for ostream
#include <iostream> // for std::ostream
// EO includes
#include <eoVector.h>
/**@name Chromosomes for evolution strategies
Each chromosome in an evolution strategies is composed of a vector of floating point
values plus a vector of sigmas, that are added to them during mutation
Each chromosome in an evolution strategies is composed of a std::vector of floating point
values plus a std::vector of sigmas, that are added to them during mutation
*/
//@{
@ -97,13 +97,13 @@ bool operator == ( eoESGene _e1, eoESGene _e2 ) {
}
///
ostream & operator << ( ostream& _s, const eoESGene& _e ) {
std::ostream & operator << ( std::ostream& _s, const eoESGene& _e ) {
_s << _e.val << ", " << _e.sigma << " | ";
return _s;
}
/// Dummy >>
istream & operator >> ( istream& _s, const eoESGene& _e ) {
std::istream & operator >> ( std::istream& _s, const eoESGene& _e ) {
_s >> _e.val;
_s >> _e.sigma;
return _s;
@ -154,7 +154,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoESChrom";};
std::string className() const {return "eoESChrom";};
//@}
};

View file

@ -27,17 +27,17 @@
#define _eoESCHROM_H
// STL libraries
#include <vector> // For vector<>
#include <vector> // For std::vector<>
#include <stdexcept>
#include <strstream>
#include <iostream> // for ostream
#include <iostream> // for std::ostream
// EO includes
#include <eoVector.h>
/**@name Chromosomes for evolution strategies
Each chromosome in an evolution strategies is composed of a vector of floating point
values plus a vector of sigmas, that are added to them during mutation
Each chromosome in an evolution strategies is composed of a std::vector of floating point
values plus a std::vector of sigmas, that are added to them during mutation
*/
//@{
@ -97,13 +97,13 @@ bool operator == ( eoESGene _e1, eoESGene _e2 ) {
}
///
ostream & operator << ( ostream& _s, const eoESGene& _e ) {
std::ostream & operator << ( std::ostream& _s, const eoESGene& _e ) {
_s << _e.val << ", " << _e.sigma << " | ";
return _s;
}
/// Dummy >>
istream & operator >> ( istream& _s, const eoESGene& _e ) {
std::istream & operator >> ( std::istream& _s, const eoESGene& _e ) {
_s >> _e.val;
_s >> _e.sigma;
return _s;
@ -154,7 +154,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoESChrom";};
std::string className() const {return "eoESChrom";};
//@}
};

View file

@ -27,28 +27,28 @@
#define _EOESFULLCHROM_H
// STL libraries
#include <vector> // For vector<>
#include <vector> // For std::vector<>
#include <stdexcept>
#include <strstream>
#include <iostream> // for ostream
#include <iostream> // for std::ostream
// EO includes
#include <eoVector.h>
#include <utils/eoRNG.h>
/**@name Chromosomes for evolution strategies
Each chromosome in an evolution strategies is composed of a vector of floating point
values plus a vector of sigmas, that are added to them during mutation and a vector of correlations
Each chromosome in an evolution strategies is composed of a std::vector of floating point
values plus a std::vector of sigmas, that are added to them during mutation and a std::vector of correlations
*/
//@{
/**@name individuals for evolution strategies -MS- 22/10/99
Each individual in an evolution strategy is composed of
a vector of floating point values
a vector of std deviations
a vector of rotation angles (for correlated mutations)
a std::vector of floating point values
a std::vector of std deviations
a std::vector of rotation angles (for correlated mutations)
These individuals CANNOT BE IMPLEMENTED as vectors of anything
These individuals CANNOT BE IMPLEMENTED as std::vectors of anything
at least in the case of correlated mutations
*/
//@{
@ -95,11 +95,11 @@ class eoESFullChrom : public eoVector<double, fitT> {
StdDevInit = parser.getFloat("-II", "--SigmaInit", "0.3",
"Initial value for std. dev. (scaled by range)" );
verbose = parser.getBool("-Iv", "--verbose",
"Verbose listing of ES individuals (mutation parameters");
"Verbose std::listing of ES individuals (mutation parameters");
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -109,10 +109,10 @@ class eoESFullChrom : public eoVector<double, fitT> {
throw invalid_argument( "No standard deviation: choose another representation please" );
}
if (num_sigma > num_genes) {
cout << "WARNING, Number of Standard Deviations > Number of Object Variables\nAdjusted!\n";
std::cout << "WARNING, Number of Standard Deviations > Number of Object Variables\nAdjusted!\n";
num_sigma = num_genes;
// modify the Param value - so .status is OK
ostrstream sloc;
std::ostrstream sloc;
sloc << num_genes;
parser.setParamValue("--NbSigma", sloc.str());
}
@ -122,8 +122,8 @@ class eoESFullChrom : public eoVector<double, fitT> {
StdDev.resize(num_sigma);
if (correlated_mutations) {
if (num_sigma < num_genes) {
cout << "WARNING less Std Dev. than number of variables + Correlated mutations\n";
cout << "Though possible, this is a strange setting" << endl;
std::cout << "WARNING less Std Dev. than number of variables + Correlated mutations\n";
std::cout << "Though possible, this is a strange setting" << std::endl;
}
// nb of rotation angles: N*(N-1)/2 (in general!)
CorCff.resize ( (2*num_genes - num_sigma)*(num_sigma - 1) / 2 );
@ -201,32 +201,32 @@ class eoESFullChrom : public eoVector<double, fitT> {
/** Print itself: inherited from eoObject implementation.
Instance from base classes are processed in
base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/
virtual void printOn( ostream& _s ) const{
copy( begin(), end(), ostream_iterator<double>( _s, " ") );
@param _s the std::ostream in which things are written*/
virtual void printOn( std::ostream& _s ) const{
copy( begin(), end(), std::ostream_iterator<double>( _s, " ") );
// The formatting instructinos shoudl be left to the caller
// _s << "\n";
if (verbose) {
_s << "\n\tStd Dev. " ;
copy( StdDev.begin(), StdDev.end(), ostream_iterator<double>( _s, " ") );
copy( StdDev.begin(), StdDev.end(), std::ostream_iterator<double>( _s, " ") );
if (CorCff.size()) {
_s << "\n\t";
copy( CorCff.begin(), CorCff.end(), ostream_iterator<double>( _s, " ") );
copy( CorCff.begin(), CorCff.end(), std::ostream_iterator<double>( _s, " ") );
}
}
};
/** This exception should be thrown when trying to insert or delete a gene
/** This std::exception should be thrown when trying to insert or delete a gene
in a fixed length chromosome
*/
class FixedLengthChromosome : public exception {
class FixedLengthChromosome : public std::exception {
public:
/**
* Constructor
*/
FixedLengthChromosome()
: exception() { };
: std::exception() { };
~FixedLengthChromosome() {};
};
@ -239,14 +239,14 @@ class eoESFullChrom : public eoVector<double, fitT> {
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoESFullChrom";};
virtual std::string className() const {return "eoESFullChrom";};
private:
// vector<double> ObjVar; /* object variable vector */
// std::vector<double> ObjVar; /* object variable std::vector */
// or shoudl the class be subclass of EOVector<double> ???
vector<double> StdDev; /* standard deviation vector */
vector<double> CorCff; /* correlation coefficient vector */
std::vector<double> StdDev; /* standard deviation std::vector */
std::vector<double> CorCff; /* correlation coefficient std::vector */
bool verbose; /* Print std deviations or not */

View file

@ -95,7 +95,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoESMutate";};
virtual std::string className() const {return "eoESMutate";};
/**
Mutate eoEsSimple
@ -197,7 +197,7 @@ public:
*/
unsigned i,k;
vector<double> VarStp(_eo.size());
std::vector<double> VarStp(_eo.size());
for (i = 0; i < _eo.size(); i++)
VarStp[i] = _eo.stdevs[i] * rng.normal();

View file

@ -30,7 +30,7 @@
/**
\defgroup EvolutionStrategies
Various classes for the initialization and mutation of real valued vectors.
Various classes for the initialization and mutation of real valued std::vectors.
Supports simple mutations and various more adaptable mutations, including
correlated mutations.

View file

@ -48,7 +48,7 @@ class eoGOpBreeder: public eoUF<eoPop<EOT>&, void>
}
/// The class name.
string className() const { return "eoGOpBreeder"; }
std::string className() const { return "eoGOpBreeder"; }
private:
eoGOpSelector<EOT>& opSel;

View file

@ -41,7 +41,7 @@ using namespace std;
/** Base class for alternative selectors, which use the generalized operator
interface. eoGOpBreeders expects this class */
template<class EOT>
class eoGOpSelector: public eoOpSelector<EOT>, public vector<eoGeneralOp<EOT>*>
class eoGOpSelector: public eoOpSelector<EOT>, public std::vector<eoGeneralOp<EOT>*>
{
public:
@ -49,7 +49,7 @@ public:
/// Dtor
virtual ~eoGOpSelector() {
for ( list< eoGeneralOp<EOT>* >::iterator i= ownOpList.begin();
for ( std::list< eoGeneralOp<EOT>* >::iterator i= ownOpList.begin();
i != ownOpList.end(); i++ ) {
delete *i;
}
@ -65,7 +65,7 @@ public:
// implementation can be found below
/** Retrieve the operator using its integer handle
@param _id The id number. Should be a valid id, or an exception
@param _id The id number. Should be a valid id, or an std::exception
will be thrown
@return a reference of the operator corresponding to that id.
*/
@ -88,22 +88,22 @@ public:
virtual eoGeneralOp<EOT>& selectOp() = 0;
///
virtual string className() const { return "eoGOpSelector"; };
virtual std::string className() const { return "eoGOpSelector"; };
///
void printOn(ostream& _os) const {}
// _os << className().c_str() << endl;
void printOn(std::ostream& _os) const {}
// _os << className().c_str() << std::endl;
// for ( unsigned i=0; i!= rates.size(); i++ ) {
// _os << *(operator[](i)) << "\t" << rates[i] << endl;
// _os << *(operator[](i)) << "\t" << rates[i] << std::endl;
// }
//}
const vector<float>& getRates(void) const { return rates; }
const std::vector<float>& getRates(void) const { return rates; }
private :
vector<float> rates;
list< eoGeneralOp<EOT>* > ownOpList;
std::vector<float> rates;
std::list< eoGeneralOp<EOT>* > ownOpList;
};
/* Implementation of longish functions defined above */
@ -121,7 +121,7 @@ inline eoOpSelector<EOT>::ID eoGOpSelector<EOT>::addOp( eoOp<EOT>& _op,
else
{
// if it's not a general op, it's a "old" op; create a wrapped op from it
// and keep it on a list to delete them afterwards
// and keep it on a std::list to delete them afterwards
// will use auto_ptr when they're readily available
switch(_op.getType())
@ -167,9 +167,9 @@ inline void eoGOpSelector<EOT>::deleteOp( ID _id )
operator[](_id) = 0;
rates[_id] = 0.0;
// check oplist and clear it there too.
// check opstd::list and clear it there too.
list< eoGeneralOp<EOT>* >::iterator it = find(ownOpList.begin(), ownOpList.end(), op);
std::list< eoGeneralOp<EOT>* >::iterator it = find(ownOpList.begin(), ownOpList.end(), op);
if(it != ownOpList.end())
{

View file

@ -42,7 +42,7 @@ public:
* reached */
virtual bool operator() ( const eoPop<EOT>& _vEO ) {
thisGeneration++;
// cout << " [" << thisGeneration << "] ";
// std::cout << " [" << thisGeneration << "] ";
return (thisGeneration < repTotalGenerations) ; // for the postincrement
}

View file

@ -65,13 +65,13 @@ template<class Chrom> class eoGeneration: public eoAlgo<Chrom>
for ( i = breeders.begin(); i != breeders.end(); i++)
evaluator(*i);
replace(breeders, pop);
} catch ( exception& e ) {
throw runtime_error( e.what() );
} catch ( std::exception& e ) {
throw std::runtime_error( e.what() );
}
}
/// Class name.
string className() const { return "eoGeneration"; }
std::string className() const { return "eoGeneration"; }
private:
eoBinPopOp<Chrom>& select;

View file

@ -46,7 +46,7 @@ public:
/// Ctor
eoGenericBinOp()
: eoOp<EOT>( eoOp<EOT>::binary ) {};
virtual string className() const {return "eoGenericBinOp";};
virtual std::string className() const {return "eoGenericBinOp";};
};
/** Converter from eoGenericBinOp to eoBinOp
@ -60,7 +60,7 @@ public:
/// Ctor
eoGeneric2TrueBinOp(eoGenericBinOp<EOT> & _binOp)
: binOp( _binOp ) {};
virtual string className() const {return "eoGeneric2TrueBinOp";}
virtual std::string className() const {return "eoGeneric2TrueBinOp";}
virtual void operator()(EOT & _eo1, const EOT & _eo2)
{

View file

@ -46,7 +46,7 @@ public:
/// Ctor
eoGenericMonOp()
: eoOp<EOT>( eoOp<EOT>::unary ) {};
virtual string className() const {return "eoGenericMonOp";};
virtual std::string className() const {return "eoGenericMonOp";};
};
/** COnverter from eoGenericMonOp to eoMonOp
@ -60,7 +60,7 @@ public:
/// Ctor
eoGeneric2TrueMonOp(eoGenericMonOp<EOT> & _monOp)
: monOp( _monOp ) {};
virtual string className() const {return "eoGeneric2trueMonOp";}
virtual std::string className() const {return "eoGeneric2trueMonOp";}
virtual void operator()(EOT & _eo)
{

View file

@ -51,7 +51,7 @@ public:
/// Ctor
eoGenericQuadOp()
: eoOp<EOT>( eoOp<EOT>::quadratic ) {};
virtual string className() const {return "eoGenericQuadOp";};
virtual std::string className() const {return "eoGenericQuadOp";};
};
/** Converter from eoGenericQuadOp to eoQuadOp
@ -65,7 +65,7 @@ public:
/// Ctor
eoGeneric2TrueQuadOp(eoGenericQuadOp<EOT> & _quadOp)
: quadOp( _quadOp ) {};
virtual string className() const {return "eoGeneric2TrueQuadOp";}
virtual std::string className() const {return "eoGeneric2TrueQuadOp";}
virtual void operator()(EOT & _eo1, EOT & _eo2)
{

View file

@ -27,8 +27,8 @@
//-----------------------------------------------------------------------------
#include <iostream> // istream, ostream
#include <string> // for string
#include <iostream> // std::istream, std::ostream
#include <string> // for std::string
using namespace std;
@ -68,14 +68,14 @@ class eoID: public Object
it's got code as an example of implementation. Only "leaf" classes
can be non-virtual.
*/
virtual string className() const { return string("[eoID]")+Object::className(); };
virtual std::string className() const { return std::string("[eoID]")+Object::className(); };
/**
* Read object.
* @param _is A istream.
* @throw runtime_exception If a valid object can't be read.
* @param _is A std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(istream& _is) {
virtual void readFrom(std::istream& _is) {
Object::readFrom( _is );
_is >> thisID;
}
@ -83,9 +83,9 @@ class eoID: public Object
/**
* Write object. It's called printOn since it prints the object _on_ a stream.
* @param _os A ostream.
* @param _os A std::ostream.
*/
virtual void printOn(ostream& _os) const{
virtual void printOn(std::ostream& _os) const{
Object::printOn( _os );
_os << thisID;
}

View file

@ -25,8 +25,8 @@ template<class Chrom> class eoInclusion: public eoMerge<Chrom>
/// (Default) Constructor.
eoInclusion(const float& _rate = 1.0): eoMerge<Chrom>( _rate ) {}
/// Ctor from istream
eoInclusion( istream& _is): eoBinPopOp<Chrom>( _is ) {};
/// Ctor from std::istream
eoInclusion( std::istream& _is): eoBinPopOp<Chrom>( _is ) {};
/// Dtor
virtual ~eoInclusion() {};
@ -55,7 +55,7 @@ template<class Chrom> class eoInclusion: public eoMerge<Chrom>
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
virtual string className() const {return "eoInclusion";};
virtual std::string className() const {return "eoInclusion";};
//@}
};

View file

@ -27,7 +27,7 @@
//-----------------------------------------------------------------------------
#include <vector> // vector
#include <vector> // std::vector
#include <utils/eoRNG.h>
#include <eoOp.h> // eoOp, eoMonOp, eoBinOp
#include <eoPop.h> // eoPop

View file

@ -46,8 +46,8 @@ template<class Chrom> class eoInsertion: public eoBinaryFunctor<eoPop<Chrom>&, c
/// (Default) Constructor.
eoInsertion(const float& _rate = 1.0): eoMerge<Chrom>( _rate ) {}
/// Ctor from istream
eoInsertion( istream& _is): eoBinPopOp<Chrom>( _is ) {};
/// Ctor from std::istream
eoInsertion( std::istream& _is): eoBinPopOp<Chrom>( _is ) {};
/// Dtor
virtual ~eoInsertion() {};
@ -86,7 +86,7 @@ template<class Chrom> class eoInsertion: public eoBinaryFunctor<eoPop<Chrom>&, c
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
virtual string className() const {return "eoInsertion";};
virtual std::string className() const {return "eoInsertion";};
//@}
};

View file

@ -54,7 +54,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoKill";};
virtual std::string className() const {return "eoKill";};
//@}
};

View file

@ -28,7 +28,7 @@
//-----------------------------------------------------------------------------
#include <stdexcept> // logic_error
#include <stdexcept> // std::logic_error
#include <utils/selectors.h> // sum_fitness
#include <eoFunctor.h>
@ -53,7 +53,7 @@ template<class EOT> class eoLottery: public eoBinaryFunctor<void, const eoPop<EO
{
if (minimizing_fitness<EOT>())
{
throw logic_error("eoLottery: minimizing fitness");
throw std::logic_error("eoLottery: minimizing fitness");
}
}

View file

@ -51,14 +51,14 @@ public:
}
/// To print me on a stream.
/// @param os The ostream.
void printOn(ostream& os) const {
/// @param os The std::ostream.
void printOn(std::ostream& os) const {
os << rate ;
}
/// To read me from a stream.
/// @param is The istream.
void readFrom(istream& is) {
/// @param is The std::istream.
void readFrom(std::istream& is) {
is >> rate ;
}
@ -68,7 +68,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoMutation";};
std::string className() const {return "eoMutation";};
//@}
protected:

View file

@ -50,17 +50,17 @@ public:
virtual ~eoOpFactory() {}
//@}
/** Another factory method: creates an object from an istream, reading from
it whatever is needed to create the object. Usually, the format for the istream will be\\
/** Another factory method: creates an object from an std::istream, reading from
it whatever is needed to create the object. Usually, the format for the std::istream will be\\
objectType parameter1 parameter2 ... parametern\\
If there are problems, an exception is raised; it should be caught at the
If there are problems, an std::exception is raised; it should be caught at the
upper level, because it might be something for that level
@param _is an stream from where a single line will be read
@throw runtime_exception if the object type is not known
@throw runtime_std::exception if the object type is not known
*/
virtual eoOp<EOT>* make(istream& _is) {
virtual eoOp<EOT>* make(std::istream& _is) {
eoOp<EOT> * opPtr = NULL;
string objectTypeStr;
std::string objectTypeStr;
_is >> objectTypeStr;
if ( objectTypeStr == "eoDup") {
opPtr = new eoDup<EOT>();

View file

@ -31,7 +31,7 @@
//-----------------------------------------------------------------------------
#include <stdexcept> // runtime_error
#include <stdexcept> // std::runtime_error
#include <eoObject.h>
#include <eoPrintable.h>
@ -63,12 +63,12 @@ public:
/** Gets a non-const reference to an operator, so that it can be changed,
modified or whatever
@param _id a previously assigned ID
@throw runtime_exception if the ID does not exist*/
@throw runtime_std::exception if the ID does not exist*/
virtual eoOp<EOT>& getOp( ID _id ) = 0;
/** Remove an operator from the operator set
@param _id a previously assigned ID
@throw runtime_exception if the ID does not exist
@throw runtime_std::exception if the ID does not exist
*/
virtual void deleteOp( ID _id ) = 0;
@ -79,9 +79,9 @@ public:
//@{
/** Return the class id.
@return the class name as a string
@return the class name as a std::string
*/
virtual string className() const { return "eoOpSelector"; };
virtual std::string className() const { return "eoOpSelector"; };
/**
* Read object and print objects are left for subclasses to define.

View file

@ -29,8 +29,8 @@
#include <string.h> // for strcasecmp ... maybe there's a c++ way of doing it?
// Yep there is, but needs either a simple functor for the equal function
// or a hand-rolled string template class (this isn't that horrible as
// it sounds, it just means a new string_traits class with two changed
// or a hand-rolled std::string template class (this isn't that horrible as
// it sounds, it just means a new std::string_traits class with two changed
// function definitions. (Maarten)
#ifdef _MSC_VER
#define strcasecmp(a,b) _strnicmp(a,b,strlen(a))
@ -44,8 +44,8 @@
#include <strstream>
#include <ctime>
// include for exceptions
#include <stdexcept> // logic_error
// include for std::exceptions
#include <stdexcept> // std::logic_error
//-----------------------------------------------------------------------------
// Class Param
@ -71,9 +71,9 @@ public:
* @param _description Description of the parameter. What is useful for.
* @param _required If it is a necessary parameter or not
*/
Param (string _shortName="-h", string _longName="--help",
string _default = "", valueType _valType= STRING,
string _description="Shows this help",
Param (std::string _shortName="-h", std::string _longName="--help",
std::string _default = "", valueType _valType= STRING,
std::string _description="Shows this help",
bool _required=false )
: repShortName(_shortName), repLongName(_longName),
repDescription(_description ), repEnv(""), repDefault(_default),
@ -108,38 +108,38 @@ public:
/**
* Returns the short name.
*/
const string& shortName ( void ) const { return repShortName; };
const std::string& shortName ( void ) const { return repShortName; };
/**
* Returns the long name.
*/
const string& longName ( void ) const { return repLongName; };
const std::string& longName ( void ) const { return repLongName; };
/**
* Returns the description of the argument
*/
const string& description ( void ) const { return repDescription; };
const std::string& description ( void ) const { return repDescription; };
/**
* Returns the environment variable of the argument
*/
const string& environment ( void ) const { return repEnv; };
const std::string& environment ( void ) const { return repEnv; };
/**
* Returns the default value of the argument
*/
const string& defValue ( void ) const { return repDefault; };
const std::string& defValue ( void ) const { return repDefault; };
/**
* Sets a value for the param.
* @param _value The new value.
*/
void value ( const string& _value ) { repValue = _value; repChanged = true; };
void value ( const std::string& _value ) { repValue = _value; repChanged = true; };
/**
* Returns the value of the param.
*/
const string& value ( void ) const { return repValue; };
const std::string& value ( void ) const { return repValue; };
/**
* Returns if required or not.
@ -157,13 +157,13 @@ public:
bool changed( void ) const { return repChanged; };
private:
string repShortName;
string repLongName;
string repDescription;
string repEnv;
string repDefault;
std::string repShortName;
std::string repLongName;
std::string repDescription;
std::string repEnv;
std::string repDefault;
string repValue;
std::string repValue;
Param::valueType repValType;
bool repRequired;
bool repChanged;
@ -194,15 +194,15 @@ public:
* @param _argc, _ argv command line arguments
* @param _programDescription Description of the work the program does
*/
Parser ( int _argc, char **_argv , string _programDescription,
string _sFileParamName = "-P",
string _lFileParamName = "--Param") :
Parser ( int _argc, char **_argv , std::string _programDescription,
std::string _sFileParamName = "-P",
std::string _lFileParamName = "--Param") :
params(),
programName( _argv[0]), programDescription( _programDescription),
parse_argc(_argc), parse_argv(_argv), InputFileName("") {
// the input file name has to be read immediately - from command-line or environement (not input0file :-)
string _default = _argv[0];
std::string _default = _argv[0];
_default += ".param";
Param param (_sFileParamName, _lFileParamName, _default, Param::STRING, "Name of the input file", 0);
@ -249,7 +249,7 @@ public:
* Adds a fake parameter == title in the output file
* @param the title
*/
void AddTitle (const string& _title)
void AddTitle (const std::string& _title)
{
Param param ( "", "", "", Param::TITLE, _title, false );
params.push_back( param );
@ -266,12 +266,12 @@ public:
*/
/**
* Gets the string value of a param from the full parameter description
* Gets the std::string value of a param from the full parameter description
* @param see above
*/
string getString (const string& _shortName, const string& _longName,
const string& _default = "",
const string& _description="", bool _required=false) {
std::string getString (const std::string& _shortName, const std::string& _longName,
const std::string& _default = "",
const std::string& _description="", bool _required=false) {
Param param ( _shortName, _longName, _default, Param::STRING, _description, _required );
parse( param );
params.push_back( param );
@ -284,8 +284,8 @@ public:
* @param see above
*/
bool getBool (const string& _shortName, const string& _longName,
const string& _description="") {
bool getBool (const std::string& _shortName, const std::string& _longName,
const std::string& _description="") {
Param param ( _shortName, _longName, "false", Param::BOOL, _description, false );
parse( param );
params.push_back( param );
@ -299,19 +299,19 @@ public:
};
/**
* Gets the "array" (vector of strings) value of a param from the full parameter description
* Gets the "array" (std::vector of std::strings) value of a param from the full parameter description
* @param see above
*/
vector<string> getArray (const string& _shortName, const string& _longName,
const string& _default = "",
const string& _description="", bool _required=false) {
std::vector<std::string> getArray (const std::string& _shortName, const std::string& _longName,
const std::string& _default = "",
const std::string& _description="", bool _required=false) {
Param param ( _shortName, _longName, _default, Param::ARRAY, _description, _required );
parse( param );
params.push_back( param );
istrstream is(param.value().c_str());
vector<string> retValue;
string tmpStr;
std::vector<std::string> retValue;
std::string tmpStr;
is >> tmpStr;
while(is){
@ -324,12 +324,12 @@ public:
/**
* Gets the int value of a param given the full description of the parameter
* @param see above
* @exception BadType if the param's value isn't a correct int
* @std::exception BadType if the param's value isn't a correct int
*/
int getInt (const string& _shortName, const string& _longName,
const string& _default = "",
const string& _description="", bool _required=false) {
int getInt (const std::string& _shortName, const std::string& _longName,
const std::string& _default = "",
const std::string& _description="", bool _required=false) {
Param param ( _shortName, _longName, _default, Param::INT, _description, _required );
parse( param );
params.push_back( param );
@ -350,12 +350,12 @@ public:
/**
* Gets the unsigned lon value of a param given ...
* @param see above
* @exception BadType if the param's value isn't a correct unsigned long
* @std::exception BadType if the param's value isn't a correct unsigned long
*/
int getUnsignedLong (const string& _shortName, const string& _longName,
const string& _default = "",
const string& _description="", bool _required=false) {
int getUnsignedLong (const std::string& _shortName, const std::string& _longName,
const std::string& _default = "",
const std::string& _description="", bool _required=false) {
Param param ( _shortName, _longName, _default, Param::UL, _description, _required );
parse( param );
params.push_back( param );
@ -376,12 +376,12 @@ public:
/**
* Gets the float value of a param given the description of the parameter
* @param see above
* @exception BadType if the param's value isn't a correct int
* @std::exception BadType if the param's value isn't a correct int
*/
float getFloat (const string& _shortName, const string& _longName,
const string& _default = "",
const string& _description="", bool _required=false) {
float getFloat (const std::string& _shortName, const std::string& _longName,
const std::string& _default = "",
const std::string& _description="", bool _required=false) {
Param param ( _shortName, _longName, _default, Param::FLOAT, _description, _required );
parse( param );
params.push_back( param );
@ -400,19 +400,19 @@ public:
};
string parse_string (istream & _is) {
string paramValue;
std::string parse_std::string (std::istream & _is) {
std::string paramValue;
_is >> paramValue;
//if the first character of the string or array is not a " => just one word or array-element.
//if the first character of the std::string or array is not a " => just one word or array-element.
if( paramValue[0] != '\"' )
return paramValue;
if( paramValue[1] == '\"' ) // the empty string
if( paramValue[1] == '\"' ) // the empty std::string
return "" ;
//else => read until the next " (the end of the string).
//else => read until the next " (the end of the std::string).
const char *c = paramValue.c_str();
string tmpStr = c+1;// skip the "
std::string tmpStr = c+1;// skip the "
if (tmpStr[tmpStr.length()-1] == '\"') { // one word only
//tmpStr[tmpStr.length()-1] = '\0';
tmpStr.erase( &tmpStr[tmpStr.length()-1] );
@ -436,11 +436,11 @@ public:
void parse (Param & param) {
int i;
string tmpStr, ReadStr, FirstWord;
std::string tmpStr, ReadStr, FirstWord;
// FIRST: look if the associated environment variables have any value, to use them.
if( getenv( param.environment().c_str() ) ) {
//cout <<"\t\t ENV param: ,"<<p->shortName()<<", ,"<<getenv(p->environment().c_str())<<endl;
//std::cout <<"\t\t ENV param: ,"<<p->shortName()<<", ,"<<getenv(p->environment().c_str())<<std::endl;
param.value(getenv(param.environment().c_str()) );
}
@ -457,7 +457,7 @@ public:
Param::valueType tmp = param.valType();
switch ( tmp ) {
case Param::TITLE:
cerr << "Error, we should not be there" << endl;
std::cerr << "Error, we should not be there" << std::endl;
exit(1);
break;
case Param::BOOL :
@ -472,18 +472,18 @@ public:
break;
case Param::STRING:
tmpStr = parse_string(is);
tmpStr = parse_std::string(is);
param.value(tmpStr);
break;
case Param::ARRAY:
ReadStr = parse_string(is);
if ( ReadStr != "<" ) { // no "<" ">" --> a single string in the array
ReadStr = parse_std::string(is);
if ( ReadStr != "<" ) { // no "<" ">" --> a single std::string in the array
param.value(ReadStr);
break;
}
// read next word - and keep it in case of <> mismatch
FirstWord = parse_string(is);
FirstWord = parse_std::string(is);
// test for empty array
if (FirstWord == ">") {
param.value("");
@ -491,15 +491,15 @@ public:
}
// else, read all words until ">"
tmpStr = FirstWord;
ReadStr = parse_string(is);
ReadStr = parse_std::string(is);
while ( is && (ReadStr != ">") ) {
tmpStr = tmpStr + " " + ReadStr;
ReadStr = parse_string(is);
ReadStr = parse_std::string(is);
}
if (!is) { // there was a "<" without the corresponding ">"
throw Parser::BadArrayParam( param.longName(), FirstWord );
param.value(FirstWord); // assume unique string
param.value(FirstWord); // assume unique std::string
}
else
param.value(tmpStr);
@ -516,18 +516,18 @@ public:
( ! strcmp(param.shortName().c_str(), parse_argv[i]) )
) { // found the parameter name
if (param.valType() == Param::BOOL) {
//cout <<"BOOL: "<<parse_argv[i]<<" <-- true"<<endl;
//std::cout <<"BOOL: "<<parse_argv[i]<<" <-- true"<<std::endl;
param.value("true");
}else{
if (param.valType() != Param::ARRAY) { //only if it is not an array
//cout <<"TYPE: "<<parse_argv[i]<<" <-- "<<parse_argv[i+1]<<endl;
//std::cout <<"TYPE: "<<parse_argv[i]<<" <-- "<<parse_argv[i+1]<<std::endl;
param.value(parse_argv[i+1]);
}else{ //if it is an ARRAY
i++;
ReadStr = parse_argv[i++];
//cout <<"ARRAY: <-- ";
//std::cout <<"ARRAY: <-- ";
if ( ReadStr != "<" ) { // no "<" ">" --> a single string in the array
if ( ReadStr != "<" ) { // no "<" ">" --> a single std::string in the array
param.value(ReadStr);
}else{
// read next word - and keep it in case of <> mismatch
@ -544,11 +544,11 @@ public:
tmpStr = tmpStr + " " + ReadStr;
ReadStr = parse_argv[i++];
}
//cout <<"tmpStr ;"<<tmpStr<<"; ("<<i<<","<<parse_argc<<") "<<endl;
//std::cout <<"tmpStr ;"<<tmpStr<<"; ("<<i<<","<<parse_argc<<") "<<std::endl;
if ( (i>=parse_argc) && (ReadStr != ">") ) { // there was a "<" without the corresponding ">"
throw Parser::BadArrayParam( param.longName(), FirstWord );
param.value(FirstWord); // assume unique string
param.value(FirstWord); // assume unique std::string
}else{
param.value(tmpStr);
}
@ -570,11 +570,11 @@ public:
* Sets a new value for a param given its short name or its long name.
* @param _name One of the names of the param.
* @param _value Value to be assigned.
* @exception UnknownArg if the param doesn't exist
* @exception MissingVal if the param hasn't got a value
* @std::exception UnknownArg if the param doesn't exist
* @std::exception MissingVal if the param hasn't got a value
*/
Param::valueType setParamValue (const string& _name, const char* _value){
vector<Param>::iterator pos;
Param::valueType setParamValue (const std::string& _name, const char* _value){
std::vector<Param>::iterator pos;
for (pos=params.begin() ; pos!=params.end() ; pos++)
if (pos->shortName()==_name || pos->longName()==_name)
@ -584,7 +584,7 @@ public:
if (pos!=params.end()) {
switch ( pos->valType() ) {
case Param::TITLE:
cerr << "Error, we should not be there" << endl;
std::cerr << "Error, we should not be there" << std::endl;
exit(1);
break;
case Param::BOOL :
@ -613,14 +613,14 @@ public:
};
/// the output method - generate the .status file (unless other name is given)
friend ostream & operator<< ( ostream & os, Parser & _parser )
friend std::ostream & operator<< ( std::ostream & os, Parser & _parser )
{
vector<Param>::iterator p;
std::vector<Param>::iterator p;
//print every param with its value
for ( p=_parser.params.begin(); p!=_parser.params.end(); p++ ) {
switch ( p->valType() ) {
case Param::BOOL :
if( p->value() == (string) "true")
if( p->value() == (std::string) "true")
os << p->longName();
else
os << "#" << p->longName() ; // so the name of the bool is commented out
@ -639,30 +639,30 @@ public:
os << p->longName()<<" \""<<p->value().c_str()<<"\" ";
break;
case Param::TITLE:
os << endl; // Title is in the description below
os << std::endl; // Title is in the description below
break;
} // switch
os << "\t #" << p->shortName() << " : " << p->description();
if (p->valType() != Param::TITLE)
os << " [" << p->defValue() << "]" ;
os << endl;
os << std::endl;
}
return os;
};
/**
* Prints out the list of parameters in the output file (if specified)
* Prints out the std::list of parameters in the output file (if specified)
*/
void outputParam(string _OutputFile="")
void outputParam(std::string _OutputFile="")
{
if (_OutputFile == "") {
_OutputFile = parse_argv[0];
_OutputFile += ".status";
}
ofstream os(_OutputFile.c_str());
std::ofstream os(_OutputFile.c_str());
os << "Parameters used by \"" << programName << "\" ("
<< programDescription << ")" << endl << endl;
<< programDescription << ")" << std::endl << std::endl;
os << *this;
};
@ -671,80 +671,80 @@ public:
* provided by parameters
*/
void printHelp() {
vector<Param>::iterator p;
std::vector<Param>::iterator p;
// unsigned i;
// print program name and description
cout << this->programName <<": "<<programDescription<<endl<<endl;
std::cout << this->programName <<": "<<programDescription<<std::endl<<std::endl;
// print the usage when calling the program from the command line
cout << "Usage: "<< programName<<" [Options]\n";
std::cout << "Usage: "<< programName<<" [Options]\n";
// only short usage!
cout << "Options of the form \"-ShortName value\" or \"--LongName value\"" << endl;
std::cout << "Options of the form \"-ShortName value\" or \"--LongName value\"" << std::endl;
// for ( i=0,p=params.begin(); p!=params.end(); i++,p++ )
// if( p->valType() != Param::TITLE ) {
// if( p->valType() != Param::BOOL ){
// cout << ( (!p->required())?"[":"");
// cout <<p->shortName()<<" value"<<i;
// cout << ( (!p->required())?"]":"")<<" ";
// std::cout << ( (!p->required())?"[":"");
// std::cout <<p->shortName()<<" value"<<i;
// std::cout << ( (!p->required())?"]":"")<<" ";
// }else{
// cout << "["<<p->shortName()<<"] ";
// std::cout << "["<<p->shortName()<<"] ";
// }
// } // for p
cout << "Where:"<<endl;
std::cout << "Where:"<<std::endl;
for ( p=params.begin(); p!=params.end(); p++ ) {
if( p->valType() != Param::TITLE ) {
// Victor: 04-Jan-2000
// Modified because the - and -- prefixes are not needed.
/*
cout << "-" << p->shortName()
std::cout << "-" << p->shortName()
<<", --"<<p->longName()<<":\t"
<<p->description()<<endl;
<<p->description()<<std::endl;
*/
cout << p->shortName()
std::cout << p->shortName()
<<", " << p->longName()<<":\t"
<<p->description()<<endl;
cout << "\t(";
<<p->description()<<std::endl;
std::cout << "\t(";
switch ( p->valType() ) {
case Param::INT: cout <<"Integer"; break;
case Param::UL: cout <<"Unsigned Long Integer"; break;
case Param::FLOAT: cout <<"Float"; break;
case Param::STRING: cout <<"String"; break;
case Param::ARRAY: cout <<"An array of strings, enclosed within < >"; break;
case Param::BOOL: cout << "Flag"; break;
case Param::INT: std::cout <<"Integer"; break;
case Param::UL: std::cout <<"Unsigned Long Integer"; break;
case Param::FLOAT: std::cout <<"Float"; break;
case Param::STRING: std::cout <<"String"; break;
case Param::ARRAY: std::cout <<"An array of std::strings, enclosed within < >"; break;
case Param::BOOL: std::cout << "Flag"; break;
case Param::TITLE: break;
} // switch
if(p->valType() == Param::BOOL)
cout << ") True if present" << endl;
std::cout << ") True if present" << std::endl;
else
cout<<") "<<( (p->required())?"Required":"Optional" )<<". By default: "<<p->defValue()<<endl;
std::cout<<") "<<( (p->required())?"Required":"Optional" )<<". By default: "<<p->defValue()<<std::endl;
}
else {
cout << "\n\t # " << p->description() << endl;
std::cout << "\n\t # " << p->description() << std::endl;
}
} // for p
cout << endl;
std::cout << std::endl;
};
/**
* This class managges unknown argument exceptions.
* This class managges unknown argument std::exceptions.
*/
class UnknownArg : public logic_error {
class UnknownArg : public std::logic_error {
public:
/**
* Constructor
* @param _arg string to be shown when the exception occurs
* @param _arg std::string to be shown when the std::exception occurs
*/
UnknownArg( const string& _arg): logic_error( "Invalid argument: "+_arg ) { };
UnknownArg( const std::string& _arg): std::logic_error( "Invalid argument: "+_arg ) { };
};
/**
* This class managges bad param types.
*/
class BadType : public logic_error {
class BadType : public std::logic_error {
public:
/**
@ -752,40 +752,40 @@ public:
* @param _param The param
* @param _value The value of the param
*/
BadType(const string& _param, const string& _value, const string& _correctType)
: logic_error("The value '" + _value + "' assigned to the argument " + _param + " isn't a correct "+_correctType) { };
BadType(const std::string& _param, const std::string& _value, const std::string& _correctType)
: std::logic_error("The value '" + _value + "' assigned to the argument " + _param + " isn't a correct "+_correctType) { };
};
/**
* This class managges exceptions produced when there isn't a value for a parameter.
* This class managges std::exceptions produced when there isn't a value for a parameter.
*/
class MissingVal : public logic_error {
class MissingVal : public std::logic_error {
public:
/**
* Constructor
* @param _param The param
*/
MissingVal(const string& _param) : logic_error("Missing value for parameter " + _param) {};
MissingVal(const std::string& _param) : std::logic_error("Missing value for parameter " + _param) {};
};
/**
* This class managges exceptions produced when the user forgot a required parameter.
* This class managges std::exceptions produced when the user forgot a required parameter.
*/
class MissingReqParam : public logic_error {
class MissingReqParam : public std::logic_error {
public:
/**
* Constructor
* @param _shortName The param's short name
*/
MissingReqParam(const string& _shortName) : logic_error("Missing required parameter " + _shortName) {};
MissingReqParam(const std::string& _shortName) : std::logic_error("Missing required parameter " + _shortName) {};
};
/**
* This class managges exceptions du to < without a > in array value
* This class managges std::exceptions du to < without a > in array value
*/
class BadArrayParam : public logic_error {
class BadArrayParam : public std::logic_error {
public:
/**
@ -793,17 +793,17 @@ public:
* @param _param The param
* @param _first_word The first word read after the "<"
*/
BadArrayParam(const string& _param, const string &_first_word) :
logic_error("Array parameter " + _param + ": No matching > (" + _first_word
BadArrayParam(const std::string& _param, const std::string &_first_word) :
std::logic_error("Array parameter " + _param + ": No matching > (" + _first_word
+ "... )") {};
};
void createParamFile( ostream& _os ) {
vector<Param>::iterator p;
void createParamFile( std::ostream& _os ) {
std::vector<Param>::iterator p;
for ( p=params.begin(); p!=params.end(); p++ ) {
switch( p->valType() ) {
case Param::TITLE:
_os << endl << "# -- ";
_os << std::endl << "# -- ";
break;
case Param::BOOL:
_os << ((p->value()=="true" )?"":"#")
@ -819,16 +819,16 @@ public:
_os << p->longName()<<"\t"<<p->value();
break;
} // switch
_os << "\t #" << p->description() << endl;
_os << "\t #" << p->description() << std::endl;
}
}
private:
vector<Param> params;
string programName;
string programDescription;
std::vector<Param> params;
std::string programName;
std::string programDescription;
int parse_argc;
char **parse_argv;
string InputFileName;
std::string InputFileName;
};

View file

@ -68,7 +68,7 @@ class eoMonPopOp: public eoObject{
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
virtual string className() const {return "eoMonPopOp";};
virtual std::string className() const {return "eoMonPopOp";};
//@}
};
@ -101,7 +101,7 @@ class eoBinPopOp: public eoObject{
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
virtual string className() const {return "eoBinPopOp";};
virtual std::string className() const {return "eoBinPopOp";};
//@}
};
@ -135,7 +135,7 @@ class eoSelectOne: public eoObject{
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
virtual string className() const {return "eoSelectOne";};
virtual std::string className() const {return "eoSelectOne";};
//@}
};

View file

@ -48,7 +48,7 @@ public:
total((pop.size() == 0) ? -1.0 : sum_fitness(pop))
{
if (minimizing_fitness<EOT>())
throw logic_error("eoProportional: minimizing fitness");
throw std::logic_error("eoProportional: minimizing fitness");
}
void setup(const eoPop<EOT>& _pop)

View file

@ -44,7 +44,7 @@ public :
}
///
virtual string className() const { return "eoGOpSelector"; };
virtual std::string className() const { return "eoGOpSelector"; };
};

View file

@ -31,7 +31,7 @@
//-----------------------------------------------------------------------------
#include <stdexcept> // runtime_error
#include <stdexcept> // std::runtime_error
#include <functional> // greater
#include <map>
@ -42,8 +42,8 @@
//-----------------------------------------------------------------------------
/** This class selects operators according to probability. All operator percentages
should add up to one; if not, an exception will be raised.\\
Operators are represented as pairs (proportion,operator)
should add up to one; if not, an std::exception will be raised.\\
Operators are represented as std::pairs (proportion,operator)
*/
template<class EOT>
class eoProportionalOpSel: public eoOpSelector<EOT>,
@ -63,14 +63,14 @@ public:
/** Gets a non-const reference to an operator, so that it can be changed,
modified or whatever
@param _id a previously assigned ID
@throw runtime_error if the ID does not exist*/
@throw std::runtime_error if the ID does not exist*/
virtual eoOp<EOT>& getOp( ID _id ) {
MMF::iterator i=begin();
ID j = 1;
while ( (i++!=end()) && (j++ != _id) );
if ( i == end() )
throw runtime_error( "No such id in eoProportionalOpSel::op\n" );
throw std::runtime_error( "No such id in eoProportionalOpSel::op\n" );
return *(i->second);
//return i->second;
}
@ -87,7 +87,7 @@ public:
/** Remove an operator from the operator set
@param _id a previously assigned ID
@throw runtime_error if the ID does not exist
@throw std::runtime_error if the ID does not exist
*/
virtual void deleteOp( ID _id ) {
unsigned j;
@ -98,7 +98,7 @@ public:
return;
}
if ( i == end() )
throw runtime_error( "No such id in eoProportionalOpSel::op\n" );
throw std::runtime_error( "No such id in eoProportionalOpSel::op\n" );
};
/// Returns a genetic operator according to the established criteria
@ -111,7 +111,7 @@ public:
acc +=i->first;
}
if ( acc != 1.0 )
throw runtime_error( "Operator rates added up different from 1.0" );
throw std::runtime_error( "Operator rates added up different from 1.0" );
// If here, operators ordered by rate and no problem
float aRnd = rng.uniform();
@ -121,7 +121,7 @@ public:
acc += i->first;
} while ( (acc <= aRnd ) && (i++!=end() ) );
if ( i == end() )
throw runtime_error( "Operator not found in eoProportionalOpSelector" );
throw std::runtime_error( "Operator not found in eoProportionalOpSelector" );
return i->second;
//return i->second;
}
@ -130,18 +130,18 @@ public:
//@{
/** Return the class id.
@return the class name as a string
@return the class name as a std::string
*/
virtual string className() const { return "eoProportionalOpSel"; };
virtual std::string className() const { return "eoProportionalOpSel"; };
/** Print itself: inherited from eoObject implementation. Declared virtual so that
it can be reimplemented anywhere. Instance from base classes are processed in
base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/
virtual void printOn( ostream& _s ) const{
_s << className().c_str() << endl;
@param _s the std::ostream in which things are written*/
virtual void printOn( std::ostream& _s ) const{
_s << className().c_str() << std::endl;
for ( MMF::const_iterator i=begin(); i!=end(); i++ ) {
_s << i->first << "\t" << *(i->second )<< endl;
_s << i->first << "\t" << *(i->second )<< std::endl;
}
}

View file

@ -27,13 +27,13 @@
#include <eoSelector.h>
/** Takes those on the selection list and creates a list of new individuals
/** Takes those on the selection std::list and creates a std::list of new individuals
* Destroys the genetic pool */
template<class EOT>
class EORandomBreed: public EOBreeder<EOT>{
public:
typedef vector< EOOp<EOT > * > vecOpT;
typedef std::vector< EOOp<EOT > * > vecOpT;
/// Ctor
EORandomBreed():vecOp() {};
@ -54,12 +54,12 @@ public:
vecOp.push_back( _eop);
};
/// Takes the operator pointed to from the operator list
/// Takes the operator pointed to from the operator std::list
virtual void deleteOp( const EOOp<EOT>* _eop);
/** Takes the genetic pool, and returns next generation, destroying the
* genetic pool container
* Non-const because it might order the operator vector. In this case,
* Non-const because it might order the operator std::vector. In this case,
* it mates all members of the population randomly */
virtual void operator() ( EOPop< EOT >& _ptVeo );
@ -133,7 +133,7 @@ template<class EOT>
class EORandomBreedLog: public EORandomBreed<EOT>{
public:
typedef vector< EOOp<EOT > * > vecOpT;
typedef std::vector< EOOp<EOT > * > vecOpT;
/// Ctor
EORandomBreedLog( EOFactory<EOT> & _eof ):EORandomBreed<EOT>(), factory( _eof ) {};
@ -148,7 +148,7 @@ public:
/** Takes the genetic pool, and returns next generation, destroying the
* genetic pool container
* Non-const because it might order the operator vector. In this case, it mates
* Non-const because it might order the operator std::vector. In this case, it mates
* all population randomly */
virtual void operator() ( EOPop< EOT >& _ptVeo ) {

View file

@ -78,11 +78,11 @@ template<class EOT> class eoRandomSelect: public eoBinPopOp<EOT>
* Should call base class, just in case.
* @param _s A istream.
* @param _s A std::istream.
*/
virtual void readFrom(istream& _s) {
virtual void readFrom(std::istream& _s) {
_s >> repRate;
@ -96,9 +96,9 @@ template<class EOT> class eoRandomSelect: public eoBinPopOp<EOT>
base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/
@param _s the std::ostream in which things are written*/
virtual void printOn( ostream& _s ) const{
virtual void printOn( std::ostream& _s ) const{
_s << repRate;
@ -112,7 +112,7 @@ template<class EOT> class eoRandomSelect: public eoBinPopOp<EOT>
*/
string className() const {return "eoRandomSelect";};
std::string className() const {return "eoRandomSelect";};

View file

@ -40,9 +40,9 @@
/**
* Takes those on the selection list and creates a list of new individuals
* Takes those on the selection std::list and creates a std::list of new individuals
* Destroys the genetic pool. There's no requisite on EOT, other than the
* genetic operators can be instantiated with it, so it fully depends on
* genetic operators can be instantiated with it, so it fully depstd::ends on
* the genetic operators used. If generic genetic operators are used, then
* EOT must be an EO
*/
@ -61,14 +61,14 @@ class eoRank: public eoSelect<EOT>, public eoObject, public eoPrintable
/** Takes the genetic pool, and returns next generation, destroying the
* genetic pool container
* Non-const because it might order the operator vector*/
* Non-const because it might order the operator std::vector*/
virtual void operator() ( const eoPop< EOT >& _ptVeo,
eoPop< EOT >& _siblings ) const {
unsigned inLen = _ptVeo.size(); // size of subPop
if ( !inLen )
throw runtime_error( "zero population in eoRank");
throw std::runtime_error( "zero population in eoRank");
for ( unsigned i = 0; i < repNewPopSize; i ++ ) {
// Create a copy of a random input EO with copy ctor. The members of the
@ -113,13 +113,13 @@ class eoRank: public eoSelect<EOT>, public eoObject, public eoPrintable
/** Return the class id.
@return the class name as a string
@return the class name as a std::string
*/
virtual string className() const { return "eoRank"; };
virtual std::string className() const { return "eoRank"; };
virtual void printOn( ostream& _s ) const
virtual void printOn( std::ostream& _s ) const
{
_s << repNewPopSize;
};

View file

@ -81,8 +81,8 @@ class eoScheme: public eoAlgo<EOT>{
eoScheme(Parser & parser) {
// read the popsize
parser.AddTitle("Description of evolution");
string Evol;
string SelectString;
std::string Evol;
std::string SelectString;
// temporary
float rate_offspring;
@ -92,9 +92,9 @@ class eoScheme: public eoAlgo<EOT>{
popsize = parser.getInt("-EP", "--population", "10",
"Population size" );
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -128,9 +128,9 @@ class eoScheme: public eoAlgo<EOT>{
ptreplace = new eoInclusion<EOT>();
// put here the choice of elitism
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -156,9 +156,9 @@ class eoScheme: public eoAlgo<EOT>{
ptselect_mate = new eoDetTournament<EOT>((int)_rate);
}
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -178,9 +178,9 @@ class eoScheme: public eoAlgo<EOT>{
ptselect_mate = new eoUniformSelect<EOT>();
ptreplace = new eoESPlus<EOT>();
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -197,9 +197,9 @@ class eoScheme: public eoAlgo<EOT>{
ptselect_mate = new eoUniformSelect<EOT>();
ptreplace = new eoESComma<EOT>();
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -218,9 +218,9 @@ class eoScheme: public eoAlgo<EOT>{
"Size of stocahstic replacement tournament" );
ptreplace = new eoEPTournament<EOT>(tsize);
}
catch (exception & e)
catch (std::exception & e)
{
cout << e.what() << endl;
std::cout << e.what() << std::endl;
parser.printHelp();
exit(1);
}
@ -249,7 +249,7 @@ class eoScheme: public eoAlgo<EOT>{
/** Inherited from eoObject. Returns the class name.
@see eoObject
*/
string className() const {return "eoScheme";};
std::string className() const {return "eoScheme";};
//@}
private:
unsigned popsize; /* but should it be here ??? */
@ -275,7 +275,7 @@ class eoScheme: public eoAlgo<EOT>{
in SSGA, nb_offspring = 1 (usually)
elitism can be used anywhere - though stupid in ES, EP and SSGA who are
elist by definition
estd::list by definition
*/
#endif _EOSCHEME_H
@ -319,7 +319,7 @@ class eoScheme: public eoAlgo<EOT>{
mate = select_mate(pop, tmp); // though useless ig mutation
else
mate = tmp; // assumed: mate will not be used!
cout << op->className() << " for offspring " << i << endl;
std::cout << op->className() << " for offspring " << i << std::endl;
tmp = (*op)( tmp, mate, pop );
op = seqselop.Op(&id);
}

View file

@ -63,11 +63,11 @@ template<class EOT> class eoSteadyStateEA: public eoAlgo<EOT>
{
step(pop);
}
catch (exception& e)
catch (std::exception& e)
{
string s = e.what();
std::string s = e.what();
s.append( " in eoSteadyStateEA ");
throw runtime_error( s );
throw std::runtime_error( s );
}
} while ( continuator( pop ) );

View file

@ -48,7 +48,7 @@ template <class EOT> class eoStochTournament: public eoSelectOne<EOT>
{
// consistency check
if (Trate < 0.5) {
cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
std::cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
Trate = 0.55;
}
}

View file

@ -66,7 +66,7 @@ public :
return *this;
}
string className(void) const { return "eoStochTournamentInserter"; }
std::string className(void) const { return "eoStochTournamentInserter"; }
private :
double t_rate;

View file

@ -51,7 +51,7 @@ class eoStringMutation: public eoMutation<EOT> {
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoStringMutation";};
std::string className() const {return "eoStringMutation";};
//@}

View file

@ -73,7 +73,7 @@ public:
unsigned thisSize = _vEO.size();
// Build vector
// Build std::vector
for ( unsigned j = 0; j < thisSize*perc; j ++ ) {
// Randomly select a tournamentSize set, and choose the best
eoPop<EOT> veoTournament;
@ -84,10 +84,10 @@ public:
veoTournament.push_back( newEO );
}
eoPop<EOT>::const_iterator best = max_element(veoTournament.begin(),
eoPop<EOT>::const_iterator best = std::max_element(veoTournament.begin(),
veoTournament.end());
if (best == veoTournament.end()) {
throw runtime_error("error in void eoTournament::operator(eoPop<EOT>&, eoPop<EOT>&)");
throw std::runtime_error("error in void eoTournament::operator(eoPop<EOT>&, eoPop<EOT>&)");
}
// The best individual is chosen for the new population
@ -106,11 +106,11 @@ public:
* Should call base class, just in case.
* @param _s A istream.
* @param _s A std::istream.
*/
virtual void readFrom(istream& _s) {
virtual void readFrom(std::istream& _s) {
_s >> perc >> repTournamentSize;
@ -124,11 +124,11 @@ public:
base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/
@param _s the std::ostream in which things are written*/
virtual void printOn( ostream& _s ) const{
virtual void printOn( std::ostream& _s ) const{
_s << perc << endl << repTournamentSize << endl;
_s << perc << std::endl << repTournamentSize << std::endl;
}
@ -140,7 +140,7 @@ public:
*/
string className() const {return "eoTournament";};
std::string className() const {return "eoTournament";};

View file

@ -41,7 +41,7 @@ class eoTranspose: public eoMonOp<EOT>
{
public:
// Specialization for a vector
// Specialization for a std::vector
void operator()(eoFixedLength<typename EOT::Fitness, typename EOT::AtomType>& _eo )
{
unsigned pos1 = rng.random(_eo.size()),
@ -54,7 +54,7 @@ public:
_eo.invalidate();
}
// Specialization for a list
// Specialization for a std::list
void operator()(eoVariableLength<typename EOT::Fitness, typename EOT::AtomType>& _eo )
{
unsigned pos1 = rng.random(_eo.size()),
@ -85,7 +85,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
virtual string className() const {return "eoTranspose";};
virtual std::string className() const {return "eoTranspose";};
//@}
};

View file

@ -110,7 +110,7 @@ class eoUniformXOver: public eoQuadraticOp< EOT >
if (rate < 0 || rate > 1)
runtime_error("UxOver --> invalid rate");
std::runtime_error("UxOver --> invalid rate");
}
@ -152,7 +152,7 @@ class eoUniformXOver: public eoQuadraticOp< EOT >
*/
string className() const {return "eoUniformXOver";};
std::string className() const {return "eoUniformXOver";};
//@}

View file

@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
eoVector.h
Turns an STL vector into an EO
Turns an STL std::vector into an EO
(c) GeNeura Team, 1998
This library is free software; you can redistribute it and/or
@ -28,19 +28,19 @@
#define _eoVector_H
// STL libraries
#include <vector> // For vector<int>
#include <vector> // For std::vector<int>
#include <stdexcept>
#include <strstream>
#include <eo1d.h>
#include <eoRnd.h>
/** Adaptor that turns an STL vector into an EO
/** Adaptor that turns an STL std::vector into an EO
with the same gene type as the type with which
the vector has been instantiated
the std::vector has been instantiated
*/
template <class T, class fitnessT=float>
class eoVector: public eo1d<T, fitnessT>, public vector<T> {
class eoVector: public eo1d<T, fitnessT>, public std::vector<T> {
public:
typedef T Type ;
@ -52,7 +52,7 @@ public:
@param _val Common initial value
*/
eoVector( unsigned _size = 0, T _val = 0)
: eo1d<T, fitnessT>(), vector<T>( _size, _val ){ };
: eo1d<T, fitnessT>(), std::vector<T>( _size, _val ){ };
/** Ctor using a random number generator
@param _size Lineal length of the object
@ -60,22 +60,22 @@ public:
*/
eoVector( unsigned _size, eoRnd<T>& _rnd );
/** Ctor from a istream. The T class should accept reading from a istream. It doesn't read fitness,
/** Ctor from a std::istream. The T class should accept reading from a std::istream. It doesn't read fitness,
which is supposed to be dynamic and dependent on environment.
@param _is the input stream; should have all values in a single line, separated by whitespace
*/
eoVector( istream& _is);
eoVector( std::istream& _is);
/// copy ctor
eoVector( const eoVector & _eo )
: eo1d<T, fitnessT>( _eo ), vector<T>( _eo ){ };
: eo1d<T, fitnessT>( _eo ), std::vector<T>( _eo ){ };
/// Assignment operator
const eoVector& operator =( const eoVector & _eo ) {
if ( this != &_eo ){
eo1d<T, fitnessT>::operator=( _eo );
vector<T>::operator=( _eo );
std::vector<T>::operator=( _eo );
}
return *this;
}
@ -86,7 +86,7 @@ which is supposed to be dynamic and dependent on environment.
//@}
/** methods that implement the eo1d <em>protocol</em>
@exception out_of_range if _i is larger than EO´s size
@std::exception out_of_range if _i is larger than EO´s size
*/
virtual T getGene( unsigned _i ) const {
if ( _i >= length() )
@ -95,7 +95,7 @@ which is supposed to be dynamic and dependent on environment.
};
/** methods that implement the eo1d <em>protocol</em>
@exception out_of_range if _i is larger than EO´s size
@std::exception out_of_range if _i is larger than EO´s size
*/
virtual void setGene( unsigned _i, const T& _value ) {
if ( _i >= size() )
@ -104,11 +104,11 @@ which is supposed to be dynamic and dependent on environment.
};
/** methods that implement the eo1d <em>protocol</em>
@exception out_of_range if _i is larger than EO´s size
@std::exception out_of_range if _i is larger than EO´s size
*/
virtual void insertGene( unsigned _i, T _val ) {
if (_i <= size() ) {
vector<T>::iterator i = begin()+_i;
std::vector<T>::iterator i = begin()+_i;
insert( i, _val );
} else {
throw out_of_range( "out_of_range when inserting a gene");
@ -116,11 +116,11 @@ which is supposed to be dynamic and dependent on environment.
};
/** Eliminates the gene at position _i
@exception out_of_range if _i is larger than EO´s size
@std::exception out_of_range if _i is larger than EO´s size
*/
virtual void deleteGene( unsigned _i ) {
if (_i < this->size() ) {
vector<T>::iterator i = this->begin()+_i;
std::vector<T>::iterator i = this->begin()+_i;
this->erase( i );
} else {
throw out_of_range( "out_of_range when deleting a gene");
@ -137,7 +137,7 @@ which is supposed to be dynamic and dependent on environment.
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoVector";};
std::string className() const {return "eoVector";};
//@}
};
@ -149,7 +149,7 @@ which is supposed to be dynamic and dependent on environment.
//____________________________________________________________________________________
template <class T, class fitnessT>
eoVector<T,fitnessT>::eoVector( unsigned _size, eoRnd<T>& _rnd )
: eo1d<T, fitnessT>(), vector<T>( _size ){
: eo1d<T, fitnessT>(), std::vector<T>( _size ){
for ( iterator i = begin(); i != end(); i ++ ) {
*i = _rnd();
}
@ -157,8 +157,8 @@ eoVector<T,fitnessT>::eoVector( unsigned _size, eoRnd<T>& _rnd )
//____________________________________________________________________________________
template <class T, class fitnessT>
eoVector<T,fitnessT>::eoVector( istream& _is)
: eo1d<T, fitnessT>(), vector<T>( ){
eoVector<T,fitnessT>::eoVector( std::istream& _is)
: eo1d<T, fitnessT>(), std::vector<T>( ){
while (_is ) {
T tmp;
_is >> tmp;

View file

@ -176,7 +176,7 @@ class eoCombinedOp : public eoGeneralOp<EOT>
counter++;
if (counter > 1000)
{
throw logic_error("eoCombinedOp: no termination after 1000 tries, did you forget to insert individuals in your eoGeneralOp?");
throw std::logic_error("eoCombinedOp: no termination after 1000 tries, did you forget to insert individuals in your eoGeneralOp?");
}
}
while (next.size() < intermediate.size());

View file

@ -69,7 +69,7 @@ public:
/** Inherited from eoObject
@see eoObject
*/
string className() const {return "eoXOver2";};
std::string className() const {return "eoXOver2";};
//@}
private:
@ -91,7 +91,7 @@ private:
len= (len1 > len2)?len2:len1;
if ( (_j > len) || (_i> len ) )
throw runtime_error( "xOver2: applying xOver past boundaries");
throw std::runtime_error( "xOver2: applying xOver past boundaries");
for ( unsigned i = _i; i < _j; i++ ) {
Type tmp = _eo.gene( i );