Skip to content

Commit

Permalink
Upgrade ensmallen to 2.20.0 (#57)
Browse files Browse the repository at this point in the history
* Upgrade ensmallen to 2.20.0

* fix entry

* Fix entries in HISTORYold.md

* Update NEWS.md

* Attempt to restore all URLs in NEWS.md

* Remove C++11 designation

* Add revdep checks

* Drop CXX11 specification

* Add changelog and news entry

---------

Co-authored-by: coatless <coatless@users.noreply.github.com>
Co-authored-by: James J Balamuta <james.balamuta@gmail.com>
  • Loading branch information
3 people committed Oct 5, 2023
1 parent 43013c9 commit 84ef62f
Show file tree
Hide file tree
Showing 32 changed files with 1,285 additions and 213 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Expand Up @@ -9,3 +9,5 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^CRAN-SUBMISSION$
^revdep$
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@ src/*.dll
inst/doc
CRAN-RELEASE
docs
CRAN-SUBMISSION
13 changes: 13 additions & 0 deletions ChangeLog
@@ -1,3 +1,16 @@
2023-10-05 James Balamuta <balamut2@illinois.edu>

* NEWS.md: Restored mlpack/ensmallen URLs

* DESCRIPTION: Removed CXX11 requirement
* src/Makevars: ditto
* src/Makevars.win: ditto

* DESCRIPTION (Version): Release 2.20.0
* NEWS.md: Update for Ensmallen release 2.20.0
* inst/include/ensmallen_bits: Upgraded to Ensmallen 2.20.0
* inst/include/ensmallen.hpp: ditto

2023-02-08 James Balamuta <balamut2@illinois.edu>

* DESCRIPTION (Version): Release 2.19.1
Expand Down
3 changes: 1 addition & 2 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: RcppEnsmallen
Title: Header-Only C++ Mathematical Optimization Library for 'Armadillo'
Version: 0.2.19.1.1
Version: 0.2.20.0.1
Authors@R: c(
person("James Joseph", "Balamuta", email = "balamut2@illinois.edu",
role = c("aut", "cre", "cph"),
Expand Down Expand Up @@ -32,7 +32,6 @@ LinkingTo: Rcpp, RcppArmadillo (>= 0.9.800.0.0)
Imports: Rcpp
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
SystemRequirements: C++11
Suggests:
knitr,
rmarkdown
Expand Down
213 changes: 114 additions & 99 deletions NEWS.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cran-comments.md
@@ -1,7 +1,7 @@
## Test environments

* local macOS install, R 4.1.0
* ubuntu 20.04 (with GitHub Actions), R 4.1.0
* local macOS install, R 4.3.1
* ubuntu 20.04 (with GitHub Actions), R 4.3.1
* win-builder (devel and release)

## R CMD check results
Expand Down
3 changes: 2 additions & 1 deletion inst/include/ensmallen.hpp
Expand Up @@ -97,6 +97,8 @@
#include "ensmallen_bits/aug_lagrangian/aug_lagrangian.hpp"
#include "ensmallen_bits/bigbatch_sgd/bigbatch_sgd.hpp"
#include "ensmallen_bits/cmaes/cmaes.hpp"
#include "ensmallen_bits/cmaes/active_cmaes.hpp"
#include "ensmallen_bits/cd/cd.hpp"
#include "ensmallen_bits/cne/cne.hpp"
#include "ensmallen_bits/de/de.hpp"
#include "ensmallen_bits/eve/eve.hpp"
Expand All @@ -118,7 +120,6 @@

#include "ensmallen_bits/sa/sa.hpp"
#include "ensmallen_bits/sarah/sarah.hpp"
#include "ensmallen_bits/scd/scd.hpp"
#include "ensmallen_bits/sdp/sdp.hpp"
#include "ensmallen_bits/sdp/lrsdp.hpp"
#include "ensmallen_bits/sdp/primal_dual.hpp"
Expand Down
@@ -1,16 +1,16 @@
/**
* @file scd.hpp
* @file cd.hpp
* @author Shikhar Bhardwaj
*
* Stochastic Coordinate Descent (SCD).
* Coordinate Descent (CD).
*
* 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_SCD_SCD_HPP
#define ENSMALLEN_SCD_SCD_HPP
#ifndef ENSMALLEN_CD_CD_HPP
#define ENSMALLEN_CD_CD_HPP

#include "descent_policies/cyclic_descent.hpp"
#include "descent_policies/random_descent.hpp"
Expand Down Expand Up @@ -42,19 +42,19 @@ namespace ens {
* }
* @endcode
*
* SCD can optimize partially differentiable functions. For more details, see
* CD can optimize partially differentiable functions. For more details, see
* the documentation on function types included with this distribution or on the
* ensmallen website.
*
* @tparam DescentPolicy Descent policy to decide the order in which the
* coordinate for descent is selected.
*/
template <typename DescentPolicyType = RandomDescent>
class SCD
class CD
{
public:
/**
* Construct the SCD optimizer with the given function and parameters. The
* Construct the CD optimizer with the given function and parameters. The
* default value here are not necessarily good for every problem, so it is
* suggested that the values used are tailored for the task at hand. The
* maximum number of iterations refers to the maximum number of "descents"
Expand All @@ -70,11 +70,11 @@ class SCD
* @param descentPolicy The policy to use for picking up the coordinate to
* descend on.
*/
SCD(const double stepSize = 0.01,
const size_t maxIterations = 100000,
const double tolerance = 1e-5,
const size_t updateInterval = 1e3,
const DescentPolicyType descentPolicy = DescentPolicyType());
CD(const double stepSize = 0.01,
const size_t maxIterations = 100000,
const double tolerance = 1e-5,
const size_t updateInterval = 1e3,
const DescentPolicyType descentPolicy = DescentPolicyType());

/**
* Optimize the given function using stochastic coordinate descent. The
Expand Down Expand Up @@ -158,6 +158,24 @@ class SCD
} // namespace ens

// Include implementation.
#include "scd_impl.hpp"
#include "cd_impl.hpp"

namespace ens {

/**
* Backwards-compatibility alias; this can be removed after ensmallen 3.10.0.
* The history here is that CD was originally named SCD, but that is an
* inaccurate name because this is not a stochastic technique; thus, it was
* renamed SCD.
*/
template<typename DescentPolicyType = RandomDescent>
using SCD = CD<DescentPolicyType>;

// Convenience typedefs.
using RandomCD = CD<RandomDescent>;
using GreedyCD = CD<GreedyDescent>;
using CyclicCD = CD<CyclicDescent>;

} // namespace ens

#endif
@@ -1,26 +1,26 @@
/**
* @file scd_impl.hpp
* @file cd_impl.hpp
* @author Shikhar Bhardwaj
*
* Implementation of stochastic coordinate descent.
* Implementation of coordinate descent.
*
* 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_SCD_SCD_IMPL_HPP
#define ENSMALLEN_SCD_SCD_IMPL_HPP
#ifndef ENSMALLEN_CD_CD_IMPL_HPP
#define ENSMALLEN_CD_CD_IMPL_HPP

// In case it hasn't been included yet.
#include "scd.hpp"
#include "cd.hpp"

#include <ensmallen_bits/function.hpp>

namespace ens {

template <typename DescentPolicyType>
SCD<DescentPolicyType>::SCD(
CD<DescentPolicyType>::CD(
const double stepSize,
const size_t maxIterations,
const double tolerance,
Expand All @@ -41,7 +41,7 @@ template <typename ResolvableFunctionType,
typename... CallbackTypes>
typename std::enable_if<IsArmaType<GradType>::value,
typename MatType::elem_type>::type
SCD<DescentPolicyType>::Optimize(
CD<DescentPolicyType>::Optimize(
ResolvableFunctionType& function,
MatType& iterateIn,
CallbackTypes&&... callbacks)
Expand Down Expand Up @@ -94,12 +94,12 @@ SCD<DescentPolicyType>::Optimize(
overallObjective, callbacks...);

// Output current objective function.
Info << "SCD: iteration " << i << ", objective " << overallObjective
Info << "CD: iteration " << i << ", objective " << overallObjective
<< "." << std::endl;

if (std::isnan(overallObjective) || std::isinf(overallObjective))
{
Warn << "SCD: converged to " << overallObjective << "; terminating"
Warn << "CD: converged to " << overallObjective << "; terminating"
<< " with failure. Try a smaller step size?" << std::endl;

Callback::EndOptimization(*this, function, iterate, callbacks...);
Expand All @@ -108,7 +108,7 @@ SCD<DescentPolicyType>::Optimize(

if (std::abs(lastObjective - overallObjective) < tolerance)
{
Info << "SCD: minimized within tolerance " << tolerance << "; "
Info << "CD: minimized within tolerance " << tolerance << "; "
<< "terminating optimization." << std::endl;

Callback::EndOptimization(*this, function, iterate, callbacks...);
Expand All @@ -119,7 +119,7 @@ SCD<DescentPolicyType>::Optimize(
}
}

Info << "SCD: maximum iterations (" << maxIterations << ") reached; "
Info << "CD: maximum iterations (" << maxIterations << ") reached; "
<< "terminating optimization." << std::endl;

// Calculate and return final objective.
Expand Down

0 comments on commit 84ef62f

Please sign in to comment.