move edo stuff, that was in the wriong place after the merge, in the edo directory
This commit is contained in:
parent
d4765851d5
commit
cbb1771dd6
77 changed files with 0 additions and 0 deletions
14
edo/src/utils/CMakeLists.txt
Normal file
14
edo/src/utils/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
######################################################################################
|
||||
### 1) Set all needed source files for the project
|
||||
######################################################################################
|
||||
|
||||
FILE(GLOB SOURCES *.cpp)
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
||||
ADD_LIBRARY(edoutils ${SOURCES})
|
||||
INSTALL(TARGETS edoutils ARCHIVE DESTINATION lib COMPONENT libraries)
|
||||
|
||||
FILE(GLOB HDRS *.h utils)
|
||||
INSTALL(FILES ${HDRS} DESTINATION include/edo/utils COMPONENT headers)
|
||||
|
||||
######################################################################################
|
||||
146
edo/src/utils/edoCheckPoint.h
Normal file
146
edo/src/utils/edoCheckPoint.h
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoCheckPoint_h
|
||||
#define _edoCheckPoint_h
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
|
||||
#include "edoContinue.h"
|
||||
#include "edoStat.h"
|
||||
|
||||
//! eoCheckPoint< EOT > classe fitted to Distribution Object library
|
||||
|
||||
template < typename D >
|
||||
class edoCheckPoint : public edoContinue< D >
|
||||
{
|
||||
public:
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
edoCheckPoint(edoContinue< D >& _cont)
|
||||
{
|
||||
_continuators.push_back( &_cont );
|
||||
}
|
||||
|
||||
bool operator()(const D& distrib)
|
||||
{
|
||||
for ( unsigned int i = 0, size = _stats.size(); i < size; ++i )
|
||||
{
|
||||
(*_stats[i])( distrib );
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _updaters.size(); i < size; ++i )
|
||||
{
|
||||
(*_updaters[i])();
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _monitors.size(); i < size; ++i )
|
||||
{
|
||||
(*_monitors[i])();
|
||||
}
|
||||
|
||||
bool bContinue = true;
|
||||
for ( unsigned int i = 0, size = _continuators.size(); i < size; ++i )
|
||||
{
|
||||
if ( !(*_continuators[i])( distrib ) )
|
||||
{
|
||||
bContinue = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bContinue )
|
||||
{
|
||||
for ( unsigned int i = 0, size = _stats.size(); i < size; ++i )
|
||||
{
|
||||
_stats[i]->lastCall( distrib );
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _updaters.size(); i < size; ++i )
|
||||
{
|
||||
_updaters[i]->lastCall();
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _monitors.size(); i < size; ++i )
|
||||
{
|
||||
_monitors[i]->lastCall();
|
||||
}
|
||||
}
|
||||
|
||||
return bContinue;
|
||||
}
|
||||
|
||||
void add(edoContinue< D >& cont) { _continuators.push_back( &cont ); }
|
||||
void add(edoStatBase< D >& 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 "edoCheckPoint"; }
|
||||
|
||||
std::string allClassNames() const
|
||||
{
|
||||
std::string s("\n" + className() + "\n");
|
||||
|
||||
s += "Stats\n";
|
||||
for ( unsigned int i = 0, size = _stats.size(); i < size; ++i )
|
||||
{
|
||||
s += _stats[i]->className() + "\n";
|
||||
}
|
||||
s += "\n";
|
||||
|
||||
s += "Updaters\n";
|
||||
for ( unsigned int i = 0; i < _updaters.size(); ++i )
|
||||
{
|
||||
s += _updaters[i]->className() + "\n";
|
||||
}
|
||||
s += "\n";
|
||||
|
||||
s += "Monitors\n";
|
||||
for ( unsigned int i = 0; i < _monitors.size(); ++i )
|
||||
{
|
||||
s += _monitors[i]->className() + "\n";
|
||||
}
|
||||
s += "\n";
|
||||
|
||||
s += "Continuators\n";
|
||||
for ( unsigned int i = 0, size = _continuators.size(); i < size; ++i )
|
||||
{
|
||||
s += _continuators[i]->className() + "\n";
|
||||
}
|
||||
s += "\n";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector< edoContinue< D >* > _continuators;
|
||||
std::vector< edoStatBase< D >* > _stats;
|
||||
std::vector< eoMonitor* > _monitors;
|
||||
std::vector< eoUpdater* > _updaters;
|
||||
};
|
||||
|
||||
#endif // !_edoCheckPoint_h
|
||||
141
edo/src/utils/edoFileSnapshot.cpp
Normal file
141
edo/src/utils/edoFileSnapshot.cpp
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
todos@geneura.ugr.es
|
||||
Marc Schoenauer <Marc.Schoenauer@polytechnique.fr>
|
||||
Martin Keijzer <mkeijzer@dhi.dk>
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <utils/edoFileSnapshot.h>
|
||||
#include <utils/compatibility.h>
|
||||
#include <utils/eoParam.h>
|
||||
|
||||
edoFileSnapshot::edoFileSnapshot(std::string dirname,
|
||||
unsigned int frequency /*= 1*/,
|
||||
std::string filename /*= "gen"*/,
|
||||
std::string delim /*= " "*/,
|
||||
unsigned int counter /*= 0*/,
|
||||
bool rmFiles /*= true*/,
|
||||
bool saveFilenames /*= true*/)
|
||||
: _dirname(dirname), _frequency(frequency),
|
||||
_filename(filename), _delim(delim),
|
||||
_counter(counter), _saveFilenames(saveFilenames),
|
||||
_descOfFiles( NULL ), _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 -f ") + _dirname+ "/" + _filename + "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = " ";
|
||||
}
|
||||
|
||||
int dummy;
|
||||
dummy = system(s.c_str());
|
||||
// all done
|
||||
|
||||
_descOfFiles = new std::ofstream( std::string(dirname + "/list_of_files.txt").c_str() );
|
||||
|
||||
}
|
||||
|
||||
edoFileSnapshot::~edoFileSnapshot()
|
||||
{
|
||||
delete _descOfFiles;
|
||||
}
|
||||
|
||||
void edoFileSnapshot::setCurrentFileName()
|
||||
{
|
||||
std::ostringstream oscount;
|
||||
oscount << _counter;
|
||||
_currentFileName = _dirname + "/" + _filename + oscount.str();
|
||||
}
|
||||
|
||||
eoMonitor& edoFileSnapshot::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 = "edoFileSnapshot: Could not open " + _currentFileName;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
if ( _saveFilenames )
|
||||
{
|
||||
*_descOfFiles << _currentFileName.c_str() << std::endl;
|
||||
}
|
||||
|
||||
return operator()(os);
|
||||
}
|
||||
|
||||
eoMonitor& edoFileSnapshot::operator()(std::ostream& os)
|
||||
{
|
||||
iterator it = vec.begin();
|
||||
|
||||
os << (*it)->getValue();
|
||||
|
||||
for ( ++it; it != vec.end(); ++it )
|
||||
{
|
||||
os << _delim.c_str() << (*it)->getValue();
|
||||
}
|
||||
|
||||
os << '\n';
|
||||
|
||||
return *this;
|
||||
}
|
||||
79
edo/src/utils/edoFileSnapshot.h
Normal file
79
edo/src/utils/edoFileSnapshot.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
todos@geneura.ugr.es
|
||||
Marc Schoenauer <Marc.Schoenauer@polytechnique.fr>
|
||||
Martin Keijzer <mkeijzer@dhi.dk>
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoFileSnapshot_h
|
||||
#define _edoFileSnapshot_h
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "utils/eoMonitor.h"
|
||||
|
||||
class edoFileSnapshot : public eoMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
edoFileSnapshot(std::string dirname,
|
||||
unsigned int frequency = 1,
|
||||
std::string filename = "gen",
|
||||
std::string delim = " ",
|
||||
unsigned int counter = 0,
|
||||
bool rmFiles = true,
|
||||
bool saveFilenames = true);
|
||||
|
||||
virtual ~edoFileSnapshot();
|
||||
|
||||
virtual bool hasChanged() {return _boolChanged;}
|
||||
virtual std::string getDirName() { return _dirname; }
|
||||
virtual unsigned int getCounter() { return _counter; }
|
||||
virtual const std::string baseFileName() { return _filename;}
|
||||
std::string getFileName() {return _currentFileName;}
|
||||
|
||||
void setCurrentFileName();
|
||||
|
||||
virtual eoMonitor& operator()(void);
|
||||
|
||||
virtual eoMonitor& operator()(std::ostream& os);
|
||||
|
||||
private :
|
||||
std::string _dirname;
|
||||
unsigned int _frequency;
|
||||
std::string _filename;
|
||||
std::string _delim;
|
||||
std::string _currentFileName;
|
||||
unsigned int _counter;
|
||||
bool _saveFilenames;
|
||||
std::ofstream* _descOfFiles;
|
||||
bool _boolChanged;
|
||||
};
|
||||
|
||||
#endif // !_edoFileSnapshot
|
||||
52
edo/src/utils/edoHyperVolume.h
Normal file
52
edo/src/utils/edoHyperVolume.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoHyperVolume_h
|
||||
#define _edoHyperVolume_h
|
||||
|
||||
template < typename EOT >
|
||||
class edoHyperVolume
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoHyperVolume() : _hv(1) {}
|
||||
|
||||
void update(AtomType v)
|
||||
{
|
||||
_hv *= ::sqrt( v );
|
||||
|
||||
assert( _hv <= std::numeric_limits< AtomType >::max() );
|
||||
}
|
||||
|
||||
AtomType get_hypervolume() const { return _hv; }
|
||||
|
||||
protected:
|
||||
AtomType _hv;
|
||||
};
|
||||
|
||||
#endif // !_edoHyperVolume_h
|
||||
70
edo/src/utils/edoPopStat.h
Normal file
70
edo/src/utils/edoPopStat.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
todos@geneura.ugr.es
|
||||
Marc Schoenauer <Marc.Schoenauer@polytechnique.fr>
|
||||
Martin Keijzer <mkeijzer@dhi.dk>
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoPopStat_h
|
||||
#define _edoPopStat_h
|
||||
|
||||
#include <utils/eoStat.h>
|
||||
|
||||
|
||||
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
|
||||
This snippet is a workaround:
|
||||
This class will "print" a whole population into a std::string - that you can later
|
||||
send to any stream
|
||||
This is the plain version - see eoPopString for the Sorted version
|
||||
|
||||
Note: this Stat should probably be used only within eoStdOutMonitor, and not
|
||||
inside an eoFileMonitor, as the eoState construct will work much better there.
|
||||
*/
|
||||
template <class EOT>
|
||||
class edoPopStat : public eoStat<EOT, std::string>
|
||||
{
|
||||
public:
|
||||
|
||||
using eoStat<EOT, std::string>::value;
|
||||
|
||||
/** default Ctor, void std::string by default, as it appears
|
||||
on the description line once at beginning of evolution. and
|
||||
is meaningless there. _howMany defaults to 0, that is, the whole
|
||||
population*/
|
||||
edoPopStat(std::string _desc ="")
|
||||
: eoStat<EOT, std::string>("", _desc) {}
|
||||
|
||||
/** Fills the value() of the eoParam with the dump of the population. */
|
||||
void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << _pop;
|
||||
value() = os.str();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoPopStat_h
|
||||
74
edo/src/utils/edoStat.h
Normal file
74
edo/src/utils/edoStat.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoStat_h
|
||||
#define _edoStat_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
template < typename D >
|
||||
class edoStatBase : public eoUF< const D&, void >
|
||||
{
|
||||
public:
|
||||
// virtual void operator()( const D& ) = 0 (provided by eoUF< A1, R >)
|
||||
|
||||
virtual void lastCall( const D& ) {}
|
||||
virtual std::string className() const { return "edoStatBase"; }
|
||||
};
|
||||
|
||||
template < typename D > class edoCheckPoint;
|
||||
|
||||
template < typename D, typename T >
|
||||
class edoStat : public eoValueParam< T >, public edoStatBase< D >
|
||||
{
|
||||
public:
|
||||
edoStat(T value, std::string description)
|
||||
: eoValueParam< T >(value, description)
|
||||
{}
|
||||
|
||||
virtual std::string className(void) const { return "edoStat"; }
|
||||
|
||||
edoStat< D, T >& addTo(edoCheckPoint< D >& cp) { cp.add(*this); return *this; }
|
||||
|
||||
// TODO: edoStat< D, T >& addTo(eoMonitor& mon) { mon.add(*this); return *this; }
|
||||
};
|
||||
|
||||
|
||||
//! A parent class for any kind of distribution to dump parameter to std::string type
|
||||
|
||||
template < typename D >
|
||||
class edoDistribStat : public edoStat< D, std::string >
|
||||
{
|
||||
public:
|
||||
using edoStat< D, std::string >::value;
|
||||
|
||||
edoDistribStat(std::string desc)
|
||||
: edoStat< D, std::string >("", desc)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif // !_edoStat_h
|
||||
55
edo/src/utils/edoStatNormalMono.h
Normal file
55
edo/src/utils/edoStatNormalMono.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoStatNormalMono_h
|
||||
#define _edoStatNormalMono_h
|
||||
|
||||
#include "edoStat.h"
|
||||
#include "edoNormalMono.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoStatNormalMono : public edoDistribStat< edoNormalMono< EOT > >
|
||||
{
|
||||
public:
|
||||
using edoDistribStat< edoNormalMono< EOT > >::value;
|
||||
|
||||
edoStatNormalMono( std::string desc = "" )
|
||||
: edoDistribStat< edoNormalMono< EOT > >( desc )
|
||||
{}
|
||||
|
||||
void operator()( const edoNormalMono< EOT >& distrib )
|
||||
{
|
||||
value() = "\n# ====== mono normal distribution dump =====\n";
|
||||
|
||||
std::ostringstream os;
|
||||
os << distrib.mean() << " " << distrib.variance() << std::endl;
|
||||
|
||||
value() += os.str();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoStatNormalMono_h
|
||||
68
edo/src/utils/edoStatNormalMulti.h
Normal file
68
edo/src/utils/edoStatNormalMulti.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoStatNormalMulti_h
|
||||
#define _edoStatNormalMulti_h
|
||||
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
|
||||
#include "edoStat.h"
|
||||
#include "edoNormalMulti.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoStatNormalMulti : public edoDistribStat< edoNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
using edoDistribStat< edoNormalMulti< EOT > >::value;
|
||||
|
||||
edoStatNormalMulti( std::string desc = "" )
|
||||
: edoDistribStat< edoNormalMulti< EOT > >( desc )
|
||||
{}
|
||||
|
||||
void operator()( const edoNormalMulti< EOT >& distrib )
|
||||
{
|
||||
value() = "\n# ====== multi normal distribution dump =====\n";
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
os << distrib.mean() << " " << distrib.varcovar() << std::endl;
|
||||
|
||||
// ublas::vector< AtomType > mean = distrib.mean();
|
||||
// std::copy(mean.begin(), mean.end(), std::ostream_iterator< std::string >( os, " " ));
|
||||
|
||||
// ublas::symmetric_matrix< AtomType, ublas::lower > varcovar = distrib.varcovar();
|
||||
// std::copy(varcovar.begin(), varcovar.end(), std::ostream_iterator< std::string >( os, " " ));
|
||||
|
||||
// os << std::endl;
|
||||
|
||||
value() += os.str();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoStatNormalMulti_h
|
||||
55
edo/src/utils/edoStatUniform.h
Normal file
55
edo/src/utils/edoStatUniform.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoStatUniform_h
|
||||
#define _edoStatUniform_h
|
||||
|
||||
#include "edoStat.h"
|
||||
#include "edoUniform.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoStatUniform : public edoDistribStat< edoUniform< EOT > >
|
||||
{
|
||||
public:
|
||||
using edoDistribStat< edoUniform< EOT > >::value;
|
||||
|
||||
edoStatUniform( std::string desc = "" )
|
||||
: edoDistribStat< edoUniform< EOT > >( desc )
|
||||
{}
|
||||
|
||||
void operator()( const edoUniform< EOT >& distrib )
|
||||
{
|
||||
value() = "\n# ====== uniform distribution dump =====\n";
|
||||
|
||||
std::ostringstream os;
|
||||
os << distrib.min() << " " << distrib.max() << std::endl;
|
||||
|
||||
value() += os.str();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoStatUniform_h
|
||||
Loading…
Add table
Add a link
Reference in a new issue