daqp_interface.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #ifndef CASADI_DAQP_INTERFACE_HPP
26 #define CASADI_DAQP_INTERFACE_HPP
27 
28 #include "casadi/core/conic_impl.hpp"
29 #include <casadi/interfaces/daqp/casadi_conic_daqp_export.h>
30 
31 #include <api.h>
32 #include <string>
33 
34 namespace casadi {
35  #include "daqp_runtime.hpp"
36 }
37 
51 
52 namespace casadi {
53 
54  struct DaqpMemory : public ConicMemory {
55  // Problem data structure
57 
58  };
59 
69  class DaqpInterface : public Conic {
70  public:
72  static Conic* creator(const std::string& name,
73  const std::map<std::string, Sparsity>& st) {
74  return new DaqpInterface(name, st);
75  }
76 
78  explicit DaqpInterface(const std::string& name,
79  const std::map<std::string, Sparsity>& st);
80 
82  ~DaqpInterface() override;
83 
84  // Get name of the plugin
85  const char* plugin_name() const override { return "daqp";}
86 
87  // Get name of the class
88  std::string class_name() const override { return "DaqpInterface";}
89 
91 
92  static const Options options_;
93  const Options& get_options() const override { return options_;}
95 
96  void set_daqp_prob();
97  void set_daqp_prob(CodeGenerator& g) const;
98 
100  void codegen_body(CodeGenerator& g) const override;
101 
103  void codegen_init_mem(CodeGenerator& g) const override;
104 
106  void codegen_free_mem(CodeGenerator& g) const override;
107 
109  std::string codegen_mem_type() const override { return "struct casadi_daqp_data"; }
110 
111  // Initialize the solver
112  void init(const Dict& opts) override;
113 
114  // Initialize dependant read-only members of class
115  void init_dependent();
116 
118  void* alloc_mem() const override { return new DaqpMemory();}
119 
121  int init_mem(void* mem) const override;
122 
124  void free_mem(void *mem) const override;
125 
127  void set_work(void* mem, const double**& arg, double**& res,
128  casadi_int*& iw, double*& w) const override;
129 
131  Dict get_stats(void* mem) const override;
132 
133  // Solve the QP
134  int solve(const double** arg, double** res,
135  casadi_int* iw, double* w, void* mem) const override;
136 
138  static const std::string meta_doc;
139 
141  Dict opts_;
142 
143  void serialize_body(SerializingStream &s) const override;
144 
146  static ProtoFunction* deserialize(DeserializingStream& s) { return new DaqpInterface(s); }
147 
149  bool integer_support() const override { return true; }
150 
151  protected:
153  explicit DaqpInterface(DeserializingStream& s);
154 
155  private:
156 
157  // Memory structure
159 
160  };
161 } // end namespace casadi
163 #endif // CASADI_DAQP_INTERFACE_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.