Merge branch 'mo-1.3' of candan.fr:do into mo-1.3
This commit is contained in:
commit
965120ffc2
2 changed files with 54 additions and 3 deletions
35
src/doBounderUniform.h
Normal file
35
src/doBounderUniform.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// (c) Thales group, 2010
|
||||
/*
|
||||
Authors:
|
||||
Johann Dreo <johann.dreo@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _doBounderUniform_h
|
||||
#define _doBounderUniform_h
|
||||
|
||||
#include "doBounder.h"
|
||||
|
||||
template < typename EOT >
|
||||
class doBounderUniform : public doBounder< EOT >
|
||||
{
|
||||
public:
|
||||
doBounderUniform( EOT min, EOT max )
|
||||
: doBounder< 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 // !_doBounderUniform_h
|
||||
|
|
@ -22,14 +22,23 @@ public:
|
|||
|
||||
CovMatrix( const eoPop< EOT >& pop )
|
||||
{
|
||||
unsigned int p_size = pop.size(); // population size
|
||||
//-------------------------------------------------------------
|
||||
// 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)
|
||||
|
|
@ -40,6 +49,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_varcovar.resize(s_size, s_size);
|
||||
|
||||
|
||||
|
|
@ -52,6 +64,8 @@ public:
|
|||
|
||||
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());
|
||||
|
|
@ -60,6 +74,8 @@ public:
|
|||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
// 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
|
||||
|
|
@ -72,7 +88,7 @@ public:
|
|||
|
||||
_varcovar = var / p_size;
|
||||
|
||||
_mean.resize(s_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 );
|
||||
|
|
|
|||
Reference in a new issue