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 CASADI_CONIC_IPQP_EXPORT IpqpMemory : public ConicMemory {
45  const char* return_status;
46  };
47 
56  class CASADI_CONIC_IPQP_EXPORT 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
108  // KKT linear solver
111  // Options
112  bool print_iter_, print_header_, print_info_;
113  std::string linear_solver_;
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
Internal class.
Definition: conic_impl.hpp:44
Helper class for Serialization.
'ipqp' plugin for Conic
Definition: ipqp.hpp:56
Sparsity kkt_
Definition: ipqp.hpp:107
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize with type disambiguation.
Definition: ipqp.hpp:120
const Options & get_options() const override
Options.
Definition: ipqp.hpp:89
const char * plugin_name() const override
Definition: ipqp.hpp:72
void * alloc_mem() const override
Create memory block.
Definition: ipqp.hpp:78
std::string class_name() const override
Readable name of the internal class.
Definition: ipqp.hpp:75
static const Options options_
Options.
Definition: ipqp.hpp:88
std::string linear_solver_
Definition: ipqp.hpp:113
casadi_ipqp_prob< double > p_
Definition: ipqp.hpp:105
bool print_header_
Definition: ipqp.hpp:112
Dict linear_solver_options_
Definition: ipqp.hpp:114
static const std::string meta_doc
A documentation string.
Definition: ipqp.hpp:103
static Conic * creator(const std::string &name, const std::map< std::string, Sparsity > &st)
Create a new QP Solver.
Definition: ipqp.hpp:63
void free_mem(void *mem) const override
Free memory block.
Definition: ipqp.hpp:84
Linsol linsol_
Definition: ipqp.hpp:109
Linear solver.
Definition: linsol.hpp:55
Base class for FunctionInternal and LinsolInternal.
Helper class for Serialization.
General sparsity class.
Definition: sparsity.hpp:106
The casadi namespace.
Definition: archiver.cpp:28
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
const char * return_status
Definition: ipqp.hpp:45
Options metadata for a class.
Definition: options.hpp:40