| 220 | } |
| 221 | |
| 222 | double OptimizationProblem::compute_centrality_error(const Vector<double>& primals, const Multipliers& multipliers, |
| 223 | double shift) const { |
| 224 | const Range variables_range = Range(this->number_variables); |
| 225 | const auto& variables_lower_bounds = this->get_variables_lower_bounds(); |
| 226 | const auto& variables_upper_bounds = this->get_variables_upper_bounds(); |
| 227 | const VectorExpression shifted_bound_complementarity{variables_range, [&](size_t variable_index) { |
| 228 | double result = 0.; |
| 229 | if (0. < multipliers.lower_bounds[variable_index]) { // lower bound |
| 230 | result = std::max(result, std::abs(multipliers.lower_bounds[variable_index] * |
| 231 | (primals[variable_index] - variables_lower_bounds[variable_index]) - shift)); |
| 232 | } |
| 233 | if (multipliers.upper_bounds[variable_index] < 0.) { // upper bound |
| 234 | result = std::max(result, std::abs(multipliers.upper_bounds[variable_index] * |
| 235 | (primals[variable_index] - variables_upper_bounds[variable_index]) - shift)); |
| 236 | } |
| 237 | return result; |
| 238 | }}; |
| 239 | return norm_inf(shifted_bound_complementarity); // TODO use a generic norm |
| 240 | } |
| 241 | |
| 242 | SolutionStatus OptimizationProblem::check_first_order_convergence(const Iterate& current_iterate, double primal_tolerance, |
| 243 | double dual_tolerance) const { |