26 #ifndef CASADI_PROXQP_INTERFACE_HPP
27 #define CASADI_PROXQP_INTERFACE_HPP
29 #include "casadi/core/conic_impl.hpp"
30 #include <casadi/interfaces/proxqp/casadi_conic_proxqp_export.h>
33 #include <proxsuite/proxqp/dense/dense.hpp>
34 #include <proxsuite/proxqp/sparse/sparse.hpp>
35 #include <proxsuite/proxqp/settings.hpp>
37 #include <Eigen/Dense>
38 #include <Eigen/Sparse>
52 struct ProxqpMemory :
public ConicMemory {
54 typedef Eigen::Triplet<double> T;
56 proxsuite::proxqp::sparse::QP<double, long long> sparse_solver;
57 proxsuite::proxqp::dense::QP<double> dense_solver;
60 Eigen::VectorXd g_vector;
61 Eigen::VectorXd b_vector;
63 Eigen::VectorXd uba_vector;
64 Eigen::VectorXd lba_vector;
65 Eigen::VectorXd ubx_vector;
66 Eigen::VectorXd lbx_vector;
67 Eigen::VectorXd ub_vector;
68 Eigen::VectorXd lb_vector;
71 std::vector<T> tripletList;
72 std::vector<T> tripletListEq;
73 std::vector<casadi_int> row, col;
76 std::unique_ptr<Eigen::VectorXd> results_x;
77 std::unique_ptr<Eigen::VectorXd> results_y;
78 std::unique_ptr<Eigen::VectorXd> results_z;
80 proxsuite::proxqp::QPSolverOutput status;
95 class ProxqpInterface :
public Conic {
98 explicit ProxqpInterface(
const std::string& name,
99 const std::map<std::string, Sparsity>& st);
102 static Conic* creator(
const std::string& name,
103 const std::map<std::string, Sparsity>& st) {
104 return new ProxqpInterface(name, st);
108 ~ProxqpInterface()
override;
111 const char* plugin_name()
const override {
return "proxqp";}
114 std::string class_name()
const override {
return "ProxqpInterface";}
118 static const Options options_;
119 const Options& get_options()
const override {
return options_;}
123 void init(
const Dict& opts)
override;
126 void* alloc_mem()
const override {
return new ProxqpMemory();}
129 int init_mem(
void* mem)
const override;
132 void free_mem(
void *mem)
const override {
delete static_cast<ProxqpMemory*
>(mem);}
135 int solve(
const double** arg,
double** res,
136 casadi_int* iw,
double* w,
void* mem)
const override;
139 bool integer_support()
const override {
return false;}
142 bool psd_support()
const override {
return false;}
145 static const std::string meta_doc;
148 Dict get_stats(
void* mem)
const override;
150 proxsuite::proxqp::Settings<double> settings_;
152 bool warm_start_primal_, warm_start_dual_;
162 void serialize_body(SerializingStream &s)
const override;
165 static ProtoFunction* deserialize(DeserializingStream& s) {
return new ProxqpInterface(s); }
169 explicit ProxqpInterface(DeserializingStream& e);
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.