Migration from SVN

This commit is contained in:
quemy 2012-08-30 11:30:11 +02:00
commit 8cd56f37db
62 changed files with 0 additions and 4096888 deletions

View file

@ -0,0 +1,46 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
### 2) Define the ga target
######################################################################################
SET(EOUTILS_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${EOUTILS_LIB_OUTPUT_PATH})
SET(EOUTILS_SOURCES
eoData.cpp
eoFileMonitor.cpp
eoGnuplot.cpp
eoGnuplot1DMonitor.cpp
eoGnuplot1DSnapshot.cpp
eoIntBounds.cpp
eoParser.cpp
eoRealBounds.cpp
eoRNG.cpp
eoState.cpp
eoOStreamMonitor.cpp
eoUpdater.cpp
make_help.cpp
pipecom.cpp
eoLogger.cpp
eoParallel.cpp
eoSignal.cpp
)
ADD_LIBRARY(eoutils STATIC ${EOUTILS_SOURCES})
INSTALL(TARGETS eoutils ARCHIVE DESTINATION local/${LIB} COMPONENT libraries)
######################################################################################
### 3) Optionnal
######################################################################################
SET(EOUTILS_VERSION ${GLOBAL_VERSION})
SET_TARGET_PROPERTIES(eoutils PROPERTIES VERSION "${EOUTILS_VERSION}")
######################################################################################

42
eo/src/utils/ChangeLog Normal file
View file

@ -0,0 +1,42 @@
2007-08-22 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoRNG.h (eoRng::random): Add comment on truncation as standard way of
floating point to integer conversion.
2006-12-04 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoRNG.h (eoRng::normal(stdev)): Revert erroneous change.
2006-12-02 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoTimedMonitor.h (eoTimedMonitor::seconds): Make unsigned.
* eoRNG.h: Cleanup docs and document /all/ members.
* eoRNG.cpp, eoRNG.h (K, M, N): Declare static and initialize in cpp.
2006-12-01 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoRNG.cpp: Use C++ style cast.
* Makefile.am: Add missing header for distribution.
2006-11-30 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoRNG.h: Generally include <cmath>
2006-11-16 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoParser.h (eoParser::getORcreateParam): Make this a real if-then-else
clause around ptParam (found or not).
* eoParam.h (eoValueParam::setValue): Document.
(eoValueParam<std::vector<double> >::setValue): Allow delimiters ',' and
';'. A plain ' ' does not work, as it is not correctly read by
eoParser::readFrom.
* Local Variables:
* coding: iso-8859-1
* mode: flyspell
* fill-column: 80
* End:

View file

@ -0,0 +1,56 @@
/*
-----------------------------------------------------------------------------
checkpointing
(c) Maarten Keijzer (mak@dhi.dk) and GeNeura Team, 1999, 2000
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
#ifndef _CHECKPOINTING_
#define _CHECKPOINTING_
#include <utils/eoParser.h>
#include <utils/eoState.h>
#include <utils/eoUpdater.h>
#include <utils/eoMonitor.h>
#include <utils/eoFileMonitor.h>
#include <utils/eoStdoutMonitor.h>
#include <utils/eoOStreamMonitor.h>
#ifndef _MSC_VER
#include <utils/eoGnuplot1DMonitor.h>
#include <utils/eoGnuplot1DSnapshot.h>
#endif
#include <utils/eoCheckPoint.h>
#include <utils/eoSignal.h>
#include <utils/eoStat.h>
#include <utils/eoScalarFitnessStat.h>
#include <utils/eoAssembledFitnessStat.h>
#include <utils/eoFDCStat.h>
#include <utils/eoMOFitnessStat.h>
#include <utils/eoPopStat.h>
#include <utils/eoTimeCounter.h>
#include <utils/eoGenCounter.h>
// and make_help - any better suggestion to include it?
void make_help(eoParser & _parser);
#endif // !_CHECKPOINTING_
// Local Variables:
// mode: C++
// End:

View file

@ -0,0 +1,82 @@
/* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
-----------------------------------------------------------------------------
compatibility.h
File to store some compiler specific stuff in. Currently handles, or
least tries to handle the min() max() problems when using MSVC
(c) Maarten Keijzer (mak@dhi.dk) and GeNeura Team, 1999, 2000
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
#ifndef COMPAT_H
#define COMPAT_H
#include <string>
#include <iostream>
#ifdef __GNUC__
#if __GNUC__ < 3
// check for stdlibc++v3 which does have ios_base
#ifndef _CPP_BITS_IOSBASE_H
typedef ios ios_base; // not currently defined in GCC
#endif
#endif
#endif
#if defined(_MSC_VER) && (_MSC_VER < 1300)
/*
Maarten: added this code here because Mirkosoft has the
nasty habit of #define min and max in stdlib.h (and windows.h)
I'm trying to undo this horrible macro magic (microsoft yet macrohard)
here. Sure hope it works
Olivier: this has been removed in .NET :) One step more standard...
*/
#pragma warning(disable:4786)
#include <stdlib.h>
#ifdef min
#undef min
#undef max // as they come in std::pairs
#endif
// add min and max to std...
namespace std
{
template <class T> const T& min(const T& a, const T& b)
{
if(a < b)
return a;
// else
return b;
}
template <class T> const T& max(const T& a, const T& b)
{
if(a > b)
return a;
// else
return b;
}
}
#endif
// _MSC_VER
#endif

View file

@ -0,0 +1,117 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoAssembledFitnessStat.h
// Marc Wintermantel & Oliver Koenig
// IMES-ST@ETHZ.CH
// April 2003
//-----------------------------------------------------------------------------
// eoStat.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoAssembledFitnessStat_h
#define _eoAssembledFitnessStat_h
#include <utils/eoStat.h>
#include <eoScalarFitnessAssembled.h>
/** @addtogroup Stats
* @{
*/
/**
Average fitness values of a population, where the fitness is
of type eoScalarAssembledFitness. Specify in the constructor,
for which fitness term (index) the average should be evaluated.
Only values of object where the failed boolean = false is set are counted.
*/
template <class EOT>
class eoAssembledFitnessAverageStat : public eoStat<EOT, double>
{
public :
using eoStat<EOT, double>::value;
typedef typename EOT::Fitness Fitness;
eoAssembledFitnessAverageStat(unsigned _whichTerm=0, std::string _description = "Average Fitness")
: eoStat<EOT, double>(Fitness(), _description), whichFitnessTerm(_whichTerm)
{}
virtual void operator()(const eoPop<EOT>& _pop) {
if( whichFitnessTerm >= _pop[0].fitness().size() )
throw std::logic_error("Fitness term requested out of range");
double result =0.0;
unsigned count = 0;
for (typename eoPop<EOT>::const_iterator it = _pop.begin(); it != _pop.end(); ++it){
if ( it->fitness().failed == false ){
result+= it->fitness()[whichFitnessTerm];
++count;
}
}
value() = result / (double) count;
}
private:
// Store an index of the fitness term to be evaluated in eoScalarFitnessAssembled
unsigned whichFitnessTerm;
};
/**
Fitness values of best individuum in a population, where the fitness is
of type eoScalarAssembledFitness. Specify in the constructor,
for which fitness term (index) the value should be evaluated.
*/
template <class EOT>
class eoAssembledFitnessBestStat : public eoStat<EOT, double>
{
public:
using eoStat<EOT, double>::value;
typedef typename EOT::Fitness Fitness;
eoAssembledFitnessBestStat(unsigned _whichTerm=0, std::string _description = "Best Fitness")
: eoStat<EOT, double>(Fitness(), _description), whichFitnessTerm(_whichTerm)
{}
virtual void operator()(const eoPop<EOT>& _pop) {
if( whichFitnessTerm >= _pop[0].fitness().size() )
throw std::logic_error("Fitness term requested out of range");
value() = _pop.best_element().fitness()[whichFitnessTerm];
}
private:
// Store an index of the fitness term to be evaluated in eoScalarFitnessAssembled
unsigned whichFitnessTerm;
};
/** @} */
#endif

183
eo/src/utils/eoCheckPoint.h Normal file
View file

@ -0,0 +1,183 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoCheckPoint.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2000
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoCheckPoint_h
#define _eoCheckPoint_h
#include <eoContinue.h>
#include <utils/eoUpdater.h>
#include <utils/eoMonitor.h>
#include <utils/eoStat.h>
/** @defgroup Checkpoints Checkpointing
*
* Checkpoints are supposed to be called perodically (for instance at each generation) and
* will call every functors you put in them.
*
* Use them with eoStats, eoUpdater and eoMonitor to get statistics at each generation.
*
* @see eoStat
* @see eoMonitor
* @see eoUpdater
*
* Example of a test program using checkpointing:
* @include t-eoCheckpointing.cpp
*
* @ingroup Utilities
*
* @{
*/
/** eoCheckPoint is a container class.
It contains std::vectors of (pointers to)
eoContinue (modif. MS July 16. 2002)
eoStats, eoUpdater and eoMonitor
it is an eoContinue, so its operator() will be called every generation -
and will return the contained-combined-eoContinue result
but before that it will call in turn every single
{statistics, updaters, monitors} that it has been given,
and after that, if stopping, all lastCall methods of the above.
*/
template <class EOT>
class eoCheckPoint : public eoContinue<EOT>
{
public :
eoCheckPoint(eoContinue<EOT>& _cont)
{
continuators.push_back(&_cont);
}
bool operator()(const eoPop<EOT>& _pop);
void add(eoContinue<EOT>& _cont) { continuators.push_back(&_cont); }
void add(eoSortedStatBase<EOT>& _stat) { sorted.push_back(&_stat); }
void add(eoStatBase<EOT>& _stat) { stats.push_back(&_stat); }
void add(eoMonitor& _mon) { monitors.push_back(&_mon); }
void add(eoUpdater& _upd) { updaters.push_back(&_upd); }
virtual std::string className(void) const { return "eoCheckPoint"; }
std::string allClassNames() const ;
private :
std::vector<eoContinue<EOT>*> continuators;
std::vector<eoSortedStatBase<EOT>*> sorted;
std::vector<eoStatBase<EOT>*> stats;
std::vector<eoMonitor*> monitors;
std::vector<eoUpdater*> updaters;
};
template <class EOT>
bool eoCheckPoint<EOT>::operator()(const eoPop<EOT>& _pop)
{
unsigned i;
std::vector<const EOT*> sorted_pop;
if (!sorted.empty())
{
_pop.sort(sorted_pop);
for (i = 0; i < sorted.size(); ++i)
{
(*sorted[i])(sorted_pop);
}
}
for (i = 0; i < stats.size(); ++i)
(*stats[i])(_pop);
for (i = 0; i < updaters.size(); ++i)
(*updaters[i])();
for (i = 0; i < monitors.size(); ++i)
(*monitors[i])();
bool bContinue = true;
for (i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_pop) )
bContinue = false;
if (! bContinue) // we're going to stop: lastCall, gentlemen
{
if (!sorted.empty())
{
for (i = 0; i < sorted.size(); ++i)
{
sorted[i]->lastCall(sorted_pop);
}
}
for (i = 0; i < stats.size(); ++i)
stats[i]->lastCall(_pop);
for (i = 0; i < updaters.size(); ++i)
updaters[i]->lastCall();
for (i = 0; i < monitors.size(); ++i)
monitors[i]->lastCall();
}
return bContinue;
}
/** returns a string with all className()
* of data separated with "\n" (for debugging)
*/
template <class EOT>
std::string eoCheckPoint<EOT>::allClassNames() const
{
unsigned i;
std::string s = "\n" + className() + "\n";
s += "Sorted Stats\n";
for (i = 0; i < sorted.size(); ++i)
s += sorted[i]->className() + "\n";
s += "\n";
s += "Stats\n";
for (i = 0; i < stats.size(); ++i)
s += stats[i]->className() + "\n";
s += "\n";
s += "Updaters\n";
for (i = 0; i < updaters.size(); ++i)
s += updaters[i]->className() + "\n";
s += "\n";
s += "Monitors\n";
for (i = 0; i < monitors.size(); ++i)
s += monitors[i]->className() + "\n";
s += "\n";
s += "Continuators\n";
for (i = 0; i < continuators.size(); ++i)
s += continuators[i]->className() + "\n";
s += "\n";
return s;
}
/** @} */
#endif

11
eo/src/utils/eoData.cpp Normal file
View file

@ -0,0 +1,11 @@
// Copyright (C) 2005 Jochen Küpper <jochen@fhi-berlin.mpg.de>
#include "eoData.h"
// Local Variables:
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

47
eo/src/utils/eoData.h Normal file
View file

@ -0,0 +1,47 @@
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
-----------------------------------------------------------------------------
eoData.h
(c) GeNeura Team & Maarten Keijzer, 1998, 1999, 2000
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
#ifndef EODATA_H
#define EODATA_H
#ifndef _MSC_VER
#include <math.h>
#define _isnan isnan
#endif
//-----------------------------------------------------------------------------
// some defines to make things easier to get at first sight
// to be used in selection / replacement procedures to indicate whether
// the argument (rate, a double) shoudl be treated as a rate (number=rate*popSize)
// or as an absolute integer (number=rate regardless of popsize).
// the default value shoudl ALWAYS be true (eo_as_a_rate).
//
// this construct is mandatory because in some cases you might not know the
// population size that will enter the replacement for instance - so you
// cannot simply have a pre-computed (double) rate of 1/popSize
#define eo_is_a_rate true
#define eo_is_an_integer false
#endif

104
eo/src/utils/eoDistance.h Normal file
View file

@ -0,0 +1,104 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoDistance.h
// (c) GeNeura Team, 1998, Marc Schoenauer 2001
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
*/
//-----------------------------------------------------------------------------
#ifndef _eoDistance_H
#define _eoDistance_H
#include <eoFunctor.h>
/** @addtogroup Stats
* @{
* */
/**
This is a generic class for distance functors:
takes 2 things and returns a double
*/
template< class EOT >
class eoDistance : public eoBF<const EOT &, const EOT &, double>
{};
/**
This is a generic class for Euclidain distance (L2 norm) computation:
assumes the 2 things are std::vectors of something that is double-castable
*/
template< class EOT >
class eoQuadDistance : public eoDistance<EOT>
{
public:
double operator()(const EOT & _v1, const EOT & _v2)
{
double sum=0.0;
for (unsigned i=0; i<_v1.size(); i++)
{
double r = static_cast<double> (_v1[i]) - static_cast<double> (_v2[i]);
sum += r*r;
}
return sqrt(sum);
}
};
/**
This is a generic class for L1 distance computation:
assumes the 2 things are std::vectors of something
that is double-castable
For bitstrings, this is the Hamming distance
*/
template< class EOT >
class eoHammingDistance : public eoDistance<EOT>
{
public:
double operator()(const EOT & _v1, const EOT & _v2)
{
double sum=0.0;
for (unsigned i=0; i<_v1.size(); i++)
{
double r = static_cast<double> (_v1[i]) - static_cast<double> (_v2[i]);
sum += fabs(r);
}
return sum;
}
};
/* this distance measures the difference in fitness
* I am not sure it can be of any use, though ...
* except for some testing
*/
template< class EOT >
class eoFitnessDistance : public eoDistance<EOT>
{
public:
double operator()(const EOT & _v1, const EOT & _v2)
{
double d = _v1.fitness() - _v2.fitness();
return sqrt(d*d);
}
};
/** @} */
#endif

144
eo/src/utils/eoFDCStat.h Normal file
View file

@ -0,0 +1,144 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoFDCStat.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000, 2001
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoFDCStat_h
#define _eoFDCStat_h
#include <utils/eoStat.h>
#include <utils/eoDistance.h>
#include <utils/eoFileSnapshot.h>
/**
The Fitness Distance Correlation computation.
Stores the values into eoValueParam<EOT,double>
so they can be snapshot by some eoGnuplotSnapshot ...
@ingroup Stats
*/
template <class EOT>
class eoFDCStat : public eoStat<EOT, double>
{
public:
using eoStat<EOT, double>::value;
/** Ctor without the optimum */
eoFDCStat(eoDistance<EOT> & _dist, std::string _description = "FDC") :
eoStat<EOT,double>(0, _description), dist(_dist), boolOpt(false) {}
/** Ctor with the optimum
*/
eoFDCStat(eoDistance<EOT> & _dist, EOT & _theBest,
std::string _description = "FDC") :
eoStat<EOT,double>(0, _description), dist(_dist),
theBest(_theBest), boolOpt(true) {}
/** Compute the FDC - either from best in pop, or from absolute best
* if it was passed in the constructor
*/
virtual void operator()(const eoPop<EOT>& _pop)
{
unsigned i;
if (!boolOpt) // take the local best
theBest = _pop.best_element();
unsigned int pSize = _pop.size();
distToBest.value().resize(pSize);
fitnesses.value().resize(pSize);
double sumFit = 0.0, sumDist = 0.0;
for (i=0; i<pSize; i++)
{
sumDist += (distToBest.value()[i] = dist(_pop[i], theBest));
sumFit += (fitnesses.value()[i] = _pop[i].fitness());
}
// now the FDC coefficient
double avgDist = sumDist/pSize;
double avgFit = sumFit/pSize;
sumDist = sumFit = 0.0;
double num = 0.0;
for (i=0; i<pSize; i++)
{
double devDist = distToBest.value()[i] - avgDist ;
double devFit = fitnesses.value()[i] - avgFit ;
sumDist += devDist*devDist;
sumFit += devFit * devFit;
num += devDist * devFit ;
}
value() = num/(sqrt(sumDist)*sqrt(sumFit));
}
/** accessors to the private eoValueParam<std::vector<double> >
*/
const eoValueParam<std::vector<double> > & theDist()
{ return distToBest; }
const eoValueParam<std::vector<double> > & theFit()
{ return fitnesses; }
private:
eoDistance<EOT> & dist;
EOT theBest;
bool boolOpt; // whether the best is known or not
eoValueParam<std::vector<double> > distToBest;
eoValueParam<std::vector<double> > fitnesses;
};
/** Specific class for FDCStat monitoring:
* As I failed to have FDC stat as an eoStat, this is the trick
* to put the 2 eoParam<std::vector<double> > into a monitor
* This class does nothing else.
@ingroup Stats
*/
template <class EOT>
class eoFDCFileSnapshot : public eoFileSnapshot // is an eoMonitor
{
public:
/** Ctor: in addition to the parameters of the ctor of an eoFileSnapshot
we need here an eoFDCStat. The 2 std::vectors (distances to optimum
and fitnesses) are added to the monitor so they can be processed
later to a file - and eventually by gnuplot
*/
eoFDCFileSnapshot(eoFDCStat<EOT> & _FDCstat,
std::string _dirname = "tmpFDC", unsigned _frequency = 1,
std::string _filename = "FDC", std::string _delim = " "):
eoFileSnapshot(_dirname, _frequency, _filename, _delim),
FDCstat(_FDCstat)
{
eoFileSnapshot::add(FDCstat.theDist());
eoFileSnapshot::add(FDCstat.theFit());
}
/** just to be sure the add method is not called further
*/
virtual void add(const eoParam& _param)
{ throw std::runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); }
private:
eoFDCStat<EOT> & FDCstat;
};
#endif

View file

@ -0,0 +1,66 @@
/*
(c) 2010 Thales group
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; version 2
of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: http://eodev.sourceforge.net
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
*/
#ifndef _eoFeasibleRatioStat_h_
#define _eoFeasibleRatioStat_h_
#include <algorithm>
#include <eoDualFitness.h>
#include <utils/eoLogger.h>
#include "eoStat.h"
/** Ratio of the number of individuals with a feasible dual fitness in the population (@see eoDualFitness)
*
* @ingroup Stats
*/
template<class EOT>
class eoFeasibleRatioStat : public eoStat< EOT, double >
{
public:
using eoStat<EOT, double>::value;
eoFeasibleRatioStat( std::string description = "FeasibleRatio" ) : eoStat<EOT,double>( 0.0, description ) {}
virtual void operator()( const eoPop<EOT> & pop )
{
#ifndef NDEBUG
assert( pop.size() > 0 );
double count = static_cast<double>( std::count_if( pop.begin(), pop.end(), eoIsFeasible<EOT> ) );
double size = static_cast<double>( pop.size() );
double ratio = count/size;
eo::log << eo::xdebug << "eoFeasibleRatioStat: " << count << " / " << size << " = " << ratio << std::endl;
value() = ratio;
#else
value() = static_cast<double>( std::count_if( pop.begin(), pop.end(), eoIsFeasible<EOT> ) ) / static_cast<double>( pop.size() );
#endif
}
virtual std::string className(void) const { return "eoFeasibleRatioStat"; }
};
#endif // _eoFeasibleRatioStat_h_

View file

@ -0,0 +1,89 @@
#ifdef _MSC_VER
// to avoid long name warnings
#pragma warning(disable:4786)
#endif
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <utils/eoFileMonitor.h>
#include <utils/compatibility.h>
#include <utils/eoParam.h>
using namespace std;
void eoFileMonitor::printHeader(std::ostream& os)
{
iterator it = vec.begin();
os << (*it)->longName();
++it;
for (; it != vec.end(); ++it)
{
// use the longName of the eoParam for the header
os << delim.c_str() << (*it)->longName();
}
os << std::endl;
}
void eoFileMonitor::printHeader()
{
// create file
ofstream os(filename.c_str());
if (!os)
{
string str = "eoFileMonitor could not open: " + filename;
throw runtime_error(str);
}
printHeader(os);
}
eoMonitor& eoFileMonitor::operator()(void)
{
ofstream os(filename.c_str(),
overwrite ?
ios_base::out|ios_base::trunc // truncate
:
ios_base::out|ios_base::app // append
);
if (!os)
{
string str = "eoFileMonitor could not write to: " + filename;
throw runtime_error(str);
}
if (
header // we want to write headers
&& firstcall // we do not want to write headers twice
&& !keep // if we append to an existing file, headers are useless
&& !overwrite // we do not want to write headers if the file is to be overwriten
) {
printHeader();
firstcall = false;
}
return operator()(os);
}
eoMonitor& eoFileMonitor::operator()(std::ostream& os)
{
iterator it = vec.begin();
os << (*it)->getValue();
for(++it; it != vec.end(); ++it)
{
os << delim.c_str() << (*it)->getValue();
}
os << std::endl;
return *this;
}

View file

@ -0,0 +1,121 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoFileMonitor.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef EO_eoFileMonitor_h
#define EO_eoFileMonitor_h
#include <string>
#include <fstream>
#include <stdexcept>
#include "utils/eoMonitor.h"
#include "eoObject.h"
/** Prints statistics to file
Modified the default behavior, so that it erases existing files. Can
be modified in the ctor.
@version MS 25/11/00
@ingroup Monitors
*/
class eoFileMonitor : public eoMonitor
{
public :
/*! Constructor
*
* Try to create the file in writing mode, erasing it if asked.
*
* @param _filename complete filename to write to
* @param _delim delimiter string to use between each item of the registered vector (e.g. of eoStats)
* @param _keep_existing if true, overwrite any existing file with the same name prior to any output
* @param _header print the header (with the descriptions of registered eoStats) at the beginning of the file (WARNING: true will discards header printing)
* @param _overwrite if true, overwrite the existing file
*/
eoFileMonitor(
std::string _filename,
std::string _delim = " ",
bool _keep_existing = false,
bool _header = false,
bool _overwrite = false
)
: filename(_filename),
delim(_delim),
keep(_keep_existing),
header(_header),
firstcall(true),
overwrite(_overwrite)
{
if (!_keep_existing) {
std::ofstream os (filename.c_str ());
if (!os) {
std::string str = "Error, eoFileMonitor could not open: " + filename;
throw std::runtime_error (str);
}
} // if ! keep
}
//! Called first, try to open the file in append mode and write the header if asked
virtual eoMonitor& operator()(void);
/*! Main call, normally called at each generation.
Write the content of the registered vector into the file, each item being separated by delim
*/
virtual eoMonitor& operator()(std::ostream& os);
//! Try to open the file, and then call printHeader(file)
void printHeader(void);
//! Print long names of the registered items, separated by delim.
virtual void printHeader(std::ostream& os);
virtual std::string getFileName() { return filename;}
private :
//! complete filename to write to
std::string filename;
//! delimiter to use between each write
std::string delim;
//! should we append or create a new file
bool keep;
//! printing header at begin of file?
bool header;
//! flag to avoid calling twice operator()(void)
bool firstcall;
//! erase the entire file prior to writing in it (mode eos_base::
bool overwrite;
};
#endif

View file

@ -0,0 +1,200 @@
//-----------------------------------------------------------------------------
// eoFileSnapshot.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoFileSnapshot_h
#define _eoFileSnapshot_h
#include <cstdlib>
#include <fstream>
#include <string>
#include <utils/eoParam.h>
#include <utils/eoMonitor.h>
#include <eoObject.h>
/**
Prints snapshots of fitnesses to a (new) file every N generations
Assumes that the parameters that are passed to the monitor
(method add in eoMonitor.h) are eoValueParam<std::vector<double> > of same size.
A dir is created and one file per snapshot is created there -
so you can later generate a movie!
@todo The counter is handled internally, but this should be changed
so that you can pass e.g. an evalcounter (minor)
I failed to templatize everything so that it can handle eoParam<std::vector<T> >
for any type T, simply calling their getValue method ...
@ingroup Monitors
*/
class eoFileSnapshot : public eoMonitor
{
public :
typedef std::vector<double> vDouble;
typedef eoValueParam<std::vector<double> > vDoubleParam;
eoFileSnapshot(std::string _dirname, unsigned _frequency = 1, std::string _filename = "gen",
std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true):
dirname(_dirname), frequency(_frequency),
filename(_filename), delim(_delim), counter(_counter), boolChanged(true)
{
std::string s = "test -d " + dirname;
int res = system(s.c_str());
// test for (unlikely) errors
if ( (res==-1) || (res==127) )
throw std::runtime_error("Problem executing test of dir in eoFileSnapshot");
// now make sure there is a dir without any genXXX file in it
if (res) // no dir present
{
s = std::string("mkdir ")+dirname;
}
else if (!res && _rmFiles)
{
s = std::string("/bin/rm ")+dirname+ "/" + filename + "*";
}
else
s = " ";
res=system(s.c_str());
// all done
}
/** accessor: has something changed (for gnuplot subclass)
*/
virtual bool hasChanged() {return boolChanged;}
/** accessor to the counter: needed by the gnuplot subclass
*/
unsigned getCounter() {return counter;}
/** accessor to the current filename: needed by the gnuplot subclass
*/
std::string getFileName() {return currentFileName;}
/** sets the current filename depending on the counter
*/
void setCurrentFileName()
{
std::ostringstream oscount;
oscount << counter;
currentFileName = dirname + "/" + filename + oscount.str();
}
/** The operator(void): opens the std::ostream and calls the write method
*/
eoMonitor& operator()(void)
{
if (counter % frequency)
{
boolChanged = false; // subclass with gnuplot will do nothing
counter++;
return (*this);
}
counter++;
boolChanged = true;
setCurrentFileName();
std::ofstream os(currentFileName.c_str());
if (!os)
{
std::string str = "eoFileSnapshot: Could not open " + currentFileName;
throw std::runtime_error(str);
}
return operator()(os);
}
/** The operator(): write on an std::ostream
*/
eoMonitor& operator()(std::ostream& _os)
{
const eoValueParam<std::vector<double> > * ptParam =
static_cast<const eoValueParam<std::vector<double> >* >(vec[0]);
const std::vector<double> v = ptParam->value();
if (vec.size() == 1) // only one std::vector: -> add number in front
{
for (unsigned k=0; k<v.size(); k++)
_os << k << " " << v[k] << "\n" ;
}
else // need to get all other std::vectors
{
std::vector<std::vector<double> > vv(vec.size());
vv[0]=v;
for (unsigned i=1; i<vec.size(); i++)
{
ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
vv[i] = ptParam->value();
if (vv[i].size() != v.size())
throw std::runtime_error("Dimension error in eoSnapshotMonitor");
}
for (unsigned k=0; k<v.size(); k++)
{
for (unsigned i=0; i<vec.size(); i++)
_os << vv[i][k] << " " ;
_os << "\n";
}
}
return *this;
}
virtual const std::string getDirName() // for eoGnuPlot
{ return dirname;}
virtual const std::string baseFileName() // the title for eoGnuPlot
{ return filename;}
/// add checks whether it is a std::vector of doubles
void add(const eoParam& _param)
{
if (!dynamic_cast<const eoValueParam<std::vector<double> >*>(&_param))
{
throw std::logic_error(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName());
}
eoMonitor::add(_param);
}
private :
std::string dirname;
unsigned frequency;
std::string filename;
std::string delim;
unsigned int counter;
std::string currentFileName;
bool boolChanged;
};
#endif
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -0,0 +1,80 @@
#ifndef eoFuncPtrStat_h
#define eoFuncPtrStat_h
#include <eoFunctorStore.h>
#include <utils/eoStat.h>
/** Wrapper to turn any stand-alone function and into an eoStat.
*
* The function should take an eoPop as argument.
*
* @ingroup Stats
*/
template <class EOT, class T>
class eoFuncPtrStat : public eoStat<EOT, T>
{
public :
typedef T (*func_t)(const eoPop<EOT>&);
eoFuncPtrStat(func_t f, std::string _description = "func_ptr")
: eoStat<EOT, T>(T(), _description), func(f)
{}
using eoStat<EOT, T>::value;
void operator()(const eoPop<EOT>& pop) {
value() = func(pop);
}
private:
func_t func;
};
/**
* @ingroup Stats
*/
template <class EOT, class T>
eoFuncPtrStat<EOT, T>& makeFuncPtrStat( T (*func)(const eoPop<EOT>&), eoFunctorStore& store, std::string description = "func") {
return store.storeFunctor(
new eoFuncPtrStat<EOT, T>( func, description)
);
}
/** Wrapper to turn any stand-alone function and into an eoStat.
*
* The function should take an eoPop as argument.
*
* @ingroup Stats
*/
template <class EOT, class T>
class eoFunctorStat : public eoStat<EOT, T>
{
public :
eoFunctorStat(eoUF< const eoPop<EOT>&, T >& f, std::string _description = "functor")
: eoStat<EOT, T>(T(), _description), func(f)
{}
using eoStat<EOT, T>::value;
void operator()(const eoPop<EOT>& pop) {
value() = func(pop);
}
private:
eoUF< const eoPop<EOT>&, T >& func;
};
/**
* @ingroup Stats
*/
template <class EOT, class T>
eoFunctorStat<EOT, T>& makeFunctorStat( eoUF< const eoPop<EOT>&, T >& func, eoFunctorStore& store, std::string description = "func") {
return store.storeFunctor(
new eoFunctorStat<EOT, T>( func, description)
);
}
#endif

View file

@ -0,0 +1,46 @@
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(c) Thales group 2011
Author: johann.dreo@thalesgroup.com
*/
#ifndef _eoGenCounter_h
#define _eoGenCounter_h
#include <string>
#include <utils/eoStat.h>
/**
An eoStat that simply gives the current generation index
@ingroup Stats
*/
class eoGenCounter : public eoUpdater, public eoValueParam<unsigned int>
{
public:
eoGenCounter( unsigned int start = 0, std::string label = "Gen" ) : eoValueParam<unsigned int>(start, label), _nb(start) {}
virtual void operator()()
{
value() = _nb++;
}
private:
unsigned int _nb;
};
#endif

View file

@ -0,0 +1,99 @@
//-----------------------------------------------------------------------------
// (c) Marc Schoenauer, 2001
// Copyright (C) 2005 Jochen Küpper
/*
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 version 2 of the License, or (at your option) any
later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@polytechnique.fr
*/
//-----------------------------------------------------------------------------
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <sstream>
#include <stdexcept>
#include "eoGnuplot.h"
unsigned eoGnuplot::numWindow=0;
eoGnuplot::eoGnuplot(std::string _title, std::string _extra)
: firstTime(true)
{
initGnuPlot(_title, _extra);
}
eoGnuplot::~eoGnuplot()
{
#ifdef HAVE_GNUPLOT
if( gpCom ) {
PipeComSend( gpCom, "quit\n" );
PipeComClose( gpCom );
gpCom =NULL;
}
#endif
}
void eoGnuplot::gnuplotCommand(const char *_command)
{
#ifdef HAVE_GNUPLOT
if(gpCom) {
PipeComSend( gpCom, _command );
PipeComSend( gpCom, "\n" );
}
#endif
}
void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
{
#ifdef HAVE_GNUPLOT
std::ostringstream os;
os << "250x150-0+" << 170 * numWindow++;
char *args[6];
args[0] = strdup( GNUPLOT_PROGRAM );
args[1] = strdup( "-geometry" );
args[2] = strdup( os.str().c_str());
args[3] = strdup( "-title" );
args[4] = strdup( _title.c_str() );
args[5] = 0;
gpCom = PipeComOpenArgv( GNUPLOT_PROGRAM, args );
if(! gpCom )
throw std::runtime_error("Cannot spawn gnuplot\n");
else {
PipeComSend( gpCom, "set grid\n" );
PipeComSend( gpCom, _extra.c_str() );
PipeComSend( gpCom, "\n" );
}
#endif
}
// Local Variables:
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

101
eo/src/utils/eoGnuplot.h Normal file
View file

@ -0,0 +1,101 @@
//-----------------------------------------------------------------------------
// eoGnuplot1DMonitor.h
// (c) Marc Schoenauer, 2001
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: Marc.Schoenauer@polytechnique.fr
*/
//-----------------------------------------------------------------------------
#ifndef EO_eoGnuplot_H
#define EO_eoGnuplot_H
#include <string>
#include "pipecom.h"
/** Base class for calls to gnuplot
This class is the abstract class that will be used by further gnuplot
calls to plots what is already written by some eoMonitor into a file
@author Marc Schoenauer
@version 0.0 (2001)
@ingroup Monitors
*/
class eoGnuplot
{
public:
/** Open pipe to Gnuplot.
@param _title Title for gnuplot window.
@param _extra Extra parameters to gnuplot (default to none: "").
*/
eoGnuplot(std::string _title, std::string _extra = std::string(""));
/** Destructor
Close the gnuplot windows if pipe was correctly opened
*/
virtual ~eoGnuplot();
/** Class name */
virtual std::string className() const
{ return "eoGnuplot"; }
/** Send command to gnuplot */
void gnuplotCommand(const char * _command);
/** Send command to gnuplot
@overload
*/
void gnuplotCommand(std::string _command)
{ gnuplotCommand(_command.c_str()); }
protected:
/** Initialize gnuplot
@param _title Title for gnuplot window.
@param _extra Extra parameters to gnuplot.
*/
void initGnuPlot(std::string _title, std::string _extra);
/** The stats might be unknown in Ctor */
bool firstTime;
/** Communication with gnuplot OK */
PCom *gpCom;
/** Internal counter for gnuplot windows */
static unsigned numWindow;
};
#endif // EO_eoGnuplot_H
// Local Variables:
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// mode: C++
// End:

View file

@ -0,0 +1,85 @@
//-----------------------------------------------------------------------------
// eoGnuplot1DMonitor.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sstream>
#include "utils/eoGnuplot1DMonitor.h"
#include "utils/eoParam.h"
eoMonitor& eoGnuplot1DMonitor::operator() (void)
{
// update file using the eoFileMonitor
eoFileMonitor::operator()();
#ifdef HAVE_GNUPLOT
// sends plot order to gnuplot
// assumes successive plots will have same nb of columns!!!
if (firstTime)
{
FirstPlot();
firstTime = false;
}
else
{
if( gpCom ) {
PipeComSend( gpCom, "replot\n" );
}
}
#endif
return *this;
}
void eoGnuplot1DMonitor::FirstPlot()
{
if (this->vec.size() < 2)
{
throw std::runtime_error("Must have some stats to plot!\n");
}
#ifdef HAVE_GNUPLOT
std::ostringstream os;
os << "plot";
for (unsigned i=1; i<this->vec.size(); i++) {
os << " '" << getFileName().c_str() <<
"' using 1:" << i+1 << " title '" << (this->vec[i])->longName() << "' with lines" ;
if (i<this->vec.size()-1)
os << ", ";
}
os << '\n';
PipeComSend( gpCom, os.str().c_str());
#endif
}
// Local Variables:
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -0,0 +1,85 @@
//-----------------------------------------------------------------------------
// eoGnuplot1DMonitor.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
/*
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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef EO_eoGnuplot1DMonitor_H
#define EO_eoGnuplot1DMonitor_H
#include <fstream>
#include <string>
#include "eoObject.h"
#include "utils/eoFileMonitor.h"
#include "utils/eoGnuplot.h"
#include "utils/pipecom.h"
/** Plot eoStat
@author Marc Schoenauer
@version 0.0 (2000)
This class plots through gnuplot the eoStat given as argument
eoGnuplot1DMonitor plots stats through gnuplot
Assumes that the same file is appened every so and so, and replots it
everytime
@ingroup Monitors
*/
class eoGnuplot1DMonitor : public eoFileMonitor, public eoGnuplot
{
public:
// this "using" directive generates a compiler internal error in GCC 4.0.0 ...
// it's been removed, and the only call to vec was replaced by this->vec in eoGnuplot1DMonitor.cpp
// using eoMonitor::vec;
/** Constructor */
eoGnuplot1DMonitor(std::string _filename, bool _top=false) :
eoFileMonitor(_filename, " "),
eoGnuplot(_filename,(_top?"":"set key bottom"))
{}
/** Destructor */
virtual ~eoGnuplot1DMonitor(){}
virtual eoMonitor& operator()();
virtual void FirstPlot();
/** Class name */
virtual std::string className() const
{ return "eoGnuplot1DMonitor"; }
};
#endif // EO_eoGnuplot1DMonitor_H
// Local Variables:
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// mode: C++
// End:

Some files were not shown because too many files have changed in this diff Show more