26 #ifndef CASADI_FATROP_INTERFACE_HPP
27 #define CASADI_FATROP_INTERFACE_HPP
29 #include <casadi/interfaces/fatrop/casadi_nlpsol_fatrop_export.h>
30 #include "casadi/core/nlpsol_impl.hpp"
31 #include "casadi/core/timing.hpp"
32 #include <fatrop/ocp/OCPAbstract.hpp>
33 #include <fatrop/ocp/StageOCPApplication.hpp>
34 #include <fatrop/ocp/OCPCInterface.h>
37 #include "fatrop_runtime.hpp"
86 struct FatropMemory :
public NlpsolMemory {
98 class FatropInterface :
public Nlpsol {
101 Sparsity hesslag_sp_;
103 explicit FatropInterface(
const std::string& name,
const Function& nlp);
104 ~FatropInterface()
override;
107 const char* plugin_name()
const override {
return "fatrop";}
110 std::string class_name()
const override {
return "FatropInterface";}
113 static Nlpsol* creator(
const std::string& name,
const Function& nlp) {
114 return new FatropInterface(name, nlp);
119 static const Options options_;
120 const Options& get_options()
const override {
return options_;}
124 void init(
const Dict& opts)
override;
127 void* alloc_mem()
const override {
return new FatropMemory();}
130 int init_mem(
void* mem)
const override;
133 void free_mem(
void *mem)
const override;
136 Dict get_stats(
void* mem)
const override;
139 void set_work(
void* mem,
const double**& arg,
double**& res,
140 casadi_int*& iw,
double*& w)
const override;
143 int solve(
void* mem)
const override;
152 static const std::string meta_doc;
157 ConvexifyData convexify_data_;
162 void set_fatrop_prob();
163 void set_fatrop_prob(CodeGenerator& g)
const;
166 void codegen_body(CodeGenerator& g)
const override;
169 void codegen_declarations(CodeGenerator& g)
const override;
172 void codegen_init_mem(CodeGenerator& g)
const override;
175 void codegen_free_mem(CodeGenerator& g)
const override;
178 std::string codegen_mem_type()
const override {
return "struct casadi_fatrop_data"; }
181 void serialize_body(SerializingStream &s)
const override;
184 static ProtoFunction* deserialize(DeserializingStream& s) {
return new FatropInterface(s); }
188 explicit FatropInterface(DeserializingStream& s);
194 static Sparsity blocksparsity(casadi_int rows, casadi_int cols,
195 const std::vector<casadi_ocp_block>& blocks,
bool eye=
false);
196 static void blockptr(std::vector<double *>& vs, std::vector<double>& v,
197 const std::vector<casadi_ocp_block>& blocks,
bool eye=
false);
198 Sparsity Isp_, ABsp_, CDsp_, RSQsp_;
200 std::vector< casadi_ocp_block > AB_blocks_, CD_blocks_, RSQ_blocks_, I_blocks_;
202 std::vector<casadi_int> nxs_;
203 std::vector<casadi_int> nus_;
204 std::vector<casadi_int> ngs_;
208 enum StructureDetection {
213 StructureDetection structure_detection_;
215 std::vector<casadi_int> AB_offsets_, CD_offsets_, RSQ_offsets_, I_offsets_;
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.