From e5940ef2f42c8ab4a820d3f1641af820c077899a Mon Sep 17 00:00:00 2001 From: Charlie Vanaret Date: Tue, 15 Oct 2024 23:20:27 +0200 Subject: [PATCH] Another couple of fixes in VectorExpression's first arguments --- .../BarrierParameterUpdateStrategy.cpp | 5 +++-- .../PrimalDualInteriorPointSubproblem.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/uno/ingredients/subproblems/interior_point_methods/BarrierParameterUpdateStrategy.cpp b/uno/ingredients/subproblems/interior_point_methods/BarrierParameterUpdateStrategy.cpp index b8d3cde5..f1b8256b 100644 --- a/uno/ingredients/subproblems/interior_point_methods/BarrierParameterUpdateStrategy.cpp +++ b/uno/ingredients/subproblems/interior_point_methods/BarrierParameterUpdateStrategy.cpp @@ -66,7 +66,8 @@ namespace uno { double BarrierParameterUpdateStrategy::compute_shifted_complementarity_error(const OptimizationProblem& problem, const Vector& primals, const Multipliers& multipliers, double shift_value) { - const VectorExpression shifted_bound_complementarity(Range(problem.number_variables), [&](size_t variable_index) { + const Range variables_range = Range(problem.number_variables); + const VectorExpression shifted_bound_complementarity{variables_range, [&](size_t variable_index) { double result = 0.; if (0. < multipliers.lower_bounds[variable_index]) { // lower bound result = std::max(result, std::abs(multipliers.lower_bounds[variable_index] * @@ -77,7 +78,7 @@ namespace uno { (primals[variable_index] - problem.variable_upper_bound(variable_index)) - shift_value)); } return result; - }); + }}; return norm_inf(shifted_bound_complementarity); // TODO use a generic norm } } // namespace diff --git a/uno/ingredients/subproblems/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp b/uno/ingredients/subproblems/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp index 57d4868c..ce2d2722 100644 --- a/uno/ingredients/subproblems/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp +++ b/uno/ingredients/subproblems/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp @@ -343,9 +343,10 @@ namespace uno { // Section 3.9 in IPOPT paper bool PrimalDualInteriorPointSubproblem::is_small_step(const OptimizationProblem& problem, const Vector& current_primals, const Vector& direction_primals) const { - const VectorExpression relative_direction_size(Range(problem.number_variables), [&](size_t variable_index) { + const Range variables_range = Range(problem.number_variables); + const VectorExpression relative_direction_size{variables_range, [&](size_t variable_index) { return direction_primals[variable_index] / (1 + std::abs(current_primals[variable_index])); - }); + }}; static double machine_epsilon = std::numeric_limits::epsilon(); return (norm_inf(relative_direction_size) <= this->parameters.small_direction_factor * machine_epsilon); }