diff --git a/ChangeLog b/ChangeLog index 5e58ac5..31ec931 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-12-03 James Balamuta + + * DESCRIPTION: Updated requirements for Armadillo and C++ compiler + + * DESCRIPTION (Version): Release 2.22.1 + * NEWS.md: Update for Ensmallen release 2.22.1 + * inst/include/ensmallen_bits: Upgraded to Ensmallen 2.22.1 + * inst/include/ensmallen.hpp: ditto + 2024-11-29 James Balamuta * inst/include/ensmallen_bits/agemoea/agemoea.hpp: removed unused private field variable diff --git a/DESCRIPTION b/DESCRIPTION index 0f6c938..b781b7c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: RcppEnsmallen Title: Header-Only C++ Mathematical Optimization Library for 'Armadillo' -Version: 0.2.22.0.1 +Version: 0.2.22.1.1 Authors@R: c( person("James Joseph", "Balamuta", email = "balamut2@illinois.edu", role = c("aut", "cre", "cph"), @@ -22,15 +22,15 @@ Description: 'Ensmallen' is a templated C++ mathematical optimization library 'RcppArmadillo' (the 'Rcpp' bindings/bridge to 'Armadillo') is licensed under the GNU GPL version 2 or later. Thus, 'RcppEnsmallen' is also licensed under similar terms. Note that 'Ensmallen' requires a compiler that supports - 'C++11' and 'Armadillo' 9.800 or later. + 'C++14' and 'Armadillo' 10.8.2 or later. Depends: R (>= 4.0.0) License: GPL (>= 2) URL: https://github.com/coatless-rpkg/rcppensmallen, https://r-pkg.thecoatlessprofessor.com/rcppensmallen/, https://github.com/mlpack/ensmallen, https://ensmallen.org/ BugReports: https://github.com/coatless-rpkg/rcppensmallen/issues Encoding: UTF-8 -LinkingTo: Rcpp, RcppArmadillo (>= 0.9.800.0.0) +LinkingTo: Rcpp, RcppArmadillo (>= 0.10.8.2.0) Imports: Rcpp -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) Suggests: knitr, diff --git a/NEWS.md b/NEWS.md index 279373f..6646136 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# RcppEnsmallen 0.2.22.1.1 + +- Upgraded to ensmallen 2.22.1: "E-Bike Excitement" (2024-12-03) + - Remove unused variables to fix compiler warnings + ([#413](https://github.com/mlpack/ensmallen/pull/413)). +- DESCRIPTION now emphasizes a C++14 or greater compiler and a requirement for + Armadillo 10.8.2 or higher library. + ([#68](https://github.com/coatless-rpkg/rcppensmallen/pull/68)). + # RcppEnsmallen 0.2.22.0.1 - Upgraded to ensmallen 2.22.0: "E-Bike Excitement" (2024-11-29) diff --git a/inst/include/ensmallen_bits/agemoea/agemoea.hpp b/inst/include/ensmallen_bits/agemoea/agemoea.hpp index 0748678..9f914da 100644 --- a/inst/include/ensmallen_bits/agemoea/agemoea.hpp +++ b/inst/include/ensmallen_bits/agemoea/agemoea.hpp @@ -347,7 +347,7 @@ class AGEMOEA size_t idxQ, const std::vector& ranks, const std::vector& survivalScore); - + /** * Normalizes the front given the extreme points in the current front. * @@ -363,7 +363,7 @@ class AGEMOEA arma::Col& normalization, const std::vector& front, const arma::Row& extreme); - + /** * Get the geometry information p of Lp norm (p > 0). * @@ -377,7 +377,7 @@ class AGEMOEA std::vector >& calculatedObjectives, const std::vector& front, const arma::Row& extreme); - + /** * Finds the pairwise Lp distance between all the points in the front. * @@ -395,7 +395,7 @@ class AGEMOEA /** * Finding the indexes of the extreme points in the front. - * + * * @param indexes vector containing the slected indexes. * @param calculatedObjectives The current population objectives. * @param front The front of the current generation. @@ -405,11 +405,11 @@ class AGEMOEA arma::Row& indexes, std::vector >& calculatedObjectives, const std::vector& front); - + /** * Finding the distance of each point in the front from the line formed * by pointA and pointB. - * + * * @param distance The vector containing the distances of the points in the fron from the line. * @param calculatedObjectives Reference to the current population evaluated Objectives. * @param front The front of the current generation(indices of population). @@ -423,10 +423,10 @@ class AGEMOEA const std::vector& front, const arma::Col& pointA, const arma::Col& pointB); - + /** * Find the Diversity score corresponding the solution S using the selected set. - * + * * @param selected The current selected set. * @param pairwiseDistance The current pairwise distance for the whole front. * @param S The relative index of S being considered within the front. diff --git a/inst/include/ensmallen_bits/ens_version.hpp b/inst/include/ensmallen_bits/ens_version.hpp index 45412ba..86c29ba 100644 --- a/inst/include/ensmallen_bits/ens_version.hpp +++ b/inst/include/ensmallen_bits/ens_version.hpp @@ -16,7 +16,7 @@ // The minor version is two digits so regular numerical comparisons of versions // work right. The first minor version of a release is always 10. #define ENS_VERSION_MINOR 22 -#define ENS_VERSION_PATCH 0 +#define ENS_VERSION_PATCH 1 // If this is a release candidate, it will be reflected in the version name // (i.e. the version name will be "RC1", "RC2", etc.). Otherwise the version // name will typically be a seemingly arbitrary set of words that does not @@ -24,8 +24,8 @@ #define ENS_VERSION_NAME "E-Bike Excitement" // Incorporate the date the version was released. #define ENS_VERSION_YEAR "2024" -#define ENS_VERSION_MONTH "11" -#define ENS_VERSION_DAY "29" +#define ENS_VERSION_MONTH "12" +#define ENS_VERSION_DAY "02" namespace ens { diff --git a/inst/include/ensmallen_bits/problems/dtlz/dtlz2_function.hpp b/inst/include/ensmallen_bits/problems/dtlz/dtlz2_function.hpp index aa56a14..6b9dcd2 100644 --- a/inst/include/ensmallen_bits/problems/dtlz/dtlz2_function.hpp +++ b/inst/include/ensmallen_bits/problems/dtlz/dtlz2_function.hpp @@ -23,8 +23,8 @@ namespace test { * \f[ * x_M = [x_i, n - M + 1 <= i <= n] * g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2 - * - * f_1(x) = 0.5 * cos(x_1 * pi * 0.5) * cos(x_2 * pi * 0.5) * ... cos(x_2 * pi * 0.5) * (1 + g(x_M)) + * + * f_1(x) = 0.5 * cos(x_1 * pi * 0.5) * cos(x_2 * pi * 0.5) * ... cos(x_2 * pi * 0.5) * (1 + g(x_M)) * f_2(x) = 0.5 * cos(x_1 * pi * 0.5) * cos(x_2 * pi * 0.5) * ... sin(x_M-1 * pi * 0.5) * (1 + g(x_M)) * . * . @@ -35,9 +35,9 @@ namespace test { * 0 <= x_i <= 1 for i = 1,...,n. * * This should be optimized to x_i = 0.5 (for all x_i in x_M), at: - * + * * For more information, please refer to: - * + * * @code * @incollection{deb2005scalable, * title={Scalable test problems for evolutionary multiobjective optimization}, @@ -62,7 +62,7 @@ namespace test { size_t numParetoPoints; public: - + /** * Object Constructor. * Initializes the individual objective functions. @@ -82,10 +82,10 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, 1, arma::fill::zeros); - } - + } + // Get the private variables. - + // Get the number of objectives. size_t GetNumObjectives () { return this -> numObjectives; } @@ -113,16 +113,16 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + for(size_t i = numObjectives - 1; i < numVariables; i++) { - innerSum += arma::pow((coords.row(i) - 0.5), 2); - } - + innerSum += arma::pow((coords.row(i) - 0.5), 2); + } + return innerSum; - } + } /** * Evaluate the objectives with the given coordinate. @@ -140,21 +140,21 @@ namespace test { arma::Row value = 0.5 * (1.0 + G); for(size_t i = 0; i < numObjectives - 1; i++) { - objectives.row(i) = value % + objectives.row(i) = value % arma::sin(coords.row(i) * arma::datum::pi * 0.5); - value = value % arma::cos(coords.row(i) * arma::datum::pi * 0.5); + value = value % arma::cos(coords.row(i) * arma::datum::pi * 0.5); } objectives.row(numObjectives - 1) = value; - return objectives; + return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct DTLZ2Objective { DTLZ2Objective(size_t stop, DTLZ2& dtlz): stop(stop), dtlz(dtlz) - {/* Nothing to do here. */} - + {/* Nothing to do here. */} + /** * Evaluate one objective with the given coordinate. * @@ -181,8 +181,8 @@ namespace test { } value = value * (1.0 + dtlz.g(coords)[0]); - return value; - } + return value; + } DTLZ2& dtlz; size_t stop; @@ -192,12 +192,12 @@ namespace test { std::tuple GetObjectives() { return std::make_tuple(objectiveF1, objectiveF2, objectiveF3); - } + } //! Get the Reference Front. //! Front. The implementation has been taken from pymoo. arma::mat GetReferenceFront() - { + { Uniform refGenerator; arma::mat refDirs = refGenerator.Generate(3, this -> numParetoPoints, 0); arma::colvec x = arma::normalise(refDirs, 2, 1); @@ -213,4 +213,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/inst/include/ensmallen_bits/problems/dtlz/dtlz4_function.hpp b/inst/include/ensmallen_bits/problems/dtlz/dtlz4_function.hpp index b01fd30..efcf381 100644 --- a/inst/include/ensmallen_bits/problems/dtlz/dtlz4_function.hpp +++ b/inst/include/ensmallen_bits/problems/dtlz/dtlz4_function.hpp @@ -23,8 +23,8 @@ namespace test { * \f[ * x_M = [x_i, n - M + 1 <= i <= n] * g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2 - * - * f_1(x) = 0.5 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... cos(x_2^alpha * pi * 0.5) * (1 + g(x_M)) + * + * f_1(x) = 0.5 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... cos(x_2^alpha * pi * 0.5) * (1 + g(x_M)) * f_2(x) = 0.5 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... sin(x_M-1^alpha * pi * 0.5) * (1 + g(x_M)) * . * . @@ -35,9 +35,9 @@ namespace test { * 0 <= x_i <= 1 for i = 1,...,n. * * This should be optimized to x_i = 0.5 (for all x_i in x_M), at: - * + * * For more information, please refer to: - * + * * @code * @incollection{deb2005scalable, * title={Scalable test problems for evolutionary multiobjective optimization}, @@ -85,8 +85,8 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, 1, arma::fill::zeros); - } - + } + // Get the private variables. // Get the number of objectives. @@ -116,16 +116,16 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + for(size_t i = numObjectives - 1; i < numVariables; i++) { - innerSum += arma::pow((coords.row(i) - 0.5), 2); - } - + innerSum += arma::pow((coords.row(i) - 0.5), 2); + } + return innerSum; - } + } /** * Evaluate the objectives with the given coordinate. @@ -143,21 +143,21 @@ namespace test { arma::Row value = 0.5 * (1.0 + G); for(size_t i = 0; i < numObjectives - 1; i++) { - objectives.row(i) = value % + objectives.row(i) = value % arma::sin(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5); - value = value % arma::cos(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5); + value = value % arma::cos(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5); } objectives.row(numObjectives - 1) = value; - return objectives; + return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct DTLZ4Objective { DTLZ4Objective(size_t stop, DTLZ4& dtlz): stop(stop), dtlz(dtlz) - {/* Nothing to do here.*/} - + {/* Nothing to do here.*/} + /** * Evaluate one objective with the given coordinate. * @@ -184,8 +184,8 @@ namespace test { } value = value * (1 + dtlz.g(coords)[0]); - return value; - } + return value; + } DTLZ4& dtlz; size_t stop; @@ -195,12 +195,12 @@ namespace test { std::tuple GetObjectives() { return std::make_tuple(objectiveF1, objectiveF2, objectiveF3); - } + } //! Get the Reference Front. //! Front. The implementation has been taken from pymoo. arma::mat GetReferenceFront() - { + { Uniform refGenerator; arma::mat refDirs = refGenerator.Generate(3, this -> numParetoPoints, 0); arma::colvec x = arma::normalise(refDirs, 2, 1); @@ -216,4 +216,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/inst/include/ensmallen_bits/problems/dtlz/dtlz5_function.hpp b/inst/include/ensmallen_bits/problems/dtlz/dtlz5_function.hpp index 6c7de5c..1a4126d 100644 --- a/inst/include/ensmallen_bits/problems/dtlz/dtlz5_function.hpp +++ b/inst/include/ensmallen_bits/problems/dtlz/dtlz5_function.hpp @@ -21,8 +21,8 @@ namespace test { * \f[ * theta_M = [theta_i, n - M + 1 <= i <= n] * g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2 - * - * f_1(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... cos(theta_M-1 * pi * 0.5) * (1 + g(theta_M)) + * + * f_1(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... cos(theta_M-1 * pi * 0.5) * (1 + g(theta_M)) * f_2(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... sin(theta_M-1 * pi * 0.5) * (1 + g(theta_M)) * . * . @@ -31,13 +31,13 @@ namespace test { * * Bounds of the variable space is: * 0 <= x_i <= 1 for i = 1,...,n. - * + * * Where theta_i = 0.5 * (1 + 2 * g(X_M) * x_i) / (1 + g(X_M)) - * + * * This should be optimized to x_i = 0.5 (for all x_i in X_M), at: - * + * * For more information, please refer to: - * + * * @code * @incollection{deb2005scalable, * title={Scalable test problems for evolutionary multiobjective optimization}, @@ -82,14 +82,14 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, 1, arma::fill::zeros); - } - + } + // Get the private variables. - + // Get the number of objectives. size_t GetNumObjectives() { return this -> numObjectives; } - + // Get the number of variables. size_t GetNumVariables() { return this -> numVariables; } @@ -113,16 +113,16 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + for(size_t i = numObjectives - 1; i < numVariables; i++) { - innerSum += arma::pow((coords.row(i) - 0.5), 2); - } - + innerSum += arma::pow((coords.row(i) - 0.5), 2); + } + return innerSum; - } + } /** * Evaluate the objectives with the given coordinate. @@ -136,27 +136,27 @@ namespace test { typedef typename MatType::elem_type ElemType; arma::Mat objectives(numObjectives, size(coords)[1]); - arma::Row G = g(coords); + arma::Row G = g(coords); arma::Row value = 0.5 * (1.0 + G); arma::Row theta; for(size_t i = 0; i < numObjectives - 1; i++) { theta = 0.5 * (1.0 + 2.0 * coords.row(i) % G) / (1.0 + G); - objectives.row(i) = value % + objectives.row(i) = value % arma::sin(theta * arma::datum::pi * 0.5); - value = value % arma::cos(theta * arma::datum::pi * 0.5); + value = value % arma::cos(theta * arma::datum::pi * 0.5); } objectives.row(numObjectives - 1) = value; return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct DTLZ5Objective { DTLZ5Objective(size_t stop, DTLZ5& dtlz): stop(stop), dtlz(dtlz) - {/* Nothing to do here. */} - + {/* Nothing to do here. */} + /** * Evaluate one objective with the given coordinate. * @@ -172,7 +172,7 @@ namespace test { ElemType G = dtlz.g(coords)[0]; for(size_t i = 0; i < stop; i++) { - theta = 0.5 * (1.0 + 2.0 * coords[i] * G) / (1.0 + G); + theta = 0.5 * (1.0 + 2.0 * coords[i] * G) / (1.0 + G); value = value * std::cos(theta * arma::datum::pi * 0.5); } theta = 0.5 * (1.0 + 2.0 * coords[stop] * G) / (1.0 + G); @@ -186,8 +186,8 @@ namespace test { } value = value * (1.0 + G); - return value; - } + return value; + } DTLZ5& dtlz; size_t stop; @@ -197,7 +197,7 @@ namespace test { std::tuple GetObjectives () { return std::make_tuple(objectiveF1, objectiveF2, objectiveF3); - } + } DTLZ5Objective objectiveF1; DTLZ5Objective objectiveF2; @@ -206,4 +206,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/inst/include/ensmallen_bits/problems/dtlz/dtlz6_function.hpp b/inst/include/ensmallen_bits/problems/dtlz/dtlz6_function.hpp index c9e4f11..c56fd7b 100644 --- a/inst/include/ensmallen_bits/problems/dtlz/dtlz6_function.hpp +++ b/inst/include/ensmallen_bits/problems/dtlz/dtlz6_function.hpp @@ -21,8 +21,8 @@ namespace test { * \f[ * theta_M = [theta_i, n - M + 1 <= i <= n] * g(x) = \Sigma{i = n - M + 1}^n (x_i)^0.1 - * - * f_1(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... cos(theta_2 * pi * 0.5) * (1 + g(theta_M)) + * + * f_1(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... cos(theta_2 * pi * 0.5) * (1 + g(theta_M)) * f_2(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... sin(theta_M-1 * pi * 0.5) * (1 + g(theta_M)) * . * . @@ -31,13 +31,13 @@ namespace test { * * Bounds of the variable space is: * 0 <= x_i <= 1 for i = 1,...,n. - * + * * Where theta_i = 0.5 * (1 + 2 * g(X_M) * x_i) / (1 + g(X_M)) - * + * * This should be optimized to x_i = 0.5 (for all x_i in X_M), at: - * + * * For more information, please refer to: - * + * * @code * @incollection{deb2005scalable, * title={Scalable test problems for evolutionary multiobjective optimization}, @@ -82,8 +82,8 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, 1, arma::fill::zeros); - } - + } + // Get the private variables. // Get number of obectives. @@ -113,16 +113,16 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + for(size_t i = numObjectives - 1; i < numVariables; i++) { - innerSum += arma::pow(coords.row(i), 0.1); + innerSum += arma::pow(coords.row(i), 0.1); } - + return innerSum; - } + } /** * Evaluate the objectives with the given coordinate. @@ -136,27 +136,27 @@ namespace test { typedef typename MatType::elem_type ElemType; arma::Mat objectives(numObjectives, size(coords)[1]); - arma::Row G = g(coords); + arma::Row G = g(coords); arma::Row value = 0.5 * (1.0 + G); arma::Row theta; for(size_t i = 0; i < numObjectives - 1; i++) { theta = 0.5 * (1.0 + 2.0 * coords.row(i) % G) / (1.0 + G); - objectives.row(i) = value % + objectives.row(i) = value % arma::sin(theta * arma::datum::pi * 0.5); - value = value % arma::cos(theta * arma::datum::pi * 0.5); + value = value % arma::cos(theta * arma::datum::pi * 0.5); } objectives.row(numObjectives - 1) = value; return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct DTLZ6Objective { DTLZ6Objective(size_t stop, DTLZ6& dtlz): stop(stop), dtlz(dtlz) - {/* Nothing to do here. */} - + {/* Nothing to do here. */} + /** * Evaluate one objective with the given coordinate. * @@ -172,7 +172,7 @@ namespace test { ElemType G = dtlz.g(coords)[0]; for(size_t i = 0; i < stop; i++) { - theta = 0.5 * (1.0 + 2.0 * coords[i] * G) / (1.0 + G); + theta = 0.5 * (1.0 + 2.0 * coords[i] * G) / (1.0 + G); value = value * std::cos(theta * arma::datum::pi * 0.5); } theta = 0.5 * (1.0 + 2.0 * coords[stop] * G) / (1.0 + G); @@ -186,8 +186,8 @@ namespace test { } value = value * (1.0 + G); - return value; - } + return value; + } DTLZ6& dtlz; size_t stop; @@ -197,7 +197,7 @@ namespace test { std::tuple GetObjectives () { return std::make_tuple(objectiveF1, objectiveF2, objectiveF3); - } + } DTLZ6Objective objectiveF1; DTLZ6Objective objectiveF2; @@ -206,4 +206,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/inst/include/ensmallen_bits/problems/dtlz/dtlz7_function.hpp b/inst/include/ensmallen_bits/problems/dtlz/dtlz7_function.hpp index fc2959e..99a262f 100644 --- a/inst/include/ensmallen_bits/problems/dtlz/dtlz7_function.hpp +++ b/inst/include/ensmallen_bits/problems/dtlz/dtlz7_function.hpp @@ -20,8 +20,8 @@ namespace test { * The DTLZ7 function, defined by: * \f[ * x_M = [x_i, n - M + 1 <= i <= n] - * g(x) = 1 + (9 / |X_M|) * (\Sigma{i = n - M + 1}^n x_i) - * + * g(x) = 1 + (9 / |X_M|) * (\Sigma{i = n - M + 1}^n x_i) + * * f_1(x) = x_1 * f_2(x) = x_2 * . @@ -33,7 +33,7 @@ namespace test { * 0 <= x_i <= 1 for i = 1,...,n. * * This should be optimized to x_i = 0.5 (for all x_i in x_M), at: - * the objective function values lie on the linear hyper-plane: + * the objective function values lie on the linear hyper-plane: * \Sigma { m = 1}^M f_m* =0.5. * * For more information, please refer to: @@ -100,7 +100,7 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, arma::fill::zeros); - } + } /** * Evaluate the G(x) with the given coordinate. @@ -114,11 +114,11 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + innerSum = (9.0 / k) * arma::sum(coords.rows(numObjectives - 1, - numVariables - 1) , 0) + 1.0; + numVariables - 1) , 0) + 1.0; return innerSum; } @@ -134,13 +134,13 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::ones); innerSum = innerSum * numObjectives; for(size_t i = 0;i < numObjectives - 1;i++) { - innerSum -= coords.row(i) % (1.0 + - arma::cos(arma::datum::pi * 3 * coords.row(i))) / (1 + G); + innerSum -= coords.row(i) % (1.0 + + arma::cos(arma::datum::pi * 3 * coords.row(i))) / (1 + G); } return innerSum; } @@ -156,21 +156,21 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - arma::Mat objectives(numObjectives, size(coords)[1]); + arma::Mat objectives(numObjectives, size(coords)[1]); arma::Row G = g(coords); arma::Row H = h(coords, G); objectives.rows(0, numObjectives - 2) = coords.rows(0, numObjectives - 2); objectives.row(numObjectives - 1) = (1 + G) % H; - return objectives; + return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct DTLZ7Objective { DTLZ7Objective(size_t stop, DTLZ7& dtlz): stop(stop), dtlz(dtlz) - {/* Nothing to do here. */} - + {/* Nothing to do here. */} + /** * Evaluate one objective with the given coordinate. * @@ -184,10 +184,10 @@ namespace test { ElemType value = 0.5; if(stop != dtlz.numObjectives - 1) { return coords[stop];} - + value = (1.0 + dtlz.g(coords)[0]) * dtlz.h(coords, dtlz.g(coords))[0]; - return value; - } + return value; + } DTLZ7& dtlz; size_t stop; @@ -197,7 +197,7 @@ namespace test { std::tuple GetObjectives() { return std::make_tuple(objectiveF1, objectiveF2, objectiveF3); - } + } DTLZ7Objective objectiveF1; DTLZ7Objective objectiveF2; @@ -210,4 +210,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/inst/include/ensmallen_bits/problems/maf/maf5_function.hpp b/inst/include/ensmallen_bits/problems/maf/maf5_function.hpp index 1ac5f1b..db8c16f 100644 --- a/inst/include/ensmallen_bits/problems/maf/maf5_function.hpp +++ b/inst/include/ensmallen_bits/problems/maf/maf5_function.hpp @@ -23,8 +23,8 @@ namespace test { * \f[ * x_M = [x_i, n - M + 1 <= i <= n] * g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2 - * - * f_1(x) = a^M * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... cos(x_2^alpha * pi * 0.5) * (1 + g(x_M)) + * + * f_1(x) = a^M * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... cos(x_2^alpha * pi * 0.5) * (1 + g(x_M)) * f_2(x) = a^M-1 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... sin(x_M-1^alpha * pi * 0.5) * (1 + g(x_M)) * . * . @@ -35,9 +35,9 @@ namespace test { * 0 <= x_i <= 1 for i = 1,...,n. * * This should be optimized to x_i = 0.5 (for all x_i in x_M), at: - * + * * For more information, please refer to: - * + * * @code * @article{cheng2017benchmark, * title={A benchmark test suite for evolutionary many-objective optimization}, @@ -87,8 +87,8 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, 1, arma::fill::zeros); - } - + } + // Get the private variables. // Get the number of objectives. @@ -109,7 +109,7 @@ namespace test { /** * Set the scale factor a. - * + * * @param a The scale factor of the objectives. */ void SetA(double a) @@ -117,7 +117,7 @@ namespace test { /** * Set the power of each variable alpha. - * + * * @param alpha The power of each variable. */ void SetAlpha(size_t alpha) @@ -134,16 +134,16 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + for (size_t i = numObjectives - 1; i < numVariables; i++) { - innerSum += arma::pow((coords.row(i) - 0.5), 2); - } - + innerSum += arma::pow((coords.row(i) - 0.5), 2); + } + return innerSum; - } + } /** * Evaluate the objectives with the given coordinate. @@ -161,22 +161,22 @@ namespace test { arma::Row value = (1.0 + G); for (size_t i = 0; i < numObjectives - 1; i++) { - objectives.row(i) = std::pow(a, i + 1) * arma::pow(value, 4) % - arma::pow(arma::sin(arma::pow(coords.row(i), alpha) * + objectives.row(i) = std::pow(a, i + 1) * arma::pow(value, 4) % + arma::pow(arma::sin(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5), 4); - value = value % arma::cos(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5); + value = value % arma::cos(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5); } objectives.row(numObjectives - 1) = arma::pow(value, 4) * std::pow(a, numObjectives); return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct MAF5Objective { MAF5Objective(size_t stop, MAF5& maf): stop(stop), maf(maf) - {/* Nothing to do here.*/} - + {/* Nothing to do here.*/} + /** * Evaluate one objective with the given coordinate. * @@ -190,21 +190,21 @@ namespace test { ElemType value = 1.0; for (size_t i = 0; i < stop; i++) { - value = value * std::cos(std::pow(coords[i], maf.GetAlpha()) + value = value * std::cos(std::pow(coords[i], maf.GetAlpha()) * arma::datum::pi * 0.5); } if(stop != maf.GetNumObjectives() - 1) { - value = value * std::sin(std::pow(coords[stop], maf.GetAlpha()) + value = value * std::sin(std::pow(coords[stop], maf.GetAlpha()) * arma::datum::pi * 0.5); } value = value * (1 + maf.g(coords)[0]); value = std::pow(value, 4); - value = value * std::pow(maf.GetA(), stop + 1); + value = value * std::pow(maf.GetA(), stop + 1); return value; - } + } MAF5& maf; size_t stop; @@ -214,7 +214,7 @@ namespace test { std::tuple GetObjectives() { return std::make_tuple(objectiveF1, objectiveF2, objectiveF3); - } + } MAF5Objective objectiveF1; MAF5Objective objectiveF2; @@ -223,4 +223,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/inst/include/ensmallen_bits/problems/maf/maf6_function.hpp b/inst/include/ensmallen_bits/problems/maf/maf6_function.hpp index e023906..2ace864 100644 --- a/inst/include/ensmallen_bits/problems/maf/maf6_function.hpp +++ b/inst/include/ensmallen_bits/problems/maf/maf6_function.hpp @@ -21,8 +21,8 @@ namespace test { * \f[ * theta_M = [theta_i, n - M + 1 <= i <= n] * g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2 - * - * f_1(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... cos(theta_2 * pi * 0.5) * (1 + g(theta_M)) + * + * f_1(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... cos(theta_2 * pi * 0.5) * (1 + g(theta_M)) * f_2(x) = 0.5 * cos(theta_1 * pi * 0.5) * cos(theta_2 * pi * 0.5) * ... sin(theta_M-1 * pi * 0.5) * (1 + g(theta_M)) * . * . @@ -31,13 +31,13 @@ namespace test { * * Bounds of the variable space is: * 0 <= x_i <= 1 for i = 1,...,n. - * + * * Where theta_i = 0.5 * (1 + 2 * g(X_M) * x_i) / (1 + g(X_M)) - * + * * This should be optimized to x_i = 0.5 (for all x_i in X_M), at: - * + * * For more information, please refer to: - * + * * @code * @article{cheng2017benchmark, * title={A benchmark test suite for evolutionary many-objective optimization}, @@ -85,13 +85,13 @@ namespace test { typedef typename MatType::elem_type ElemType; return arma::Col(numVariables, 1, arma::fill::zeros); } - + // Get the private variables. - + // Get the number of objectives. size_t GetNumObjectives() { return this -> numObjectives; } - + // Get the number of variables. size_t GetNumVariables() { return this -> numVariables; } @@ -119,16 +119,16 @@ namespace test { // Convenience typedef. typedef typename MatType::elem_type ElemType; - + arma::Row innerSum(size(coords)[1], arma::fill::zeros); - + for (size_t i = numObjectives - 1; i < numVariables; i++) { - innerSum += arma::pow((coords.row(i) - 0.5), 2); - } - + innerSum += arma::pow((coords.row(i) - 0.5), 2); + } + return innerSum; - } + } /** * Evaluate the objectives with the given coordinate. @@ -142,34 +142,34 @@ namespace test { typedef typename MatType::elem_type ElemType; arma::Mat objectives(numObjectives, size(coords)[1]); - arma::Row G = g(coords); + arma::Row G = g(coords); arma::Row value = (1.0 + 100 * G); arma::Row theta; for (size_t i = 0; i < numObjectives - 1; i++) { if(i < I) - { + { theta = coords.row(i) * arma::datum::pi * 0.5; } else { theta = 0.25 * (1.0 + 2.0 * coords.row(i) % G) / (1.0 + G); } - objectives.row(i) = value % + objectives.row(i) = value % arma::sin(theta); - value = value % arma::cos(theta); + value = value % arma::cos(theta); } objectives.row(numObjectives - 1) = value; return objectives; } - + // Individual Objective function. - // Changes based on stop variable provided. + // Changes based on stop variable provided. struct MAF6Objective { MAF6Objective(size_t stop, MAF6& maf): stop(stop), maf(maf) {/* Nothing to do here. */} - + /** * Evaluate one objective with the given coordinate. * @@ -211,8 +211,8 @@ namespace test { } value = value * (1.0 + 100 * G); - return value; - } + return value; + } MAF6& maf; size_t stop; @@ -231,4 +231,4 @@ namespace test { } //namespace test } //namespace ens -#endif +#endif \ No newline at end of file diff --git a/man/RcppEnsmallen-package.Rd b/man/RcppEnsmallen-package.Rd index 059c706..6d38562 100644 --- a/man/RcppEnsmallen-package.Rd +++ b/man/RcppEnsmallen-package.Rd @@ -6,7 +6,7 @@ \alias{RcppEnsmallen-package} \title{RcppEnsmallen: Header-Only C++ Mathematical Optimization Library for 'Armadillo'} \description{ -'Ensmallen' is a templated C++ mathematical optimization library (by the 'MLPACK' team) that provides a simple set of abstractions for writing an objective function to optimize. Provided within are various standard and cutting-edge optimizers that include full-batch gradient descent techniques, small-batch techniques, gradient-free optimizers, and constrained optimization. The 'RcppEnsmallen' package includes the header files from the 'Ensmallen' library and pairs the appropriate header files from 'armadillo' through the 'RcppArmadillo' package. Therefore, users do not need to install 'Ensmallen' nor 'Armadillo' to use 'RcppEnsmallen'. Note that 'Ensmallen' is licensed under 3-Clause BSD, 'Armadillo' starting from 7.800.0 is licensed under Apache License 2, 'RcppArmadillo' (the 'Rcpp' bindings/bridge to 'Armadillo') is licensed under the GNU GPL version 2 or later. Thus, 'RcppEnsmallen' is also licensed under similar terms. Note that 'Ensmallen' requires a compiler that supports 'C++11' and 'Armadillo' 9.800 or later. +'Ensmallen' is a templated C++ mathematical optimization library (by the 'MLPACK' team) that provides a simple set of abstractions for writing an objective function to optimize. Provided within are various standard and cutting-edge optimizers that include full-batch gradient descent techniques, small-batch techniques, gradient-free optimizers, and constrained optimization. The 'RcppEnsmallen' package includes the header files from the 'Ensmallen' library and pairs the appropriate header files from 'armadillo' through the 'RcppArmadillo' package. Therefore, users do not need to install 'Ensmallen' nor 'Armadillo' to use 'RcppEnsmallen'. Note that 'Ensmallen' is licensed under 3-Clause BSD, 'Armadillo' starting from 7.800.0 is licensed under Apache License 2, 'RcppArmadillo' (the 'Rcpp' bindings/bridge to 'Armadillo') is licensed under the GNU GPL version 2 or later. Thus, 'RcppEnsmallen' is also licensed under similar terms. Note that 'Ensmallen' requires a compiler that supports 'C++14' and 'Armadillo' 10.8.2 or later. } \seealso{ Useful links: diff --git a/tools/HISTORYold.md b/tools/HISTORYold.md index 9b53459..5b33034 100644 --- a/tools/HISTORYold.md +++ b/tools/HISTORYold.md @@ -1,3 +1,8 @@ +### ensmallen 2.22.1: "E-Bike Excitement" +###### 2024-12-02 + * Remove unused variables to fix compiler warnings + ([#413](https://github.com/mlpack/ensmallen/pull/413)). + ### ensmallen 2.22.0: "E-Bike Excitement" ###### 2024-11-29 * Update to C++14 standard