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
42 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
|
||||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue