8 #ifndef SOT_EXPERIMENTAL_DESIGN_H 9 #define SOT_EXPERIMENTAL_DESIGN_H 13 #include "merit_functions.h" 34 virtual int dim()
const = 0;
66 mNumPoints = points.n_cols;
138 mat points = arma::zeros<mat>(mDim, mNumPoints);
139 points.row(0) = arma::linspace<vec>(1, mNumPoints, mNumPoints).t();
141 int middleInd = mNumPoints/2;
143 if (mNumPoints % 2 == 1) {
144 points.col(middleInd).fill(middleInd + 1);
148 for(
int j=1; j < mDim; j++) {
149 for(
int i=0; i < middleInd; i++) {
151 points(j, i) = mNumPoints -i;
154 points(j, i) = i + 1;
158 points(j, arma::span(0, middleInd - 1)) = arma::shuffle(points(j, arma::span(0, middleInd - 1)));
162 for(
int i=middleInd; i < mNumPoints; i++) {
163 points.col(i) = mNumPoints + 1 - points.col(mNumPoints - 1 - i);
166 return points/double(mNumPoints);
216 double bestScore = 0;
219 for(
int iter=0; iter < 100; iter++) {
220 X = arma::zeros(mDim, mNumPoints);
221 vec xvec = (arma::linspace<vec>(1, mNumPoints, mNumPoints) - 0.5) / mNumPoints;
223 for(
int j=0; j < mDim; j++) {
224 X.row(j) = xvec(arma::shuffle(arma::linspace<uvec>(0, mNumPoints - 1, mNumPoints))).t();
228 double score = arma::min((
vec)arma::min(dists).t());
230 if (score > bestScore) {
260 mNumPoints = pow(2, dim);
262 if(dim >= 15) {
throw std::logic_error(
"Using 2-Factorial for dim >= 15 is a bad idea"); }
283 mat xSample = arma::zeros<mat>(mDim, mNumPoints);
284 for(
int i=0; i < mDim; i++) {
286 int flip = pow(2, i);
287 for(
int j=0; j < mNumPoints; j++) {
288 xSample(i, j) = elem;
289 if((j+1) % flip == 0) { elem = (elem + 1) % 2; }
315 mNumPoints = 1 + pow(2, dim);
317 if(dim >= 15) {
throw std::logic_error(
"Using Corners + Mid for dim >= 15 is a bad idea"); }
338 mat xSample = arma::zeros<mat>(mDim, mNumPoints);
340 for(
int i=0; i < mDim; i++) {
342 int flip = pow(2, i);
343 for(
int j = 0; j < mNumPoints; j++) {
344 xSample(i, j) = elem;
345 if((j + 1) % flip == 0) { elem = (elem + 1) % 2; }
348 xSample.col(mNumPoints - 1).fill(0.5);
mat generatePoints() const
Method that returns the user supplied experimental design.
Definition: experimental_design.h:86
arma::vec vec
Default (column) vector class.
Definition: common.h:17
int numPoints() const
Method for getting the number of points in the experimental design.
Definition: experimental_design.h:206
int numPoints() const
Method for getting the number of points in the experimental design.
Definition: experimental_design.h:130
int mDim
Definition: experimental_design.h:252
virtual mat generatePoints() const =0
Virtual method for generating an experimental design.
Latin hypercube design.
Definition: experimental_design.h:181
int mDim
Definition: experimental_design.h:106
mat mPoints
Definition: experimental_design.h:57
int dim() const
Method for getting the number of dimensions.
Definition: experimental_design.h:323
2-Factorial design
Definition: experimental_design.h:250
int mNumPoints
Definition: experimental_design.h:184
FixedDesign(mat &points)
Constructor.
Definition: experimental_design.h:63
CornersMid(int dim)
Constructor.
Definition: experimental_design.h:314
int mNumPoints
Definition: experimental_design.h:253
double rand()
Generate a U[0,1] realization.
Definition: utils.h:386
int mNumPoints
Definition: experimental_design.h:308
mat generatePoints() const
Method that generates a symmetric Latin hypercube design.
Definition: experimental_design.h:137
int dim() const
Method for getting the number of dimensions.
Definition: experimental_design.h:72
mat generatePoints() const
Method that generates a symmetric Latin hypercube design.
Definition: experimental_design.h:213
mat generatePoints() const
Method that generates a symmetric Latin hypercube design.
Definition: experimental_design.h:337
int mDim
Definition: experimental_design.h:307
MatType squaredPairwiseDistance(const MatType &X, const MatType &Y)
Fast level-3 distance computation between two sets of points.
Definition: utils.h:48
int numPoints() const
Method for getting the number of points in the experimental design.
Definition: experimental_design.h:275
virtual int numPoints() const =0
Virtual method for getting the number of points in the experimental design.
int mDim
Definition: experimental_design.h:183
Abstract class for a SOT experimental design class.
Definition: experimental_design.h:31
LatinHypercube(int numPoints, int dim)
Constructor.
Definition: experimental_design.h:191
Fixed experimental design.
Definition: experimental_design.h:53
int numPoints() const
Method for getting the number of points in the experimental design.
Definition: experimental_design.h:330
int mNumPoints
Definition: experimental_design.h:56
int numPoints() const
Method for getting the number of points in the experimental design.
Definition: experimental_design.h:79
int dim() const
Method for getting the number of dimensions.
Definition: experimental_design.h:123
int dim() const
Method for getting the number of dimensions.
Definition: experimental_design.h:268
Symmetric Latin hypercube design.
Definition: experimental_design.h:104
virtual int dim() const =0
Virtual method for getting the number of dimensions.
SOT namespace.
Definition: sot.h:27
Corners + Midpoint.
Definition: experimental_design.h:305
mat generatePoints() const
Method that generates a symmetric Latin hypercube design.
Definition: experimental_design.h:282
int mNumPoints
Definition: experimental_design.h:107
TwoFactorial(int dim)
Constructor.
Definition: experimental_design.h:259
arma::mat mat
Default matrix class.
Definition: common.h:16
int mDim
Definition: experimental_design.h:55
int dim() const
Method for getting the number of dimensions.
Definition: experimental_design.h:199
SymmetricLatinHypercube(int numPoints, int dim)
Constructor.
Definition: experimental_design.h:115