26 #ifndef CASADI_KNITRO_INTERFACE_HPP
27 #define CASADI_KNITRO_INTERFACE_HPP
29 #include <casadi/interfaces/knitro/casadi_nlpsol_knitro_export.h>
31 #include "casadi/core/nlpsol_impl.hpp"
45 class KnitroInterface;
47 struct KnitroMemory :
public NlpsolMemory {
49 const KnitroInterface&
self;
58 double *wlbx, *wubx, *wlbg, *wubg;
61 const char* return_status;
64 KnitroMemory(
const KnitroInterface&
self);
74 class KnitroInterface :
public Nlpsol {
79 explicit KnitroInterface(
const std::string& name,
const Function& nlp);
80 ~KnitroInterface()
override;
83 const char* plugin_name()
const override {
return "knitro";}
86 std::string class_name()
const override {
return "KnitroInterface";}
89 static Nlpsol* creator(
const std::string& name,
const Function& nlp) {
90 return new KnitroInterface(name, nlp);
95 static const Options options_;
96 const Options& get_options()
const override {
return options_;}
100 void init(
const Dict& opts)
override;
103 void* alloc_mem()
const override {
return new KnitroMemory(*
this);}
106 int init_mem(
void* mem)
const override;
109 void free_mem(
void *mem)
const override {
delete static_cast<KnitroMemory*
>(mem);}
112 void set_work(
void* mem,
const double**& arg,
double**& res,
113 casadi_int*& iw,
double*& w)
const override;
116 int solve(
void* mem)
const override;
119 bool integer_support()
const override {
return true;}
122 static int callback(KN_context_ptr kc,
124 KN_eval_request_ptr
const evalRequest,
125 KN_eval_result_ptr
const evalResult,
126 void *
const userParams);
129 static const char* return_codes(
int flag);
132 Dict get_stats(
void* mem)
const override;
138 std::vector<int> contype_;
141 std::vector<int> comp_type_;
144 std::vector<int> comp_i1_;
145 std::vector<int> comp_i2_;
148 std::string options_file_;
151 static const std::string meta_doc;
154 void serialize_body(SerializingStream &s)
const override;
157 static ProtoFunction* deserialize(DeserializingStream& s) {
return new KnitroInterface(s); }
161 explicit KnitroInterface(DeserializingStream& s);
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.