6#ifndef PROXSUITE_PROXQP_SPARSE_WORKSPACE_HPP
7#define PROXSUITE_PROXQP_SPARSE_WORKSPACE_HPP
24#include <Eigen/IterativeLinearSolvers>
25#include <unsupported/Eigen/IterativeSolvers>
31template<
typename T,
typename I>
42 isize n_tot = kkt_active.nrows();
43 T mu_eq_neg = -results.
info.mu_eq;
50 mu_in_neg = -results.
info.mu_in;
60 kkt_active.symbolic(),
65 for (usize j = 0; j <
usize(kkt_active.ncols()); ++j) {
66 nnz +=
usize(kkt_active.col_end(j) - kkt_active.col_start(j));
69 auto _diag = stack.make_new_for_overwrite(xtag, n_tot);
72 for (isize i = 0; i < data.
dim; ++i) {
73 diag[i] = results.
info.rho;
75 for (isize i = 0; i < data.
n_eq; ++i) {
76 diag[data.
dim + i] = mu_eq_neg;
78 for (isize i = 0; i < data.
n_in; ++i) {
79 diag[(data.
dim + data.
n_eq) + i] =
80 active_constraints[i] ? mu_in_neg : T(1);
91 kkt_active.as_const(),
95 active_constraints.as_const(),
100 results.
info.mu_eq_inv,
101 results.
info.mu_in_inv } };
106template<
typename T,
typename I>
118template<
typename T,
typename I>
140 std::unique_ptr<detail::AugmentedKkt<T, I>>
143 std::unique_ptr<Eigen::MINRES<detail::AugmentedKkt<T, I>,
144 Eigen::Upper | Eigen::Lower,
145 Eigen::IdentityPreconditioner>>
192 data.
dim = H.nrows();
193 data.
n_eq = AT.ncols();
194 data.
n_in = CT.ncols();
195 data.
H_nnz = H.nnz();
196 data.
A_nnz = AT.nnz();
197 data.
C_nnz = CT.nnz();
204 isize n_eq = AT.ncols();
205 isize n_in = CT.ncols();
206 isize
n_tot = n + n_eq + n_in;
208 isize
nnz_tot = H.nnz() + AT.nnz() + CT.nnz();
228 I
const*
mi =
m.row_indices();
229 isize ncols =
m.ncols();
231 for (usize
j = 0;
j <
usize(ncols); ++
j) {
232 usize col_start =
m.col_start(
j);
233 usize col_end =
m.col_end(
j);
236 checked_non_negative_plus(
kktp[col], I(col_end - col_start));
239 for (usize p = col_start; p < col_end; ++p) {
240 usize
i = zero_extend(
mi[p]);
270 ldl.col_ptrs.resize_for_overwrite(
n_tot + 1);
271 ldl.perm_inv.resize_for_overwrite(
n_tot);
277 ldl.etree.resize_for_overwrite(
n_tot);
282 proxsuite::linalg::sparse::from_raw_parts,
291 ldl.col_ptrs.ptr_mut() +
294 ldl.perm_inv.ptr_mut(),
295 static_cast<I
const*
>(
nullptr),
357 data.
dim =
qp.H.nrows();
358 data.
n_eq =
qp.AT.ncols();
359 data.
n_in =
qp.CT.ncols();
364 data.
g =
qp.g.to_eigen();
365 data.
b =
qp.b.to_eigen();
366 data.
l =
qp.l.to_eigen();
367 data.
u =
qp.u.to_eigen();
376 isize n =
qp.H.nrows();
377 isize n_eq =
qp.AT.ncols();
378 isize n_in =
qp.CT.ncols();
379 isize
n_tot = n + n_eq + n_in;
403 I
const*
mi =
m.row_indices();
404 T
const*
mx =
m.values();
405 isize ncols =
m.ncols();
407 for (usize
j = 0;
j <
usize(ncols); ++
j) {
408 usize col_start =
m.col_start(
j);
409 usize col_end =
m.col_end(
j);
412 checked_non_negative_plus(
kktp[col], I(col_end - col_start));
415 for (usize p = col_start; p < col_end; ++p) {
416 usize
i = zero_extend(
mi[p]);
448 ldl.col_ptrs.resize_for_overwrite(
n_tot + 1);
449 ldl.perm_inv.resize_for_overwrite(
n_tot);
455 ldl.etree.resize_for_overwrite(
n_tot);
460 proxsuite::linalg::sparse::from_raw_parts,
469 ldl.col_ptrs.ptr_mut() + 1,
471 ldl.perm_inv.ptr_mut(),
472 static_cast<I
const*
>(
nullptr),
511 T
const*
mx =
m.values();
512 isize ncols =
m.ncols();
514 for (usize
j = 0;
j <
usize(ncols); ++
j) {
515 usize col_start =
m.col_start(
j);
516 usize col_end =
m.col_end(
j);
517 for (usize p = col_start; p < col_end; ++p) {
531#define PROX_QP_ALL_OF(...) \
532 ::proxsuite::linalg::veg::dynstack::StackReq::and_( \
533 ::proxsuite::linalg::veg::init_list(__VA_ARGS__))
534#define PROX_QP_ANY_OF(...) \
535 ::proxsuite::linalg::veg::dynstack::StackReq::or_( \
536 ::proxsuite::linalg::veg::init_list(__VA_ARGS__))
557 SR::with_len(
itag, 0),
559 SR::with_len(
xtag, 0),
653 SR::with_len(
itag, 0),
654 SR::with_len(
xtag, 0),
669 proxsuite::linalg::veg::unsafe,
700 (data.
u.array() <= T(1.E20))
702 Eigen::Matrix<T, Eigen::Dynamic, 1>::Zero(data.
n_in).array() +
705 (data.
l.array() >= T(-1.E20))
707 Eigen::Matrix<T, Eigen::Dynamic, 1>::Zero(data.
n_in).array() -
730 proxsuite::linalg::sparse::from_raw_parts,
739 kkt.row_indices_mut(),
744 Eigen::Upper | Eigen::Lower,
745 Eigen::IdentityPreconditioner>;
752 kkt_active.as_const(),
764 auto zx = proxsuite::linalg::sparse::util::zero_extend;
#define VEG_ONLY_USED_FOR_DEBUG(var)
auto temp_vec_req(proxsuite::linalg::veg::Tag< T >, isize rows) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
void factorize_symbolic_non_zeros(I *nnz_per_col, I *etree, I *perm_inv, I const *perm, SymbolicMatRef< I > a, DynStackMut stack) noexcept
auto delete_row_req(proxsuite::linalg::veg::Tag< T >, proxsuite::linalg::veg::Tag< I >, isize n, isize max_nnz) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
void factorize_numeric(T *values, I *row_indices, proxsuite::linalg::veg::DoNotDeduce< T const * > diag_to_add, proxsuite::linalg::veg::DoNotDeduce< I const * > perm, I const *col_ptrs, I const *etree, I const *perm_inv, MatRef< T, I > a, DynStackMut stack) noexcept(false)
auto factorize_symbolic_req(proxsuite::linalg::veg::Tag< I > tag, isize n, isize nnz, Ordering o) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
auto factorize_numeric_req(proxsuite::linalg::veg::Tag< T >, proxsuite::linalg::veg::Tag< I >, isize n, isize a_nnz, Ordering o) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
auto add_row_req(proxsuite::linalg::veg::Tag< T >, proxsuite::linalg::veg::Tag< I >, isize n, bool id_perm, isize nnz, isize max_nnz) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
auto middle_cols_mut(proxsuite::linalg::sparse::MatMut< T, I > mat, isize start, isize ncols, isize nnz) -> proxsuite::linalg::sparse::MatMut< T, I >
auto top_rows_mut_unchecked(proxsuite::linalg::veg::Unsafe, proxsuite::linalg::sparse::MatMut< T, I > mat, isize nrows) -> proxsuite::linalg::sparse::MatMut< T, I >
void refactorize(Workspace< T, I > &work, Results< T > const &results, Settings< T > const &settings, proxsuite::linalg::sparse::MatMut< T, I > kkt_active, proxsuite::linalg::veg::SliceMut< bool > active_constraints, Model< T, I > const &data, proxsuite::linalg::veg::dynstack::DynStackMut stack, proxsuite::linalg::veg::Tag< T > &xtag)
Eigen::Matrix< bool, DYN, 1 > VecBool
decltype(sizeof(0)) usize
#define PROX_QP_ALL_OF(...)
#define PROX_QP_ANY_OF(...)
VEG_NODISCARD VEG_INLINE auto ptr_mut() VEG_NOEXCEPT -> T *
VEG_NODISCARD VEG_INLINE auto as_mut() VEG_NOEXCEPT -> SliceMut< T >
VEG_NODISCARD VEG_INLINE auto ptr() const VEG_NOEXCEPT -> T const *
VEG_NODISCARD auto ptr_mut() const VEG_NOEXCEPT -> void *
This class stores all the results of PROXQP solvers with sparse and dense backends.
This class defines the settings of PROXQP solvers with sparse and dense backends.
MeritFunctionType merit_function_type
SparseBackend sparse_backend
bool primal_infeasibility_solving
isize preconditioner_max_iter
T preconditioner_accuracy
This class mimics the way "boost/timer/timer.hpp" operates while using the modern std::chrono library...
proxsuite::linalg::veg::Vec< I > nnz_counts
proxsuite::linalg::veg::Vec< I > row_indices
proxsuite::linalg::veg::Vec< T > values
proxsuite::linalg::veg::Vec< I > etree
proxsuite::linalg::veg::Vec< I > perm_inv
proxsuite::linalg::veg::Vec< I > col_ptrs
proxsuite::linalg::veg::Vec< I > perm
This class stores the model of the QP problem.
proxsuite::linalg::veg::Vec< I > kkt_col_ptrs
proxsuite::linalg::veg::Vec< T > kkt_values
proxsuite::linalg::veg::Vec< I > kkt_row_indices_unscaled
proxsuite::linalg::veg::Vec< T > kkt_values_unscaled
auto kkt_mut() -> proxsuite::linalg::sparse::MatMut< T, I >
proxsuite::linalg::veg::Vec< I > kkt_row_indices
proxsuite::linalg::veg::Vec< I > kkt_col_ptrs_unscaled
This class defines the workspace of the sparse solver.
bool proximal_parameter_update
Eigen::Matrix< T, Eigen::Dynamic, 1 > u_scaled
std::unique_ptr< detail::AugmentedKkt< T, I > > matrix_free_kkt
proxsuite::linalg::veg::Vec< bool > active_inequalities
Eigen::Matrix< T, Eigen::Dynamic, 1 > b_scaled
void setup_impl(const QpView< T, I > qp, Model< T, I > &data, const Settings< T > &settings, bool execute_or_not, P &precond, proxsuite::linalg::veg::dynstack::StackReq precond_req)
auto ldl_col_ptrs_mut() -> I *
std::unique_ptr< Eigen::MINRES< detail::AugmentedKkt< T, I >, Eigen::Upper|Eigen::Lower, Eigen::IdentityPreconditioner > > matrix_free_solver
Eigen::Matrix< T, Eigen::Dynamic, 1 > l_scaled
Eigen::Matrix< T, Eigen::Dynamic, 1 > g_scaled
struct proxsuite::proxqp::sparse::Workspace::@16 internal
proxsuite::linalg::veg::Vec< I > kkt_nnz_counts
auto stack_mut() -> proxsuite::linalg::veg::dynstack::DynStackMut
void setup_symbolic_factorizaton(Model< T, I > &data, proxsuite::linalg::sparse::SymbolicMatRef< I > H, proxsuite::linalg::sparse::SymbolicMatRef< I > AT, proxsuite::linalg::sparse::SymbolicMatRef< I > CT)
auto ldl_col_ptrs() const -> I const *
proxsuite::linalg::veg::Vec< proxsuite::linalg::veg::mem::byte > storage