Merge branch 'mo-1.3' of git:do into mo-1.3
This commit is contained in:
commit
6a613bc4a1
1 changed files with 35 additions and 0 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue