code formating
This commit is contained in:
parent
c7d060efc0
commit
37a2c68b69
4 changed files with 142 additions and 192 deletions
|
|
@ -30,7 +30,7 @@ Authors:
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include "edoBounder.h"
|
||||
#include "edoRepairer.h"
|
||||
#include "edoBounderNo.h"
|
||||
|
||||
//! edoSampler< D >
|
||||
|
|
@ -41,15 +41,15 @@ class edoSampler : public eoUF< D&, typename D::EOType >
|
|||
public:
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
edoSampler(edoBounder< EOType > & bounder)
|
||||
: /*_dummy_bounder(),*/ _bounder(bounder)
|
||||
edoSampler(edoRepairer< EOType > & repairer)
|
||||
: _dummy_repairer(), _repairer(repairer)
|
||||
{}
|
||||
|
||||
/*
|
||||
|
||||
edoSampler()
|
||||
: _dummy_bounder(), _bounder( _dummy_bounder )
|
||||
: _dummy_repairer(), _repairer( _dummy_repairer )
|
||||
{}
|
||||
*/
|
||||
|
||||
|
||||
// virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >)
|
||||
|
||||
|
|
@ -58,28 +58,15 @@ public:
|
|||
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);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_repairer(solution);
|
||||
|
||||
return solution;
|
||||
}
|
||||
|
|
@ -89,10 +76,10 @@ protected:
|
|||
virtual EOType sample( D& ) = 0;
|
||||
|
||||
private:
|
||||
//edoBounderNo<EOType> _dummy_bounder;
|
||||
edoBounderNo<EOType> _dummy_repairer;
|
||||
|
||||
//! Bounder functor
|
||||
edoBounder< EOType > & _bounder;
|
||||
//! repairer functor
|
||||
edoRepairer< EOType > & _repairer;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,31 +45,19 @@ class edoSamplerNormalMono : public edoSampler< edoNormalMono< EOT > >
|
|||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoSamplerNormalMono( edoBounder< EOT > & bounder )
|
||||
: edoSampler< edoNormalMono< EOT > >( bounder )
|
||||
{}
|
||||
edoSamplerNormalMono( edoRepairer<EOT> & repairer ) : edoSampler( repairer) {}
|
||||
|
||||
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];
|
||||
|
|
@ -81,9 +69,6 @@ public:
|
|||
solution.push_back(random);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
return solution;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ class edoSamplerNormalMulti : public edoSampler< edoNormalMulti< EOT > >
|
|||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoSamplerNormalMulti( edoRepairer<EOT> & repairer ) : edoSampler( repairer) {}
|
||||
|
||||
class Cholesky
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -44,51 +44,27 @@ 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> >()
|
||||
{}
|
||||
*/
|
||||
edoSamplerUniform( edoRepairer<EOT> & repairer ) : edoSampler( repairer) {}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Reference in a new issue