OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SampleSequence.h
Go to the documentation of this file.
1 #ifndef OPAL_SAMPLE_SEQUENCE_H
2 #define OPAL_SAMPLE_SEQUENCE_H
3 
5 
6 template <typename T>
8 {
9  // provides a sequence of equidistant sampling points. It
10  // can't be garanteed that the sampling is equidistant if
11  // an integer type is chosen and the difference between
12  // the upper and lower limit isn't divisible by the number
13  // of sampling points.
14 
15 public:
16 
17  SampleSequence(T lower, T upper, size_t modulo, int nSample)
18  : lowerLimit_m(lower)
19  , stepSize_m( (upper - lower) / double(nSample - 1) )
20  , numSamples_m(nSample)
21  , volumeLowerDimensions_m(modulo)
22  { }
23 
24  void create(boost::shared_ptr<SampleIndividual>& ind, size_t i) {
25 
26  unsigned int id = ind->id;
27 
28  int bin = int(id / volumeLowerDimensions_m) % numSamples_m;
29 
30  ind->genes[i] = static_cast<T>(lowerLimit_m + stepSize_m * bin);
31  }
32 
33 private:
35  double stepSize_m;
36  unsigned int numSamples_m; // size of this "dimension"
37  size_t volumeLowerDimensions_m; // the "volume" of the sampling space of the lower "dimensions"
38 };
39 
40 #endif
Definition: rbendmap.h:8
size_t volumeLowerDimensions_m
void create(boost::shared_ptr< SampleIndividual > &ind, size_t i)
SampleSequence(T lower, T upper, size_t modulo, int nSample)
unsigned int numSamples_m