5#include <qpalm/sparse.hpp>
33 using mindexvec = Eigen::Map<Eigen::VectorX<qpalm::sp_index_t>>;
35 auto m =
static_cast<index_t>(A.nrow), n =
static_cast<index_t>(A.ncol);
101 for (
index_t i = 0; i < n; ++i) {
118 default:
throw std::invalid_argument(
"Invalid symmetry");
129 const auto n = problem.
get_n(), m = problem.
get_m();
132 vec x = vec::Zero(n), y = vec::Zero(m), g(m);
142 SparsityConv
sp_Q{
sp_Q_orig, {.order = SparseCSC::SortedRows}};
143 auto nnz_Q =
static_cast<qpalm::sp_index_t
>(
sp_Q.get_sparsity().nnz());
144 auto symm = convert_symmetry(
sp_Q.get_sparsity().symmetry);
145 qp.sto->Q = qpalm::ladel_sparse_create(n, n,
nnz_Q,
symm);
146 qp.Q =
qp.sto->Q.get();
148 std::ranges::copy(
sp_Q.get_sparsity().inner_idx,
qp.Q->i);
149 std::ranges::copy(
sp_Q.get_sparsity().outer_ptr,
qp.Q->p);
157 SparsityConv
sp_A{
sp_A_orig, {.order = SparseCSC::SortedRows}};
158 auto nnz_A =
static_cast<qpalm::sp_index_t
>(
sp_A.get_sparsity().nnz());
159 auto symm = convert_symmetry(
sp_A.get_sparsity().symmetry);
160 qp.sto->A = qpalm::ladel_sparse_create(m, n,
nnz_A + n,
symm);
161 qp.A =
qp.sto->A.get();
163 std::ranges::copy(
sp_A.get_sparsity().inner_idx,
qp.A->i);
164 std::ranges::copy(
sp_A.get_sparsity().outer_ptr,
qp.A->p);
170 add_bound_constr_to_constr_matrix(*
qp.A, problem.
get_box_C());
177 qp.q =
qp.sto->q.data();
181 qp.sto->b.lowerbound.resize(
qp.A->nrow);
182 qp.sto->b.upperbound.resize(
qp.A->nrow);
183 qp.bmin =
qp.sto->b.lowerbound.data();
184 qp.bmax =
qp.sto->b.upperbound.data();
187 combine_bound_constr(
qp.sto->b, C, D, g);
189 qp.m =
static_cast<size_t>(
qp.A->nrow);
190 qp.n =
static_cast<size_t>(
qp.Q->nrow);
The main polymorphic minimization problem interface.
const Box & get_box_D() const
[Optional] Get the rectangular constraint set of the general constraint function, .
void eval_jac_g(crvec x, rvec J_values) const
[Optional] Function that evaluates the nonzero values of the Jacobian matrix of the constraints,
Sparsity get_jac_g_sparsity() const
[Optional] Function that returns (a view of) the sparsity pattern of the Jacobian of the constraints.
length_t get_n() const
[Required] Number of decision variables.
Sparsity get_hess_L_sparsity() const
[Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the Lagrangian.
length_t get_m() const
[Required] Number of constraints.
real_t eval_f_grad_f(crvec x, rvec grad_fx) const
[Optional] Evaluate both and its gradient, .
void eval_g(crvec x, rvec gx) const
[Required] Function that evaluates the constraints,
void eval_hess_L(crvec x, crvec y, real_t scale, rvec H_values) const
[Optional] Function that evaluates the nonzero values of the Hessian of the Lagrangian,
const Box & get_box_C() const
[Optional] Get the rectangular constraint set of the decision variables, .
#define USING_ALPAQA_CONFIG(Conf)
void combine_bound_constr(Box< config_t > &b, const Box< config_t > &C, const Box< config_t > &D, crvec g)
For each constraint C(i) with finite bounds, insert these bounds into b(i), followed by all bounds D,...
void add_bound_constr_to_constr_matrix(ladel_sparse_matrix &A, const Box< config_t > &C)
Update the constraint matrix A, such that for each constraint C(i) with finite bounds,...
int convert_symmetry(sparsity::Symmetry symmetry)
bool is_bound(const Box< config_t > &C, index_t i)
Symmetry
Describes the symmetry of matrices.
@ Unsymmetric
No symmetry.
@ Upper
Symmetric, upper-triangular part is stored.
@ Lower
Symmetric, lower-triangular part is stored.
Converts one matrix storage format to another.
typename Conf::mindexvec mindexvec
OwningQPALMData build_qpalm_problem(const TypeErasedProblem< EigenConfigd > &problem)
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec
Double-precision double configuration.
Sparse compressed-column structure (CCS or CSC).
Stores any of the supported sparsity patterns.