2222#include < Eigen/Eigenvalues>
2323#include < Eigen/QR>
2424
25- using Matrix = Eigen::MatrixXd;
26- using Vector = Eigen::VectorXd;
27- using Array = Eigen::ArrayXd;
25+ using Float = long double ;
26+ using Matrix = Eigen::Matrix<Float, -1 , -1 >;
27+ using Vector = Eigen::Matrix<Float, -1 , 1 >;
28+ using Array = Eigen::Array<Float, -1 , 1 >;
2829using size_to = std::optional<size_t >;
2930
3031template <typename T>
3132std::ostream &operator <<(std::ostream &os, const std::vector<T> &x);
3233
33- using FunctionType = std::function<double (const Vector &)>;
34+ using FunctionType = std::function<Float (const Vector &)>;
3435
3536namespace constants
3637{
37- extern double tolup_sigma;
38- extern double tol_condition_cov;
39- extern double tol_min_sigma;
40- extern double stagnation_quantile;
41- extern double sigma_threshold;
38+ extern Float tolup_sigma;
39+ extern Float tol_condition_cov;
40+ extern Float tol_min_sigma;
41+ extern Float stagnation_quantile;
42+ extern Float sigma_threshold;
4243 extern size_t cache_max_doubles;
4344 extern size_t cache_min_samples;
4445 extern bool cache_samples;
46+ extern Float lb_sigma;
47+ extern Float ub_sigma;
48+ extern bool clip_sigma;
4549}
4650
4751/* *
4852 * @brief Cdf of a standard normal distribution.
4953 *
5054 * see: ndtr_ndtri.cpp
5155 * @param x lower tail of the probabilty
52- * @return double quantile corresponding to the lower tail probability q
56+ * @return Float quantile corresponding to the lower tail probability q
5357 */
54- double cdf (const double x);
58+ Float cdf (const Float x);
5559
5660/* *
5761 * @brief Percent point function (inverse of cdf) of a standard normal distribution.
5862 *
5963 * see: ndtri.cpp
6064 * @param x lower tail of the probabilty
61- * @return double quantile corresponding to the lower tail probability q
65+ * @return Float quantile corresponding to the lower tail probability q
6266 */
63- double ppf (const double x);
67+ Float ppf (const Float x);
6468
6569/* *
6670 * @brief Generate a sobol sequence using 8 byte integer numbers.
@@ -70,24 +74,24 @@ double ppf(const double x);
7074 * @param seed The current seed of the sobol sequence
7175 * @param quasi the vector of random numbers in which to place the output
7276 */
73- void i8_sobol (int dim_num, long long int *seed, double quasi[]);
77+ void i8_sobol (int dim_num, long long int *seed, Float quasi[]);
7478
7579struct Solution
7680{
7781 // ! Coordinates
7882 Vector x;
7983 // ! Function value
80- double y;
84+ Float y;
8185 // ! Generation
8286 size_t t;
8387 // ! Evaluations
8488 size_t e;
8589
86- Solution (const Vector &x, const double y, const size_t t = 0 , const size_t e = 0 ) : x(x), y(y), t(t), e(e)
90+ Solution (const Vector &x, const Float y, const size_t t = 0 , const size_t e = 0 ) : x(x), y(y), t(t), e(e)
8791 {
8892 }
8993
90- Solution () : Solution({}, std::numeric_limits<double >::infinity()) {}
94+ Solution () : Solution({}, std::numeric_limits<Float >::infinity()) {}
9195
9296 [[nodiscard]] size_t n () const
9397 {
@@ -171,9 +175,9 @@ namespace utils
171175 *
172176 * @param running_times the vector of measured running times
173177 * @param budget the maximum budget allocated to each run
174- * @return std::pair<double , size_t> (ERT, number of successfull runs)
178+ * @return std::pair<Float , size_t> (ERT, number of successfull runs)
175179 */
176- std::pair<double , size_t > compute_ert (const std::vector<size_t > &running_times, size_t budget);
180+ std::pair<Float , size_t > compute_ert (const std::vector<size_t > &running_times, size_t budget);
177181
178182 /* *
179183 * \brief calculate the nearest power of two
@@ -184,7 +188,7 @@ namespace utils
184188 template <typename T>
185189 T nearest_power_of_2 (const T value)
186190 {
187- const double val = static_cast <double >(value);
191+ const Float val = static_cast <Float >(value);
188192 return static_cast <T>(pow (2.0 , std::floor (std::log2 (val))));
189193 }
190194
@@ -251,14 +255,14 @@ namespace rng
251255 size_t dim;
252256 size_t n_samples;
253257
254- std::vector<double > cache;
258+ std::vector<Float > cache;
255259 Shuffler shuffler;
256260
257261 CachedShuffleSequence (const size_t d);
258262
259- void fill (const std::vector<double >& c);
263+ void fill (const std::vector<Float >& c);
260264
261- void transform (const std::function<double ( double )>& f);
265+ void transform (const std::function<Float(Float )>& f);
262266
263267 Vector get_index (const size_t idx);
264268
@@ -269,7 +273,7 @@ namespace rng
269273 * @brief distribution which in combination with mt19997 produces the same
270274 * random numbers for gcc and msvc
271275 */
272- template <typename T = double >
276+ template <typename T = Float >
273277 struct uniform
274278 {
275279 /* *
@@ -290,7 +294,7 @@ namespace rng
290294 * @brief Box-Muller random normal number generator. Ensures similar numbers generated
291295 * on different operating systems.
292296 */
293- template <typename T = double >
297+ template <typename T = Float >
294298 struct normal
295299 {
296300 T mu;
@@ -314,7 +318,7 @@ namespace rng
314318 template <typename G>
315319 T operator ()(G &gen)
316320 {
317- static uniform<double > rng;
321+ static uniform<Float > rng;
318322 static T r1, r2;
319323 static bool generate = true ;
320324
@@ -338,6 +342,7 @@ namespace rng
338342
339343namespace functions
340344{
341- double sphere (const Vector &x);
342- double rastrigin (const Vector &x);
345+ Float sphere (const Vector &x);
346+ Float rastrigin (const Vector &x);
347+ Float ellipse (const Vector& x);
343348}
0 commit comments