|
15 | 15 | namespace uno { |
16 | 16 | LBFGSHessian::LBFGSHessian(double objective_multiplier, const Options& options): |
17 | 17 | HessianModel(), |
18 | | - objective_multiplier(objective_multiplier), |
| 18 | + fixed_objective_multiplier(objective_multiplier), |
19 | 19 | memory_size(options.get_unsigned_int("quasi_newton_memory_size")) { |
20 | 20 | } |
21 | 21 |
|
@@ -75,7 +75,7 @@ namespace uno { |
75 | 75 | // Bk v = (B0 - U U^T + V V^T) v = delta v - U U^T x + V V^T x |
76 | 76 | void LBFGSHessian::compute_hessian_vector_product(const Model& model, const double* /*x*/, const double* vector, |
77 | 77 | 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) { |
79 | 79 | throw std::runtime_error("The L-BFGS Hessian model was initialized with a different objective multiplier"); |
80 | 80 | } |
81 | 81 |
|
@@ -158,9 +158,9 @@ namespace uno { |
158 | 158 | const OptimizationProblem problem{model}; |
159 | 159 | //problem.evaluate_lagrangian_gradient(current_split_lagrangian_gradient, current_iterate, trial_iterate.multipliers); |
160 | 160 | //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 |
162 | 162 | + 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 |
164 | 164 | + trial_split_lagrangian_gradient.constraints_contribution; |
165 | 165 | this->Y_matrix.column(this->current_memory_slot) = trial_lagrangian_gradient - current_lagrangian_gradient; |
166 | 166 | } |
@@ -207,7 +207,7 @@ namespace uno { |
207 | 207 | // add M += Ltilde Ltilde^T |
208 | 208 | LBFGSHessian::perform_high_rank_update(this->M_matrix, this->number_entries_in_memory, this->memory_size, Ltilde_matrix, |
209 | 209 | 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 |
211 | 211 | LBFGSHessian::perform_high_rank_update_transpose(this->M_matrix, this->number_entries_in_memory, this->memory_size, |
212 | 212 | this->S_matrix, this->number_entries_in_memory, this->dimension, this->initial_identity_multiple, 1.); |
213 | 213 | DEBUG << "> M: " << this->M_matrix; |
@@ -266,7 +266,9 @@ namespace uno { |
266 | 266 | // return delta = 1/gamma where gamma is given by (7.20) in Numerical optimization (Nocedal & Wright) |
267 | 267 | const double numerator = dot(last_column_Y, last_column_Y); |
268 | 268 | 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 | + } |
270 | 272 | return numerator/denominator; |
271 | 273 | } |
272 | 274 |
|
|
0 commit comments