36#include <unordered_map>
54 "The \"SAMPLING\" statement defines methods used for the optimizer in sample mode.")
58 (
"TYPE",
"Distribution type.",
64 "RANDOM_SEQUENCE_UNIFORM_INT",
65 "RANDOM_SEQUENCE_UNIFORM"});
68 (
"VARIABLE",
"Name of design variable");
71 (
"SEED",
"seed for random sampling");
74 (
"FNAME",
"File to read from the sampling points");
77 (
"N",
"Number of sampling points", 1);
80 (
"RANDOM",
"Whether sequence should be sampled randomly (default: false)",
false);
83 (
"STEP",
"Increment for randomized sequences (default: 1)", 1.0);
107 if (sampling ==
nullptr) {
109 "OpalSample \"" +
name +
"\" not found.");
116 double lower,
double upper,
117 size_t modulo,
bool ) {
119 if ( lower >= upper ) {
121 "Lower bound >= upper bound.");
124 static const std::unordered_map<std::string, OpalSampleMethod> stringOpalSampleMethod_s = {
136 "The attribute \"TYPE\" isn't set for the \"SAMPLING\" statement");
157 "The sampling method \"TYPE=" +
type +
"\" is not supported out of random sampling mode");
225 "Invalid \"TYPE\" for the \"SAMPLING\" statement");
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
int seed
The current random seed.
boost::function< boost::tuple< double, bool >(arguments_t)> type
double FromFile(std::string file, const std::vector< double > &referencePoint)
The base class for all OPAL definitions.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
std::vector< Attribute > itsAttr
The object attributes.
Object * find(const std::string &name)
Find entry.
static OpalData * getInstance()
static OpalSample * find(const std::string &name)
Find sampling method.
void initialize(const std::string &dvarName, double lower, double upper, size_t modulo=1, bool sequence=false)
unsigned int getSize() const
std::shared_ptr< SamplingMethod > sampleMethod_m
virtual void execute()
Check the OpalSample data.
virtual OpalSample * clone(const std::string &name)
Make clone.
@ RANDOM_SEQUENCE_UNIFORM
@ RANDOM_SEQUENCE_UNIFORM_INT
std::string getVariable() const
OpalSample()
Exemplar constructor.
The base class for all OPAL exceptions.