OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalSample.h
Go to the documentation of this file.
1//
2// Class OpalSample
3// The SAMPLING definition.
4// A SAMPLING definition is used to run the optimizer in sample mode.
5//
6// Copyright (c) 2018, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
7// All rights reserved
8//
9// Implemented as part of the PhD thesis
10// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
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_H
23#define OPAL_SAMPLE_H
24
27
28#include <memory>
29#include <string>
30
31class OpalSample: public Definition {
32
33public:
35 OpalSample();
36
37 virtual ~OpalSample() {};
38
40 virtual OpalSample* clone(const std::string& name);
41
43 virtual void execute();
44
46 static OpalSample* find(const std::string& name);
47
48 void initialize(const std::string& dvarName,
49 double lower,
50 double upper,
51 size_t modulo = 1,
52 bool sequence = false);
53
54 std::string getVariable() const;
55
56 unsigned int getSize() const;
57
58 std::shared_ptr<SamplingMethod> sampleMethod_m;
59
60private:
61 enum class OpalSampleMethod: unsigned short {
62 UNIFORM_INT,
63 UNIFORM,
64 GAUSSIAN,
66 LATIN_HYPERCUBE,
67 RANDOM_SEQUENCE_UNIFORM_INT,
68 RANDOM_SEQUENCE_UNIFORM
69 };
70
72 OpalSample (const OpalSample&) = delete;
73 void operator=(const OpalSample&) = delete;
76 OpalSample(const std::string& name, OpalSample* parent);
77
78 unsigned int size_m;
79};
80
81inline
82unsigned int OpalSample::getSize() const{
83 return size_m;
84}
85#endif
const std::string name
The base class for all OPAL definitions.
Definition: Definition.h:30
static OpalSample * find(const std::string &name)
Find sampling method.
Definition: OpalSample.cpp:104
void initialize(const std::string &dvarName, double lower, double upper, size_t modulo=1, bool sequence=false)
Definition: OpalSample.cpp:115
void operator=(const OpalSample &)=delete
unsigned int getSize() const
Definition: OpalSample.h:82
std::shared_ptr< SamplingMethod > sampleMethod_m
Definition: OpalSample.h:58
unsigned int size_m
Definition: OpalSample.h:78
virtual void execute()
Check the OpalSample data.
Definition: OpalSample.cpp:99
virtual OpalSample * clone(const std::string &name)
Make clone.
Definition: OpalSample.cpp:94
virtual ~OpalSample()
Definition: OpalSample.h:37
OpalSample(const OpalSample &)=delete
Not implemented.
std::string getVariable() const
Definition: OpalSample.cpp:232
OpalSample()
Exemplar constructor.
Definition: OpalSample.cpp:52