Skip to content

Commit 201f5a5

Browse files
committed
Minor changes
1 parent 63066fa commit 201f5a5

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

uno/ingredients/hessian_models/HessianModelFactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "options/Options.hpp"
1515

1616
namespace uno {
17-
std::unique_ptr<HessianModel> HessianModelFactory::create(double objective_multiplier, const Options& options) {
17+
std::unique_ptr<HessianModel> HessianModelFactory::create([[maybe_unused]] double objective_multiplier, const Options& options) {
1818
const std::string& hessian_model = options.get_string("hessian_model");
1919
if (hessian_model == "exact") {
2020
return std::make_unique<ExactHessian>();

uno/ingredients/hessian_models/HessianModelFactory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace uno {
1414

1515
class HessianModelFactory {
1616
public:
17-
static std::unique_ptr<HessianModel> create(double fixed_objective_multiplier, const Options& options);
17+
static std::unique_ptr<HessianModel> create(double objective_multiplier, const Options& options);
1818
};
1919
} // namespace
2020

uno/ingredients/hessian_models/quasi_newton/LBFGSHessian.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace uno {
1616
LBFGSHessian::LBFGSHessian(double objective_multiplier, const Options& options):
1717
HessianModel(),
18-
objective_multiplier(objective_multiplier),
18+
fixed_objective_multiplier(objective_multiplier),
1919
memory_size(options.get_unsigned_int("quasi_newton_memory_size")) {
2020
}
2121

@@ -75,7 +75,7 @@ namespace uno {
7575
// Bk v = (B0 - U U^T + V V^T) v = delta v - U U^T x + V V^T x
7676
void LBFGSHessian::compute_hessian_vector_product(const Model& model, const double* /*x*/, const double* vector,
7777
double objective_multiplier, const Vector<double>& /*constraint_multipliers*/, double* result) {
78-
if (objective_multiplier != this->objective_multiplier) {
78+
if (objective_multiplier != this->fixed_objective_multiplier) {
7979
throw std::runtime_error("The L-BFGS Hessian model was initialized with a different objective multiplier");
8080
}
8181

@@ -158,9 +158,9 @@ namespace uno {
158158
const OptimizationProblem problem{model};
159159
//problem.evaluate_lagrangian_gradient(current_split_lagrangian_gradient, current_iterate, trial_iterate.multipliers);
160160
//problem.evaluate_lagrangian_gradient(trial_split_lagrangian_gradient, trial_iterate, trial_iterate.multipliers);
161-
const auto current_lagrangian_gradient = this->objective_multiplier * current_split_lagrangian_gradient.objective_contribution
161+
const auto current_lagrangian_gradient = this->fixed_objective_multiplier * current_split_lagrangian_gradient.objective_contribution
162162
+ current_split_lagrangian_gradient.constraints_contribution;
163-
const auto trial_lagrangian_gradient = this->objective_multiplier * trial_split_lagrangian_gradient.objective_contribution
163+
const auto trial_lagrangian_gradient = this->fixed_objective_multiplier * trial_split_lagrangian_gradient.objective_contribution
164164
+ trial_split_lagrangian_gradient.constraints_contribution;
165165
this->Y_matrix.column(this->current_memory_slot) = trial_lagrangian_gradient - current_lagrangian_gradient;
166166
}
@@ -207,7 +207,7 @@ namespace uno {
207207
// add M += Ltilde Ltilde^T
208208
LBFGSHessian::perform_high_rank_update(this->M_matrix, this->number_entries_in_memory, this->memory_size, Ltilde_matrix,
209209
this->number_entries_in_memory, this->memory_size, 1., 1.);
210-
// add M += S^T B0 S (= delta S^T S)
210+
// add M += S^T B0 S = delta S^T S
211211
LBFGSHessian::perform_high_rank_update_transpose(this->M_matrix, this->number_entries_in_memory, this->memory_size,
212212
this->S_matrix, this->number_entries_in_memory, this->dimension, this->initial_identity_multiple, 1.);
213213
DEBUG << "> M: " << this->M_matrix;
@@ -266,7 +266,9 @@ namespace uno {
266266
// return delta = 1/gamma where gamma is given by (7.20) in Numerical optimization (Nocedal & Wright)
267267
const double numerator = dot(last_column_Y, last_column_Y);
268268
const double denominator = dot(last_column_S, last_column_Y); // TODO should be the current D entry
269-
assert(denominator != 0 && "LBFGSHessian::compute_initial_identity_factor: the denominator is 0");
269+
if (denominator == 0.) {
270+
throw std::runtime_error("LBFGSHessian::compute_initial_identity_factor: the denominator is 0");
271+
}
270272
return numerator/denominator;
271273
}
272274

uno/ingredients/hessian_models/quasi_newton/LBFGSHessian.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace uno {
3939

4040
protected:
4141
size_t dimension{};
42-
const double objective_multiplier;
42+
const double fixed_objective_multiplier;
4343
const size_t memory_size; // user defined
4444
size_t number_entries_in_memory{0}; // 0 <= used_memory_size <= memory_size
4545
size_t current_memory_slot{0}; // 0 <= current_available_slot < memory_size

uno/linear_algebra/DenseMatrix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace uno {
6868
UPPER_TRIANGULAR
6969
};
7070

71-
// DenseMatrix is an m x n matrix in column-order order where the columns are concatenated in a long vector
71+
// DenseMatrix is an m x n matrix in column-major order where the columns are concatenated in a long vector
7272
template <typename ElementType, MatrixShape Shape = MatrixShape::GENERAL>
7373
class DenseMatrix {
7474
public:

0 commit comments

Comments
 (0)