14 #include "surrogate.h" 49 mMaxPoints = maxPoints;
52 mX.resize(dim, maxPoints);
53 mfX.resize(maxPoints);
65 return mX.cols(0, mNumPoints-1);
67 double fX(
int i)
const {
71 return mfX.rows(0, mNumPoints-1);
82 if(mNumPoints >= mMaxPoints) {
83 throw std::logic_error(
"Capacity exceeded");
85 mX.col(mNumPoints) = point;
86 mfX(mNumPoints) = funVal;
98 int n = points.n_cols;
101 throw std::logic_error(
"Use add_point instead");
103 if(mNumPoints + n > mMaxPoints) {
104 throw std::logic_error(
"Capacity exceeded");
107 mX.cols(mNumPoints, mNumPoints + n - 1) = points;
108 mfX.rows(mNumPoints, mNumPoints + n - 1) = funVals;
113 vec dists = squaredPointSetDistance<mat,vec>(point,
X());
116 double scores = dists.min(closest);
120 vec weights = arma::pow(dists, -mp/2.0);
121 return arma::dot(weights,
fX())/arma::sum(weights);
130 vec vals = arma::zeros<vec>(points.n_cols);
131 for(
int i=0; i < points.n_cols; i++) {
132 vals(i) =
eval(points.col(i));
138 return evals(points);
146 throw std::logic_error(
"No derivatives for Shepard");
void addPoint(const vec &point, double funVal)
Method for adding a point with a known value.
Definition: shepard.h:81
int mMaxPoints
Definition: shepard.h:35
arma::vec vec
Default (column) vector class.
Definition: common.h:17
int numPoints() const
Method for getting the current number of points.
Definition: shepard.h:58
mat mfX
Definition: shepard.h:39
double mp
Definition: shepard.h:33
Abstract class for a SOT surrogate model.
Definition: surrogate.h:25
Shepard(int maxPoints, int dim, double p)
Constructor.
Definition: shepard.h:47
double eval(const vec &point, const vec &dists) const
Method for evaluating the surrogate at multiple points.
Definition: shepard.h:125
vec X(int i) const
Method for getting current point number i (0 is the first)
Definition: shepard.h:61
vec evals(const mat &points, const mat &dists) const
Method for evaluating the surrogate at multiple points.
Definition: shepard.h:137
Shepard's method
Definition: shepard.h:31
mat mX
Definition: shepard.h:38
int mNumPoints
Definition: shepard.h:36
vec fX() const
Method for getting the values of the current points.
Definition: shepard.h:70
double fX(int i) const
Method for getting the value of current point number i (0 is the first)
Definition: shepard.h:67
double eval(const vec &point) const
Method for evaluating the surrogate model at a point.
Definition: shepard.h:112
mat X() const
Method for getting the current points.
Definition: shepard.h:64
vec deriv(const vec &point) const
Method for evaluating the kNN derivative at one point (not implemented)
Definition: shepard.h:145
int dim() const
Method for getting the number of dimensions.
Definition: shepard.h:55
void reset()
Method for resetting the surrogate model.
Definition: shepard.h:148
void fit()
Fits the interpolant (does nothing)
Definition: shepard.h:150
double mDistTol
Definition: shepard.h:34
void addPoints(const mat &points, const vec &funVals)
Method for adding multiple points with known values.
Definition: shepard.h:97
SOT namespace.
Definition: sot.h:27
int mDim
Definition: shepard.h:37
arma::mat mat
Default matrix class.
Definition: common.h:16
vec evals(const mat &points) const
Method for evaluating the surrogate at multiple points.
Definition: shepard.h:129