OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Normal.h
Go to the documentation of this file.
1 #ifndef OPAL_NORMAL_RANDOM_SAMPLING_H
2 #define OPAL_NORMAL_RANDOM_SAMPLING_H
3 
5 #include "Sample/RNGStream.h"
6 
7 #include <type_traits>
8 
9 class Normal : public SamplingMethod
10 {
11 
12 public:
13  typedef std::normal_distribution<double> dist_t;
14 
15 
16  Normal(double lower, double upper)
17  : dist_m(0.5 * (lower + upper), (upper - lower) / 10)
18  , RNGInstance_m(RNGStream::getInstance())
19  , seed_m(RNGStream::getGlobalSeed())
20  {}
21 
22  Normal(double lower, double upper, std::size_t seed)
23  : dist_m(0.5 * (lower + upper), (upper - lower) / 10)
24  , RNGInstance_m(nullptr)
25  , seed_m(seed)
26  {}
27 
28  ~Normal() {
29  if ( RNGInstance_m)
31  }
32 
33  void create(boost::shared_ptr<SampleIndividual>& ind, size_t i) {
34  ind->genes[i] = RNGInstance_m->getNext(dist_m);
35  }
36 
37  void allocate(const CmdArguments_t& args, const Comm::Bundle_t& comm) {
38  if ( !RNGInstance_m )
40  }
41 
42 private:
44 
46 
47  std::size_t seed_m;
48 };
49 
50 #endif
int seed
The current random seed.
Definition: Options.cpp:41
RNGStream * RNGInstance_m
Definition: Normal.h:45
int island_id
Definition: types.h:15
boost::shared_ptr< CmdArguments > CmdArguments_t
Definition: CmdArguments.h:169
~Normal()
Definition: Normal.h:28
Normal(double lower, double upper)
Definition: Normal.h:16
Definition: Normal.h:9
void create(boost::shared_ptr< SampleIndividual > &ind, size_t i)
Definition: Normal.h:33
Normal(double lower, double upper, std::size_t seed)
Definition: Normal.h:22
std::normal_distribution< double > dist_t
Definition: Normal.h:13
void allocate(const CmdArguments_t &args, const Comm::Bundle_t &comm)
Definition: Normal.h:37
static void deleteInstance(RNGStream *&generator)
Definition: RNGStream.cpp:21
std::size_t seed_m
Definition: Normal.h:47
DISTR::result_type getNext(DISTR &RNGDist)
Definition: RNGStream.h:20
static RNGStream * getInstance()
Definition: RNGStream.cpp:9
bundles all communicators for a specific role/pid
Definition: types.h:14
dist_t dist_m
Definition: Normal.h:43