diff --git a/eo/src/utils/eoGnuplot.h b/eo/src/utils/eoGnuplot.h index 24efca0e..f53b6b5b 100644 --- a/eo/src/utils/eoGnuplot.h +++ b/eo/src/utils/eoGnuplot.h @@ -77,6 +77,16 @@ class eoGnuplot } } + /** send a command to gnuplot directly + */ + void gnuplotCommand(char * _command) + { + if( gpCom ) { + PipeComSend( gpCom, _command ); + PipeComSend( gpCom, "\n" ); + } + } + protected: void initGnuPlot(std::string _title, std::string _extra); @@ -129,7 +139,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) * Created......: Mon Mar 13 13:50:11 1995 * Description..: Communication par pipe bidirectionnel avec un autre process * - * Ident........: $Id: eoGnuplot.h,v 1.4 2001-09-08 05:59:17 evomarc Exp $ + * Ident........: $Id: eoGnuplot.h,v 1.5 2002-08-23 15:40:59 evomarc Exp $ * ---------------------------------------------------------------------- */ diff --git a/eo/src/utils/eoGnuplot1DSnapshot.h b/eo/src/utils/eoGnuplot1DSnapshot.h index 919f1b31..ce570734 100644 --- a/eo/src/utils/eoGnuplot1DSnapshot.h +++ b/eo/src/utils/eoGnuplot1DSnapshot.h @@ -28,6 +28,7 @@ #define _eoGnuplot1DSnapshot_H #include +#include #include #include @@ -43,6 +44,7 @@ This class plots through gnuplot the eoStat given as argument //----------------------------------------------------------------------------- #include +#include "eoRealVectorBounds.h" #include @@ -62,6 +64,16 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot pointSize(5) {} + // Ctor + eoGnuplot1DSnapshot(std::string _dirname, eoRealVectorBounds & _bounds, + unsigned _frequency = 1, + std::string _filename = "gen", std::string _delim = " ") : + eoFileSnapshot(_dirname, _frequency, _filename, _delim), + eoGnuplot(_filename,"set data style points"), + pointSize(5) + { + handleBounds(_bounds); + } // Ctor eoGnuplot1DSnapshot(eoFileSnapshot & _fSnapshot) : eoFileSnapshot(_fSnapshot), @@ -69,6 +81,15 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot pointSize(5) {} + // Ctor with range + eoGnuplot1DSnapshot(eoFileSnapshot & _fSnapshot, eoRealVectorBounds & _bounds) : + eoFileSnapshot(_fSnapshot), + eoGnuplot(_fSnapshot.baseFileName(),"set data style points"), + pointSize(5) + { + handleBounds(_bounds); + } + // Dtor virtual ~eoGnuplot1DSnapshot(){} @@ -77,6 +98,19 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot /// Class name. virtual string className() const { return "eoGnuplot1DSnapshot"; } + virtual void handleBounds(eoRealVectorBounds & _bounds) + { + ostringstream os; + os << "set autoscale\nset yrange [" ; + if (_bounds.isMinBounded(0)) + os << _bounds.minimum(0); + os << ":" ; + if (_bounds.isMaxBounded(0)) + os << _bounds.maximum(0); + os << "]\n"; + gnuplotCommand(os.str()); + } + unsigned pointSize; private: diff --git a/eo/src/utils/eoScalarFitnessStat.h b/eo/src/utils/eoScalarFitnessStat.h index acfcae5d..9bf8b017 100644 --- a/eo/src/utils/eoScalarFitnessStat.h +++ b/eo/src/utils/eoScalarFitnessStat.h @@ -27,6 +27,7 @@ #ifndef _eoScalarFitnessStat_h #define _eoScalarFitnessStat_h +#include #include /** @@ -36,15 +37,24 @@ template class eoScalarFitnessStat : public eoSortedStat > { public : - eoScalarFitnessStat(std::string _description = "FitnessES") : - eoSortedStat >(vector(0), _description) {} - - virtual void operator()(const vector& _popPters) + eoScalarFitnessStat(std::string _description = "FitnessES", + eoRealVectorBounds & _bounds = eoDummyVectorNoBounds) : + eoSortedStat >(vector(0), _description) , + range(*_bounds[0]) + {} + + virtual void operator()(const vector& _popPters) { value().resize(_popPters.size()); for (unsigned i=0; i<_popPters.size(); i++) - value()[i] = _popPters[i]->fitness(); + { + value()[i] = _popPters[i]->fitness(); + range.truncate(value()[i]); + } } + +private : + eoRealBounds & range; }; #endif