Skip to content

Commit 3a2ee72

Browse files
committed
Address comments
1 parent 042c52d commit 3a2ee72

3 files changed

Lines changed: 33 additions & 18 deletions

File tree

gtsam/constrained/AugmentedLagrangian.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <gtsam/constrained/AugmentedLagrangian.h>
2020
#include <gtsam/constrained/AugmentedLagrangianOptimizer.h>
2121
#include <gtsam/slam/AntiFactor.h>
22+
2223
#include <iostream>
2324

2425
namespace gtsam {
@@ -97,7 +98,7 @@ NonlinearFactorGraph AugmentedLagrangianFunction(
9798
const NonlinearEqualityConstraints& eqConstraints = problem.eConstraints();
9899
for (size_t i = 0; i < eqConstraints.size(); i++) {
99100
const auto& constraint = eqConstraints.at(i);
100-
Vector bias = lambdaEq[i] / muEq * constraint->sigmas();
101+
Vector bias = (lambdaEq[i] / muEq).cwiseProduct(constraint->sigmas());
101102
auto penalty_l2 = constraint->penaltyFactor(muEq);
102103
graph.emplace_shared<BiasedFactor>(penalty_l2, bias);
103104
}
@@ -111,7 +112,7 @@ NonlinearFactorGraph AugmentedLagrangianFunction(
111112
// Create factors corresponding to Lagrange multiplier terms of i-constraints.
112113
for (size_t i = 0; i < ineqConstraints.size(); i++) {
113114
const auto& constraint = ineqConstraints.at(i);
114-
Vector bias = lambdaIneq[i] / epsilon * constraint->sigmas();
115+
Vector bias = constraint->sigmas() * (lambdaIneq[i] / epsilon);
115116
auto penalty_l2 = constraint->penaltyFactorEquality(epsilon);
116117
graph.emplace_shared<BiasedFactor>(penalty_l2, bias);
117118
graph.emplace_shared<AntiFactor>(penalty_l2);

gtsam/constrained/BoundConstrainedLagrangian.h

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,32 @@
2323

2424
namespace gtsam {
2525

26-
/// Parameters for Augmented Lagrangian method
26+
/// Parameters for the bound-constrained augmented Lagrangian outer loop.
2727
class GTSAM_EXPORT BoundConstrainedLagrangianParams
2828
: public AugmentedLagrangianParams {
2929
public:
3030
using Base = AugmentedLagrangianParams;
3131
using This = BoundConstrainedLagrangianParams;
3232
using shared_ptr = std::shared_ptr<BoundConstrainedLagrangianParams>;
3333

34-
double k = 2; // mu increase rate factor
34+
/// Multiplicative factor used to increase the equality penalty `muEq`
35+
/// when the iterate is not yet feasible enough for a multiplier update.
36+
double k = 2;
37+
38+
/// Exponent used in the BCL threshold update
39+
/// `eta_{k+1} = eta_k / mu_k^alpha` after an accepted multiplier step.
3540
double alpha = 0.5;
41+
42+
/// Initial feasibility threshold for the equality-constraint violation.
3643
double eta0 = 1.0;
44+
45+
/// Initial stationarity threshold for the cost-gradient infinity norm.
3746
double omega0 = 1.0;
47+
48+
/// Stop when feasibility threshold `eta` has been reduced below this value.
3849
double eta_threshold = 1e-3;
50+
51+
/// Stop when threshold `omega` has been reduced below this value.
3952
double omega_threshold = 1e-3;
4053

4154
BoundConstrainedLagrangianParams() {
@@ -57,6 +70,9 @@ class GTSAM_EXPORT BoundConstrainedLagrangianState
5770
using Base::Base;
5871
};
5972

73+
/**
74+
* Augmented Lagrangian method with BCL globalization strategy
75+
*/
6076
class GTSAM_EXPORT BoundConstrainedLagrangian : public ConstrainedOptimizer {
6177
public:
6278
using Base = ConstrainedOptimizer;
@@ -72,42 +88,40 @@ class GTSAM_EXPORT BoundConstrainedLagrangian : public ConstrainedOptimizer {
7288
mutable Progress progress_;
7389

7490
public:
75-
/** Constructor. */
91+
/// Constructor.
7692
BoundConstrainedLagrangian(const ConstrainedOptProblem& problem,
7793
const Values& initialValues,
7894
Params::shared_ptr p = std::make_shared<Params>())
7995
: Base(problem, initialValues), p_(p) {}
8096

81-
/** Solve one step of optimization, updating multipliers and parameters. */
97+
/// Solve one step of optimization, updating multipliers and parameters.
8298
State iterate(const State& state) const;
8399

84-
/** Run optimization for the bound-constrained problem and return the result. */
100+
/// Run optimization for the bound-constrained problem and return the result.
85101
Values optimize() const override;
86102

87-
/** Return progress of iterations as a read-only sequence of states. */
103+
/// Return progress of iterations as a read-only sequence of states.
88104
const Progress& progress() const { return progress_; }
89105

90106
protected:
91-
/** Create an unconstrained optimizer that solves the augmented Lagrangian. */
107+
/// Create an unconstrained optimizer that solves the augmented Lagrangian.
92108
SharedOptimizer createUnconstrainedOptimizer(
93109
const NonlinearFactorGraph& graph, const Values& values) const;
94110

95-
/** Update the Lagrange multipliers using dual ascent. */
111+
/// Update the Lagrange multipliers using dual ascent.
96112
void updateMultipliers(const State& prev_state, State* state) const;
97113

98-
/** Build the augmented Lagrangian factor graph for the given state. */
114+
/// Build the augmented Lagrangian factor graph for the given state.
99115
NonlinearFactorGraph augmentedLagrangianFunction(
100116
const State& state, const double epsilon = 1.0) const;
101117

102-
/** Store and log the initial state of the optimization. */
118+
/// Store and log the initial state of the optimization.
103119
void logInitialState(const State& state) const;
104120

105-
/** Store and log the state after an iteration of the optimization. */
121+
/// Store and log the state after an iteration of the optimization.
106122
void logIteration(const State& state) const;
107123

108-
/**
109-
* Customized convergence check for bound-constrained optimization.
110-
*/
124+
/// Customized convergence check for bound-constrained optimization.
111125
bool checkConvergenceBC(const State& state, const State& previousState,
112126
const Params& params) const;
113127
};

gtsam/constrained/doc/BoundConstrainedLagrangian.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ and then repeats outer iterations until [checkConvergenceBC()](../BoundConstrain
202202
The customized stopping rule terminates as soon as either
203203

204204
$$
205-
\eta_k < \texttt{eta_threshold}
205+
\eta_k < \eta_{threshold}
206206
\qquad \text{or} \qquad
207-
\omega_k < \texttt{omega_threshold}.
207+
\omega_k < \omega_{threshold}.
208208
$$
209209

210210
## What the Current Code Is, and Is Not

0 commit comments

Comments
 (0)