Skip to content

Commit c327405

Browse files
authored
Upgrade ensmallen to 1.13.0 (#8)
* Upgrade ensmallen to 1.13.0 * Add NEWS entry for 1.13.0 * Bump description * Add changelog * Change initialization order. * No comments...
1 parent 4d59ce6 commit c327405

File tree

11 files changed

+348
-45
lines changed

11 files changed

+348
-45
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2019-01-20 James Balamuta <[email protected]>
2+
3+
* DESCRIPTION (Version, Date): Release 1.13.0
4+
5+
* NEWS.md: Update for Ensmallen release 1.13.0
6+
7+
* inst/include/ensmallen_bits: Upgraded to Ensmallen 1.13.0
8+
* inst/include/ensmallen.hpp: ditto
9+
110
2018-12-30 James Balamuta <[email protected]>
211

312
* DESCRIPTION (Version, Date): Release 1.12.0

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: RcppEnsmallen
22
Title: Header-Only C++ Mathematical Optimization Library for 'Armadillo'
3-
Version: 0.1.12.0.1
3+
Version: 0.1.13.0.1
44
Authors@R: c(
55
person("James Joseph", "Balamuta", email = "[email protected]",
66
role = c("aut", "cre", "cph"),

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# RcppEnsmallen 0.1.13.0.1
2+
3+
- Upgraded to ensmallen release 1.13.0 "Coronavirus Invasion" (2019-01-14)
4+
- Enhance options for AugLagrangian optimizer (#66).
5+
- Add SPSA optimizer (#69).
6+
- Fix list of contributors.
7+
- Make sure all files end with newlines.
8+
- Reordered SPSA parameters to quiet initialization error surfaced with `-Wreorder`.
9+
110
# RcppEnsmallen 0.1.12.0.1
211

312
- Upgraded to ensmallen release 1.12.0 "New Year's Party" (2018-12-30)

cran-comments.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@
77
## R CMD check results
88

99
0 errors | 0 warnings | 0 note
10-
11-
- This release fixes the line ending note given on the package's check page.

inst/include/ensmallen.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
#include "ensmallen_bits/sgdr/snapshot_sgdr.hpp"
9999
#include "ensmallen_bits/smorms3/smorms3.hpp"
100100
#include "ensmallen_bits/spalera_sgd/spalera_sgd.hpp"
101+
#include "ensmallen_bits/spsa/spsa.hpp"
101102
#include "ensmallen_bits/svrg/svrg.hpp"
102103
#include "ensmallen_bits/swats/swats.hpp"
103104
#include "ensmallen_bits/wn_grad/wn_grad.hpp"

inst/include/ensmallen_bits/aug_lagrangian/aug_lagrangian.hpp

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ class AugLagrangian
3434
{
3535
public:
3636
/**
37-
* Initialize the Augmented Lagrangian with the default L-BFGS optimizer. We
38-
* limit the number of L-BFGS iterations to 1000, rather than the unlimited
39-
* default L-BFGS.
37+
* Initialize the Augmented Lagrangian with the default L-BFGS optimizer.
38+
* @param penaltyThresholdFactor When the penalty threshold is updated set
39+
* the penalty threshold to the penalty multplied by this factor. The
40+
* default value of 0.25 is is taken from Burer and Monteiro (2002).
41+
* @param sigmaUpdateFactor When sigma is updated multiply sigma by this
42+
* value. The default value of 10 is taken from Burer and Monteiro (2002).
43+
* @param maxIterations Maximum number of iterations of the Augmented
44+
* Lagrangian algorithm. 0 indicates no maximum.
4045
*/
41-
AugLagrangian();
46+
AugLagrangian(const size_t maxIterations = 1000,
47+
const double penaltyThresholdFactor = 0.25,
48+
const double sigmaUpdateFactor = 10.0,
49+
const L_BFGS& lbfgs = L_BFGS());
4250

4351
/**
4452
* Optimize the function. The value '1' is used for the initial value of each
@@ -49,13 +57,10 @@ class AugLagrangian
4957
* class.
5058
* @param function The function to optimize.
5159
* @param coordinates Output matrix to store the optimized coordinates in.
52-
* @param maxIterations Maximum number of iterations of the Augmented
53-
* Lagrangian algorithm. 0 indicates no maximum.
5460
*/
5561
template<typename LagrangianFunctionType>
5662
bool Optimize(LagrangianFunctionType& function,
57-
arma::mat& coordinates,
58-
const size_t maxIterations = 1000);
63+
arma::mat& coordinates);
5964

6065
/**
6166
* Optimize the function, giving initial estimates for the Lagrange
@@ -69,15 +74,12 @@ class AugLagrangian
6974
* @param initLambda Vector of initial Lagrange multipliers. Should have
7075
* length equal to the number of constraints.
7176
* @param initSigma Initial penalty parameter.
72-
* @param maxIterations Maximum number of iterations of the Augmented
73-
* Lagrangian algorithm. 0 indicates no maximum.
7477
*/
7578
template<typename LagrangianFunctionType>
7679
bool Optimize(LagrangianFunctionType& function,
7780
arma::mat& coordinates,
7881
const arma::vec& initLambda,
79-
const double initSigma,
80-
const size_t maxIterations = 1000);
82+
const double initSigma);
8183

8284
//! Get the L-BFGS object used for the actual optimization.
8385
const L_BFGS& LBFGS() const { return lbfgs; }
@@ -94,12 +96,33 @@ class AugLagrangian
9496
//! Modify the penalty parameter.
9597
double& Sigma() { return sigma; }
9698

99+
//! Get the maximum iterations
100+
size_t MaxIterations() const { return maxIterations; }
101+
//! Modify the maximum iterations
102+
size_t& MaxIterations() { return maxIterations; }
103+
104+
//! Get the penalty threshold updating parameter
105+
double PenaltyThresholdFactor() const { return penaltyThresholdFactor; }
106+
//! Modify the penalty threshold updating parameter
107+
double& PenaltyThresholdFactor() { return penaltyThresholdFactor; }
108+
109+
//! Get the sigma update factor
110+
double SigmaUpdateFactor() const { return sigmaUpdateFactor; }
111+
//! Modify the sigma update factor
112+
double& SigmaUpdateFactor() { return sigmaUpdateFactor; }
113+
97114
private:
98-
//! If the user did not pass an L_BFGS object, we'll use our own internal one.
99-
L_BFGS lbfgsInternal;
115+
//! Maximum number of iterations.
116+
size_t maxIterations;
117+
118+
//! Parameter for updating the penalty threshold
119+
double penaltyThresholdFactor;
120+
121+
//! Parameter for updating sigma
122+
double sigmaUpdateFactor;
100123

101124
//! The L-BFGS optimizer that we will use.
102-
L_BFGS& lbfgs;
125+
L_BFGS lbfgs;
103126

104127
//! Lagrange multipliers.
105128
arma::vec lambda;
@@ -112,8 +135,7 @@ class AugLagrangian
112135
*/
113136
template<typename LagrangianFunctionType>
114137
bool Optimize(AugLagrangianFunction<LagrangianFunctionType>& augfunc,
115-
arma::mat& coordinates,
116-
const size_t maxIterations);
138+
arma::mat& coordinates);
117139
};
118140

119141
} // namespace ens

inst/include/ensmallen_bits/aug_lagrangian/aug_lagrangian_impl.hpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,54 @@
1919

2020
namespace ens {
2121

22-
inline AugLagrangian::AugLagrangian() :
23-
lbfgsInternal(),
24-
lbfgs(lbfgsInternal)
22+
inline AugLagrangian::AugLagrangian(const size_t maxIterations,
23+
const double penaltyThresholdFactor,
24+
const double sigmaUpdateFactor,
25+
const L_BFGS& lbfgs) :
26+
maxIterations(maxIterations),
27+
penaltyThresholdFactor(penaltyThresholdFactor),
28+
sigmaUpdateFactor(sigmaUpdateFactor),
29+
lbfgs(lbfgs)
2530
{
26-
lbfgs.MaxIterations() = 1000;
2731
}
2832

2933
template<typename LagrangianFunctionType>
3034
bool AugLagrangian::Optimize(LagrangianFunctionType& function,
3135
arma::mat& coordinates,
3236
const arma::vec& initLambda,
33-
const double initSigma,
34-
const size_t maxIterations)
37+
const double initSigma)
3538
{
3639
lambda = initLambda;
3740
sigma = initSigma;
3841

3942
AugLagrangianFunction<LagrangianFunctionType> augfunc(function,
4043
lambda, sigma);
4144

42-
return Optimize(augfunc, coordinates, maxIterations);
45+
return Optimize(augfunc, coordinates);
4346
}
4447

4548
template<typename LagrangianFunctionType>
4649
bool AugLagrangian::Optimize(LagrangianFunctionType& function,
47-
arma::mat& coordinates,
48-
const size_t maxIterations)
50+
arma::mat& coordinates)
4951
{
5052
// If the user did not specify the right size for sigma and lambda, we will
5153
// use defaults.
5254
if (!lambda.is_empty())
5355
{
54-
AugLagrangianFunction<LagrangianFunctionType> augfunc(function, lambda,
55-
sigma);
56-
return Optimize(augfunc, coordinates, maxIterations);
56+
AugLagrangianFunction<LagrangianFunctionType> augfunc(function, lambda, sigma);
57+
return Optimize(augfunc, coordinates);
5758
}
5859
else
5960
{
6061
AugLagrangianFunction<LagrangianFunctionType> augfunc(function);
61-
return Optimize(augfunc, coordinates, maxIterations);
62+
return Optimize(augfunc, coordinates);
6263
}
6364
}
6465

6566
template<typename LagrangianFunctionType>
6667
bool AugLagrangian::Optimize(
6768
AugLagrangianFunction<LagrangianFunctionType>& augfunc,
68-
arma::mat& coordinates,
69-
const size_t maxIterations)
69+
arma::mat& coordinates)
7070
{
7171
traits::CheckConstrainedFunctionTypeAPI<LagrangianFunctionType>();
7272

@@ -133,17 +133,14 @@ bool AugLagrangian::Optimize(
133133
function.EvaluateConstraint(i, coordinates);
134134

135135
// We also update the penalty threshold to be a factor of the current
136-
// penalty. TODO: this factor should be a parameter (from CLI). The
137-
// value of 0.25 is taken from Burer and Monteiro (2002).
138-
penaltyThreshold = 0.25 * penalty;
136+
// penalty.
137+
penaltyThreshold = penaltyThresholdFactor * penalty;
139138
Info << "Lagrange multiplier estimates updated." << std::endl;
140139
}
141140
else
142141
{
143-
// We multiply sigma by a constant value. TODO: this factor should be a
144-
// parameter (from CLI). The value of 10 is taken from Burer and Monteiro
145-
// (2002).
146-
augfunc.Sigma() *= 10;
142+
// We multiply sigma by a constant value.
143+
augfunc.Sigma() *= sigmaUpdateFactor;
147144
Info << "Updated sigma to " << augfunc.Sigma() << "." << std::endl;
148145
}
149146
}

inst/include/ensmallen_bits/ens_version.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
#define ENS_VERSION_MAJOR 1
1616
// The minor version is two digits so regular numerical comparisons of versions
1717
// work right. The first minor version of a release is always 10.
18-
#define ENS_VERSION_MINOR 12
18+
#define ENS_VERSION_MINOR 13
1919
#define ENS_VERSION_PATCH 0
2020
// If this is a release candidate, it will be reflected in the version name
2121
// (i.e. the version name will be "RC1", "RC2", etc.). Otherwise the version
2222
// name will typically be a seemingly arbitrary set of words that does not
2323
// contain the capitalized string "RC".
24-
#define ENS_VERSION_NAME "New Year's Party"
24+
#define ENS_VERSION_NAME "Coronavirus Invasion"
2525

2626
namespace ens {
2727

inst/include/ensmallen_bits/sdp/lrsdp_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ template <typename SDPType>
3030
double LRSDP<SDPType>::Optimize(arma::mat& coordinates)
3131
{
3232
augLag.Sigma() = 10;
33-
augLag.Optimize(function, coordinates, maxIterations);
33+
augLag.MaxIterations() = maxIterations;
34+
augLag.Optimize(function, coordinates);
3435

3536
return function.Evaluate(coordinates);
3637
}

0 commit comments

Comments
 (0)