diff --git a/include/ensmallen_bits/problems/nist.hpp b/include/ensmallen_bits/problems/nist.hpp new file mode 100644 index 000000000..03d4d62fe --- /dev/null +++ b/include/ensmallen_bits/problems/nist.hpp @@ -0,0 +1,2398 @@ +/** + * @file nist.hpp + * @author Marcus Edel + * + * Definition of the National Institute of Standards and Technology non-linear + * least squares problems. + * + * ensmallen is free software; you may redistribute it and/or modify it under + * the terms of the 3-clause BSD license. You should have received a copy of + * the 3-clause BSD license along with ensmallen. If not, see + * http://www.opensource.org/licenses/BSD-3-Clause for more information. + */ +#ifndef ENSMALLEN_PROBLEMS_NIST_HPP +#define ENSMALLEN_PROBLEMS_NIST_HPP + +namespace ens { +namespace test { + +/** + * The National Institute of Standards and Technology has released a set of + * problems to test non-linear least squares solvers. More information about the + * background on these problems and suggested evaluation methodology can be + * found at: + * + * http://www.itl.nist.gov/div898/strd/nls/nls_info.shtml + * + * The problem data themselves can be found at: + * + * http://www.itl.nist.gov/div898/strd/nls/nls_main.shtml + * + * The problems are divided into three levels of difficulty, Lower, + * Average and Higher. For each problem there are two starting guesses, + * the first one far away from the global minimum and the second + * closer to it. + */ +class Misra1a +{ + public: + //! Initialize Misra1a. + Misra1a() : initial("500 250; 0.0001 0.0005") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * + (1.0 - arma::exp(-1.0 * coordinates(1) * predictors)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(-1.0 * coordinates(1) * predictors); + const arma::mat expr2 = 1.0 - expr1; + + jacobian.row(0) = expr2; + jacobian.row(1) = coordinates(0) * expr1 % predictors; + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Chwirut1 +{ + public: + //! Initialize Chwirut1. + Chwirut1() : initial("0.1 0.15; 0.01 0.008; 0.02 0.010") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = arma::exp(-1.0 * coordinates(0) * predictors) % (1.0 / + (coordinates(1) + coordinates(2) * predictors)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(-1.0 * coordinates(0) * predictors); + const arma::mat expr2 = coordinates(1) + coordinates(2) * predictors; + const arma::mat expr3 = expr1 % predictors; + const arma::mat expr4 = arma::pow(expr2, 2.0); + + jacobian.row(0) = -1.0 * (expr3 % (1.0 / expr2)); + jacobian.row(1) = -1.0 * (expr1 % (1.0 / expr4)); + jacobian.row(2) = -1.0 * (expr3 % (1.0 / expr4)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +using Chwirut2 = Chwirut1; + +class Lanczos3 +{ + public: + //! Initialize Lanczos3. + Lanczos3() : initial("1.2 0.5; 0.3 0.7; 5.6 3.6; 5.5 4.2; 6.5 4; 7.6 6.3") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * arma::exp(-1.0 * coordinates(1) * predictors) + + coordinates(2) * arma::exp(-1.0 * coordinates(3) * predictors) + + coordinates(4) * arma::exp(-1.0 * coordinates(5) * predictors) - + responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(-1.0 * coordinates(1) * predictors); + const arma::mat expr2 = arma::exp(-1.0 * coordinates(3) * predictors); + const arma::mat expr3 = arma::exp(-1.0 * coordinates(5) * predictors); + + jacobian.row(0) = expr1; + jacobian.row(1) = -1.0 * (coordinates(0) * (expr1 % predictors)); + jacobian.row(2) = expr2; + jacobian.row(3) = -1.0 * (coordinates(2) * (expr2 % predictors)); + jacobian.row(4) = expr3; + jacobian.row(5) = -1.0 * (coordinates(4) * (expr3 % predictors)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Gauss1 +{ + public: + //! Initialize Gauss1. + Gauss1() : initial("97.0 94.0; 0.009 0.0105; 100.0 99.0; 65.0 63.0; \ + 20.0 25.0; 70.0 71.0; 178.0 180.0; 16.5 20.0") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * arma::exp(-1.0 * coordinates(1) * predictors) + + coordinates(2) * arma::exp(-1.0 * arma::pow(predictors - + coordinates(3), 2.0) / std::pow(coordinates(4), 2.0)) + coordinates(5) * + arma::exp(-1.0 * arma::pow(predictors - coordinates(6), 2.0) / + std::pow(coordinates(7), 2.0)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(-1.0 * coordinates(1) * predictors); + const arma::mat expr2 = predictors - coordinates(3); + const arma::mat expr3 = arma::pow(expr2, 2.0); + const double expr4 = std::pow(coordinates(4), 2.0); + const arma::mat expr5 = arma::exp(-1.0 * expr3 / expr4); + const arma::mat expr6 = predictors - coordinates(6); + const arma::mat expr7 = arma::pow(expr6, 2.0); + const double expr8 = std::pow(coordinates(7), 2.0); + const arma::mat expr9 = arma::exp(-1.0 * expr7 / expr8); + + jacobian.row(0) = expr1; + jacobian.row(1) = -1.0 * (coordinates(0) * (expr1 % predictors)); + jacobian.row(2) = expr5; + jacobian.row(3) = coordinates(2) * (expr5 % (2.0 * expr2 / expr4)); + jacobian.row(4) = coordinates(2) * (expr5 % (expr3 * (2.0 * coordinates(4)) + / std::pow(expr4, 2.0))); + jacobian.row(5) = expr9; + jacobian.row(6) = coordinates(5) * (expr9 % (2.0 * expr6 / expr8)); + jacobian.row(7) = coordinates(5) * (expr9 % (expr7 * (2.0 * coordinates(7)) + / std::pow(expr8, 2.0))); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Gauss2 +{ + public: + //! Initialize Gauss2. + Gauss2() : initial("96.0 98.0; 0.009 0.0105; 103.0 103.0; 106.0 105.0; \ + 18.0 20.0; 72.0 73.0; 151.0 150.0; 18.0 20.0") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + function.Evaluate(coordinates, predictors, responses, result); + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + function.Jacobian(coordinates, jacobian, predictors, responses); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + return function.Gradient(coordinates, gradient, predictors, responses); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + arma::mat initial; + + //! Locally stored initial starting points. + Gauss1 function; +}; + +class DanWood +{ + public: + //! Initialize DanWood. + DanWood() : initial("1 0.7; 5 4") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * (arma::pow(predictors, coordinates(1))) - + responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::pow(predictors, coordinates(1)); + jacobian.row(0) = expr1; + jacobian.row(1) = coordinates(0) * (expr1 % arma::log(predictors)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Misra1b +{ + public: + //! Initialize Misra1b. + Misra1b() : initial("500 300; 0.0001 0.0002") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * (1.0 - arma::pow(1.0 + coordinates(1) * + predictors / 2.0, -2.0)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = 1.0 + coordinates(1) * predictors / 2.0; + + jacobian.row(0) = 1.0 - arma::pow(expr1, -2.0); + jacobian.row(1) = -1.0 * (coordinates(0) * arma::pow(expr1, -3.0) % + (-2.0 * (predictors / 2.0))); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Kirby2 +{ + public: + //! Initialize Kirby2. + Kirby2() : initial("2 1.5; -0.1 -0.15; 0.003 0.0025; \ + -0.001 -0.0015; 0.00001 0.00002") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) + coordinates(1) * predictors + coordinates(2) * + arma::pow(predictors, 2.0) % (1.0 / (1.0 + coordinates(3) * + predictors + coordinates(4) * arma::pow(predictors, 2.0))) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = predictors % predictors; + const arma::mat expr2 = coordinates(0) + coordinates(1) * predictors + + coordinates(2) * expr1; + const arma::mat expr3 = 1.0 + coordinates(3) * predictors + + coordinates(4) * expr1; + const arma::mat expr4 = expr3 % expr3; + + jacobian.row(0) = 1.0 / expr3; + jacobian.row(1) = predictors % jacobian.row(0); + jacobian.row(2) = expr1 % jacobian.row(0); + jacobian.row(3) = -1.0 * (expr2 % predictors % (1.0 / expr4)); + jacobian.row(4) = -1.0 * (expr2 % expr1 % (1.0 / expr4)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Hahn1 +{ + public: + //! Initialize Hahn1. + Hahn1() : initial("10 1; -1 -0.1; 0.05 0.005; -0.00001 -0.000001; \ + -0.05 -0.005; 0.001 0.0001; -0.000001 -0.0000001") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = (coordinates(0) + coordinates(1) * predictors + coordinates(2) * + arma::pow(predictors, 2.0) + coordinates(3) * + arma::pow(predictors, 3.0)) % (1.0 / (1.0 + coordinates(4) * + predictors + coordinates(5) * arma::pow(predictors, 2.0) + + coordinates(6) * arma::pow(predictors, 3.0))) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = predictors % predictors; + const arma::mat expr2 = predictors % expr1; + const arma::mat expr3 = coordinates(0) + coordinates(1) * predictors + + coordinates(2) * expr1 + coordinates(3) * expr2; + const arma::mat expr4 = 1.0 + coordinates(4) * predictors + coordinates(5) * + expr1 + coordinates(6) * expr2; + const arma::mat expr5 = expr4 % expr4; + + jacobian.row(0) = 1.0 / expr4; + jacobian.row(1) = predictors % jacobian.row(0); + jacobian.row(2) = expr1 % (1.0 / expr4); + jacobian.row(3) = expr2 % (1.0 / expr4); + jacobian.row(4) =-1.0 * (expr3 % predictors % (1.0 / expr5)); + jacobian.row(5) =-1.0 * (expr3 % expr1 % (1.0 / expr5)); + jacobian.row(6) =-1.0 * (expr3 % expr2 % (1.0 / expr5)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Nelson +{ + public: + //! Initialize Nelson. + Nelson() : initial("2 2.5; 0.0001 0.000000005; -0.01 -0.05") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) - coordinates(1) * predictors.row(0) % arma::exp( + -1.0 * coordinates(2) * predictors.row(1)) - arma::log(responses); + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = coordinates(1) * predictors.row(0); + const arma::mat expr2 = arma::exp(-1.0 * coordinates(2) * + predictors.row(1)); + + jacobian.row(0).ones(); + jacobian.row(1) = -1.0 * (predictors.row(0) % expr2); + jacobian.row(2) = expr1 % (expr2 % predictors.row(1)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class MGH17 +{ + public: + //! Initialize MGH17. + MGH17() : initial("50 0.5; 150 1.5; -100 -1; 1 0.01; 2 0.02") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) + coordinates(1) * arma::exp(-1.0 * predictors * + coordinates(3)) + coordinates(2) * arma::exp(-1.0 * predictors * + coordinates(4)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = -1.0 * predictors; + const arma::mat expr2 = arma::exp(expr1 * coordinates(3)); + const arma::mat expr3 = arma::exp(expr1 * coordinates(4)); + + jacobian.row(0).ones(); + jacobian.row(1) = expr2; + jacobian.row(2) = expr3; + jacobian.row(3) = -1.0 * (coordinates(1) * (expr2 % predictors)); + jacobian.row(4) = -1.0 * (coordinates(2) * (expr3 % predictors)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Lanczos1 +{ + public: + //! Initialize Lanczos1. + Lanczos1() : initial("1.2 0.5; 0.3 0.7; 5.6 3.6; 5.5 4.2; 6.5 4; 7.6 6.3") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * arma::exp(-1.0 * coordinates(1) * predictors) + + coordinates(2) * arma::exp(-1.0 * coordinates(3) * predictors) + + coordinates(4) * arma::exp(-1.0 * coordinates(5) * predictors) - + responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(-1.0 * coordinates(1) * predictors); + const arma::mat expr2 = arma::exp(-1.0 * coordinates(3) * predictors); + const arma::mat expr3 = arma::exp(-1.0 * coordinates(5) * predictors); + + jacobian.row(0) = expr1; + jacobian.row(1) = -1.0 * (coordinates(0) * (expr1 % predictors)); + jacobian.row(1) = expr2; + jacobian.row(1) = -1.0 * (coordinates(2) * (expr2 % predictors)); + jacobian.row(1) = expr3; + jacobian.row(1) = -1.0 * (coordinates(4) * (expr3 % predictors)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +using Lanczos2 = Lanczos1; + +class Gauss3 +{ + public: + //! Initialize Gauss3. + Gauss3() : initial("94.9 96.0; 0.009 0.0096; 90.1 80.0; 113.0 110.0; \ + 20.0 25.0; 73.8 74.0; 140.0 139.0; 20.0 25.0") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + function.Evaluate(coordinates, predictors, responses, result); + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + function.Jacobian(coordinates, jacobian, predictors, responses); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + return function.Gradient(coordinates, gradient, predictors, responses); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; + + //! Locally stored function instantiation. + Gauss1 function; +}; + +class Misra1c +{ + public: + //! Initialize Misra1c. + Misra1c() : initial("500 600; 0.0001 0.0002") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * (1.0 - arma::pow(1.0 + 2.0 * coordinates(1) * + predictors, -0.5)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = 1.0 + 2.0 * coordinates(1) * predictors; + + jacobian.row(0) = 1.0 - arma::pow(expr1, -0.5); + jacobian.row(1) = -1.0 * (coordinates(0) * arma::pow(expr1, -1.5) % + (-0.5 * (2.0 * predictors))); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Misra1d +{ + public: + //! Initialize Misra1d. + Misra1d() : initial("500 450; 0.0001 0.0003") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * coordinates(1) * predictors % + (arma::pow(1.0 + coordinates(1) * predictors, -1.0)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = coordinates(0) * coordinates(1) * predictors; + const arma::mat expr2 = coordinates(1) * predictors; + const arma::mat expr3 = 1.0 + expr2; + const arma::mat expr4 = arma::pow(expr3, -1.0); + + jacobian.row(0) = expr2 % expr4; + jacobian.row(1) = coordinates(0) * predictors % expr4 + expr1 % + (arma::pow(expr3, -2.0) % (-1.0 * predictors)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Roszman1 +{ + public: + //! Initialize Roszman1. + Roszman1() : initial("0.1 0.2; -0.00001 -0.000005; 1000 1200; -100 -150") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) - coordinates(1) * predictors - arma::atan( + coordinates(2) / (predictors - coordinates(3))) / M_PI - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = predictors - coordinates(3); + const arma::mat expr2 = coordinates(2) / expr1; + const arma::mat expr3 = 1.0 + arma::pow(expr2, 2.0); + + jacobian.row(0).ones(); + jacobian.row(1) = predictors; + jacobian.row(2) = (1.0 / expr1) % (1.0 / expr3) / M_PI; + jacobian.row(3) = coordinates(2) / arma::pow(expr1, 2.0) % + (1.0 / expr3) / M_PI; + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class ENSO +{ + public: + //! Initialize ENSO. + ENSO() : initial("11.0 10.0; 3.0 3.0; 0.5 0.5; 40.0 44.0; -0.7 -1.5; \ + -1.3 0.5; 25.0 26.0; -0.3 -0.1; 1.4 1.5") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) + + coordinates(1) * arma::cos(2.0 * M_PI * predictors / 12.0) + + coordinates(2) * arma::sin(2.0 * M_PI * predictors / 12) + + coordinates(4) * arma::cos(2.0 * M_PI * predictors / coordinates(3)) + + coordinates(5) * arma::sin(2.0 * M_PI * predictors / coordinates(3)) + + coordinates(7) * arma::cos(2.0 * M_PI * predictors / coordinates(6)) + + coordinates(8) * arma::sin(2.0 * M_PI * predictors / coordinates(6)) - + responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = 2.0 * M_PI * predictors; + const arma::mat expr2 = expr1 / 12.0; + const arma::mat expr3 = arma::cos(expr2); + const arma::mat expr4 = arma::sin(expr2); + const arma::mat expr5 = expr1 / coordinates(3); + const arma::mat expr6 = arma::cos(expr5); + const arma::mat expr7 = arma::sin(expr5); + const arma::mat expr8 = expr1 / coordinates(6); + const arma::mat expr9 = arma::cos(expr8); + const arma::mat expr10 = arma::sin(expr8); + const arma::mat expr11 = expr1 / (std::pow(coordinates(3), 2.0)); + const arma::mat expr12 = expr1 / (std::pow(coordinates(6), 2.0)); + + jacobian.row(0).ones(); + jacobian.row(1) = expr3; + jacobian.row(2) = expr4; + jacobian.row(3) = coordinates(4) * (expr7 % expr11) - + coordinates(5) * (expr6 % expr11); + jacobian.row(4) = expr6; + jacobian.row(5) = expr7; + jacobian.row(6) = coordinates(7) * (expr9 % expr12) - + coordinates(8) * (expr9 % expr12); + jacobian.row(7) = expr9; + jacobian.row(8) = expr10; + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class MGH09 +{ + public: + //! Initialize MGH09. + MGH09() : initial("25 0.25; 39 0.39; 41.5 0.415; 39 0.39") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * (arma::pow(predictors, 2.0) + predictors * + coordinates(1)) % (1.0 / (arma::pow(predictors, 2.0) + predictors * + coordinates(2) + coordinates(3))) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = predictors % predictors; + const arma::mat expr2 = expr1 + predictors * coordinates(1); + const arma::mat expr3 = coordinates(0) * expr2; + const arma::mat expr4 = expr1 + predictors * coordinates(2) + + coordinates(3); + const arma::mat expr5 = expr4 % expr4; + + jacobian.row(0) = expr2 % (1.0 / expr4); + jacobian.row(1) = coordinates(0) * (predictors % (1.0 / expr4)); + jacobian.row(2) = -1.0 * (expr3 % (predictors % (1.0 / expr5))); + jacobian.row(3) = -1.0 * (expr3 % (1.0 / expr5)); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Thurber +{ + public: + //! Initialize Thurber. + Thurber() : initial("1000 1300; 1000 1500; 400 500; 40 75; 0.7 1; \ + 0.3 0.4; 0.03 0.05") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = (coordinates(0) + coordinates(1) * predictors + + coordinates(2) * arma::pow(predictors, 2.0) + coordinates(3) * + arma::pow(predictors, 3.0)) % (1.0 / (1.0 + coordinates(4) * + predictors + coordinates(5) * arma::pow(predictors, 2.0) + + coordinates(6) * arma::pow(predictors, 3.0))) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = coordinates(0) + coordinates(1) * predictors + + coordinates(2) * arma::pow(predictors, 2.0) + coordinates(3) * + arma::pow(predictors, 3.0); + const arma::mat expr2 = 1.0 + coordinates(4) * predictors + coordinates(5) * + arma::pow(predictors, 2.0) + coordinates(6) * + arma::pow(predictors, 3.0); + + jacobian.row(0) = 1.0 / expr2; + jacobian.row(1) = predictors % (1.0 / expr2); + jacobian.row(2) = jacobian.row(1) % predictors; + jacobian.row(3) = jacobian.row(2) % predictors; + jacobian.row(4) = expr1 % (1.0 / (expr2 % expr2)) % predictors; + jacobian.row(5) = jacobian.row(4) % predictors; + jacobian.row(6) = jacobian.row(5) % predictors; + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class BoxBOD +{ + public: + //! Initialize BoxBOD. + BoxBOD() : initial("1 100; 1 0.75") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * (1.0 - arma::exp(-1.0 * coordinates(1) * + predictors)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + jacobian.row(0) = (1.0 - arma::exp(-1.0 * coordinates(1) * predictors)); + jacobian.row(1) = coordinates(0) * predictors % + arma::exp(-1.0 * coordinates(1) * predictors); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Rat42 +{ + public: + //! Initialize Rat42. + Rat42() : initial("100 75; 1 2.5; 0.1 0.07") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) / (1.0 + arma::exp(coordinates(1) - coordinates(2) * + predictors)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(coordinates(1) - coordinates(2) * + predictors); + const arma::mat expr2 = 1.0 + expr1; + const arma::mat expr3 = expr2 % expr2; + + jacobian.row(0) = 1.0 / expr2; + jacobian.row(1) = -1.0 * (coordinates(0) * (expr1 % (1.0 / expr3))); + jacobian.row(1) = coordinates(0) * (expr1 % predictors) % (1.0 / expr3); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class MGH10 +{ + public: + //! Initialize MGH10. + MGH10() : initial("2 0.02; 400000 4000; 25000 250") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * arma::exp(coordinates(1) / + (predictors + coordinates(2))) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = predictors + coordinates(2); + const arma::mat expr2 = arma::exp(coordinates(1) / expr1); + + jacobian.row(0) = expr2; + jacobian.row(1) = coordinates(0) * (expr2 % (1.0 / expr1)); + jacobian.row(2) = -1.0 * (coordinates(0) * (expr2 % (coordinates(1) * + (1.0 / (expr1 % expr1))))); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Eckerle4 +{ + public: + //! Initialize Eckerle4. + Eckerle4() : initial("1 1.5; 10 5; 500 450") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = (coordinates(0) / coordinates(1)) * arma::exp(-0.5 * + arma::pow((predictors - coordinates(2)) / coordinates(1), 2.0)) - + responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const double expr1 = coordinates(0) / coordinates(1); + const arma::mat expr2 = predictors - coordinates(2); + const arma::mat expr3 = expr2 / coordinates(1); + const arma::mat expr4 = arma::exp(-0.5 * arma::pow(expr3, 2.0)); + const double expr5 = 1.0 / coordinates(1); + const double expr6 = std::pow(coordinates(1), 2.0); + + jacobian.row(0) = expr5 * expr4; + jacobian.row(1) = expr1 * (expr4 % (0.5 * (2.0 * (expr2 / expr6 % expr3)))) + - coordinates(0) / expr6 * expr4; + jacobian.row(2) = expr1 * (expr4 % (0.5 * (2.0 * (expr5 * expr3)))); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Rat43 +{ + public: + //! Initialize Rat43. + Rat43() : initial("100 700; 10 5; 1 0.75; 1 1.3") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) / + arma::pow(1.0 + arma::exp(coordinates(1) - coordinates(2) * + predictors), 1.0 / coordinates(3)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = arma::exp(coordinates(1) - coordinates(2) * + predictors); + const arma::mat expr2 = 1.0 + expr1; + const double expr3 = 1.0 / coordinates(3); + const arma::mat expr4 = arma::pow(expr2, expr3); + const arma::mat expr5 = arma::pow(expr2, expr3 - 1.0); + const arma::mat expr6 = expr4 % expr4; + + jacobian.row(0) = 1.0 / expr4; + jacobian.row(1) = -1.0 * (coordinates(0) * (expr5 % (expr3 * expr1 % + predictors)) % (1.0 / expr6)); + jacobian.row(2) = coordinates(0) * (expr5 % (expr3 * expr1)) % + (1.0 / expr6); + jacobian.row(3) = coordinates(0) * (expr4 % arma::log(expr2) * (1.0 / + (coordinates(3) * coordinates(3)))) % (1.0 / expr6); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +class Bennett5 +{ + public: + //! Initialize Bennett5. + Bennett5() : initial("-2000 -1500; 50 45; 0.8 0.85") {} + + /** + * Evaluate the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @param result The calculated function result. + */ + void Evaluate(const arma::mat& coordinates, + const arma::mat& predictors, + const arma::rowvec& responses, + arma::mat& result) const + { + result = coordinates(0) * arma::pow(coordinates(1) + predictors, + -1.0 / coordinates(2)) - responses; + } + + /** + * Jacobian of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param jacobian The calculated jacobian matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + void Jacobian(const arma::mat& coordinates, + arma::mat& jacobian, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + jacobian.zeros(coordinates.n_elem, predictors.n_cols); + + const arma::mat expr1 = coordinates(1) + predictors; + const double expr2 = -1.0 / coordinates(2); + const arma::mat expr3 = arma::pow(expr1, expr2); + + jacobian.row(0) = expr3; + jacobian.row(1) = coordinates(0) * arma::pow(expr1, (expr2 - 1)) * expr2; + jacobian.row(2) = coordinates(0) * (expr3 % (arma::log(expr1) * + (1.0 / std::pow(coordinates(2), 2.0)))); + } + + /** + * Gradient of the function with the given parameter. + * + * @param coordinates The function coordinates. + * @param gradient The calculated gradient matrix. + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + * @return The calculated error. + */ + double Gradient(const arma::mat& coordinates, + arma::mat& gradient, + const arma::mat& predictors, + const arma::rowvec& responses) const + { + arma::mat jacobian, result; + Jacobian(coordinates, jacobian, predictors, responses); + Evaluate(coordinates, predictors, responses, result); + gradient = arma::trans(2.0 * result * jacobian.t()); + + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Get the starting point. + * + * @param index The index of the starting point. + */ + arma::mat GetInitialPoint(const size_t index = 0) const + { + return initial.col(index); + } + + //! Get the number of starting points. + size_t Functions() const { return 2; } + + //! Locally stored initial starting points. + arma::mat initial; +}; + +template +class NIST +{ + public: + /** + * Create the NIST object with the given parameter. + * + * @param predictors Matrix of data points (X). + * @param responses The measured data for each point in X (y). + */ + NIST(const arma::mat& predictors, const arma::rowvec& responses) : + predictors(predictors), responses(responses) + { + /* Nothing to do here. */ + } + + /** + * Shuffle the order of function visitation. This may be called by the + * optimizer. + */ + void Shuffle() + { + /* Nothing to do here. */ + } + + //! Return 1 (the number of functions). + size_t NumFunctions() const { return 1; } + + //! Get the starting point. + arma::mat GetInitialPoint(const size_t index = 0) const + { + return function.GetInitialPoint(index); + } + + /* + * Evaluate a function for a particular batch-size. + * + * @param coordinates The function coordinates. + * @param begin The first function. + * @param batchSize Number of points to process. + */ + double Evaluate(const arma::mat& coordinates, + const size_t /*begin*/, + const size_t /*batchSize*/) const + { + return Evaluate(coordinates); + } + + /* + * Evaluate a function with the given coordinates. + * + * @param coordinates The function coordinates. + */ + double Evaluate(const arma::mat& coordinates) const + { + arma::mat result; + function.Evaluate(coordinates, predictors, responses, result); + return arma::accu(arma::pow(result, 2.0)); + } + + /** + * Evaluate the gradient of the function with the given parameters. + * + * @param coordinates The function coordinates. + * @param gradient Vector to output gradient into. + */ + void Gradient(const arma::mat& coordinates, arma::mat& gradient) const + { + + function.Gradient(coordinates, gradient, predictors, responses); + } + + /* + * Evaluate the gradient of a function for a particular batch-size. + * + * @param coordinates The function coordinates. + * @param begin The first function. + * @param gradient The function gradient. + * @param batchSize Number of points to process. + */ + void Gradient(const arma::mat& coordinates, + const size_t /*begin*/, + arma::mat& gradient, + const size_t /*batchSize*/) const + { + function.Gradient(coordinates, gradient, predictors, responses); + } + + /** + * Evaluate the objective function and gradient of the function + * simultaneously with the given parameters. + * + * @param coordinates The function coordinates. + * @param gradient The function gradient. + */ + double EvaluateWithGradient(const arma::mat& coordinates, arma::mat& gradient) + { + return function.Gradient(coordinates, gradient, predictors, responses); + } + + /** + * Evaluate the objective function and gradient of the function + * simultaneously with the given parameters. + * + * @param coordinates The function coordinates. + * @param begin The first function. + * @param gradient The function gradient. + * @param batchSize Number of points to process. + */ + double EvaluateWithGradient(const arma::mat& coordinates, + const size_t begin, + arma::mat& gradient, + const size_t batchSize = 1) + { + return function.Gradient(coordinates, gradient, predictors, responses); + } + + //! Return the function instantiation. + FunctionType& Function() { return function; } + + private: + //! Matrix of data points (X). + arma::mat predictors; + + //! The measured data for each point in X (y). + arma::rowvec responses; + + //! The instantiated objective function. + FunctionType function; +}; + +} // namespace test +} // namespace ens + +#endif // ENSMALLEN_PROBLEMS_NIST_HPP diff --git a/include/ensmallen_bits/problems/problems.hpp b/include/ensmallen_bits/problems/problems.hpp index 88f9e581e..fc9bf305f 100644 --- a/include/ensmallen_bits/problems/problems.hpp +++ b/include/ensmallen_bits/problems/problems.hpp @@ -20,6 +20,7 @@ #include "logistic_regression_function.hpp" #include "matyas_function.hpp" #include "mc_cormick_function.hpp" +#include "nist.hpp" #include "rastrigin_function.hpp" #include "rosenbrock_function.hpp" #include "rosenbrock_wood_function.hpp" diff --git a/tests/data/bennett5.csv b/tests/data/bennett5.csv new file mode 100644 index 000000000..a81397b66 --- /dev/null +++ b/tests/data/bennett5.csv @@ -0,0 +1,154 @@ +-34.834702E0,7.447168E0 +-34.393200E0,8.102586E0 +-34.152901E0,8.452547E0 +-33.979099E0,8.711278E0 +-33.845901E0,8.916774E0 +-33.732899E0,9.087155E0 +-33.640301E0,9.232590E0 +-33.559200E0,9.359535E0 +-33.486801E0,9.472166E0 +-33.423100E0,9.573384E0 +-33.365101E0,9.665293E0 +-33.313000E0,9.749461E0 +-33.260899E0,9.827092E0 +-33.217400E0,9.899128E0 +-33.176899E0,9.966321E0 +-33.139198E0,10.029280E0 +-33.101601E0,10.088510E0 +-33.066799E0,10.144430E0 +-33.035000E0,10.197380E0 +-33.003101E0,10.247670E0 +-32.971298E0,10.295560E0 +-32.942299E0,10.341250E0 +-32.916302E0,10.384950E0 +-32.890202E0,10.426820E0 +-32.864101E0,10.467000E0 +-32.841000E0,10.505640E0 +-32.817799E0,10.542830E0 +-32.797501E0,10.578690E0 +-32.774300E0,10.613310E0 +-32.757000E0,10.646780E0 +-32.733799E0,10.679150E0 +-32.716400E0,10.710520E0 +-32.699100E0,10.740920E0 +-32.678799E0,10.770440E0 +-32.661400E0,10.799100E0 +-32.644001E0,10.826970E0 +-32.626701E0,10.854080E0 +-32.612202E0,10.880470E0 +-32.597698E0,10.906190E0 +-32.583199E0,10.931260E0 +-32.568699E0,10.955720E0 +-32.554298E0,10.979590E0 +-32.539799E0,11.002910E0 +-32.525299E0,11.025700E0 +-32.510799E0,11.047980E0 +-32.499199E0,11.069770E0 +-32.487598E0,11.091100E0 +-32.473202E0,11.111980E0 +-32.461601E0,11.132440E0 +-32.435501E0,11.152480E0 +-32.435501E0,11.172130E0 +-32.426800E0,11.191410E0 +-32.412300E0,11.210310E0 +-32.400799E0,11.228870E0 +-32.392101E0,11.247090E0 +-32.380501E0,11.264980E0 +-32.366001E0,11.282560E0 +-32.357300E0,11.299840E0 +-32.348598E0,11.316820E0 +-32.339901E0,11.333520E0 +-32.328400E0,11.349940E0 +-32.319698E0,11.366100E0 +-32.311001E0,11.382000E0 +-32.299400E0,11.397660E0 +-32.290699E0,11.413070E0 +-32.282001E0,11.428240E0 +-32.273300E0,11.443200E0 +-32.264599E0,11.457930E0 +-32.256001E0,11.472440E0 +-32.247299E0,11.486750E0 +-32.238602E0,11.500860E0 +-32.229900E0,11.514770E0 +-32.224098E0,11.528490E0 +-32.215401E0,11.542020E0 +-32.203800E0,11.555380E0 +-32.198002E0,11.568550E0 +-32.189400E0,11.581560E0 +-32.183601E0,11.594420E0 +-32.174900E0,11.607121E0 +-32.169102E0,11.619640E0 +-32.163300E0,11.632000E0 +-32.154598E0,11.644210E0 +-32.145901E0,11.656280E0 +-32.140099E0,11.668200E0 +-32.131401E0,11.679980E0 +-32.125599E0,11.691620E0 +-32.119801E0,11.703130E0 +-32.111198E0,11.714510E0 +-32.105400E0,11.725760E0 +-32.096699E0,11.736880E0 +-32.090900E0,11.747890E0 +-32.088001E0,11.758780E0 +-32.079300E0,11.769550E0 +-32.073502E0,11.780200E0 +-32.067699E0,11.790730E0 +-32.061901E0,11.801160E0 +-32.056099E0,11.811480E0 +-32.050301E0,11.821700E0 +-32.044498E0,11.831810E0 +-32.038799E0,11.841820E0 +-32.033001E0,11.851730E0 +-32.027199E0,11.861550E0 +-32.024300E0,11.871270E0 +-32.018501E0,11.880890E0 +-32.012699E0,11.890420E0 +-32.004002E0,11.899870E0 +-32.001099E0,11.909220E0 +-31.995300E0,11.918490E0 +-31.989500E0,11.927680E0 +-31.983700E0,11.936780E0 +-31.977900E0,11.945790E0 +-31.972099E0,11.954730E0 +-31.969299E0,11.963590E0 +-31.963501E0,11.972370E0 +-31.957701E0,11.981070E0 +-31.951900E0,11.989700E0 +-31.946100E0,11.998260E0 +-31.940300E0,12.006740E0 +-31.937401E0,12.015150E0 +-31.931601E0,12.023490E0 +-31.925800E0,12.031760E0 +-31.922899E0,12.039970E0 +-31.917101E0,12.048100E0 +-31.911301E0,12.056170E0 +-31.908400E0,12.064180E0 +-31.902599E0,12.072120E0 +-31.896900E0,12.080010E0 +-31.893999E0,12.087820E0 +-31.888201E0,12.095580E0 +-31.885300E0,12.103280E0 +-31.882401E0,12.110920E0 +-31.876600E0,12.118500E0 +-31.873699E0,12.126030E0 +-31.867901E0,12.133500E0 +-31.862101E0,12.140910E0 +-31.859200E0,12.148270E0 +-31.856300E0,12.155570E0 +-31.850500E0,12.162830E0 +-31.844700E0,12.170030E0 +-31.841801E0,12.177170E0 +-31.838900E0,12.184270E0 +-31.833099E0,12.191320E0 +-31.830200E0,12.198320E0 +-31.827299E0,12.205270E0 +-31.821600E0,12.212170E0 +-31.818701E0,12.219030E0 +-31.812901E0,12.225840E0 +-31.809999E0,12.232600E0 +-31.807100E0,12.239320E0 +-31.801300E0,12.245990E0 +-31.798401E0,12.252620E0 +-31.795500E0,12.259200E0 +-31.789700E0,12.265750E0 +-31.786800E0,12.272240E0 \ No newline at end of file diff --git a/tests/data/boxBOD.csv b/tests/data/boxBOD.csv new file mode 100644 index 000000000..b6610f7d2 --- /dev/null +++ b/tests/data/boxBOD.csv @@ -0,0 +1,6 @@ +109,1 +149,2 +149,3 +191,5 +213,7 +224,10 \ No newline at end of file diff --git a/tests/data/chwirut1.csv b/tests/data/chwirut1.csv new file mode 100644 index 000000000..ff26d7481 --- /dev/null +++ b/tests/data/chwirut1.csv @@ -0,0 +1,214 @@ +92.9000,0.5000 +78.7000,0.6250 +64.2000,0.7500 +64.9000,0.8750 +57.1000,1.0000 +43.3000,1.2500 +31.1000,1.7500 +23.6000,2.2500 +31.0500,1.7500 +23.7750,2.2500 +17.7375,2.7500 +13.8000,3.2500 +11.5875,3.7500 +9.4125,4.2500 +7.7250,4.7500 +7.3500,5.2500 +8.0250,5.7500 +90.6000,0.5000 +76.9000,0.6250 +71.6000,0.7500 +63.6000,0.8750 +54.0000,1.0000 +39.2000,1.2500 +29.3000,1.7500 +21.4000,2.2500 +29.1750,1.7500 +22.1250,2.2500 +17.5125,2.7500 +14.2500,3.2500 +9.4500,3.7500 +9.1500,4.2500 +7.9125,4.7500 +8.4750,5.2500 +6.1125,5.7500 +80.0000,0.5000 +79.0000,0.6250 +63.8000,0.7500 +57.2000,0.8750 +53.2000,1.0000 +42.5000,1.2500 +26.8000,1.7500 +20.4000,2.2500 +26.8500,1.7500 +21.0000,2.2500 +16.4625,2.7500 +12.5250,3.2500 +10.5375,3.7500 +8.5875,4.2500 +7.1250,4.7500 +6.1125,5.2500 +5.9625,5.7500 +74.1000,0.5000 +67.3000,0.6250 +60.8000,0.7500 +55.5000,0.8750 +50.3000,1.0000 +41.0000,1.2500 +29.4000,1.7500 +20.4000,2.2500 +29.3625,1.7500 +21.1500,2.2500 +16.7625,2.7500 +13.2000,3.2500 +10.8750,3.7500 +8.1750,4.2500 +7.3500,4.7500 +5.9625,5.2500 +5.6250,5.7500 +81.5000, .5000 +62.4000, .7500 +32.5000,1.5000 +12.4100,3.0000 +13.1200,3.0000 +15.5600,3.0000 +5.6300,6.0000 +78.0000, .5000 +59.9000, .7500 +33.2000,1.5000 +13.8400,3.0000 +12.7500,3.0000 +14.6200,3.0000 +3.9400,6.0000 +76.8000, .5000 +61.0000, .7500 +32.9000,1.5000 +13.8700,3.0000 +11.8100,3.0000 +13.3100,3.0000 +5.4400,6.0000 +78.0000, .5000 +63.5000, .7500 +33.8000,1.5000 +12.5600,3.0000 +5.6300,6.0000 +12.7500,3.0000 +13.1200,3.0000 +5.4400,6.0000 +76.8000, .5000 +60.0000, .7500 +47.8000,1.0000 +32.0000,1.5000 +22.2000,2.0000 +22.5700,2.0000 +18.8200,2.5000 +13.9500,3.0000 +11.2500,4.0000 +9.0000,5.0000 +6.6700,6.0000 +75.8000, .5000 +62.0000, .7500 +48.8000,1.0000 +35.2000,1.5000 +20.0000,2.0000 +20.3200,2.0000 +19.3100,2.5000 +12.7500,3.0000 +10.4200,4.0000 +7.3100,5.0000 +7.4200,6.0000 +70.5000, .5000 +59.5000, .7500 +48.5000,1.0000 +35.8000,1.5000 +21.0000,2.0000 +21.6700,2.0000 +21.0000,2.5000 +15.6400,3.0000 +8.1700,4.0000 +8.5500,5.0000 +10.1200,6.0000 +78.0000, .5000 +66.0000, .6250 +62.0000, .7500 +58.0000, .8750 +47.7000,1.0000 +37.8000,1.2500 +20.2000,2.2500 +21.0700,2.2500 +13.8700,2.7500 +9.6700,3.2500 +7.7600,3.7500 +5.4400,4.2500 +4.8700,4.7500 +4.0100,5.2500 +3.7500,5.7500 +24.1900,3.0000 +25.7600,3.0000 +18.0700,3.0000 +11.8100,3.0000 +12.0700,3.0000 +16.1200,3.0000 +70.8000, .5000 +54.7000, .7500 +48.0000,1.0000 +39.8000,1.5000 +29.8000,2.0000 +23.7000,2.5000 +29.6200,2.0000 +23.8100,2.5000 +17.7000,3.0000 +11.5500,4.0000 +12.0700,5.0000 +8.7400,6.0000 +80.7000, .5000 +61.3000, .7500 +47.5000,1.0000 +29.0000,1.5000 +24.0000,2.0000 +17.7000,2.5000 +24.5600,2.0000 +18.6700,2.5000 +16.2400,3.0000 +8.7400,4.0000 +7.8700,5.0000 +8.5100,6.0000 +66.7000, .5000 +59.2000, .7500 +40.8000,1.0000 +30.7000,1.5000 +25.7000,2.0000 +16.3000,2.5000 +25.9900,2.0000 +16.9500,2.5000 +13.3500,3.0000 +8.6200,4.0000 +7.2000,5.0000 +6.6400,6.0000 +13.6900,3.0000 +81.0000, .5000 +64.5000, .7500 +35.5000,1.5000 +13.3100,3.0000 +4.8700,6.0000 +12.9400,3.0000 +5.0600,6.0000 +15.1900,3.0000 +14.6200,3.0000 +15.6400,3.0000 +25.5000,1.7500 +25.9500,1.7500 +81.7000, .5000 +61.6000, .7500 +29.8000,1.7500 +29.8100,1.7500 +17.1700,2.7500 +10.3900,3.7500 +28.4000,1.7500 +28.6900,1.7500 +81.3000, .5000 +60.9000, .7500 +16.6500,2.7500 +10.0500,3.7500 +28.9000,1.7500 +28.9500,1.7500 \ No newline at end of file diff --git a/tests/data/chwirut2.csv b/tests/data/chwirut2.csv new file mode 100644 index 000000000..d2b518a72 --- /dev/null +++ b/tests/data/chwirut2.csv @@ -0,0 +1,54 @@ +92.9000,0.500 +57.1000,1.000 +31.0500,1.750 +11.5875,3.750 + 8.0250,5.750 +63.6000,0.875 +21.4000,2.250 +14.2500,3.250 + 8.4750,5.250 +63.8000,0.750 +26.8000,1.750 +16.4625,2.750 + 7.1250,4.750 +67.3000,0.625 +41.0000,1.250 +21.1500,2.250 + 8.1750,4.250 +81.5000, .500 +13.1200,3.000 +59.9000, .750 +14.6200,3.000 +32.9000,1.500 + 5.4400,6.000 +12.5600,3.000 + 5.4400,6.000 +32.0000,1.500 +13.9500,3.000 +75.8000, .500 +20.0000,2.000 +10.4200,4.000 +59.5000, .750 +21.6700,2.000 + 8.5500,5.000 +62.0000, .750 +20.2000,2.250 + 7.7600,3.750 + 3.7500,5.750 +11.8100,3.000 +54.7000, .750 +23.7000,2.500 +11.5500,4.000 +61.3000, .750 +17.7000,2.500 + 8.7400,4.000 +59.2000, .750 +16.3000,2.500 + 8.6200,4.000 +81.0000, .500 + 4.8700,6.000 +14.6200,3.000 +81.7000, .500 +17.1700,2.750 +81.3000, .500 +28.9000,1.750 \ No newline at end of file diff --git a/tests/data/danWood.csv b/tests/data/danWood.csv new file mode 100644 index 000000000..d82d650f4 --- /dev/null +++ b/tests/data/danWood.csv @@ -0,0 +1,6 @@ +2.138E0,1.309E0 +3.421E0,1.471E0 +3.597E0,1.490E0 +4.340E0,1.565E0 +4.882E0,1.611E0 +5.660E0,1.680E0 \ No newline at end of file diff --git a/tests/data/eckerle4.csv b/tests/data/eckerle4.csv new file mode 100644 index 000000000..0a43d246a --- /dev/null +++ b/tests/data/eckerle4.csv @@ -0,0 +1,35 @@ +0.0001575E0,400.000000E0 +0.0001699E0,405.000000E0 +0.0002350E0,410.000000E0 +0.0003102E0,415.000000E0 +0.0004917E0,420.000000E0 +0.0008710E0,425.000000E0 +0.0017418E0,430.000000E0 +0.0046400E0,435.000000E0 +0.0065895E0,436.500000E0 +0.0097302E0,438.000000E0 +0.0149002E0,439.500000E0 +0.0237310E0,441.000000E0 +0.0401683E0,442.500000E0 +0.0712559E0,444.000000E0 +0.1264458E0,445.500000E0 +0.2073413E0,447.000000E0 +0.2902366E0,448.500000E0 +0.3445623E0,450.000000E0 +0.3698049E0,451.500000E0 +0.3668534E0,453.000000E0 +0.3106727E0,454.500000E0 +0.2078154E0,456.000000E0 +0.1164354E0,457.500000E0 +0.0616764E0,459.000000E0 +0.0337200E0,460.500000E0 +0.0194023E0,462.000000E0 +0.0117831E0,463.500000E0 +0.0074357E0,465.000000E0 +0.0022732E0,470.000000E0 +0.0008800E0,475.000000E0 +0.0004579E0,480.000000E0 +0.0002345E0,485.000000E0 +0.0001586E0,490.000000E0 +0.0001143E0,495.000000E0 +0.0000710E0,500.000000E0 \ No newline at end of file diff --git a/tests/data/enso.csv b/tests/data/enso.csv new file mode 100644 index 000000000..d8f5b1807 --- /dev/null +++ b/tests/data/enso.csv @@ -0,0 +1,168 @@ +12.90000,1.000000 +11.30000,2.000000 +10.60000,3.000000 +11.20000,4.000000 +10.90000,5.000000 +7.500000,6.000000 +7.700000,7.000000 +11.70000,8.000000 +12.90000,9.000000 +14.30000,10.000000 +10.90000,11.00000 +13.70000,12.00000 +17.10000,13.00000 +14.00000,14.00000 +15.30000,15.00000 +8.500000,16.00000 +5.700000,17.00000 +5.500000,18.00000 +7.600000,19.00000 +8.600000,20.00000 +7.300000,21.00000 +7.600000,22.00000 +12.70000,23.00000 +11.00000,24.00000 +12.70000,25.00000 +12.90000,26.00000 +13.00000,27.00000 +10.90000,28.00000 +10.400000,29.00000 +10.200000,30.00000 +8.000000,31.00000 +10.90000,32.00000 +13.60000,33.00000 +10.500000,34.00000 +9.200000,35.00000 +12.40000,36.00000 +12.70000,37.00000 +13.30000,38.00000 +10.100000,39.00000 +7.800000,40.00000 +4.800000,41.00000 +3.000000,42.00000 +2.500000,43.00000 +6.300000,44.00000 +9.700000,45.00000 +11.60000,46.00000 +8.600000,47.00000 +12.40000,48.00000 +10.500000,49.00000 +13.30000,50.00000 +10.400000,51.00000 +8.100000,52.00000 +3.700000,53.00000 +10.70000,54.00000 +5.100000,55.00000 +10.400000,56.00000 +10.90000,57.00000 +11.70000,58.00000 +11.40000,59.00000 +13.70000,60.00000 +14.10000,61.00000 +14.00000,62.00000 +12.50000,63.00000 +6.300000,64.00000 +9.600000,65.00000 +11.70000,66.00000 +5.000000,67.00000 +10.80000,68.00000 +12.70000,69.00000 +10.80000,70.00000 +11.80000,71.00000 +12.60000,72.00000 +15.70000,73.00000 +12.60000,74.00000 +14.80000,75.00000 +7.800000,76.00000 +7.100000,77.00000 +11.20000,78.00000 +8.100000,79.00000 +6.400000,80.00000 +5.200000,81.00000 +12.00000,82.00000 +10.200000,83.00000 +12.70000,84.00000 +10.200000,85.00000 +14.70000,86.00000 +12.20000,87.00000 +7.100000,88.00000 +5.700000,89.00000 +6.700000,90.00000 +3.900000,91.00000 +8.500000,92.00000 +8.300000,93.00000 +10.80000,94.00000 +16.70000,95.00000 +12.60000,96.00000 +12.50000,97.00000 +12.50000,98.00000 +9.800000,99.00000 +7.200000,100.00000 +4.100000,101.00000 +10.60000,102.00000 +10.100000,103.00000 +10.100000,104.00000 +11.90000,105.00000 +13.60000,106.0000 +16.30000,107.0000 +17.60000,108.0000 +15.50000,109.0000 +16.00000,110.0000 +15.20000,111.0000 +11.20000,112.0000 +14.30000,113.0000 +14.50000,114.0000 +8.500000,115.0000 +12.00000,116.0000 +12.70000,117.0000 +11.30000,118.0000 +14.50000,119.0000 +15.10000,120.0000 +10.400000,121.0000 +11.50000,122.0000 +13.40000,123.0000 +7.500000,124.0000 +0.6000000,125.0000 +0.3000000,126.0000 +5.500000,127.0000 +5.000000,128.0000 +4.600000,129.0000 +8.200000,130.0000 +9.900000,131.0000 +9.200000,132.0000 +12.50000,133.0000 +10.90000,134.0000 +9.900000,135.0000 +8.900000,136.0000 +7.600000,137.0000 +9.500000,138.0000 +8.400000,139.0000 +10.70000,140.0000 +13.60000,141.0000 +13.70000,142.0000 +13.70000,143.0000 +16.50000,144.0000 +16.80000,145.0000 +17.10000,146.0000 +15.40000,147.0000 +9.500000,148.0000 +6.100000,149.0000 +10.100000,150.0000 +9.300000,151.0000 +5.300000,152.0000 +11.20000,153.0000 +16.60000,154.0000 +15.60000,155.0000 +12.00000,156.0000 +11.50000,157.0000 +8.600000,158.0000 +13.80000,159.0000 +8.700000,160.0000 +8.600000,161.0000 +8.600000,162.0000 +8.700000,163.0000 +12.80000,164.0000 +13.20000,165.0000 +14.00000,166.0000 +13.40000,167.0000 +14.80000,168.0000 \ No newline at end of file diff --git a/tests/data/gauss1.csv b/tests/data/gauss1.csv new file mode 100644 index 000000000..51ecdbb78 --- /dev/null +++ b/tests/data/gauss1.csv @@ -0,0 +1,250 @@ +97.62227,1.000000 +97.80724,2.000000 +96.62247,3.000000 +92.59022,4.000000 +91.23869,5.000000 +95.32704,6.000000 +90.35040,7.000000 +89.46235,8.000000 +91.72520,9.000000 +89.86916,10.000000 +86.88076,11.00000 +85.94360,12.00000 +87.60686,13.00000 +86.25839,14.00000 +80.74976,15.00000 +83.03551,16.00000 +88.25837,17.00000 +82.01316,18.00000 +82.74098,19.00000 +83.30034,20.00000 +81.27850,21.00000 +81.85506,22.00000 +80.75195,23.00000 +80.09573,24.00000 +81.07633,25.00000 +78.81542,26.00000 +78.38596,27.00000 +79.93386,28.00000 +79.48474,29.00000 +79.95942,30.00000 +76.10691,31.00000 +78.39830,32.00000 +81.43060,33.00000 +82.48867,34.00000 +81.65462,35.00000 +80.84323,36.00000 +88.68663,37.00000 +84.74438,38.00000 +86.83934,39.00000 +85.97739,40.00000 +91.28509,41.00000 +97.22411,42.00000 +93.51733,43.00000 +94.10159,44.00000 +101.91760,45.00000 +98.43134,46.00000 +110.4214,47.00000 +107.6628,48.00000 +111.7288,49.00000 +116.5115,50.00000 +120.7609,51.00000 +123.9553,52.00000 +124.2437,53.00000 +130.7996,54.00000 +133.2960,55.00000 +130.7788,56.00000 +132.0565,57.00000 +138.6584,58.00000 +142.9252,59.00000 +142.7215,60.00000 +144.1249,61.00000 +147.4377,62.00000 +148.2647,63.00000 +152.0519,64.00000 +147.3863,65.00000 +149.2074,66.00000 +148.9537,67.00000 +144.5876,68.00000 +148.1226,69.00000 +148.0144,70.00000 +143.8893,71.00000 +140.9088,72.00000 +143.4434,73.00000 +139.3938,74.00000 +135.9878,75.00000 +136.3927,76.00000 +126.7262,77.00000 +124.4487,78.00000 +122.8647,79.00000 +113.8557,80.00000 +113.7037,81.00000 +106.8407,82.00000 +107.0034,83.00000 +102.46290,84.00000 +96.09296,85.00000 +94.57555,86.00000 +86.98824,87.00000 +84.90154,88.00000 +81.18023,89.00000 +76.40117,90.00000 +67.09200,91.00000 +72.67155,92.00000 +68.10848,93.00000 +67.99088,94.00000 +63.34094,95.00000 +60.55253,96.00000 +56.18687,97.00000 +53.64482,98.00000 +53.70307,99.00000 +48.07893,100.00000 +42.21258,101.00000 +45.65181,102.00000 +41.69728,103.00000 +41.24946,104.00000 +39.21349,105.00000 +37.71696,106.0000 +36.68395,107.0000 +37.30393,108.0000 +37.43277,109.0000 +37.45012,110.0000 +32.64648,111.0000 +31.84347,112.0000 +31.39951,113.0000 +26.68912,114.0000 +32.25323,115.0000 +27.61008,116.0000 +33.58649,117.0000 +28.10714,118.0000 +30.26428,119.0000 +28.01648,120.0000 +29.11021,121.0000 +23.02099,122.0000 +25.65091,123.0000 +28.50295,124.0000 +25.23701,125.0000 +26.13828,126.0000 +33.53260,127.0000 +29.25195,128.0000 +27.09847,129.0000 +26.52999,130.0000 +25.52401,131.0000 +26.69218,132.0000 +24.55269,133.0000 +27.71763,134.0000 +25.20297,135.0000 +25.61483,136.0000 +25.06893,137.0000 +27.63930,138.0000 +24.94851,139.0000 +25.86806,140.0000 +22.48183,141.0000 +26.90045,142.0000 +25.39919,143.0000 +17.90614,144.0000 +23.76039,145.0000 +25.89689,146.0000 +27.64231,147.0000 +22.86101,148.0000 +26.47003,149.0000 +23.72888,150.0000 +27.54334,151.0000 +30.52683,152.0000 +28.07261,153.0000 +34.92815,154.0000 +28.29194,155.0000 +34.19161,156.0000 +35.41207,157.0000 +37.09336,158.0000 +40.98330,159.0000 +39.53923,160.0000 +47.80123,161.0000 +47.46305,162.0000 +51.04166,163.0000 +54.58065,164.0000 +57.53001,165.0000 +61.42089,166.0000 +62.79032,167.0000 +68.51455,168.0000 +70.23053,169.0000 +74.42776,170.0000 +76.59911,171.0000 +81.62053,172.0000 +83.42208,173.0000 +79.17451,174.0000 +88.56985,175.0000 +85.66525,176.0000 +86.55502,177.0000 +90.65907,178.0000 +84.27290,179.0000 +85.72220,180.0000 +83.10702,181.0000 +82.16884,182.0000 +80.42568,183.0000 +78.15692,184.0000 +79.79691,185.0000 +77.84378,186.0000 +74.50327,187.0000 +71.57289,188.0000 +65.88031,189.0000 +65.01385,190.0000 +60.19582,191.0000 +59.66726,192.0000 +52.95478,193.0000 +53.87792,194.0000 +44.91274,195.0000 +41.09909,196.0000 +41.68018,197.0000 +34.53379,198.0000 +34.86419,199.0000 +33.14787,200.0000 +29.58864,201.0000 +27.29462,202.0000 +21.91439,203.0000 +19.08159,204.0000 +24.90290,205.0000 +19.82341,206.0000 +16.75551,207.0000 +18.24558,208.0000 +17.23549,209.0000 +16.34934,210.0000 +13.71285,211.0000 +14.75676,212.0000 +13.97169,213.0000 +12.42867,214.0000 +14.35519,215.0000 +7.703309,216.0000 +10.234410,217.0000 +11.78315,218.0000 +13.87768,219.0000 +4.535700,220.0000 +10.059280,221.0000 +8.424824,222.0000 +10.533120,223.0000 +9.602255,224.0000 +7.877514,225.0000 +6.258121,226.0000 +8.899865,227.0000 +7.877754,228.0000 +12.51191,229.0000 +10.66205,230.0000 +6.035400,231.0000 +6.790655,232.0000 +8.783535,233.0000 +4.600288,234.0000 +8.400915,235.0000 +7.216561,236.0000 +10.017410,237.0000 +7.331278,238.0000 +6.527863,239.0000 +2.842001,240.0000 +10.325070,241.0000 +4.790995,242.0000 +8.377101,243.0000 +6.264445,244.0000 +2.706213,245.0000 +8.362329,246.0000 +8.983658,247.0000 +3.362571,248.0000 +1.182746,249.0000 +4.875359,250.0000 \ No newline at end of file diff --git a/tests/data/gauss2.csv b/tests/data/gauss2.csv new file mode 100644 index 000000000..b9c19d60b --- /dev/null +++ b/tests/data/gauss2.csv @@ -0,0 +1,250 @@ +97.58776,1.000000 +97.76344,2.000000 +96.56705,3.000000 +92.52037,4.000000 +91.15097,5.000000 +95.21728,6.000000 +90.21355,7.000000 +89.29235,8.000000 +91.51479,9.000000 +89.60966,10.000000 +86.56187,11.00000 +85.55316,12.00000 +87.13054,13.00000 +85.67940,14.00000 +80.04851,15.00000 +82.18925,16.00000 +87.24081,17.00000 +80.79407,18.00000 +81.28570,19.00000 +81.56940,20.00000 +79.22715,21.00000 +79.43275,22.00000 +77.90195,23.00000 +76.75468,24.00000 +77.17377,25.00000 +74.27348,26.00000 +73.11900,27.00000 +73.84826,28.00000 +72.47870,29.00000 +71.92292,30.00000 +66.92176,31.00000 +67.93835,32.00000 +69.56207,33.00000 +69.07066,34.00000 +66.53983,35.00000 +63.87883,36.00000 +69.71537,37.00000 +63.60588,38.00000 +63.37154,39.00000 +60.01835,40.00000 +62.67481,41.00000 +65.80666,42.00000 +59.14304,43.00000 +56.62951,44.00000 +61.21785,45.00000 +54.38790,46.00000 +62.93443,47.00000 +56.65144,48.00000 +57.13362,49.00000 +58.29689,50.00000 +58.91744,51.00000 +58.50172,52.00000 +55.22885,53.00000 +58.30375,54.00000 +57.43237,55.00000 +51.69407,56.00000 +49.93132,57.00000 +53.70760,58.00000 +55.39712,59.00000 +52.89709,60.00000 +52.31649,61.00000 +53.98720,62.00000 +53.54158,63.00000 +56.45046,64.00000 +51.32276,65.00000 +53.11676,66.00000 +53.28631,67.00000 +49.80555,68.00000 +54.69564,69.00000 +56.41627,70.00000 +54.59362,71.00000 +54.38520,72.00000 +60.15354,73.00000 +59.78773,74.00000 +60.49995,75.00000 +65.43885,76.00000 +60.70001,77.00000 +63.71865,78.00000 +67.77139,79.00000 +64.70934,80.00000 +70.78193,81.00000 +70.38651,82.00000 +77.22359,83.00000 +79.52665,84.00000 +80.13077,85.00000 +85.67823,86.00000 +85.20647,87.00000 +90.24548,88.00000 +93.61953,89.00000 +95.86509,90.00000 +93.46992,91.00000 +105.8137,92.00000 +107.8269,93.00000 +114.0607,94.00000 +115.5019,95.00000 +118.5110,96.00000 +119.6177,97.00000 +122.1940,98.00000 +126.9903,99.00000 +125.7005,100.00000 +123.7447,101.00000 +130.6543,102.00000 +129.7168,103.00000 +131.8240,104.00000 +131.8759,105.00000 +131.9994,106.0000 +132.1221,107.0000 +133.4414,108.0000 +133.8252,109.0000 +133.6695,110.0000 +128.2851,111.0000 +126.5182,112.0000 +124.7550,113.0000 +118.4016,114.0000 +122.0334,115.0000 +115.2059,116.0000 +118.7856,117.0000 +110.7387,118.0000 +110.2003,119.0000 +105.17290,120.0000 +103.44720,121.0000 +94.54280,122.0000 +94.40526,123.0000 +94.57964,124.0000 +88.76605,125.0000 +87.28747,126.0000 +92.50443,127.0000 +86.27997,128.0000 +82.44307,129.0000 +80.47367,130.0000 +78.36608,131.0000 +78.74307,132.0000 +76.12786,133.0000 +79.13108,134.0000 +76.76062,135.0000 +77.60769,136.0000 +77.76633,137.0000 +81.28220,138.0000 +79.74307,139.0000 +81.97964,140.0000 +80.02952,141.0000 +85.95232,142.0000 +85.96838,143.0000 +79.94789,144.0000 +87.17023,145.0000 +90.50992,146.0000 +93.23373,147.0000 +89.14803,148.0000 +93.11492,149.0000 +90.34337,150.0000 +93.69421,151.0000 +95.74256,152.0000 +91.85105,153.0000 +96.74503,154.0000 +87.60996,155.0000 +90.47012,156.0000 +88.11690,157.0000 +85.70673,158.0000 +85.01361,159.0000 +78.53040,160.0000 +81.34148,161.0000 +75.19295,162.0000 +72.66115,163.0000 +69.85504,164.0000 +66.29476,165.0000 +63.58502,166.0000 +58.33847,167.0000 +57.50766,168.0000 +52.80498,169.0000 +50.79319,170.0000 +47.03490,171.0000 +46.47090,172.0000 +43.09016,173.0000 +34.11531,174.0000 +39.28235,175.0000 +32.68386,176.0000 +30.44056,177.0000 +31.98932,178.0000 +23.63330,179.0000 +23.69643,180.0000 +20.26812,181.0000 +19.07074,182.0000 +17.59544,183.0000 +16.08785,184.0000 +18.94267,185.0000 +18.61354,186.0000 +17.25800,187.0000 +16.62285,188.0000 +13.48367,189.0000 +15.37647,190.0000 +13.47208,191.0000 +15.96188,192.0000 +12.32547,193.0000 +16.33880,194.0000 +10.438330,195.0000 +9.628715,196.0000 +13.12268,197.0000 +8.772417,198.0000 +11.76143,199.0000 +12.55020,200.0000 +11.33108,201.0000 +11.20493,202.0000 +7.816916,203.0000 +6.800675,204.0000 +14.26581,205.0000 +10.66285,206.0000 +8.911574,207.0000 +11.56733,208.0000 +11.58207,209.0000 +11.59071,210.0000 +9.730134,211.0000 +11.44237,212.0000 +11.22912,213.0000 +10.172130,214.0000 +12.50905,215.0000 +6.201493,216.0000 +9.019605,217.0000 +10.80607,218.0000 +13.09625,219.0000 +3.914271,220.0000 +9.567886,221.0000 +8.038448,222.0000 +10.231040,223.0000 +9.367410,224.0000 +7.695971,225.0000 +6.118575,226.0000 +8.793207,227.0000 +7.796692,228.0000 +12.45065,229.0000 +10.61601,230.0000 +6.001003,231.0000 +6.765098,232.0000 +8.764653,233.0000 +4.586418,234.0000 +8.390783,235.0000 +7.209202,236.0000 +10.012090,237.0000 +7.327461,238.0000 +6.525136,239.0000 +2.840065,240.0000 +10.323710,241.0000 +4.790035,242.0000 +8.376431,243.0000 +6.263980,244.0000 +2.705892,245.0000 +8.362109,246.0000 +8.983507,247.0000 +3.362469,248.0000 +1.182678,249.0000 +4.875312,250.0000 \ No newline at end of file diff --git a/tests/data/gauss3.csv b/tests/data/gauss3.csv new file mode 100644 index 000000000..3ab48f17e --- /dev/null +++ b/tests/data/gauss3.csv @@ -0,0 +1,250 @@ +97.58776,1.000000 +97.76344,2.000000 +96.56705,3.000000 +92.52037,4.000000 +91.15097,5.000000 +95.21728,6.000000 +90.21355,7.000000 +89.29235,8.000000 +91.51479,9.000000 +89.60965,10.000000 +86.56187,11.00000 +85.55315,12.00000 +87.13053,13.00000 +85.67938,14.00000 +80.04849,15.00000 +82.18922,16.00000 +87.24078,17.00000 +80.79401,18.00000 +81.28564,19.00000 +81.56932,20.00000 +79.22703,21.00000 +79.43259,22.00000 +77.90174,23.00000 +76.75438,24.00000 +77.17338,25.00000 +74.27296,26.00000 +73.11830,27.00000 +73.84732,28.00000 +72.47746,29.00000 +71.92128,30.00000 +66.91962,31.00000 +67.93554,32.00000 +69.55841,33.00000 +69.06592,34.00000 +66.53371,35.00000 +63.87094,36.00000 +69.70526,37.00000 +63.59295,38.00000 +63.35509,39.00000 +59.99747,40.00000 +62.64843,41.00000 +65.77345,42.00000 +59.10141,43.00000 +56.57750,44.00000 +61.15313,45.00000 +54.30767,46.00000 +62.83535,47.00000 +56.52957,48.00000 +56.98427,49.00000 +58.11459,50.00000 +58.69576,51.00000 +58.23322,52.00000 +54.90490,53.00000 +57.91442,54.00000 +56.96629,55.00000 +51.13831,56.00000 +49.27123,57.00000 +52.92668,58.00000 +54.47693,59.00000 +51.81710,60.00000 +51.05401,61.00000 +52.51731,62.00000 +51.83710,63.00000 +54.48196,64.00000 +49.05859,65.00000 +50.52315,66.00000 +50.32755,67.00000 +46.44419,68.00000 +50.89281,69.00000 +52.13203,70.00000 +49.78741,71.00000 +49.01637,72.00000 +54.18198,73.00000 +53.17456,74.00000 +53.20827,75.00000 +57.43459,76.00000 +51.95282,77.00000 +54.20282,78.00000 +57.46687,79.00000 +53.60268,80.00000 +58.86728,81.00000 +57.66652,82.00000 +63.71034,83.00000 +65.24244,84.00000 +65.10878,85.00000 +69.96313,86.00000 +68.85475,87.00000 +73.32574,88.00000 +76.21241,89.00000 +78.06311,90.00000 +75.37701,91.00000 +87.54449,92.00000 +89.50588,93.00000 +95.82098,94.00000 +97.48390,95.00000 +100.86070,96.00000 +102.48510,97.00000 +105.7311,98.00000 +111.3489,99.00000 +111.0305,100.00000 +110.1920,101.00000 +118.3581,102.00000 +118.8086,103.00000 +122.4249,104.00000 +124.0953,105.00000 +125.9337,106.0000 +127.8533,107.0000 +131.0361,108.0000 +133.3343,109.0000 +135.1278,110.0000 +131.7113,111.0000 +131.9151,112.0000 +132.1107,113.0000 +127.6898,114.0000 +133.2148,115.0000 +128.2296,116.0000 +133.5902,117.0000 +127.2539,118.0000 +128.3482,119.0000 +124.8694,120.0000 +124.6031,121.0000 +117.0648,122.0000 +118.1966,123.0000 +119.5408,124.0000 +114.7946,125.0000 +114.2780,126.0000 +120.3484,127.0000 +114.8647,128.0000 +111.6514,129.0000 +110.1826,130.0000 +108.4461,131.0000 +109.0571,132.0000 +106.5308,133.0000 +109.4691,134.0000 +106.8709,135.0000 +107.3192,136.0000 +106.9000,137.0000 +109.6526,138.0000 +107.1602,139.0000 +108.2509,140.0000 +104.96310,141.0000 +109.3601,142.0000 +107.6696,143.0000 +99.77286,144.0000 +104.96440,145.0000 +106.1376,146.0000 +106.5816,147.0000 +100.12860,148.0000 +101.66910,149.0000 +96.44254,150.0000 +97.34169,151.0000 +96.97412,152.0000 +90.73460,153.0000 +93.37949,154.0000 +82.12331,155.0000 +83.01657,156.0000 +78.87360,157.0000 +74.86971,158.0000 +72.79341,159.0000 +65.14744,160.0000 +67.02127,161.0000 +60.16136,162.0000 +57.13996,163.0000 +54.05769,164.0000 +50.42265,165.0000 +47.82430,166.0000 +42.85748,167.0000 +42.45495,168.0000 +38.30808,169.0000 +36.95794,170.0000 +33.94543,171.0000 +34.19017,172.0000 +31.66097,173.0000 +23.56172,174.0000 +29.61143,175.0000 +23.88765,176.0000 +22.49812,177.0000 +24.86901,178.0000 +17.29481,179.0000 +18.09291,180.0000 +15.34813,181.0000 +14.77997,182.0000 +13.87832,183.0000 +12.88891,184.0000 +16.20763,185.0000 +16.29024,186.0000 +15.29712,187.0000 +14.97839,188.0000 +12.11330,189.0000 +14.24168,190.0000 +12.53824,191.0000 +15.19818,192.0000 +11.70478,193.0000 +15.83745,194.0000 +10.035850,195.0000 +9.307574,196.0000 +12.86800,197.0000 +8.571671,198.0000 +11.60415,199.0000 +12.42772,200.0000 +11.23627,201.0000 +11.13198,202.0000 +7.761117,203.0000 +6.758250,204.0000 +14.23375,205.0000 +10.63876,206.0000 +8.893581,207.0000 +11.55398,208.0000 +11.57221,209.0000 +11.58347,210.0000 +9.724857,211.0000 +11.43854,212.0000 +11.22636,213.0000 +10.170150,214.0000 +12.50765,215.0000 +6.200494,216.0000 +9.018902,217.0000 +10.80557,218.0000 +13.09591,219.0000 +3.914033,220.0000 +9.567723,221.0000 +8.038338,222.0000 +10.230960,223.0000 +9.367358,224.0000 +7.695937,225.0000 +6.118552,226.0000 +8.793192,227.0000 +7.796682,228.0000 +12.45064,229.0000 +10.61601,230.0000 +6.001000,231.0000 +6.765096,232.0000 +8.764652,233.0000 +4.586417,234.0000 +8.390782,235.0000 +7.209201,236.0000 +10.012090,237.0000 +7.327461,238.0000 +6.525136,239.0000 +2.840065,240.0000 +10.323710,241.0000 +4.790035,242.0000 +8.376431,243.0000 +6.263980,244.0000 +2.705892,245.0000 +8.362109,246.0000 +8.983507,247.0000 +3.362469,248.0000 +1.182678,249.0000 +4.875312,250.0000 \ No newline at end of file diff --git a/tests/data/hahn1.csv b/tests/data/hahn1.csv new file mode 100644 index 000000000..2c6b5e8fe --- /dev/null +++ b/tests/data/hahn1.csv @@ -0,0 +1,236 @@ +0.591E0,24.41E0 +1.547E0,34.82E0 +2.902E0,44.09E0 +2.894E0,45.07E0 +4.703E0,54.98E0 +6.307E0,65.51E0 +7.03E0,70.53E0 +7.898E0,75.70E0 +9.470E0,89.57E0 +9.484E0,91.14E0 +10.072E0,96.40E0 +10.163E0,97.19E0 +11.615E0,114.26E0 +12.005E0,120.25E0 +12.478E0,127.08E0 +12.982E0,133.55E0 +12.970E0,133.61E0 +13.926E0,158.67E0 +14.452E0,172.74E0 +14.404E0,171.31E0 +15.190E0,202.14E0 +15.550E0,220.55E0 +15.528E0,221.05E0 +15.499E0,221.39E0 +16.131E0,250.99E0 +16.438E0,268.99E0 +16.387E0,271.80E0 +16.549E0,271.97E0 +16.872E0,321.31E0 +16.830E0,321.69E0 +16.926E0,330.14E0 +16.907E0,333.03E0 +16.966E0,333.47E0 +17.060E0,340.77E0 +17.122E0,345.65E0 +17.311E0,373.11E0 +17.355E0,373.79E0 +17.668E0,411.82E0 +17.767E0,419.51E0 +17.803E0,421.59E0 +17.765E0,422.02E0 +17.768E0,422.47E0 +17.736E0,422.61E0 +17.858E0,441.75E0 +17.877E0,447.41E0 +17.912E0,448.7E0 +18.046E0,472.89E0 +18.085E0,476.69E0 +18.291E0,522.47E0 +18.357E0,522.62E0 +18.426E0,524.43E0 +18.584E0,546.75E0 +18.610E0,549.53E0 +18.870E0,575.29E0 +18.795E0,576.00E0 +19.111E0,625.55E0 +0.367E0,20.15E0 +0.796E0,28.78E0 +0.892E0,29.57E0 +1.903E0,37.41E0 +2.150E0,39.12E0 +3.697E0,50.24E0 +5.870E0,61.38E0 +6.421E0,66.25E0 +7.422E0,73.42E0 +9.944E0,95.52E0 +11.023E0,107.32E0 +11.87E0,122.04E0 +12.786E0,134.03E0 +14.067E0,163.19E0 +13.974E0,163.48E0 +14.462E0,175.70E0 +14.464E0,179.86E0 +15.381E0,211.27E0 +15.483E0,217.78E0 +15.59E0,219.14E0 +16.075E0,262.52E0 +16.347E0,268.01E0 +16.181E0,268.62E0 +16.915E0,336.25E0 +17.003E0,337.23E0 +16.978E0,339.33E0 +17.756E0,427.38E0 +17.808E0,428.58E0 +17.868E0,432.68E0 +18.481E0,528.99E0 +18.486E0,531.08E0 +19.090E0,628.34E0 +16.062E0,253.24E0 +16.337E0,273.13E0 +16.345E0,273.66E0 +16.388E0,282.10E0 +17.159E0,346.62E0 +17.116E0,347.19E0 +17.164E0,348.78E0 +17.123E0,351.18E0 +17.979E0,450.10E0 +17.974E0,450.35E0 +18.007E0,451.92E0 +17.993E0,455.56E0 +18.523E0,552.22E0 +18.669E0,553.56E0 +18.617E0,555.74E0 +19.371E0,652.59E0 +19.330E0,656.20E0 +0.080E0,14.13E0 +0.248E0,20.41E0 +1.089E0,31.30E0 +1.418E0,33.84E0 +2.278E0,39.70E0 +3.624E0,48.83E0 +4.574E0,54.50E0 +5.556E0,60.41E0 +7.267E0,72.77E0 +7.695E0,75.25E0 +9.136E0,86.84E0 +9.959E0,94.88E0 +9.957E0,96.40E0 +11.600E0,117.37E0 +13.138E0,139.08E0 +13.564E0,147.73E0 +13.871E0,158.63E0 +13.994E0,161.84E0 +14.947E0,192.11E0 +15.473E0,206.76E0 +15.379E0,209.07E0 +15.455E0,213.32E0 +15.908E0,226.44E0 +16.114E0,237.12E0 +17.071E0,330.90E0 +17.135E0,358.72E0 +17.282E0,370.77E0 +17.368E0,372.72E0 +17.483E0,396.24E0 +17.764E0,416.59E0 +18.185E0,484.02E0 +18.271E0,495.47E0 +18.236E0,514.78E0 +18.237E0,515.65E0 +18.523E0,519.47E0 +18.627E0,544.47E0 +18.665E0,560.11E0 +19.086E0,620.77E0 +0.214E0,18.97E0 +0.943E0,28.93E0 +1.429E0,33.91E0 +2.241E0,40.03E0 +2.951E0,44.66E0 +3.782E0,49.87E0 +4.757E0,55.16E0 +5.602E0,60.90E0 +7.169E0,72.08E0 +8.920E0,85.15E0 +10.055E0,97.06E0 +12.035E0,119.63E0 +12.861E0,133.27E0 +13.436E0,143.84E0 +14.167E0,161.91E0 +14.755E0,180.67E0 +15.168E0,198.44E0 +15.651E0,226.86E0 +15.746E0,229.65E0 +16.216E0,258.27E0 +16.445E0,273.77E0 +16.965E0,339.15E0 +17.121E0,350.13E0 +17.206E0,362.75E0 +17.250E0,371.03E0 +17.339E0,393.32E0 +17.793E0,448.53E0 +18.123E0,473.78E0 +18.49E0,511.12E0 +18.566E0,524.70E0 +18.645E0,548.75E0 +18.706E0,551.64E0 +18.924E0,574.02E0 +19.1E0,623.86E0 +0.375E0,21.46E0 +0.471E0,24.33E0 +1.504E0,33.43E0 +2.204E0,39.22E0 +2.813E0,44.18E0 +4.765E0,55.02E0 +9.835E0,94.33E0 +10.040E0,96.44E0 +11.946E0,118.82E0 +12.596E0,128.48E0 +13.303E0,141.94E0 +13.922E0,156.92E0 +14.440E0,171.65E0 +14.951E0,190.00E0 +15.627E0,223.26E0 +15.639E0,223.88E0 +15.814E0,231.50E0 +16.315E0,265.05E0 +16.334E0,269.44E0 +16.430E0,271.78E0 +16.423E0,273.46E0 +17.024E0,334.61E0 +17.009E0,339.79E0 +17.165E0,349.52E0 +17.134E0,358.18E0 +17.349E0,377.98E0 +17.576E0,394.77E0 +17.848E0,429.66E0 +18.090E0,468.22E0 +18.276E0,487.27E0 +18.404E0,519.54E0 +18.519E0,523.03E0 +19.133E0,612.99E0 +19.074E0,638.59E0 +19.239E0,641.36E0 +19.280E0,622.05E0 +19.101E0,631.50E0 +19.398E0,663.97E0 +19.252E0,646.9E0 +19.89E0,748.29E0 +20.007E0,749.21E0 +19.929E0,750.14E0 +19.268E0,647.04E0 +19.324E0,646.89E0 +20.049E0,746.9E0 +20.107E0,748.43E0 +20.062E0,747.35E0 +20.065E0,749.27E0 +19.286E0,647.61E0 +19.972E0,747.78E0 +20.088E0,750.51E0 +20.743E0,851.37E0 +20.83E0,845.97E0 +20.935E0,847.54E0 +21.035E0,849.93E0 +20.93E0,851.61E0 +21.074E0,849.75E0 +21.085E0,850.98E0 +20.935E0,848.23E0 \ No newline at end of file diff --git a/tests/data/kirby2.csv b/tests/data/kirby2.csv new file mode 100644 index 000000000..7cd8d2362 --- /dev/null +++ b/tests/data/kirby2.csv @@ -0,0 +1,151 @@ +0.0082E0,9.65E0 +0.0112E0,10.74E0 +0.0149E0,11.81E0 +0.0198E0,12.88E0 +0.0248E0,14.06E0 +0.0324E0,15.28E0 +0.0420E0,16.63E0 +0.0549E0,18.19E0 +0.0719E0,19.88E0 +0.0963E0,21.84E0 +0.1291E0,24.00E0 +0.1710E0,26.25E0 +0.2314E0,28.86E0 +0.3227E0,31.85E0 +0.4809E0,35.79E0 +0.7084E0,40.18E0 +1.0220E0,44.74E0 +1.4580E0,49.53E0 +1.9520E0,53.94E0 +2.5410E0,58.29E0 +3.2230E0,62.63E0 +3.9990E0,67.03E0 +4.8520E0,71.25E0 +5.7320E0,75.22E0 +6.7270E0,79.33E0 +7.8350E0,83.56E0 +9.0250E0,87.75E0 +10.2670E0,91.93E0 +11.5780E0,96.10E0 +12.9440E0,100.28E0 +14.3770E0,104.46E0 +15.8560E0,108.66E0 +17.3310E0,112.71E0 +18.8850E0,116.88E0 +20.5750E0,121.33E0 +22.3200E0,125.79E0 +22.3030E0,125.79E0 +23.4600E0,128.74E0 +24.0600E0,130.27E0 +25.2720E0,133.33E0 +25.8530E0,134.79E0 +27.1100E0,137.93E0 +27.6580E0,139.33E0 +28.9240E0,142.46E0 +29.5110E0,143.90E0 +30.7100E0,146.91E0 +31.3500E0,148.51E0 +32.5200E0,151.41E0 +33.2300E0,153.17E0 +34.3300E0,155.97E0 +35.0600E0,157.76E0 +36.1700E0,160.56E0 +36.8400E0,162.30E0 +38.0100E0,165.21E0 +38.6700E0,166.90E0 +39.8700E0,169.92E0 +40.0300E0,170.32E0 +40.5000E0,171.54E0 +41.3700E0,173.79E0 +41.6700E0,174.57E0 +42.3100E0,176.25E0 +42.7300E0,177.34E0 +43.4600E0,179.19E0 +44.1400E0,181.02E0 +44.5500E0,182.08E0 +45.2200E0,183.88E0 +45.9200E0,185.75E0 +46.3000E0,186.80E0 +47.0000E0,188.63E0 +47.6800E0,190.45E0 +48.0600E0,191.48E0 +48.7400E0,193.35E0 +49.4100E0,195.22E0 +49.7600E0,196.23E0 +50.4300E0,198.05E0 +51.1100E0,199.97E0 +51.5000E0,201.06E0 +52.1200E0,202.83E0 +52.7600E0,204.69E0 +53.1800E0,205.86E0 +53.7800E0,207.58E0 +54.4600E0,209.50E0 +54.8300E0,210.65E0 +55.4000E0,212.33E0 +56.4300E0,215.43E0 +57.0300E0,217.16E0 +58.0000E0,220.21E0 +58.6100E0,221.98E0 +59.5800E0,225.06E0 +60.1100E0,226.79E0 +61.1000E0,229.92E0 +61.6500E0,231.69E0 +62.5900E0,234.77E0 +63.1200E0,236.60E0 +64.0300E0,239.63E0 +64.6200E0,241.50E0 +65.4900E0,244.48E0 +66.0300E0,246.40E0 +66.8900E0,249.35E0 +67.4200E0,251.32E0 +68.2300E0,254.22E0 +68.7700E0,256.24E0 +69.5900E0,259.11E0 +70.1100E0,261.18E0 +70.8600E0,264.02E0 +71.4300E0,266.13E0 +72.1600E0,268.94E0 +72.7000E0,271.09E0 +73.4000E0,273.87E0 +73.9300E0,276.08E0 +74.6000E0,278.83E0 +75.1600E0,281.08E0 +75.8200E0,283.81E0 +76.3400E0,286.11E0 +76.9800E0,288.81E0 +77.4800E0,291.08E0 +78.0800E0,293.75E0 +78.6000E0,295.99E0 +79.1700E0,298.64E0 +79.6200E0,300.84E0 +79.8800E0,302.02E0 +80.1900E0,303.48E0 +80.6600E0,305.65E0 +81.2200E0,308.27E0 +81.6600E0,310.41E0 +82.1600E0,313.01E0 +82.5900E0,315.12E0 +83.1400E0,317.71E0 +83.5000E0,319.79E0 +84.0000E0,322.36E0 +84.4000E0,324.42E0 +84.8900E0,326.98E0 +85.2600E0,329.01E0 +85.7400E0,331.56E0 +86.0700E0,333.56E0 +86.5400E0,336.10E0 +86.8900E0,338.08E0 +87.3200E0,340.60E0 +87.6500E0,342.57E0 +88.1000E0,345.08E0 +88.4300E0,347.02E0 +88.8300E0,349.52E0 +89.1200E0,351.44E0 +89.5400E0,353.93E0 +89.8500E0,355.83E0 +90.2500E0,358.32E0 +90.5500E0,360.20E0 +90.9300E0,362.67E0 +91.2000E0,364.53E0 +91.5500E0,367.00E0 +92.2000E0,371.30E0 \ No newline at end of file diff --git a/tests/data/lanczos1.csv b/tests/data/lanczos1.csv new file mode 100644 index 000000000..d3f6d3c6e --- /dev/null +++ b/tests/data/lanczos1.csv @@ -0,0 +1,24 @@ +2.513400000000E+00,0.000000000000E+00 +2.044333373291E+00,5.000000000000E-02 +1.668404436564E+00,1.000000000000E-01 +1.366418021208E+00,1.500000000000E-01 +1.123232487372E+00,2.000000000000E-01 +9.268897180037E-01,2.500000000000E-01 +7.679338563728E-01,3.000000000000E-01 +6.388775523106E-01,3.500000000000E-01 +5.337835317402E-01,4.000000000000E-01 +4.479363617347E-01,4.500000000000E-01 +3.775847884350E-01,5.000000000000E-01 +3.197393199326E-01,5.500000000000E-01 +2.720130773746E-01,6.000000000000E-01 +2.324965529032E-01,6.500000000000E-01 +1.996589546065E-01,7.000000000000E-01 +1.722704126914E-01,7.500000000000E-01 +1.493405660168E-01,8.000000000000E-01 +1.300700206922E-01,8.500000000000E-01 +1.138119324644E-01,9.000000000000E-01 +1.000415587559E-01,9.500000000000E-01 +8.833209084540E-02,1.000000000000E+00 +7.833544019350E-02,1.050000000000E+00 +6.976693743449E-02,1.100000000000E+00 +6.239312536719E-02,1.150000000000E+00 \ No newline at end of file diff --git a/tests/data/lanczos2.csv b/tests/data/lanczos2.csv new file mode 100644 index 000000000..6bc0efc96 --- /dev/null +++ b/tests/data/lanczos2.csv @@ -0,0 +1,24 @@ +2.51340E+00,0.00000E+00 +2.04433E+00,5.00000E-02 +1.66840E+00,1.00000E-01 +1.36642E+00,1.50000E-01 +1.12323E+00,2.00000E-01 +9.26890E-01,2.50000E-01 +7.67934E-01,3.00000E-01 +6.38878E-01,3.50000E-01 +5.33784E-01,4.00000E-01 +4.47936E-01,4.50000E-01 +3.77585E-01,5.00000E-01 +3.19739E-01,5.50000E-01 +2.72013E-01,6.00000E-01 +2.32497E-01,6.50000E-01 +1.99659E-01,7.00000E-01 +1.72270E-01,7.50000E-01 +1.49341E-01,8.00000E-01 +1.30070E-01,8.50000E-01 +1.13812E-01,9.00000E-01 +1.00042E-01,9.50000E-01 +8.83321E-02,1.00000E+00 +7.83354E-02,1.05000E+00 +6.97669E-02,1.10000E+00 +6.23931E-02,1.15000E+00 \ No newline at end of file diff --git a/tests/data/lanczos3.csv b/tests/data/lanczos3.csv new file mode 100644 index 000000000..d4c6dfc2f --- /dev/null +++ b/tests/data/lanczos3.csv @@ -0,0 +1,24 @@ +2.5134E+00,0.00000E+00 +2.0443E+00,5.00000E-02 +1.6684E+00,1.00000E-01 +1.3664E+00,1.50000E-01 +1.1232E+00,2.00000E-01 +0.9269E+00,2.50000E-01 +0.7679E+00,3.00000E-01 +0.6389E+00,3.50000E-01 +0.5338E+00,4.00000E-01 +0.4479E+00,4.50000E-01 +0.3776E+00,5.00000E-01 +0.3197E+00,5.50000E-01 +0.2720E+00,6.00000E-01 +0.2325E+00,6.50000E-01 +0.1997E+00,7.00000E-01 +0.1723E+00,7.50000E-01 +0.1493E+00,8.00000E-01 +0.1301E+00,8.50000E-01 +0.1138E+00,9.00000E-01 +0.1000E+00,9.50000E-01 +0.0883E+00,1.00000E+00 +0.0783E+00,1.05000E+00 +0.0698E+00,1.10000E+00 +0.0624E+00,1.15000E+00 \ No newline at end of file diff --git a/tests/data/mgh09.csv b/tests/data/mgh09.csv new file mode 100644 index 000000000..dc70f0372 --- /dev/null +++ b/tests/data/mgh09.csv @@ -0,0 +1,11 @@ +1.957000E-01,4.000000E+00 +1.947000E-01,2.000000E+00 +1.735000E-01,1.000000E+00 +1.600000E-01,5.000000E-01 +8.440000E-02,2.500000E-01 +6.270000E-02,1.670000E-01 +4.560000E-02,1.250000E-01 +3.420000E-02,1.000000E-01 +3.230000E-02,8.330000E-02 +2.350000E-02,7.140000E-02 +2.460000E-02,6.250000E-02 \ No newline at end of file diff --git a/tests/data/mgh10.csv b/tests/data/mgh10.csv new file mode 100644 index 000000000..bab7f26b0 --- /dev/null +++ b/tests/data/mgh10.csv @@ -0,0 +1,16 @@ +3.478000E+04,5.000000E+01 +2.861000E+04,5.500000E+01 +2.365000E+04,6.000000E+01 +1.963000E+04,6.500000E+01 +1.637000E+04,7.000000E+01 +1.372000E+04,7.500000E+01 +1.154000E+04,8.000000E+01 +9.744000E+03,8.500000E+01 +8.261000E+03,9.000000E+01 +7.030000E+03,9.500000E+01 +6.005000E+03,1.000000E+02 +5.147000E+03,1.050000E+02 +4.427000E+03,1.100000E+02 +3.820000E+03,1.150000E+02 +3.307000E+03,1.200000E+02 +2.872000E+03,1.250000E+02 \ No newline at end of file diff --git a/tests/data/mgh17.csv b/tests/data/mgh17.csv new file mode 100644 index 000000000..3b2f2a639 --- /dev/null +++ b/tests/data/mgh17.csv @@ -0,0 +1,33 @@ +8.440000E-01,0.000000E+00 +9.080000E-01,1.000000E+01 +9.320000E-01,2.000000E+01 +9.360000E-01,3.000000E+01 +9.250000E-01,4.000000E+01 +9.080000E-01,5.000000E+01 +8.810000E-01,6.000000E+01 +8.500000E-01,7.000000E+01 +8.180000E-01,8.000000E+01 +7.840000E-01,9.000000E+01 +7.510000E-01,1.000000E+02 +7.180000E-01,1.100000E+02 +6.850000E-01,1.200000E+02 +6.580000E-01,1.300000E+02 +6.280000E-01,1.400000E+02 +6.030000E-01,1.500000E+02 +5.800000E-01,1.600000E+02 +5.580000E-01,1.700000E+02 +5.380000E-01,1.800000E+02 +5.220000E-01,1.900000E+02 +5.060000E-01,2.000000E+02 +4.900000E-01,2.100000E+02 +4.780000E-01,2.200000E+02 +4.670000E-01,2.300000E+02 +4.570000E-01,2.400000E+02 +4.480000E-01,2.500000E+02 +4.380000E-01,2.600000E+02 +4.310000E-01,2.700000E+02 +4.240000E-01,2.800000E+02 +4.200000E-01,2.900000E+02 +4.140000E-01,3.000000E+02 +4.110000E-01,3.100000E+02 +4.060000E-01,3.200000E+02 \ No newline at end of file diff --git a/tests/data/misra1a.csv b/tests/data/misra1a.csv new file mode 100644 index 000000000..5801794c1 --- /dev/null +++ b/tests/data/misra1a.csv @@ -0,0 +1,14 @@ +10.07,77.6 +14.73,114.9 +17.94,141.1 +23.93,190.8 +29.61,239.9 +35.18,289.0 +40.02,332.8 +44.82,378.4 +50.76,434.8 +55.05,477.3 +61.01,536.8 +66.40,593.1 +75.47,689.1 +81.78,760.0 \ No newline at end of file diff --git a/tests/data/misra1b.csv b/tests/data/misra1b.csv new file mode 100644 index 000000000..0db9a16ef --- /dev/null +++ b/tests/data/misra1b.csv @@ -0,0 +1,14 @@ +10.07E0,77.6E0 +14.73E0,114.9E0 +17.94E0,141.1E0 +23.93E0,190.8E0 +29.61E0,239.9E0 +35.18E0,289.0E0 +40.02E0,332.8E0 +44.82E0,378.4E0 +50.76E0,434.8E0 +55.05E0,477.3E0 +61.01E0,536.8E0 +66.40E0,593.1E0 +75.47E0,689.1E0 +81.78E0,760.0E0 \ No newline at end of file diff --git a/tests/data/misra1c.csv b/tests/data/misra1c.csv new file mode 100644 index 000000000..0db9a16ef --- /dev/null +++ b/tests/data/misra1c.csv @@ -0,0 +1,14 @@ +10.07E0,77.6E0 +14.73E0,114.9E0 +17.94E0,141.1E0 +23.93E0,190.8E0 +29.61E0,239.9E0 +35.18E0,289.0E0 +40.02E0,332.8E0 +44.82E0,378.4E0 +50.76E0,434.8E0 +55.05E0,477.3E0 +61.01E0,536.8E0 +66.40E0,593.1E0 +75.47E0,689.1E0 +81.78E0,760.0E0 \ No newline at end of file diff --git a/tests/data/misra1d.csv b/tests/data/misra1d.csv new file mode 100644 index 000000000..0db9a16ef --- /dev/null +++ b/tests/data/misra1d.csv @@ -0,0 +1,14 @@ +10.07E0,77.6E0 +14.73E0,114.9E0 +17.94E0,141.1E0 +23.93E0,190.8E0 +29.61E0,239.9E0 +35.18E0,289.0E0 +40.02E0,332.8E0 +44.82E0,378.4E0 +50.76E0,434.8E0 +55.05E0,477.3E0 +61.01E0,536.8E0 +66.40E0,593.1E0 +75.47E0,689.1E0 +81.78E0,760.0E0 \ No newline at end of file diff --git a/tests/data/nelson.csv b/tests/data/nelson.csv new file mode 100644 index 000000000..8adbe58d5 --- /dev/null +++ b/tests/data/nelson.csv @@ -0,0 +1,128 @@ +15.00E0,1E0,180E0 +17.00E0,1E0,180E0 +15.50E0,1E0,180E0 +16.50E0,1E0,180E0 +15.50E0,1E0,225E0 +15.00E0,1E0,225E0 +16.00E0,1E0,225E0 +14.50E0,1E0,225E0 +15.00E0,1E0,250E0 +14.50E0,1E0,250E0 +12.50E0,1E0,250E0 +11.00E0,1E0,250E0 +14.00E0,1E0,275E0 +13.00E0,1E0,275E0 +14.00E0,1E0,275E0 +11.50E0,1E0,275E0 +14.00E0,2E0,180E0 +16.00E0,2E0,180E0 +13.00E0,2E0,180E0 +13.50E0,2E0,180E0 +13.00E0,2E0,225E0 +13.50E0,2E0,225E0 +12.50E0,2E0,225E0 +12.50E0,2E0,225E0 +12.50E0,2E0,250E0 +12.00E0,2E0,250E0 +11.50E0,2E0,250E0 +12.00E0,2E0,250E0 +13.00E0,2E0,275E0 +11.50E0,2E0,275E0 +13.00E0,2E0,275E0 +12.50E0,2E0,275E0 +13.50E0,4E0,180E0 +17.50E0,4E0,180E0 +17.50E0,4E0,180E0 +13.50E0,4E0,180E0 +12.50E0,4E0,225E0 +12.50E0,4E0,225E0 +15.00E0,4E0,225E0 +13.00E0,4E0,225E0 +12.00E0,4E0,250E0 +13.00E0,4E0,250E0 +12.00E0,4E0,250E0 +13.50E0,4E0,250E0 +10.00E0,4E0,275E0 +11.50E0,4E0,275E0 +11.00E0,4E0,275E0 +9.50E0,4E0,275E0 +15.00E0,8E0,180E0 +15.00E0,8E0,180E0 +15.50E0,8E0,180E0 +16.00E0,8E0,180E0 +13.00E0,8E0,225E0 +10.50E0,8E0,225E0 +13.50E0,8E0,225E0 +14.00E0,8E0,225E0 +12.50E0,8E0,250E0 +12.00E0,8E0,250E0 +11.50E0,8E0,250E0 +11.50E0,8E0,250E0 +6.50E0,8E0,275E0 +5.50E0,8E0,275E0 +6.00E0,8E0,275E0 +6.00E0,8E0,275E0 +18.50E0,16E0,180E0 +17.00E0,16E0,180E0 +15.30E0,16E0,180E0 +16.00E0,16E0,180E0 +13.00E0,16E0,225E0 +14.00E0,16E0,225E0 +12.50E0,16E0,225E0 +11.00E0,16E0,225E0 +12.00E0,16E0,250E0 +12.00E0,16E0,250E0 +11.50E0,16E0,250E0 +12.00E0,16E0,250E0 +6.00E0,16E0,275E0 +6.00E0,16E0,275E0 +5.00E0,16E0,275E0 +5.50E0,16E0,275E0 +12.50E0,32E0,180E0 +13.00E0,32E0,180E0 +16.00E0,32E0,180E0 +12.00E0,32E0,180E0 +11.00E0,32E0,225E0 +9.50E0,32E0,225E0 +11.00E0,32E0,225E0 +11.00E0,32E0,225E0 +11.00E0,32E0,250E0 +10.00E0,32E0,250E0 +10.50E0,32E0,250E0 +10.50E0,32E0,250E0 +2.70E0,32E0,275E0 +2.70E0,32E0,275E0 +2.50E0,32E0,275E0 +2.40E0,32E0,275E0 +13.00E0,48E0,180E0 +13.50E0,48E0,180E0 +16.50E0,48E0,180E0 +13.60E0,48E0,180E0 +11.50E0,48E0,225E0 +10.50E0,48E0,225E0 +13.50E0,48E0,225E0 +12.00E0,48E0,225E0 +7.00E0,48E0,250E0 +6.90E0,48E0,250E0 +8.80E0,48E0,250E0 +7.90E0,48E0,250E0 +1.20E0,48E0,275E0 +1.50E0,48E0,275E0 +1.00E0,48E0,275E0 +1.50E0,48E0,275E0 +13.00E0,64E0,180E0 +12.50E0,64E0,180E0 +16.50E0,64E0,180E0 +16.00E0,64E0,180E0 +11.00E0,64E0,225E0 +11.50E0,64E0,225E0 +10.50E0,64E0,225E0 +10.00E0,64E0,225E0 +7.27E0,64E0,250E0 +7.50E0,64E0,250E0 +6.70E0,64E0,250E0 +7.60E0,64E0,250E0 +1.50E0,64E0,275E0 +1.00E0,64E0,275E0 +1.20E0,64E0,275E0 +1.20E0,64E0,275E0 \ No newline at end of file diff --git a/tests/data/rat42.csv b/tests/data/rat42.csv new file mode 100644 index 000000000..65216c8b2 --- /dev/null +++ b/tests/data/rat42.csv @@ -0,0 +1,9 @@ +8.930E0,9.000E0 +10.800E0,14.000E0 +18.590E0,21.000E0 +22.330E0,28.000E0 +39.350E0,42.000E0 +56.110E0,57.000E0 +61.730E0,63.000E0 +64.620E0,70.000E0 +67.080E0,79.000E0 \ No newline at end of file diff --git a/tests/data/rat43.csv b/tests/data/rat43.csv new file mode 100644 index 000000000..1c40f8376 --- /dev/null +++ b/tests/data/rat43.csv @@ -0,0 +1,15 @@ +16.08E0,1.0E0 +33.83E0,2.0E0 +65.80E0,3.0E0 +97.20E0,4.0E0 +191.55E0,5.0E0 +326.20E0,6.0E0 +386.87E0,7.0E0 +520.53E0,8.0E0 +590.03E0,9.0E0 +651.92E0,10.0E0 +724.93E0,11.0E0 +699.56E0,12.0E0 +689.96E0,13.0E0 +637.56E0,14.0E0 +717.41E0,15.0E0 \ No newline at end of file diff --git a/tests/data/roszman1.csv b/tests/data/roszman1.csv new file mode 100644 index 000000000..ff56ada16 --- /dev/null +++ b/tests/data/roszman1.csv @@ -0,0 +1,25 @@ +0.252429,-4868.68 +0.252141,-4868.09 +0.251809,-4867.41 +0.297989,-3375.19 +0.296257,-3373.14 +0.295319,-3372.03 +0.339603,-2473.74 +0.337731,-2472.35 +0.333820,-2469.45 +0.389510,-1894.65 +0.386998,-1893.40 +0.438864,-1497.24 +0.434887,-1495.85 +0.427893,-1493.41 +0.471568,-1208.68 +0.461699,-1206.18 +0.461144,-1206.04 +0.513532,-997.92 +0.506641,-996.61 +0.505062,-996.31 +0.535648,-834.94 +0.533726,-834.66 +0.568064,-710.03 +0.612886,-530.16 +0.624169,-464.17 \ No newline at end of file diff --git a/tests/data/thurber.csv b/tests/data/thurber.csv new file mode 100644 index 000000000..ba8d9b16c --- /dev/null +++ b/tests/data/thurber.csv @@ -0,0 +1,37 @@ +80.574E0,-3.067E0 +84.248E0,-2.981E0 +87.264E0,-2.921E0 +87.195E0,-2.912E0 +89.076E0,-2.840E0 +89.608E0,-2.797E0 +89.868E0,-2.702E0 +90.101E0,-2.699E0 +92.405E0,-2.633E0 +95.854E0,-2.481E0 +100.696E0,-2.363E0 +101.060E0,-2.322E0 +401.672E0,-1.501E0 +390.724E0,-1.460E0 +567.534E0,-1.274E0 +635.316E0,-1.212E0 +733.054E0,-1.100E0 +759.087E0,-1.046E0 +894.206E0,-0.915E0 +990.785E0,-0.714E0 +1090.109E0,-0.566E0 +1080.914E0,-0.545E0 +1122.643E0,-0.400E0 +1178.351E0,-0.309E0 +1260.531E0,-0.109E0 +1273.514E0,-0.103E0 +1288.339E0,0.010E0 +1327.543E0,0.119E0 +1353.863E0,0.377E0 +1414.509E0,0.790E0 +1425.208E0,0.963E0 +1421.384E0,1.006E0 +1442.962E0,1.115E0 +1464.350E0,1.572E0 +1468.705E0,1.841E0 +1447.894E0,2.047E0 +1457.628E0,2.200E0 \ No newline at end of file diff --git a/tests/lbfgs_test.cpp b/tests/lbfgs_test.cpp index bf5568320..95d034259 100644 --- a/tests/lbfgs_test.cpp +++ b/tests/lbfgs_test.cpp @@ -12,10 +12,28 @@ #include #include "catch.hpp" +#include "test_function_tools.hpp" using namespace ens; using namespace ens::test; +/** + * Tests the L-BFGS optimizer on the NIST functions. + */ +TEST_CASE("LBFGSNISTTest", "[LBFGSTest]") +{ + // We use a simple instance of the L-BFGS optimizer just to test if the + // optimizer is able to solve one problem from the NIST test suite. + L_BFGS lbfgs(2); + lbfgs.MaxIterations() = 20; + + NISTProblems nistProblems(lbfgs); + arma::vec results = nistProblems.Evaluate(); + + // Just check if the result isn't zero, so at least one problem is solved. + REQUIRE(arma::accu(results) != 0); +} + /** * Tests the L-BFGS optimizer using the Rosenbrock Function. */ diff --git a/tests/test_function_tools.hpp b/tests/test_function_tools.hpp index 31d5fd354..e30176a01 100644 --- a/tests/test_function_tools.hpp +++ b/tests/test_function_tools.hpp @@ -13,8 +13,235 @@ #ifndef ENSMALLEN_TESTS_TEST_FUNCTION_TOOLS_HPP #define ENSMALLEN_TESTS_TEST_FUNCTION_TOOLS_HPP +#include #include "catch.hpp" +using namespace ens; +using namespace ens::test; + +/** + * The National Institute of Standards and Technology has released a set of + * problems to test non-linear least squares solvers. More information about the + * background on these problems and suggested evaluation methodology can be + * found at: + * + * http://www.itl.nist.gov/div898/strd/nls/nls_info.shtml + * + * The problem data themselves can be found at: + * + * http://www.itl.nist.gov/div898/strd/nls/nls_main.shtml + * + * The problems are divided into three levels of difficulty, Lower, + * Average and Higher. For each problem there are two starting guesses, + * the first one far away from the global minimum and the second + * closer to it. + * + * @tparam OptimizerType The optimizer type used to optimize the + * Non-linear Least Square problems. + */ +template +class NISTProblems +{ + public: + /** + * NISTProblems object instantiation with the given optimizer. + * + * @param optimizer The optimizer that is used to solve the NIST problems. + */ + NISTProblems(OptimizerType& optimizer) : optimizer(optimizer) + { + /* Nothing to do here. */ + } + + /** + * Evaluate the optimizer on the NIST Non-linear Least Square problems. + * + * @return Number of successfully solved starting values and the log relative + * error. + */ + arma::vec Evaluate() + { + arma::vec results(3 + 3); + + // Level of difficulty: Lower. + arma::vec lowerResults = arma::zeros(2); + lowerResults += Evaluate("data/misra1a.csv", + arma::mat("2.3894212918E+02, 5.5015643181E-04")); + lowerResults += Evaluate("data/chwirut2.csv", + arma::mat("1.6657666537E-01, 5.1653291286E-03, 1.2150007096E-02")); + lowerResults += Evaluate("data/chwirut1.csv", + arma::mat("1.9027818370E-01, 6.1314004477E-03, 1.0530908399E-02")); + lowerResults += Evaluate("data/lanczos3.csv", + arma::mat("8.6816414977E-02, 9.5498101505E-01, 8.4400777463E-01, \ + 2.9515951832E+00, 1.5825685901E+00, 4.9863565084E+00")); + lowerResults += Evaluate("data/gauss1.csv", + arma::mat("9.8778210871E+01, 1.0497276517E-02, 1.0048990633E+02, \ + 6.7481111276E+01, 2.3129773360E+01, 7.1994503004E+01, \ + 1.7899805021E+02, 1.8389389025E+01")); + lowerResults += Evaluate("data/gauss2.csv", + arma::mat("9.9018328406E+01, 1.0994945399E-02, 1.0188022528E+02, \ + 1.0703095519E+02, 2.3578584029E+01, 7.2045589471E+01, \ + 1.5327010194E+02, 1.9525972636E+01")); + lowerResults += Evaluate("data/danWood.csv", + arma::mat("7.6886226176E-01, 3.8604055871E+00")); + lowerResults += Evaluate("data/misra1b.csv", + arma::mat("3.3799746163E+02, 3.9039091287E-04")); + + // Level of difficulty: Average. + arma::vec averageResults = arma::zeros(2); + averageResults += Evaluate("data/kirby2.csv", + arma::mat("1.6745063063E+00, -1.3927397867E-01, 2.5961181191E-03, \ + -1.7241811870E-03, 2.1664802578E-05")); + averageResults += Evaluate("data/hahn1.csv", + arma::mat("1.0776351733E+00, -1.2269296921E-01, 4.0863750610E-03, \ + -1.4262662514E-06, -5.7609940901E-03, 2.4053735503E-04, \ + -1.2314450199E-07")); + averageResults += Evaluate("data/nelson.csv", + arma::mat("2.5906836021E+00, 5.6177717026E-09, -5.7701013174E-02")); + averageResults += Evaluate("data/mgh17.csv", + arma::mat("3.7541005211E-01, 1.9358469127E+00, -1.4646871366E+00, \ + 1.2867534640E-02, 2.2122699662E-02")); + averageResults += Evaluate("data/lanczos1.csv", + arma::mat("9.5100000027E-02, 1.0000000001E+00, 8.6070000013E-01, \ + 3.0000000002E+00, 1.5575999998E+00, 5.0000000001E+00")); + averageResults += Evaluate("data/lanczos2.csv", + arma::mat("9.6251029939E-02, 1.0057332849E+00, 8.6424689056E-01, \ + 3.0078283915E+00, 1.5529016879E+00, 5.0028798100E+00")); + averageResults += Evaluate("data/gauss3.csv", + arma::mat("9.8940368970E+01, 1.0945879335E-02, 1.0069553078E+02, \ + 1.1163619459E+02, 2.3300500029E+01, 7.3705031418E+01, \ + 1.4776164251E+02, 1.9668221230E+01")); + averageResults += Evaluate("data/misra1c.csv", + arma::mat("6.3642725809E+02, 2.0813627256E-04")); + averageResults += Evaluate("data/misra1d.csv", + arma::mat("4.3736970754E+02, 3.0227324449E-04")); + averageResults += Evaluate("data/roszman1.csv", + arma::mat("2.0196866396E-01, -6.1953516256E-06, 1.2044556708E+03, \ + -1.8134269537E+02")); + averageResults += Evaluate("data/enso.csv", + arma::mat("1.0510749193E+01, 3.0762128085E+00, 5.3280138227E-01, \ + 4.4311088700E+01, -1.6231428586E+00, 5.2554493756E-01, \ + 2.6887614440E+01, 2.1232288488E-01, 1.4966870418E+00")); + + // Level of difficulty: Higher. + arma::vec higherResults = arma::zeros(2); + higherResults += Evaluate("data/mgh09.csv", + arma::mat("1.9280693458E-01, 1.9128232873E-01, 1.2305650693E-01, \ + 1.3606233068E-01")); + higherResults += Evaluate("data/thurber.csv", + arma::mat("1.2881396800E+03, 1.4910792535E+03, 5.8323836877E+02, \ + 7.5416644291E+01, 9.6629502864E-01, 3.9797285797E-01, \ + 4.9727297349E-02")); + higherResults += Evaluate("data/boxBOD.csv", + arma::mat("2.1380940889E+02, 5.4723748542E-01")); + higherResults += Evaluate("data/rat42.csv", + arma::mat("7.2462237576E+01, 2.6180768402E+00, 6.7359200066E-02")); + higherResults += Evaluate("data/mgh10.csv", + arma::mat("5.6096364710E-03, 6.1813463463E+03, 3.4522363462E+02")); + higherResults += Evaluate("data/eckerle4.csv", + arma::mat("1.5543827178E+00, 4.0888321754E+00, 4.5154121844E+02")); + higherResults += Evaluate("data/rat43.csv", + arma::mat("6.9964151270E+02, 5.2771253025E+00, 7.5962938329E-01, \ + 1.2792483859E+00")); + higherResults += Evaluate("data/bennett5.csv", + arma::mat("-2.5235058043E+03, 4.6736564644E+010, 9.3218483193E-01")); + + results(0) = lowerResults(0); + results(1) = lowerResults(1) / lowerResults(0); + + results(2) = averageResults(0); + results(3) = averageResults(0) > 0 ? averageResults(1) / + averageResults(0) : 0; + + results(4) = higherResults(0); + results(5) = higherResults(0) > 0 ? higherResults(1) / + higherResults(0) : 0; + + Info << "Level of Difficulty: Lower solved: " << lowerResults(0) + << " LRE: " << lowerResults(1) << std::endl; + Info << "Level of Difficulty: Average solved: " << averageResults(0) + << " LRE: " << averageResults(1) << std::endl; + Info << "Level of Difficulty: Higher solved: " << higherResults(0) + << " LRE: " << higherResults(1) << std::endl; + + return results; + } + + private: + //! The locally stored optimizer. + OptimizerType optimizer; + + /** + * Evaluate the optimizer on the given function. + * + * @tparam FuctionType The function type of the Non-linear Least Square + * problem. + * @param filename The filename that holds the Non-linear Least Squares + * problem predictions and responses. + * @param expected The expected output. + * @return Number of successfully solved starting values and the log relative + * error. + */ + template + arma::vec Evaluate(const std::string& filename, const arma::mat& expected) + { + arma::vec results = arma::zeros(2); + size_t result = 0; + + arma::mat data; + data.load(filename, arma::csv_ascii); + inplace_trans(data); + + const arma::mat predictors = data.rows(1, data.n_rows - 1); + const arma::rowvec responses = data.row(0); + + NIST function(predictors, responses); + + for (size_t i = 0; i < function.Function().Functions(); ++i) + { + arma::mat coordinates = function.GetInitialPoint(i); + optimizer.Optimize(function, coordinates); + + const double lre = LogRelativeError(expected, coordinates); + if (lre > 4) + { + results(0)++; + results(1) += lre; + } + } + + const double lre = (results(0) > 0 ? (results(1) / results(0)) : 0); + + Info << "Problem: " << filename << " solved: " << results(0) << " of " + << function.Function().Functions() << " LRE: " << lre << std::endl; + + return results; + } + + /** + * Compute the log relative error by comparing each component of the solution + * with the ground truth, and taking the minimum. + * + * @param expected The expected output. + * @param actual The actual calculated output by the optimizer. + * @return The log relative error. + */ + double LogRelativeError(const arma::mat& expected, const arma::mat& actual) + { + double lre = 12; + for (size_t i = 0; i < expected.n_elem; ++i) + { + const double tlre = -std::log10(std::fabs(expected(i) - actual(i)) / + std::fabs(expected(i))); + + lre = std::min(lre, std::max(0.0, std::min(11.0, tlre))); + } + + return lre; + } + +}; + /** * Create the data for the a logistic regression test. *