23 model(
const rbf::rbf_base& rbf,
int poly_dimension,
int poly_degree) : rbf_(rbf.clone()),
24 poly_dimension_(poly_dimension), poly_degree_(poly_degree) {
25 if(poly_dimension < 0 or poly_dimension > 3) {
26 throw std::invalid_argument(
"poly_dimension must be within the range of 0 to 3.");
28 if(poly_degree < rbf.cpd_order() - 1 or poly_degree > 2) {
29 throw std::invalid_argument(
"poly_degree must be within the range of rbf.cpd_order() - 1 to 2.");
36 poly_degree_(
model.poly_degree_), nugget_(
model.nugget_) {}
43 [[nodiscard]]
double nugget()
const {
return nugget_;}
45 [[nodiscard]]
int num_parameters()
const {
return 1 + rbf_->num_parameters();}
47 [[nodiscard]] std::vector<double> parameter_lower_bounds()
const {
48 std::vector<double> lower_bounds{0.0};
49 lower_bounds.insert(std::end(lower_bounds), std::begin(rbf_->parameter_lower_bounds()), std::end(rbf_->parameter_lower_bounds()));
53 [[nodiscard]] std::vector<double> parameter_upper_bounds()
const {
54 std::vector<double> upper_bounds{std::numeric_limits<double>::infinity()};
55 upper_bounds.insert(std::end(upper_bounds), std::begin(rbf_->parameter_upper_bounds()), std::end(rbf_->parameter_upper_bounds()));
59 [[nodiscard]] std::vector<double> parameters()
const {
60 std::vector<double> params{nugget()};
61 params.insert(std::end(params), std::begin(rbf_->parameters()), std::end(rbf_->parameters()));
65 [[nodiscard]] index_t poly_basis_size()
const {
66 return polynomial::polynomial_basis_base::basis_size(poly_dimension_, poly_degree_);
69 [[nodiscard]]
int poly_degree()
const {
73 [[nodiscard]]
int poly_dimension()
const {
74 return poly_dimension_;
77 [[nodiscard]]
const rbf::rbf_base& rbf()
const {
return *rbf_;}
79 void set_nugget(
double nugget) {
81 throw std::invalid_argument(
"nugget mest be greater than or equal to 0.0.");
87 void set_parameters(
const std::vector<double>& params) {
88 if(
static_cast<int>(params.size()) != num_parameters()) {
89 throw std::invalid_argument(
"params.size() must be " + std::to_string(num_parameters()) +
".");
91 set_nugget(params[0]);
92 rbf_->set_parameters(std::vector<double>(std::begin(params) + 1, std::end(params)));
95 [[nodiscard]]
model without_poly()
const {
100 explicit model(
const rbf::rbf_base& rbf) : rbf_(rbf.clone()), poly_dimension_(-1), poly_degree_(-1) {}
102 std::unique_ptr<rbf::rbf_base> rbf_;