Added new files to the brew, mainly distance and new-op-interface related

This commit is contained in:
jmerelo 2000-02-07 17:16:16 +00:00
commit 7db1492943
40 changed files with 2490 additions and 992 deletions

View file

@ -1,9 +1,11 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
/* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eo1d.h
// (c) GeNeura Team, 1998
/*
-----------------------------------------------------------------------------
eo1d.h
Serial EO.
(c) GeNeura Team, 1998
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@ -43,7 +45,6 @@ using namespace std;
*/
//@{
/** eo1d: Base class for "chromosomes" with a single dimension
#T# is the type it will be instantiated with; this type must have, at
least, a copy ctor, assignment operators,
@ -91,7 +92,7 @@ public:
This implies that T must have a copy ctor .
@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
@return what's inside the gene, with the correct type
@exception out_of_range if _i > size()
*/
virtual T getGene( unsigned _i ) const = 0;
@ -99,8 +100,8 @@ public:
/** Overwrites the gene placed in position _i with a
* new value. This means that the assignment operator
* for T must be defined .
@param _i index
@return what's inside the gene, with the correct type
@param _i index
@return what's inside the gene, with the correct type
@exception out_of_range if _i > size()
*/
virtual void setGene( unsigned _i, const T& _value ) = 0;
@ -121,16 +122,16 @@ public:
/// Returns the number of genes in the eo1d
virtual unsigned length() const = 0;
/// @name Methods from eoObject
/// @name Methods from eoObject
//@{
/**
* Read object. Theoretically, the length is known in advance. All objects
* 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.
*/
virtual void readFrom(istream& _s) {
virtual void readFrom(istream& _s) {
for ( unsigned i = 0; i < length(); i ++ ) {
T tmp;
@ -142,7 +143,7 @@ public:
}
/** Print itself: inherited from eoObject implementation.
Instance from base classes are processed in
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{
@ -155,8 +156,8 @@ public:
@see eoObject
*/
string className() const {return "eo1d";};
//@}
//@}
};
@ -171,7 +172,7 @@ public:
@param _ID An ID string, preferably unique
*/
template< class T, class fitnessT>
eo1d<T,fitnessT>::eo1d<T,fitnessT>( unsigned _size, eoRnd<T>& _rndGen,
eo1d<T,fitnessT>::eo1d<T,fitnessT>( unsigned _size, eoRnd<T>& _rndGen,
const string& _ID )
:EO<fitnessT> ( _ID ) {
for ( unsigned i = 0; i < _size; i ++ ) {