Removed "using namespace std" statements from header files in EO -- "std::" identifier were added where necessary.
This commit is contained in:
parent
6441ea1ec3
commit
86fa476c67
55 changed files with 2009 additions and 1976 deletions
|
|
@ -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() );
|
||||
|
|
|
|||
|
|
@ -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";};
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
string className() const {return "eoAtomBitFlip";};
|
||||
std::string className() const {return "eoAtomBitFlip";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
virtual string className() const {return "eoAtomCreep";};
|
||||
virtual std::string className() const {return "eoAtomCreep";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
string className() const {return "eoAtomRandom";};
|
||||
std::string className() const {return "eoAtomRandom";};
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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"; }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public :
|
|||
return *this;
|
||||
}
|
||||
|
||||
string className(void) const { return "eoDetTournamentInserter"; }
|
||||
std::string className(void) const { return "eoDetTournamentInserter"; }
|
||||
|
||||
private :
|
||||
unsigned t_size;
|
||||
|
|
|
|||
|
|
@ -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"; }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public:
|
|||
/** Inherited from eoObject
|
||||
@see eoObject
|
||||
*/
|
||||
virtual string className() const {return "eoDup";};
|
||||
virtual std::string className() const {return "eoDup";};
|
||||
//@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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";};
|
||||
//@}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue