26 #ifndef CASADI_NEWTON_HPP
27 #define CASADI_NEWTON_HPP
29 #include "casadi/core/rootfinder_impl.hpp"
30 #include <casadi/solvers/casadi_rootfinder_newton_export.h>
46 :
public RootfinderMemory {
58 const char* return_status;
71 class Newton :
public Rootfinder {
74 explicit Newton(
const std::string& name,
const Function& f);
80 const char* plugin_name()
const override {
return "newton";}
83 std::string class_name()
const override {
return "Newton";}
86 static Rootfinder* creator(
const std::string& name,
const Function& f) {
87 return new Newton(name, f);
92 static const Options options_;
93 const Options& get_options()
const override {
return options_;}
97 void init(
const Dict& opts)
override;
100 void* alloc_mem()
const override {
return new NewtonMemory();}
103 int init_mem(
void* mem)
const override;
106 void free_mem(
void *mem)
const override {
delete static_cast<NewtonMemory*
>(mem);}
109 void set_work(
void* mem,
const double**& arg,
double**& res,
110 casadi_int*& iw,
double*& w)
const override;
113 int solve(
void* mem)
const override;
116 static const std::string meta_doc;
119 Dict get_stats(
void* mem)
const override;
122 void serialize_body(SerializingStream &s)
const override;
125 static ProtoFunction* deserialize(DeserializingStream& s) {
return new Newton(s); }
129 explicit Newton(DeserializingStream& s);
132 casadi_int max_iter_;
141 bool print_iteration_;
144 casadi_int print_iteration_interval_;
149 void printIteration(std::ostream &stream)
const;
152 void printIteration(std::ostream &stream, casadi_int iter,
153 double abstol,
double abstolStep,
double alpha)
const;
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.