Sleipnir C++ API
Loading...
Searching...
No Matches
is_locally_infeasible.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <Eigen/Core>
6#include <Eigen/SparseCore>
7
8// See docs/algorithms.md#Works_cited for citation definitions
9
10namespace slp {
11
19template <typename Scalar>
20bool is_equality_locally_infeasible(
21 const Eigen::SparseMatrix<Scalar>& A_e,
22 const Eigen::Vector<Scalar, Eigen::Dynamic>& c_e) {
23 // The equality constraints are locally infeasible if
24 //
25 // Aₑᵀcₑ → 0
26 // ‖cₑ‖ > ε
27 //
28 // See "Infeasibility detection" in section 6 of [3].
29 return A_e.rows() > 0 && (A_e.transpose() * c_e).norm() < Scalar(1e-6) &&
30 c_e.norm() > Scalar(1e-2);
31}
32
40template <typename Scalar>
41bool is_inequality_locally_infeasible(
42 const Eigen::SparseMatrix<Scalar>& A_i,
43 const Eigen::Vector<Scalar, Eigen::Dynamic>& c_i) {
44 // The inequality constraints are locally infeasible if
45 //
46 // Aᵢᵀcᵢ⁺ → 0
47 // ‖cᵢ⁺‖ > ε
48 //
49 // where cᵢ⁺ = min(cᵢ, 0).
50 //
51 // See "Infeasibility detection" in section 6 of [3].
52 //
53 // cᵢ⁺ is used instead of cᵢ⁻ from the paper to follow the convention that
54 // feasible inequality constraints are ≥ 0.
55 if (A_i.rows() > 0) {
56 Eigen::Vector<Scalar, Eigen::Dynamic> c_i_plus = c_i.cwiseMin(Scalar(0));
57 if ((A_i.transpose() * c_i_plus).norm() < Scalar(1e-6) &&
58 c_i_plus.norm() > Scalar(1e-6)) {
59 return true;
60 }
61 }
62
63 return false;
64}
65
66} // namespace slp