OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
SampleSequence.h
Go to the documentation of this file.
1
//
2
// Class SampleSequence
3
// This class provides a sequence of equidistant sampling points. It
4
// can't be garanteed that the sampling is equidistant if
5
// an integer type is chosen and the difference between
6
// the upper and lower limit isn't divisible by the number
7
// of sampling points.
8
//
9
// Copyright (c) 2018, Christof Metzger-Kraus, Open Sourcerer
10
// All rights reserved
11
//
12
// This file is part of OPAL.
13
//
14
// OPAL is free software: you can redistribute it and/or modify
15
// it under the terms of the GNU General Public License as published by
16
// the Free Software Foundation, either version 3 of the License, or
17
// (at your option) any later version.
18
//
19
// You should have received a copy of the GNU General Public License
20
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21
//
22
#ifndef OPAL_SAMPLE_SEQUENCE_H
23
#define OPAL_SAMPLE_SEQUENCE_H
24
25
#include "
Sample/SamplingMethod.h
"
26
27
template
<
typename
T>
28
class
SampleSequence
:
public
SamplingMethod
29
{
30
31
public
:
32
33
SampleSequence
(T lower, T upper,
size_t
modulo,
int
nSample)
34
:
lowerLimit_m
(lower)
35
,
stepSize_m
( (upper - lower) / double(nSample - 1) )
36
,
numSamples_m
(nSample)
37
,
volumeLowerDimensions_m
(modulo)
38
{ }
39
40
void
create
(std::shared_ptr<SampleIndividual>& ind,
size_t
i) {
41
42
unsigned
int
id
= ind->id;
43
44
int
bin = int(
id
/
volumeLowerDimensions_m
) %
numSamples_m
;
45
46
ind->genes[i] =
static_cast<
T
>
(
lowerLimit_m
+
stepSize_m
* bin);
47
}
48
49
private
:
50
T
lowerLimit_m
;
51
double
stepSize_m
;
52
unsigned
int
numSamples_m
;
// size of this "dimension"
53
size_t
volumeLowerDimensions_m
;
// the "volume" of the sampling space of the lower "dimensions"
54
};
55
56
#endif
SamplingMethod.h
SampleSequence::lowerLimit_m
T lowerLimit_m
Definition
SampleSequence.h:50
SampleSequence::SampleSequence
SampleSequence(T lower, T upper, size_t modulo, int nSample)
Definition
SampleSequence.h:33
SampleSequence::volumeLowerDimensions_m
size_t volumeLowerDimensions_m
Definition
SampleSequence.h:53
SampleSequence::stepSize_m
double stepSize_m
Definition
SampleSequence.h:51
SampleSequence::create
void create(std::shared_ptr< SampleIndividual > &ind, size_t i)
Definition
SampleSequence.h:40
SampleSequence::numSamples_m
unsigned int numSamples_m
Definition
SampleSequence.h:52
SamplingMethod
Definition
SamplingMethod.h:33