ooqp_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 
26 #ifndef CASADI_OOQP_INTERFACE_HPP
27 #define CASADI_OOQP_INTERFACE_HPP
28 
29 #include "casadi/core/conic_impl.hpp"
30 #include <casadi/interfaces/ooqp/casadi_conic_ooqp_export.h>
31 
45 namespace casadi {
46 
47  struct OoqpMemory : public ConicMemory {
48  int return_status;
49  };
50 
57  class OoqpInterface : public Conic {
58  public:
60  explicit OoqpInterface(const std::string& name,
61  const std::map<std::string, Sparsity>& st);
62 
64  static Conic* creator(const std::string& name,
65  const std::map<std::string, Sparsity>& st) {
66  return new OoqpInterface(name, st);
67  }
68 
70  ~OoqpInterface() override;
71 
72  // Get name of the plugin
73  const char* plugin_name() const override { return "ooqp";}
74 
75  // Get name of the class
76  std::string class_name() const override { return "OoqpInterface";}
77 
79 
80  static const Options options_;
81  const Options& get_options() const override { return options_;}
83 
85  void init(const Dict& opts) override;
86 
88  int solve(const double** arg, double** res,
89  casadi_int* iw, double* w, void* mem) const override;
90 
92  void* alloc_mem() const override { return new OoqpMemory();}
93 
95  void free_mem(void *mem) const override { delete static_cast<OoqpMemory*>(mem);}
96 
98  static const char* errFlag(int flag);
99 
101  static std::string printBounds(const std::vector<double>& b,
102  const std::vector<char>& ib, casadi_int n, const char *sign);
103 
105  Dict get_stats(void* mem) const override;
106 
107  // Transpose of linear constraints
108  Sparsity spAT_;
109 
110  // Number of nonzeros in upper triangular half of Hessian
111  casadi_int nQ_;
112 
113  // Number of nonzeros in Hessian
114  casadi_int nH_;
115 
116  // Number of nonzeros in constraint matrix
117  casadi_int nA_;
118 
119  // Print level
120  casadi_int print_level_;
121 
122  // Tolerances
123  double mutol_, artol_;
124 
126  static const std::string meta_doc;
127 
129  void serialize_body(SerializingStream &s) const override;
130 
132  static ProtoFunction* deserialize(DeserializingStream& s) { return new OoqpInterface(s); }
133 
134  protected:
136  explicit OoqpInterface(DeserializingStream& s);
137  };
138 
139 } // namespace casadi
140 
142 #endif // CASADI_OOQP_INTERFACE_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.