6#include <qpalm/sparse.hpp>
22 default:
throw std::invalid_argument(
"Invalid symmetry");
33 const auto n = problem.
get_n(), m = problem.
get_m();
36 vec x = vec::Zero(n), y = vec::Zero(m), g(m);
49 SparsityConv
sp_Q{
sp_Q_orig, {.order = SparseCSC::SortedRows}};
51 auto symm = convert_symmetry(
sp_Q.get_sparsity().symmetry);
52 qp.sto->Q = qpalm::ladel_sparse_create(n, n,
nnz_Q,
symm);
53 qp.Q =
qp.sto->Q.get();
55 std::ranges::copy(
sp_Q.get_sparsity().inner_idx,
qp.Q->i);
56 std::ranges::copy(
sp_Q.get_sparsity().outer_ptr,
qp.Q->p);
64 SparsityConv
sp_A{
sp_A_orig, {.order = SparseCSC::SortedRows}};
66 auto symm = convert_symmetry(
sp_A.get_sparsity().symmetry);
67 qp.sto->A = qpalm::ladel_sparse_create(m, n,
nnz_A + n,
symm);
68 qp.A =
qp.sto->A.get();
70 std::ranges::copy(
sp_A.get_sparsity().inner_idx,
qp.A->i);
71 std::ranges::copy(
sp_A.get_sparsity().outer_ptr,
qp.A->p);
77 ConstrConv::SparseView A{
80 .inner_idx =
span{
qp.A->i,
static_cast<size_t>(
qp.A->nzmax)},
81 .outer_ptr =
span{
qp.A->p,
static_cast<size_t>(
qp.A->ncol) + 1},
82 .values =
span{
qp.A->x,
static_cast<size_t>(
qp.A->nzmax)},
84 ConstrConv::add_box_constr_to_constr_matrix(A, problem.
get_box_C());
92 qp.q =
qp.sto->q.data();
96 qp.sto->b.lowerbound.resize(
qp.A->nrow);
97 qp.sto->b.upperbound.resize(
qp.A->nrow);
98 qp.bmin =
qp.sto->b.lowerbound.data();
99 qp.bmax =
qp.sto->b.upperbound.data();
102 ConstrConv::combine_bound_constr(C, D,
qp.sto->b, g);
104 qp.m =
static_cast<size_t>(
qp.A->nrow);
105 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)
int convert_symmetry(sparsity::Symmetry symmetry)
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.
OwningQPALMData build_qpalm_problem(const TypeErasedProblem< EigenConfigd > &problem)
Double-precision double configuration.
Sparse compressed-column structure (CCS or CSC).
Stores any of the supported sparsity patterns.