23 #ifndef __TEST_FUNCTIONS_HPP__ 24 #define __TEST_FUNCTIONS_HPP__ 26 #define _USE_MATH_DEFINES 29 #include <boost/math/constants/constants.hpp> 30 #include <boost/numeric/ublas/assignment.hpp> 46 std::cout <<
"WARNING: This only works for 1D inputs." << std::endl
47 <<
"WARNING: Using only first component." << std::endl;
51 return (x-0.3)*(x-0.3) + sin(20*x)*0.2;
59 std::cout <<
"Optimal:" << 0.23719 << std::endl;
75 std::cout <<
"WARNING: This only works for 2D inputs." << std::endl
76 <<
"WARNING: Using only first two components." << std::endl;
79 double x = xin(0) * 15 - 5;
80 double y = xin(1) * 15;
85 double branin(
double x,
double y)
87 const double pi = boost::math::constants::pi<double>();
88 const double rpi = pi*pi;
89 return sqr(y-(5.1/(4*rpi))*sqr(x)
90 +5*x/pi-6)+10*(1-1/(8*pi))*cos(x)+10;
96 inline double sqr(
double x ){
return x*x; };
101 sv(0) = 0.1238938; sv(1) = 0.818333;
102 std::cout <<
"Solutions: " << sv <<
"->" 104 sv(0) = 0.5427728; sv(1) = 0.151667;
105 std::cout <<
"Solutions: " << sv <<
"->" 107 sv(0) = 0.961652; sv(1) = 0.1650;
108 std::cout <<
"Solutions: " << sv <<
"->" 125 std::cout <<
"WARNING: This only works for 2D inputs." << std::endl
126 <<
"WARNING: Using only first two components." << std::endl;
128 double x1_2 = x(0)*x(0);
129 double x2_2 = x(1)*x(1);
131 double tmp1 = (4 - 2.1 * x1_2 + (x1_2*x1_2)/3) * x1_2;
132 double tmp2 = x(0)*x(1);
133 double tmp3 = (-4 + 4 * x2_2) * x2_2;
134 return tmp1 + tmp2 + tmp3;
140 inline double sqr(
double x ){
return x*x; };
145 sv(0) = 0.0898; sv(1) = -0.7126;
146 std::cout <<
"Solutions: " << sv <<
"->" 148 sv(0) = -0.0898; sv(1) = 0.7126;
149 std::cout <<
"Solutions: " << sv <<
"->" 163 mA <<= 10.0, 3.0, 17.0, 3.5, 1.7, 8.0,
164 0.05, 10.0, 17.0, 0.1, 8.0, 14.0,
165 3.0, 3.5, 1.7, 10.0, 17.0, 8.0,
166 17.0, 8.0, 0.05, 10.0, 0.1, 14.0;
168 mC <<= 1.0, 1.2, 3.0, 3.2;
170 mP <<= 0.1312, 0.1696, 0.5569, 0.0124, 0.8283, 0.5886,
171 0.2329, 0.4135, 0.8307, 0.3736, 0.1004, 0.9991,
172 0.2348, 0.1451, 0.3522, 0.2883, 0.3047, 0.6650,
173 0.4047, 0.8828, 0.8732, 0.5743, 0.1091, 0.0381;
179 for(
size_t i=0; i<4; ++i)
182 for(
size_t j=0;j<6; ++j)
184 double val = xin(j)-mP(i,j);
185 sum -= mA(i,j)*val*val;
187 y -= mC(i)*std::exp(sum);
195 inline double sqr(
double x ){
return x*x; };
200 sv <<= 0.20169, 0.150011, 0.476874, 0.275332, 0.311652, 0.6573;
202 std::cout <<
"Solution: " << sv <<
"->" double evaluateSample(const vectord &x)
Function that defines the actual function to be optimized.
Boost vector and matrix types.
bool checkReachability(const vectord &query)
This function checks if the query is valid or not.
Bayesian optimization for functions in continuous input spaces.
ContinuousModel()
Default constructor forbidden.
bool checkReachability(const vectord &query)
This function checks if the query is valid or not.
BayesOpt main C++ interface.
bool checkReachability(const vectord &query)
This function checks if the query is valid or not.
bool checkReachability(const vectord &query)
This function checks if the query is valid or not.
double evaluateSample(const vectord &xin)
Function that defines the actual function to be optimized.
double evaluateSample(const vectord &xin)
Function that defines the actual function to be optimized.
double evaluateSample(const vectord &xin)
Function that defines the actual function to be optimized.