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
21
edo/src/CMakeLists.txt
Normal file
21
edo/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
######################################################################################
|
||||
### 1) Set all needed source files for the project
|
||||
######################################################################################
|
||||
|
||||
FILE(GLOB HDRS *.h edo)
|
||||
INSTALL(FILES ${HDRS} DESTINATION include/edo COMPONENT headers)
|
||||
|
||||
FILE(GLOB SOURCES *.cpp)
|
||||
|
||||
SET(SAMPLE_SRCS ${SOURCES} PARENT_SCOPE)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
ADD_SUBDIRECTORY(utils)
|
||||
|
||||
######################################################################################
|
||||
0
edo/src/TODO
Normal file
0
edo/src/TODO
Normal file
79
edo/src/edo
Normal file
79
edo/src/edo
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) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edo_
|
||||
#define _edo_
|
||||
|
||||
#include "edoAlgo.h"
|
||||
#include "edoEDASA.h"
|
||||
#include "edoEDA.h"
|
||||
|
||||
#include "edoDistrib.h"
|
||||
#include "edoUniform.h"
|
||||
#include "edoNormalMono.h"
|
||||
#include "edoNormalMulti.h"
|
||||
|
||||
#include "edoEstimator.h"
|
||||
#include "edoEstimatorUniform.h"
|
||||
#include "edoEstimatorNormalMono.h"
|
||||
#include "edoEstimatorNormalMulti.h"
|
||||
|
||||
#include "edoModifier.h"
|
||||
#include "edoModifierDispersion.h"
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoUniformCenter.h"
|
||||
#include "edoNormalMonoCenter.h"
|
||||
#include "edoNormalMultiCenter.h"
|
||||
|
||||
#include "edoSampler.h"
|
||||
#include "edoSamplerUniform.h"
|
||||
#include "edoSamplerNormalMono.h"
|
||||
#include "edoSamplerNormalMulti.h"
|
||||
|
||||
#include "edoVectorBounds.h"
|
||||
|
||||
#include "edoBounder.h"
|
||||
#include "edoBounderNo.h"
|
||||
#include "edoBounderBound.h"
|
||||
#include "edoBounderRng.h"
|
||||
|
||||
#include "edoContinue.h"
|
||||
#include "utils/edoCheckPoint.h"
|
||||
|
||||
#include "utils/edoStat.h"
|
||||
#include "utils/edoStatUniform.h"
|
||||
#include "utils/edoStatNormalMono.h"
|
||||
#include "utils/edoStatNormalMulti.h"
|
||||
|
||||
#include "utils/edoFileSnapshot.h"
|
||||
#include "utils/edoPopStat.h"
|
||||
|
||||
#endif // !_edo_
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// End:
|
||||
28
edo/src/edo.cpp
Normal file
28
edo/src/edo.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
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:
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#include "edo"
|
||||
|
||||
44
edo/src/edoAlgo.h
Normal file
44
edo/src/edoAlgo.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
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 _edoAlgo_h
|
||||
#define _edoAlgo_h
|
||||
|
||||
#include <eoAlgo.h>
|
||||
|
||||
template < typename D >
|
||||
class edoAlgo : public eoAlgo< typename D::EOType >
|
||||
{
|
||||
//! Alias for the type
|
||||
typedef typename D::EOType EOT;
|
||||
|
||||
public:
|
||||
virtual ~edoAlgo(){}
|
||||
};
|
||||
|
||||
#endif // !_edoAlgo_h
|
||||
54
edo/src/edoBounder.h
Normal file
54
edo/src/edoBounder.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
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 _edoBounder_h
|
||||
#define _edoBounder_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
template < typename EOT >
|
||||
class edoBounder : public eoUF< EOT&, void >
|
||||
{
|
||||
public:
|
||||
edoBounder( EOT min = EOT(1, 0), EOT max = EOT(1, 0) )
|
||||
: _min(min), _max(max)
|
||||
{
|
||||
assert(_min.size() > 0);
|
||||
assert(_min.size() == _max.size());
|
||||
}
|
||||
|
||||
// virtual void operator()( EOT& ) = 0 (provided by eoUF< A1, R >)
|
||||
|
||||
EOT& min(){return _min;}
|
||||
EOT& max(){return _max;}
|
||||
|
||||
private:
|
||||
EOT _min;
|
||||
EOT _max;
|
||||
};
|
||||
|
||||
#endif // !_edoBounder_h
|
||||
62
edo/src/edoBounderBound.h
Normal file
62
edo/src/edoBounderBound.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
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 _edoBounderBound_h
|
||||
#define _edoBounderBound_h
|
||||
|
||||
#include "edoBounder.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoBounderBound : public edoBounder< EOT >
|
||||
{
|
||||
public:
|
||||
edoBounderBound( EOT min, EOT max )
|
||||
: edoBounder< EOT >( min, max )
|
||||
{}
|
||||
|
||||
void operator()( EOT& x )
|
||||
{
|
||||
unsigned int size = x.size();
|
||||
assert(size > 0);
|
||||
|
||||
for (unsigned int d = 0; d < size; ++d) // browse all dimensions
|
||||
{
|
||||
if (x[d] < this->min()[d])
|
||||
{
|
||||
x[d] = this->min()[d];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (x[d] > this->max()[d])
|
||||
{
|
||||
x[d] = this->max()[d];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoBounderBound_h
|
||||
40
edo/src/edoBounderNo.h
Normal file
40
edo/src/edoBounderNo.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
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 _edoBounderNo_h
|
||||
#define _edoBounderNo_h
|
||||
|
||||
#include "edoBounder.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoBounderNo : public edoBounder< EOT >
|
||||
{
|
||||
public:
|
||||
void operator()( EOT& ) {}
|
||||
};
|
||||
|
||||
#endif // !_edoBounderNo_h
|
||||
63
edo/src/edoBounderRng.h
Normal file
63
edo/src/edoBounderRng.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
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 _edoBounderRng_h
|
||||
#define _edoBounderRng_h
|
||||
|
||||
#include "edoBounder.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoBounderRng : public edoBounder< EOT >
|
||||
{
|
||||
public:
|
||||
edoBounderRng( EOT min, EOT max, eoRndGenerator< double > & rng )
|
||||
: edoBounder< EOT >( min, max ), _rng(rng)
|
||||
{}
|
||||
|
||||
void operator()( EOT& x )
|
||||
{
|
||||
unsigned int size = x.size();
|
||||
assert(size > 0);
|
||||
|
||||
for (unsigned int d = 0; d < size; ++d) // browse all dimensions
|
||||
{
|
||||
|
||||
// FIXME: attention: les bornes RNG ont les memes bornes quelque soit les dimensions idealement on voudrait avoir des bornes differentes pour chaque dimensions.
|
||||
|
||||
if (x[d] < this->min()[d] || x[d] > this->max()[d])
|
||||
{
|
||||
x[d] = _rng();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
eoRndGenerator< double> & _rng;
|
||||
};
|
||||
|
||||
#endif // !_edoBounderRng_h
|
||||
|
||||
55
edo/src/edoBounderUniform.h
Normal file
55
edo/src/edoBounderUniform.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>
|
||||
*/
|
||||
|
||||
#ifndef _edoBounderUniform_h
|
||||
#define _edoBounderUniform_h
|
||||
|
||||
#include "edoBounder.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoBounderUniform : public edoBounder< EOT >
|
||||
{
|
||||
public:
|
||||
edoBounderUniform( EOT min, EOT max )
|
||||
: edoBounder< EOT >( min, max )
|
||||
{}
|
||||
|
||||
void operator()( EOT& sol )
|
||||
{
|
||||
unsigned int size = sol.size();
|
||||
assert(size > 0);
|
||||
|
||||
for (unsigned int d = 0; d < size; ++d) {
|
||||
|
||||
if ( sol[d] < this->min()[d] || sol[d] > this->max()[d]) {
|
||||
// use EO's global "rng"
|
||||
sol[d] = rng.uniform( this->min()[d], this->max()[d] );
|
||||
}
|
||||
} // for d in size
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoBounderUniform_h
|
||||
61
edo/src/edoContinue.h
Normal file
61
edo/src/edoContinue.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
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 _doContinue_h
|
||||
#define _doContinue_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <eoPersistent.h>
|
||||
|
||||
//! edoContinue< EOT > classe fitted to Distribution Object library
|
||||
|
||||
template < typename D >
|
||||
class edoContinue : public eoUF< const D&, bool >, public eoPersistent
|
||||
{
|
||||
public:
|
||||
virtual std::string className(void) const { return "edoContinue"; }
|
||||
|
||||
void readFrom(std::istream&)
|
||||
{
|
||||
/* It should be implemented by subclasses ! */
|
||||
}
|
||||
|
||||
void printOn(std::ostream&) const
|
||||
{
|
||||
/* It should be implemented by subclasses ! */
|
||||
}
|
||||
};
|
||||
|
||||
template < typename D >
|
||||
class edoDummyContinue : public edoContinue< D >
|
||||
{
|
||||
bool operator()(const D&){ return true; }
|
||||
|
||||
virtual std::string className() const { return "edoDummyContinue"; }
|
||||
};
|
||||
|
||||
#endif // !_edoContinue_h
|
||||
43
edo/src/edoDistrib.h
Normal file
43
edo/src/edoDistrib.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 _edoDistrib_h
|
||||
#define _edoDistrib_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
template < typename EOT >
|
||||
class edoDistrib : public eoFunctorBase
|
||||
{
|
||||
public:
|
||||
//! Alias for the type
|
||||
typedef EOT EOType;
|
||||
|
||||
virtual ~edoDistrib(){}
|
||||
};
|
||||
|
||||
#endif // !_edoDistrib_h
|
||||
272
edo/src/edoEDA.h
Normal file
272
edo/src/edoEDA.h
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
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 _edoEDA_h
|
||||
#define _edoEDA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edoAlgo.h"
|
||||
#include "edoEstimator.h"
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoSampler.h"
|
||||
#include "edoContinue.h"
|
||||
|
||||
template < typename D >
|
||||
class edoEDA : public edoAlgo< D >
|
||||
{
|
||||
public:
|
||||
//! Alias for the type EOT
|
||||
typedef typename D::EOType EOT;
|
||||
|
||||
//! Alias for the atom type
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! edoEDA constructor
|
||||
/*!
|
||||
All the boxes used by a EDASA need to be given.
|
||||
|
||||
\param selector Population Selector
|
||||
\param estimator Distribution Estimator
|
||||
\param selectone SelectOne
|
||||
\param modifier Distribution Modifier
|
||||
\param sampler Distribution Sampler
|
||||
\param pop_continue Population Continuator
|
||||
\param distribution_continue Distribution Continuator
|
||||
\param evaluation Evaluation function.
|
||||
\param sa_continue Stopping criterion.
|
||||
\param cooling_schedule Cooling schedule, describes how the temperature is modified.
|
||||
\param initial_temperature The initial temperature.
|
||||
\param replacor Population replacor
|
||||
*/
|
||||
edoEDA (eoSelect< EOT > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
eoSelectOne< EOT > & selectone,
|
||||
edoModifierMass< D > & modifier,
|
||||
edoSampler< D > & sampler,
|
||||
eoContinue< EOT > & pop_continue,
|
||||
edoContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
//moContinuator< moDummyNeighbor<EOT> > & sa_continue,
|
||||
//moCoolingSchedule<EOT> & cooling_schedule,
|
||||
//double initial_temperature,
|
||||
eoReplacement< EOT > & replacor
|
||||
)
|
||||
: _selector(selector),
|
||||
_estimator(estimator),
|
||||
_selectone(selectone),
|
||||
_modifier(modifier),
|
||||
_sampler(sampler),
|
||||
_pop_continue(pop_continue),
|
||||
_distribution_continue(distribution_continue),
|
||||
_evaluation(evaluation),
|
||||
//_sa_continue(sa_continue),
|
||||
//_cooling_schedule(cooling_schedule),
|
||||
//_initial_temperature(initial_temperature),
|
||||
_replacor(replacor)
|
||||
|
||||
{}
|
||||
|
||||
//! function that launches the EDASA algorithm.
|
||||
/*!
|
||||
As a moTS or a moHC, the EDASA can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
|
||||
\param pop A population to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
//double temperature = _initial_temperature;
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
|
||||
eoPop< EOT > selected_pop;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Estimating a first time the distribution parameter thanks
|
||||
// to population.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
D distrib = _estimator(pop);
|
||||
|
||||
double size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
//-------------------------------------------------------------
|
||||
// (3) Selection of the best points in the population
|
||||
//-------------------------------------------------------------
|
||||
|
||||
selected_pop.clear();
|
||||
|
||||
_selector(pop, selected_pop);
|
||||
|
||||
assert( selected_pop.size() > 0 );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// (4) Estimation of the distribution parameters
|
||||
//-------------------------------------------------------------
|
||||
|
||||
distrib = _estimator(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
// TODO: utiliser selected_pop ou pop ???
|
||||
|
||||
assert(selected_pop.size() > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Init of a variable contening a point with the bestest fitnesses
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT current_solution = _selectone(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Fit the current solution with the distribution parameters (bounds)
|
||||
//-------------------------------------------------------------
|
||||
|
||||
// FIXME: si besoin de modifier la dispersion de la distribution
|
||||
// _modifier_dispersion(distribution, selected_pop);
|
||||
_modifier(distrib, current_solution);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Evaluating a first time the current solution
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_evaluation( current_solution );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Building of the sampler in current_pop
|
||||
//-------------------------------------------------------------
|
||||
|
||||
//_sa_continue.init( current_solution );
|
||||
|
||||
current_pop.clear();
|
||||
|
||||
for ( unsigned int i = 0; i < pop.size(); ++i )
|
||||
//do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
_evaluation( candidate_solution );
|
||||
|
||||
// TODO: verifier le critere d'acceptation
|
||||
if ( candidate_solution.fitness() < current_solution.fitness()
|
||||
// || rng.uniform() < exp( ::fabs(candidate_solution.fitness() - current_solution.fitness()) / temperature )
|
||||
)
|
||||
{
|
||||
current_pop.push_back(candidate_solution);
|
||||
current_solution = candidate_solution;
|
||||
}
|
||||
}
|
||||
//while ( _sa_continue( current_solution) );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_replacor(pop, current_pop); // copy current_pop in pop
|
||||
|
||||
pop.sort();
|
||||
|
||||
//if ( ! _cooling_schedule( temperature ) ){ eo::log << eo::debug << "_cooling_schedule" << std::endl; break; }
|
||||
|
||||
if ( ! _distribution_continue( distrib ) ){ eo::log << eo::debug << "_distribution_continue" << std::endl; break; }
|
||||
|
||||
if ( ! _pop_continue( pop ) ){ eo::log << eo::debug << "_pop_continue" << std::endl; break; }
|
||||
|
||||
}
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
edoEstimator< D > & _estimator;
|
||||
|
||||
//! SelectOne
|
||||
eoSelectOne< EOT > & _selectone;
|
||||
|
||||
//! A D modifier
|
||||
edoModifierMass< D > & _modifier;
|
||||
|
||||
//! A D sampler
|
||||
edoSampler< D > & _sampler;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continue;
|
||||
|
||||
//! A D continuator
|
||||
edoContinue < D > & _distribution_continue;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & _evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
//moContinuator< moDummyNeighbor<EOT> > & _sa_continue;
|
||||
|
||||
//! The cooling schedule
|
||||
//moCoolingSchedule<EOT> & _cooling_schedule;
|
||||
|
||||
//! Initial temperature
|
||||
//double _initial_temperature;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
};
|
||||
|
||||
#endif // !_edoEDA_h
|
||||
270
edo/src/edoEDASA.h
Normal file
270
edo/src/edoEDASA.h
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
/*
|
||||
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 _edoEDASA_h
|
||||
#define _edoEDASA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edoAlgo.h"
|
||||
#include "edoEstimator.h"
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoSampler.h"
|
||||
#include "edoContinue.h"
|
||||
|
||||
template < typename D >
|
||||
class edoEDASA : public edoAlgo< D >
|
||||
{
|
||||
public:
|
||||
//! Alias for the type EOT
|
||||
typedef typename D::EOType EOT;
|
||||
|
||||
//! Alias for the atom type
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! edoEDASA constructor
|
||||
/*!
|
||||
All the boxes used by a EDASA need to be given.
|
||||
|
||||
\param selector Population Selector
|
||||
\param estimator Distribution Estimator
|
||||
\param selectone SelectOne
|
||||
\param modifier Distribution Modifier
|
||||
\param sampler Distribution Sampler
|
||||
\param pop_continue Population Continuator
|
||||
\param distribution_continue Distribution Continuator
|
||||
\param evaluation Evaluation function.
|
||||
\param sa_continue Stopping criterion.
|
||||
\param cooling_schedule Cooling schedule, describes how the temperature is modified.
|
||||
\param initial_temperature The initial temperature.
|
||||
\param replacor Population replacor
|
||||
*/
|
||||
edoEDASA (eoSelect< EOT > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
eoSelectOne< EOT > & selectone,
|
||||
edoModifierMass< D > & modifier,
|
||||
edoSampler< D > & sampler,
|
||||
eoContinue< EOT > & pop_continue,
|
||||
edoContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
moContinuator< moDummyNeighbor<EOT> > & sa_continue,
|
||||
moCoolingSchedule<EOT> & cooling_schedule,
|
||||
double initial_temperature,
|
||||
eoReplacement< EOT > & replacor
|
||||
)
|
||||
: _selector(selector),
|
||||
_estimator(estimator),
|
||||
_selectone(selectone),
|
||||
_modifier(modifier),
|
||||
_sampler(sampler),
|
||||
_pop_continue(pop_continue),
|
||||
_distribution_continue(distribution_continue),
|
||||
_evaluation(evaluation),
|
||||
_sa_continue(sa_continue),
|
||||
_cooling_schedule(cooling_schedule),
|
||||
_initial_temperature(initial_temperature),
|
||||
_replacor(replacor)
|
||||
|
||||
{}
|
||||
|
||||
//! function that launches the EDASA algorithm.
|
||||
/*!
|
||||
As a moTS or a moHC, the EDASA can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
|
||||
\param pop A population to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
double temperature = _initial_temperature;
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
|
||||
eoPop< EOT > selected_pop;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Estimating a first time the distribution parameter thanks
|
||||
// to population.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
D distrib = _estimator(pop);
|
||||
|
||||
double size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
//-------------------------------------------------------------
|
||||
// (3) Selection of the best points in the population
|
||||
//-------------------------------------------------------------
|
||||
|
||||
selected_pop.clear();
|
||||
|
||||
_selector(pop, selected_pop);
|
||||
|
||||
assert( selected_pop.size() > 0 );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// (4) Estimation of the distribution parameters
|
||||
//-------------------------------------------------------------
|
||||
|
||||
distrib = _estimator(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
// TODO: utiliser selected_pop ou pop ???
|
||||
|
||||
assert(selected_pop.size() > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Init of a variable contening a point with the bestest fitnesses
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT current_solution = _selectone(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Fit the current solution with the distribution parameters (bounds)
|
||||
//-------------------------------------------------------------
|
||||
|
||||
// FIXME: si besoin de modifier la dispersion de la distribution
|
||||
// _modifier_dispersion(distribution, selected_pop);
|
||||
_modifier(distrib, current_solution);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Evaluating a first time the current solution
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_evaluation( current_solution );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Building of the sampler in current_pop
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_sa_continue.init( current_solution );
|
||||
|
||||
current_pop.clear();
|
||||
|
||||
do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
_evaluation( candidate_solution );
|
||||
|
||||
// TODO: verifier le critere d'acceptation
|
||||
if ( candidate_solution.fitness() < current_solution.fitness() ||
|
||||
rng.uniform() < exp( ::fabs(candidate_solution.fitness() - current_solution.fitness()) / temperature ) )
|
||||
{
|
||||
current_pop.push_back(candidate_solution);
|
||||
current_solution = candidate_solution;
|
||||
}
|
||||
}
|
||||
while ( _sa_continue( current_solution ) );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_replacor(pop, current_pop); // copy current_pop in pop
|
||||
|
||||
pop.sort();
|
||||
|
||||
if ( ! _cooling_schedule( temperature ) ){ eo::log << eo::debug << "_cooling_schedule" << std::endl; break; }
|
||||
|
||||
if ( ! _distribution_continue( distrib ) ){ eo::log << eo::debug << "_distribution_continue" << std::endl; break; }
|
||||
|
||||
if ( ! _pop_continue( pop ) ){ eo::log << eo::debug << "_pop_continue" << std::endl; break; }
|
||||
|
||||
}
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
edoEstimator< D > & _estimator;
|
||||
|
||||
//! SelectOne
|
||||
eoSelectOne< EOT > & _selectone;
|
||||
|
||||
//! A D modifier
|
||||
edoModifierMass< D > & _modifier;
|
||||
|
||||
//! A D sampler
|
||||
edoSampler< D > & _sampler;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continue;
|
||||
|
||||
//! A D continuator
|
||||
edoContinue < D > & _distribution_continue;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & _evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
moContinuator< moDummyNeighbor<EOT> > & _sa_continue;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule<EOT> & _cooling_schedule;
|
||||
|
||||
//! Initial temperature
|
||||
double _initial_temperature;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
};
|
||||
|
||||
#endif // !_edoEDASA_h
|
||||
43
edo/src/edoEstimator.h
Normal file
43
edo/src/edoEstimator.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 _edoEstimator_h
|
||||
#define _edoEstimator_h
|
||||
|
||||
#include <eoPop.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
template < typename D >
|
||||
class edoEstimator : public eoUF< eoPop< typename D::EOType >&, D >
|
||||
{
|
||||
public:
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
// virtual D operator() ( eoPop< EOT >& )=0 (provided by eoUF< A1, R >)
|
||||
};
|
||||
|
||||
#endif // !_edoEstimator_h
|
||||
97
edo/src/edoEstimatorNormalMono.h
Normal file
97
edo/src/edoEstimatorNormalMono.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
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 _edoEstimatorNormalMono_h
|
||||
#define _edoEstimatorNormalMono_h
|
||||
|
||||
#include "edoEstimator.h"
|
||||
#include "edoNormalMono.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoEstimatorNormalMono : public edoEstimator< edoNormalMono< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
class Variance
|
||||
{
|
||||
public:
|
||||
Variance() : _sumvar(0){}
|
||||
|
||||
void update(AtomType v)
|
||||
{
|
||||
_n++;
|
||||
|
||||
AtomType d = v - _mean;
|
||||
|
||||
_mean += 1 / _n * d;
|
||||
_sumvar += (_n - 1) / _n * d * d;
|
||||
}
|
||||
|
||||
AtomType get_mean() const {return _mean;}
|
||||
AtomType get_var() const {return _sumvar / (_n - 1);}
|
||||
AtomType get_std() const {return sqrt( get_var() );}
|
||||
|
||||
private:
|
||||
AtomType _n;
|
||||
AtomType _mean;
|
||||
AtomType _sumvar;
|
||||
};
|
||||
|
||||
public:
|
||||
edoNormalMono< EOT > operator()(eoPop<EOT>& pop)
|
||||
{
|
||||
unsigned int popsize = pop.size();
|
||||
assert(popsize > 0);
|
||||
|
||||
unsigned int dimsize = pop[0].size();
|
||||
assert(dimsize > 0);
|
||||
|
||||
std::vector< Variance > var( dimsize );
|
||||
|
||||
for (unsigned int i = 0; i < popsize; ++i)
|
||||
{
|
||||
for (unsigned int d = 0; d < dimsize; ++d)
|
||||
{
|
||||
var[d].update( pop[i][d] );
|
||||
}
|
||||
}
|
||||
|
||||
EOT mean( dimsize );
|
||||
EOT variance( dimsize );
|
||||
|
||||
for (unsigned int d = 0; d < dimsize; ++d)
|
||||
{
|
||||
mean[d] = var[d].get_mean();
|
||||
variance[d] = var[d].get_var();
|
||||
}
|
||||
|
||||
return edoNormalMono< EOT >( mean, variance );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoEstimatorNormalMono_h
|
||||
150
edo/src/edoEstimatorNormalMulti.h
Normal file
150
edo/src/edoEstimatorNormalMulti.h
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
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 _edoEstimatorNormalMulti_h
|
||||
#define _edoEstimatorNormalMulti_h
|
||||
|
||||
#include "edoEstimator.h"
|
||||
#include "edoNormalMulti.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoEstimatorNormalMulti : public edoEstimator< edoNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
class CovMatrix
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
CovMatrix( const eoPop< EOT >& pop )
|
||||
{
|
||||
//-------------------------------------------------------------
|
||||
// Some checks before starting to estimate covar
|
||||
//-------------------------------------------------------------
|
||||
|
||||
unsigned int p_size = pop.size(); // population size
|
||||
assert(p_size > 0);
|
||||
|
||||
unsigned int s_size = pop[0].size(); // solution size
|
||||
assert(s_size > 0);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Copy the population to an ublas matrix
|
||||
//-------------------------------------------------------------
|
||||
|
||||
ublas::matrix< AtomType > sample( p_size, s_size );
|
||||
|
||||
for (unsigned int i = 0; i < p_size; ++i)
|
||||
{
|
||||
for (unsigned int j = 0; j < s_size; ++j)
|
||||
{
|
||||
sample(i, j) = pop[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_varcovar.resize(s_size, s_size);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// variance-covariance matrix are symmetric (and semi-definite
|
||||
// positive), thus a triangular storage is sufficient
|
||||
//
|
||||
// variance-covariance matrix computation : transpose(A) * A
|
||||
//-------------------------------------------------------------
|
||||
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > var = ublas::prod( ublas::trans( sample ), sample );
|
||||
|
||||
// Be sure that the symmetric matrix got the good size
|
||||
|
||||
assert(var.size1() == s_size);
|
||||
assert(var.size2() == s_size);
|
||||
assert(var.size1() == _varcovar.size1());
|
||||
assert(var.size2() == _varcovar.size2());
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
// TODO: to remove the comment below
|
||||
|
||||
// for (unsigned int i = 0; i < s_size; ++i)
|
||||
// {
|
||||
// // triangular LOWER matrix, thus j is not going further than i
|
||||
// for (unsigned int j = 0; j <= i; ++j)
|
||||
// {
|
||||
// // we want a reducted covariance matrix
|
||||
// _varcovar(i, j) = var(i, j) / p_size;
|
||||
// }
|
||||
// }
|
||||
|
||||
_varcovar = var / p_size;
|
||||
|
||||
_mean.resize(s_size); // FIXME: check if it is really used because of the assignation below
|
||||
|
||||
// unit vector
|
||||
ublas::scalar_vector< AtomType > u( p_size, 1 );
|
||||
|
||||
// sum over columns
|
||||
_mean = ublas::prod( ublas::trans( sample ), u );
|
||||
|
||||
// division by n
|
||||
_mean /= p_size;
|
||||
}
|
||||
|
||||
const ublas::symmetric_matrix< AtomType, ublas::lower >& get_varcovar() const {return _varcovar;}
|
||||
|
||||
const ublas::vector< AtomType >& get_mean() const {return _mean;}
|
||||
|
||||
private:
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > _varcovar;
|
||||
ublas::vector< AtomType > _mean;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoNormalMulti< EOT > operator()(eoPop<EOT>& pop)
|
||||
{
|
||||
unsigned int popsize = pop.size();
|
||||
assert(popsize > 0);
|
||||
|
||||
unsigned int dimsize = pop[0].size();
|
||||
assert(dimsize > 0);
|
||||
|
||||
CovMatrix cov( pop );
|
||||
|
||||
return edoNormalMulti< EOT >( cov.get_mean(), cov.get_varcovar() );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoEstimatorNormalMulti_h
|
||||
71
edo/src/edoEstimatorUniform.h
Normal file
71
edo/src/edoEstimatorUniform.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
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 _edoEstimatorUniform_h
|
||||
#define _edoEstimatorUniform_h
|
||||
|
||||
#include "edoEstimator.h"
|
||||
#include "edoUniform.h"
|
||||
|
||||
// TODO: calcule de la moyenne + covariance dans une classe derivee
|
||||
|
||||
template < typename EOT >
|
||||
class edoEstimatorUniform : public edoEstimator< edoUniform< EOT > >
|
||||
{
|
||||
public:
|
||||
edoUniform< EOT > operator()(eoPop<EOT>& pop)
|
||||
{
|
||||
unsigned int size = pop.size();
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
EOT min = pop[0];
|
||||
EOT max = pop[0];
|
||||
|
||||
for (unsigned int i = 1; i < size; ++i)
|
||||
{
|
||||
unsigned int size = pop[i].size();
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
// possibilité d'utiliser std::min_element et std::max_element mais exige 2 pass au lieu d'1.
|
||||
|
||||
for (unsigned int d = 0; d < size; ++d)
|
||||
{
|
||||
if (pop[i][d] < min[d])
|
||||
min[d] = pop[i][d];
|
||||
|
||||
if (pop[i][d] > max[d])
|
||||
max[d] = pop[i][d];
|
||||
}
|
||||
}
|
||||
|
||||
return edoUniform< EOT >(min, max);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoEstimatorUniform_h
|
||||
41
edo/src/edoModifier.h
Normal file
41
edo/src/edoModifier.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
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 _edoModifier_h
|
||||
#define _edoModifier_h
|
||||
|
||||
template < typename D >
|
||||
class edoModifier
|
||||
{
|
||||
public:
|
||||
virtual ~edoModifier(){}
|
||||
|
||||
typedef typename D::EOType EOType;
|
||||
};
|
||||
|
||||
#endif // !_edoModifier_h
|
||||
|
||||
43
edo/src/edoModifierDispersion.h
Normal file
43
edo/src/edoModifierDispersion.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 _edoModifierDispersion_h
|
||||
#define _edoModifierDispersion_h
|
||||
|
||||
#include <eoPop.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include "edoModifier.h"
|
||||
|
||||
template < typename D >
|
||||
class edoModifierDispersion : public edoModifier< D >, public eoBF< D&, eoPop< typename D::EOType >&, void >
|
||||
{
|
||||
public:
|
||||
// virtual void operator() ( D&, eoPop< D::EOType >& )=0 (provided by eoBF< A1, A2, R >)
|
||||
};
|
||||
|
||||
#endif // !_edoModifierDispersion_h
|
||||
45
edo/src/edoModifierMass.h
Normal file
45
edo/src/edoModifierMass.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
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 _edoModifierMass_h
|
||||
#define _edoModifierMass_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include "edoModifier.h"
|
||||
|
||||
template < typename D >
|
||||
class edoModifierMass : public edoModifier< D >, public eoBF< D&, typename D::EOType&, void >
|
||||
{
|
||||
public:
|
||||
//typedef typename D::EOType::AtomType AtomType; // does not work !!!
|
||||
|
||||
// virtual void operator() ( D&, D::EOType& )=0 (provided by eoBF< A1, A2, R >)
|
||||
};
|
||||
|
||||
#endif // !_edoModifierMass_h
|
||||
|
||||
58
edo/src/edoNormalMono.h
Normal file
58
edo/src/edoNormalMono.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
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 _edoNormalMono_h
|
||||
#define _edoNormalMono_h
|
||||
|
||||
#include "edoDistrib.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoNormalMono : public edoDistrib< EOT >
|
||||
{
|
||||
public:
|
||||
edoNormalMono( const EOT& mean, const EOT& variance )
|
||||
: _mean(mean), _variance(variance)
|
||||
{
|
||||
assert(_mean.size() > 0);
|
||||
assert(_mean.size() == _variance.size());
|
||||
}
|
||||
|
||||
unsigned int size()
|
||||
{
|
||||
assert(_mean.size() == _variance.size());
|
||||
return _mean.size();
|
||||
}
|
||||
|
||||
EOT mean(){return _mean;}
|
||||
EOT variance(){return _variance;}
|
||||
|
||||
private:
|
||||
EOT _mean;
|
||||
EOT _variance;
|
||||
};
|
||||
|
||||
#endif // !_edoNormalMono_h
|
||||
47
edo/src/edoNormalMonoCenter.h
Normal file
47
edo/src/edoNormalMonoCenter.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
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 _edoNormalMonoCenter_h
|
||||
#define _edoNormalMonoCenter_h
|
||||
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoNormalMono.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoNormalMonoCenter : public edoModifierMass< edoNormalMono< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
void operator() ( edoNormalMono< EOT >& distrib, EOT& mass )
|
||||
{
|
||||
distrib.mean() = mass;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoNormalMonoCenter_h
|
||||
|
||||
51
edo/src/edoNormalMulti.h
Normal file
51
edo/src/edoNormalMulti.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// (c) Thales group, 2010
|
||||
/*
|
||||
Authors:
|
||||
Johann Dreo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoNormalMulti_h
|
||||
#define _edoNormalMulti_h
|
||||
|
||||
#include <boost/numeric/ublas/symmetric.hpp>
|
||||
#include <boost/numeric/ublas/lu.hpp>
|
||||
|
||||
#include "edoDistrib.h"
|
||||
|
||||
namespace ublas = boost::numeric::ublas;
|
||||
|
||||
template < typename EOT >
|
||||
class edoNormalMulti : public edoDistrib< EOT >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoNormalMulti
|
||||
(
|
||||
const ublas::vector< AtomType >& mean,
|
||||
const ublas::symmetric_matrix< AtomType, ublas::lower >& varcovar
|
||||
)
|
||||
: _mean(mean), _varcovar(varcovar)
|
||||
{
|
||||
assert(_mean.size() > 0);
|
||||
assert(_mean.size() == _varcovar.size1());
|
||||
assert(_mean.size() == _varcovar.size2());
|
||||
}
|
||||
|
||||
unsigned int size()
|
||||
{
|
||||
assert(_mean.size() == _varcovar.size1());
|
||||
assert(_mean.size() == _varcovar.size2());
|
||||
return _mean.size();
|
||||
}
|
||||
|
||||
ublas::vector< AtomType > mean() const {return _mean;}
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > varcovar() const {return _varcovar;}
|
||||
|
||||
private:
|
||||
ublas::vector< AtomType > _mean;
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > _varcovar;
|
||||
};
|
||||
|
||||
#endif // !_edoNormalMulti_h
|
||||
48
edo/src/edoNormalMultiCenter.h
Normal file
48
edo/src/edoNormalMultiCenter.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
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 _edoNormalMultiCenter_h
|
||||
#define _edoNormalMultiCenter_h
|
||||
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoNormalMulti.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoNormalMultiCenter : public edoModifierMass< edoNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
void operator() ( edoNormalMulti< EOT >& distrib, EOT& mass )
|
||||
{
|
||||
ublas::vector< AtomType > mean( distrib.size() );
|
||||
std::copy( mass.begin(), mass.end(), mean.begin() );
|
||||
distrib.mean() = mean;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoNormalMultiCenter_h
|
||||
95
edo/src/edoSampler.h
Normal file
95
edo/src/edoSampler.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
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 _edoSampler_h
|
||||
#define _edoSampler_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include "edoBounder.h"
|
||||
#include "edoBounderNo.h"
|
||||
|
||||
template < typename D >
|
||||
class edoSampler : public eoUF< D&, typename D::EOType >
|
||||
{
|
||||
public:
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
edoSampler(edoBounder< EOType > & bounder)
|
||||
: /*_dummy_bounder(),*/ _bounder(bounder)
|
||||
{}
|
||||
|
||||
/*
|
||||
edoSampler()
|
||||
: _dummy_bounder(), _bounder( _dummy_bounder )
|
||||
{}
|
||||
*/
|
||||
|
||||
// virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >)
|
||||
|
||||
virtual EOType sample( D& ) = 0;
|
||||
|
||||
EOType operator()( D& distrib )
|
||||
{
|
||||
unsigned int size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Point we want to sample to get higher a set of points
|
||||
// (coordinates in n dimension)
|
||||
// x = {x1, x2, ..., xn}
|
||||
// the sample method is implemented in the derivated class
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOType solution(sample(distrib));
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Now we are bounding the distribution thanks to min and max
|
||||
// parameters.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_bounder(solution);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
return solution;
|
||||
}
|
||||
|
||||
private:
|
||||
//edoBounderNo<EOType> _dummy_bounder;
|
||||
|
||||
//! Bounder functor
|
||||
edoBounder< EOType > & _bounder;
|
||||
|
||||
};
|
||||
|
||||
#endif // !_edoSampler_h
|
||||
91
edo/src/edoSamplerNormalMono.h
Normal file
91
edo/src/edoSamplerNormalMono.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
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 _edoSamplerNormalMono_h
|
||||
#define _edoSamplerNormalMono_h
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edoSampler.h"
|
||||
#include "edoNormalMono.h"
|
||||
#include "edoBounder.h"
|
||||
|
||||
/**
|
||||
* edoSamplerNormalMono
|
||||
* This class uses the NormalMono distribution parameters (bounds) to return
|
||||
* a random position used for population sampling.
|
||||
*/
|
||||
template < typename EOT >
|
||||
class edoSamplerNormalMono : public edoSampler< edoNormalMono< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoSamplerNormalMono( edoBounder< EOT > & bounder )
|
||||
: edoSampler< edoNormalMono< EOT > >( bounder )
|
||||
{}
|
||||
|
||||
EOT sample( edoNormalMono< EOT >& distrib )
|
||||
{
|
||||
unsigned int size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Point we want to sample to get higher a set of points
|
||||
// (coordinates in n dimension)
|
||||
// x = {x1, x2, ..., xn}
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT solution;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Sampling all dimensions
|
||||
//-------------------------------------------------------------
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
{
|
||||
AtomType mean = distrib.mean()[i];
|
||||
AtomType variance = distrib.variance()[i];
|
||||
AtomType random = rng.normal(mean, variance);
|
||||
|
||||
assert(variance >= 0);
|
||||
|
||||
solution.push_back(random);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
return solution;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoSamplerNormalMono_h
|
||||
174
edo/src/edoSamplerNormalMulti.h
Normal file
174
edo/src/edoSamplerNormalMulti.h
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
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 _edoSamplerNormalMulti_h
|
||||
#define _edoSamplerNormalMulti_h
|
||||
|
||||
#include <edoSampler.h>
|
||||
#include <boost/numeric/ublas/lu.hpp>
|
||||
#include <boost/numeric/ublas/symmetric.hpp>
|
||||
|
||||
template< class EOT >
|
||||
class edoSamplerNormalMulti : public edoSampler< edoNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
class Cholesky
|
||||
{
|
||||
public:
|
||||
Cholesky( const ublas::symmetric_matrix< AtomType, ublas::lower >& V)
|
||||
{
|
||||
unsigned int Vl = V.size1();
|
||||
|
||||
assert(Vl > 0);
|
||||
|
||||
unsigned int Vc = V.size2();
|
||||
|
||||
assert(Vc > 0);
|
||||
|
||||
assert( Vl == Vc );
|
||||
|
||||
_L.resize(Vl, Vc);
|
||||
|
||||
unsigned int i,j,k;
|
||||
|
||||
// first column
|
||||
i=0;
|
||||
|
||||
// diagonal
|
||||
j=0;
|
||||
_L(0, 0) = sqrt( V(0, 0) );
|
||||
|
||||
// end of the column
|
||||
for ( j = 1; j < Vc; ++j )
|
||||
{
|
||||
_L(j, 0) = V(0, j) / _L(0, 0);
|
||||
}
|
||||
|
||||
// end of the matrix
|
||||
for ( i = 1; i < Vl; ++i ) // each column
|
||||
{
|
||||
|
||||
// diagonal
|
||||
double sum = 0.0;
|
||||
|
||||
for ( k = 0; k < i; ++k)
|
||||
{
|
||||
sum += _L(i, k) * _L(i, k);
|
||||
}
|
||||
|
||||
_L(i,i) = sqrt( fabs( V(i,i) - sum) );
|
||||
|
||||
for ( j = i + 1; j < Vl; ++j ) // rows
|
||||
{
|
||||
// one element
|
||||
sum = 0.0;
|
||||
|
||||
for ( k = 0; k < i; ++k )
|
||||
{
|
||||
sum += _L(j, k) * _L(i, k);
|
||||
}
|
||||
|
||||
_L(j, i) = (V(j, i) - sum) / _L(i, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ublas::symmetric_matrix< AtomType, ublas::lower >& get_L() const {return _L;}
|
||||
|
||||
private:
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > _L;
|
||||
};
|
||||
|
||||
edoSamplerNormalMulti( edoBounder< EOT > & bounder )
|
||||
: edoSampler< edoNormalMulti< EOT > >( bounder )
|
||||
{}
|
||||
|
||||
EOT sample( edoNormalMulti< EOT >& distrib )
|
||||
{
|
||||
unsigned int size = distrib.size();
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Cholesky factorisation gererating matrix L from covariance
|
||||
// matrix V.
|
||||
// We must use cholesky.get_L() to get the resulting matrix.
|
||||
//
|
||||
// L = cholesky decomposition of varcovar
|
||||
//-------------------------------------------------------------
|
||||
|
||||
Cholesky cholesky( distrib.varcovar() );
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > L = cholesky.get_L();
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// T = vector of size elements drawn in N(0,1) rng.normal(1.0)
|
||||
//-------------------------------------------------------------
|
||||
|
||||
ublas::vector< AtomType > T( size );
|
||||
|
||||
for ( unsigned int i = 0; i < size; ++i )
|
||||
{
|
||||
T( i ) = rng.normal( 1.0 );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// LT = prod( L, T )
|
||||
//-------------------------------------------------------------
|
||||
|
||||
ublas::vector< AtomType > LT = ublas::prod( L, T );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// solution = means + LT
|
||||
//-------------------------------------------------------------
|
||||
|
||||
ublas::vector< AtomType > mean = distrib.mean();
|
||||
|
||||
ublas::vector< AtomType > ublas_solution = mean + LT;
|
||||
|
||||
EOT solution( size );
|
||||
|
||||
std::copy( ublas_solution.begin(), ublas_solution.end(), solution.begin() );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
return solution;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoSamplerNormalMulti_h
|
||||
96
edo/src/edoSamplerUniform.h
Normal file
96
edo/src/edoSamplerUniform.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
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 _edoSamplerUniform_h
|
||||
#define _edoSamplerUniform_h
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edoSampler.h"
|
||||
#include "edoUniform.h"
|
||||
|
||||
/**
|
||||
* edoSamplerUniform
|
||||
* This class uses the Uniform distribution parameters (bounds) to return
|
||||
* a random position used for population sampling.
|
||||
*/
|
||||
template < typename EOT, class D=edoUniform<EOT> > // FIXME: D template name is there really used ?!?
|
||||
class edoSamplerUniform : public edoSampler< edoUniform< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef D Distrib;
|
||||
|
||||
edoSamplerUniform(edoBounder< EOT > & bounder)
|
||||
: edoSampler< edoUniform<EOT> >(bounder) // FIXME: Why D is not used here ?
|
||||
{}
|
||||
|
||||
/*
|
||||
edoSamplerUniform()
|
||||
: edoSampler< edoUniform<EOT> >()
|
||||
{}
|
||||
*/
|
||||
|
||||
EOT sample( edoUniform< EOT >& distrib )
|
||||
{
|
||||
unsigned int size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Point we want to sample to get higher a set of points
|
||||
// (coordinates in n dimension)
|
||||
// x = {x1, x2, ..., xn}
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT solution;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Sampling all dimensions
|
||||
//-------------------------------------------------------------
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
{
|
||||
double min = distrib.min()[i];
|
||||
double max = distrib.max()[i];
|
||||
double random = rng.uniform(min, max);
|
||||
|
||||
assert(min <= random && random <= max);
|
||||
|
||||
solution.push_back(random);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
return solution;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoSamplerUniform_h
|
||||
43
edo/src/edoUniform.h
Normal file
43
edo/src/edoUniform.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 _edoUniform_h
|
||||
#define _edoUniform_h
|
||||
|
||||
#include "edoDistrib.h"
|
||||
#include "edoVectorBounds.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoUniform : public edoDistrib< EOT >, public edoVectorBounds< EOT >
|
||||
{
|
||||
public:
|
||||
edoUniform(EOT min, EOT max)
|
||||
: edoVectorBounds< EOT >(min, max)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif // !_edoUniform_h
|
||||
55
edo/src/edoUniformCenter.h
Normal file
55
edo/src/edoUniformCenter.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 _edoUniformCenter_h
|
||||
#define _edoUniformCenter_h
|
||||
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoUniform.h"
|
||||
|
||||
template < typename EOT >
|
||||
class edoUniformCenter : public edoModifierMass< edoUniform< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
void operator() ( edoUniform< EOT >& distrib, EOT& mass )
|
||||
{
|
||||
for (unsigned int i = 0, n = mass.size(); i < n; ++i)
|
||||
{
|
||||
AtomType& min = distrib.min()[i];
|
||||
AtomType& max = distrib.max()[i];
|
||||
|
||||
AtomType range = (max - min) / 2;
|
||||
|
||||
min = mass[i] - range;
|
||||
max = mass[i] + range;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_edoUniformCenter_h
|
||||
56
edo/src/edoVectorBounds.h
Normal file
56
edo/src/edoVectorBounds.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
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 _edoVectorBounds_h
|
||||
#define _edoVectorBounds_h
|
||||
|
||||
template < typename EOT >
|
||||
class edoVectorBounds
|
||||
{
|
||||
public:
|
||||
edoVectorBounds(EOT min, EOT max)
|
||||
: _min(min), _max(max)
|
||||
{
|
||||
assert(_min.size() > 0);
|
||||
assert(_min.size() == _max.size());
|
||||
}
|
||||
|
||||
EOT min(){return _min;}
|
||||
EOT max(){return _max;}
|
||||
|
||||
unsigned int size()
|
||||
{
|
||||
assert(_min.size() == _max.size());
|
||||
return _min.size();
|
||||
}
|
||||
|
||||
private:
|
||||
EOT _min;
|
||||
EOT _max;
|
||||
};
|
||||
|
||||
#endif // !_edoVectorBounds_h
|
||||
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
|
||||
Reference in a new issue