OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SampleRandomizedSequence.h
Go to the documentation of this file.
1 #ifndef OPAL_SAMPLE_WEIGHTED_SEQUENCE_H
2 #define OPAL_SAMPLE_WEIGHTED_SEQUENCE_H
3 
4 #include "Sample/Uniform.h"
5 
6 template <typename T>
8 {
9 
10 public:
11 
12  SampleRandomizedSequence(T lower, T upper, double step)
13  : unif_m(0, size_t((upper - lower) / step))
14  , lower_m(lower)
15  , step_m(step)
16  { }
17 
18  SampleRandomizedSequence(T lower, T upper, double step, size_t seed)
19  : unif_m(0, size_t((upper - lower) / step), seed)
20  , lower_m(lower)
21  , step_m(step)
22  { }
23 
24  void create(boost::shared_ptr<SampleIndividual>& ind, size_t i) {
25  size_t idx = unif_m.getNext();
26  ind->genes[i] = static_cast<T>(lower_m + idx * step_m);
27  }
28 
29  void allocate(const CmdArguments_t& args, const Comm::Bundle_t& comm) {
30  unif_m.allocate(args, comm);
31  }
32 
33 private:
34  std::vector<T> points_m;
37  double step_m;
38 };
39 
40 #endif
int seed
The current random seed.
Definition: Options.cpp:41
Definition: rbendmap.h:8
boost::shared_ptr< CmdArguments > CmdArguments_t
Definition: CmdArguments.h:169
SampleRandomizedSequence(T lower, T upper, double step)
void allocate(const CmdArguments_t &args, const Comm::Bundle_t &comm)
Definition: Uniform.h:41
T getNext()
Definition: Uniform.h:46
void allocate(const CmdArguments_t &args, const Comm::Bundle_t &comm)
void create(boost::shared_ptr< SampleIndividual > &ind, size_t i)
bundles all communicators for a specific role/pid
Definition: types.h:14
SampleRandomizedSequence(T lower, T upper, double step, size_t seed)