From 18f6c3151390a7a2589e56a2d279799664113ee6 Mon Sep 17 00:00:00 2001 From: jmerelo Date: Tue, 19 Oct 1999 11:47:15 +0000 Subject: [PATCH] Small modifications --- eo/src/EO.h | 88 +++++++++++++++++++++--------------------- eo/test/t-eoEasyEA.cpp | 1 + 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index 233746bc..bc573200 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -1,5 +1,5 @@ -// -*- 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; -*- + //----------------------------------------------------------------------------- // EO.h // (c) GeNeura Team 1998 @@ -32,13 +32,13 @@ #include //----------------------------------------------------------------------------- -/** EO is a base class for evolvable objects, that is, the subjects of evolution. - EOs have only got a fitness, which at the same time needs to be only an object with the - operation less than (<) defined. Fitness says how good is the object; evolution or change - of these objects is left to the genetic operators. A fitness less than another means a - worse fitness, in whatever the context; thus, fitness is always maximized; although - it can be minimized with a proper definition of the < operator.\\ - The fitness object must have, besides an void ctor, a copy ctor. +/** EO is a base class for evolvable objects, that is, the subjects of evolution. + EOs have only got a fitness, which at the same time needs to be only an object with the + operation less than (<) defined. Fitness says how good is the object; evolution or change + of these objects is left to the genetic operators. A fitness less than another means a + worse fitness, in whatever the context; thus, fitness is always maximized; although + it can be minimized with a proper definition of the < operator.\\ + The fitness object must have, besides an void ctor, a copy ctor. */ template class EO: public eoObject, public eoPersistent { @@ -59,11 +59,11 @@ public: invalidFitness = false; }; - /// Copy ctor - EO( const EO& _eo ): repFitness( _eo.repFitness ), invalidFitness( _eo.invalidFitness ) {}; - - /// Virtual dtor - virtual ~EO() {}; + /// Copy ctor + EO( const EO& _eo ): repFitness( _eo.repFitness ), invalidFitness( _eo.invalidFitness ) {}; + + /// Virtual dtor + virtual ~EO() {}; /// Return fitness value. Fitness fitness() const @@ -89,43 +89,43 @@ public: /** Return true If fitness value is invalid, false otherwise. * @return true If fitness is invalid. */ - bool invalid() const { return invalidFitness; } + bool invalid() const { return invalidFitness; } /** Returns true if @return true if the fitness is higher */ bool operator<(const EO& _eo2) const { return fitness() < _eo2.fitness();} - /// Methods inherited from eoObject - //@{ - - /** Return the class id. - * @return the class name as a string - */ - virtual string className() const { return "EO"; }; - - /** - * Read object.\\ - * Calls base class, just in case that one had something to do. The read and print - * methods should be compatible and have the same format. In principle, format is - * "plain": they just print a number - * @param _is a istream. - * @throw runtime_exception If a valid object can't be read. - */ - virtual void readFrom(istream& _is) { - _is >> repFitness; - invalidFitness = false; - } - - /** - * Write object. It's called printOn since it prints the object _on_ a stream. - * @param _os A ostream. - */ - virtual void printOn(ostream& _os) const { - _os << repFitness << endl; - } + /// Methods inherited from eoObject + //@{ - //@} + /** Return the class id. + * @return the class name as a string + */ + virtual string className() const { return "EO"; }; + + /** + * Read object.\\ + * Calls base class, just in case that one had something to do. The read and print + * methods should be compatible and have the same format. In principle, format is + * "plain": they just print a number + * @param _is a istream. + * @throw runtime_exception If a valid object can't be read. + */ + virtual void readFrom(istream& _is) { + _is >> repFitness; + invalidFitness = false; + } + + /** + * Write object. It's called printOn since it prints the object _on_ a stream. + * @param _os A ostream. + */ + virtual void printOn(ostream& _os) const { + _os << repFitness << endl; + } + + //@} private: Fitness repFitness; // value of fitness for this chromosome diff --git a/eo/test/t-eoEasyEA.cpp b/eo/test/t-eoEasyEA.cpp index 59a1d33d..bf81e63d 100644 --- a/eo/test/t-eoEasyEA.cpp +++ b/eo/test/t-eoEasyEA.cpp @@ -5,6 +5,7 @@ // to avoid long name warnings #pragma warning(disable:4786) + #include #include "binary_value.h"