Skip to content

Commit

Permalink
Another couple of fixes in VectorExpression's first arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanaret committed Oct 15, 2024
1 parent e446e85 commit e5940ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ namespace uno {

double BarrierParameterUpdateStrategy::compute_shifted_complementarity_error(const OptimizationProblem& problem, const Vector<double>& 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] *
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,10 @@ namespace uno {
// Section 3.9 in IPOPT paper
bool PrimalDualInteriorPointSubproblem::is_small_step(const OptimizationProblem& problem, const Vector<double>& current_primals,
const Vector<double>& 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<double>::epsilon();
return (norm_inf(relative_direction_size) <= this->parameters.small_direction_factor * machine_epsilon);
}
Expand Down

0 comments on commit e5940ef

Please sign in to comment.