ipqp.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_IPQP_HPP
27 #define CASADI_IPQP_HPP
28 
29 #include "casadi/core/conic_impl.hpp"
30 #include <casadi/solvers/casadi_conic_ipqp_export.h>
31 #include "casadi/core/linsol.hpp"
32 
43 namespace casadi {
44  struct IpqpMemory : public ConicMemory {
45  const char* return_status;
46  };
47 
56  class Ipqp : public Conic {
57  public:
59  explicit Ipqp(const std::string& name,
60  const std::map<std::string, Sparsity> &st);
61 
63  static Conic* creator(const std::string& name,
64  const std::map<std::string, Sparsity>& st) {
65  return new Ipqp(name, st);
66  }
67 
69  ~Ipqp() override;
70 
71  // Get name of the plugin
72  const char* plugin_name() const override { return "ipqp";}
73 
74  // Get name of the class
75  std::string class_name() const override { return "Ipqp";}
76 
78  void* alloc_mem() const override { return new IpqpMemory();}
79 
81  int init_mem(void* mem) const override;
82 
84  void free_mem(void *mem) const override { delete static_cast<IpqpMemory*>(mem);}
85 
87 
88  static const Options options_;
89  const Options& get_options() const override { return options_;}
91 
93  void init(const Dict& opts) override;
94 
96  int solve(const double** arg, double** res,
97  casadi_int* iw, double* w, void* mem) const override;
98 
100  Dict get_stats(void* mem) const override;
101 
103  static const std::string meta_doc;
104  // Memory structure
106  // KKT system
107  Sparsity kkt_;
108  // KKT linear solver
109  Linsol linsol_;
111  // Options
112  bool print_iter_, print_header_, print_info_;
113  std::string linear_solver_;
114  Dict linear_solver_options_;
116 
117  void serialize_body(SerializingStream &s) const override;
118 
120  static ProtoFunction* deserialize(DeserializingStream& s) { return new Ipqp(s); }
121 
122  protected:
124  explicit Ipqp(DeserializingStream& s);
125 
126  private:
127  void set_qp_prob();
128  };
129 
130 } // namespace casadi
132 #endif // CASADI_IPQP_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.