qrqp.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_QRQP_HPP
27 #define CASADI_QRQP_HPP
28 
29 #include "casadi/core/conic_impl.hpp"
30 #include <casadi/solvers/casadi_conic_qrqp_export.h>
31 
43 namespace casadi {
44  struct QrqpMemory : public ConicMemory {
45  // Problem data structure
47  const char* return_status;
48  };
49 
58  class Qrqp : public Conic {
59  public:
61  explicit Qrqp(const std::string& name,
62  const std::map<std::string, Sparsity> &st);
63 
65  static Conic* creator(const std::string& name,
66  const std::map<std::string, Sparsity>& st) {
67  return new Qrqp(name, st);
68  }
69 
71  ~Qrqp() override;
72 
73  // Get name of the plugin
74  const char* plugin_name() const override { return "qrqp";}
75 
76  // Get name of the class
77  std::string class_name() const override { return "Qrqp";}
78 
80  void* alloc_mem() const override { return new QrqpMemory();}
81 
83  int init_mem(void* mem) const override;
84 
86  void free_mem(void *mem) const override { delete static_cast<QrqpMemory*>(mem);}
87 
89  void set_work(void* mem, const double**& arg, double**& res,
90  casadi_int*& iw, double*& w) const override;
91 
93 
94  static const Options options_;
95  const Options& get_options() const override { return options_;}
97 
99  void init(const Dict& opts) override;
100 
102  int solve(const double** arg, double** res,
103  casadi_int* iw, double* w, void* mem) const override;
104 
106  Dict get_stats(void* mem) const override;
107 
109  void codegen_body(CodeGenerator& g) const override;
110 
112  static const std::string meta_doc;
113  // Memory structure
115  // KKT system and its QR factorization
116  Sparsity AT_, kkt_, sp_v_, sp_r_;
117  // KKT system permutation
118  std::vector<casadi_int> prinv_, pc_;
120  // Options
121  bool print_iter_, print_header_, print_info_, print_lincomb_;
123 
124  void serialize_body(SerializingStream &s) const override;
125 
127  static ProtoFunction* deserialize(DeserializingStream& s) { return new Qrqp(s); }
128 
129  protected:
131  explicit Qrqp(DeserializingStream& s);
132 
133  private:
134  void set_qrqp_prob();
135  };
136 
137 } // namespace casadi
139 #endif // CASADI_QRQP_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.