callbackfunctions.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef INCLUDE_CALLBACKFUNCTIONS
00010 #define INCLUDE_CALLBACKFUNCTIONS
00011
00012 #include "mex.h"
00013 #include "iterate.hpp"
00014 #include "sparsematrix.hpp"
00015 #include "matlabfunctionhandle.hpp"
00016 #include "IpIpoptCalculatedQuantities.hpp"
00017 #include "IpIpoptData.hpp"
00018 #include "IpTNLPAdapter.hpp"
00019 #include "IpOrigIpoptNLP.hpp"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class CallbackFunctions {
00030 public:
00031
00032
00033
00034
00035 explicit CallbackFunctions (const mxArray* ptr);
00036
00037
00038 ~CallbackFunctions();
00039
00040
00041
00042 bool constraintFuncIsAvailable() const { return *constraintfunc; };
00043 bool jacobianFuncIsAvailable () const { return *jacobianfunc; };
00044 bool hessianFuncIsAvailable () const { return *hessianfunc; };
00045 bool iterFuncIsAvailable () const { return *iterfunc; };
00046
00047
00048
00049
00050 double computeObjective (const Iterate& x) const;
00051
00052
00053
00054
00055 void computeGradient (const Iterate& x, double* g) const;
00056
00057
00058
00059
00060 void computeConstraints (const Iterate& x, int m, double* c) const;
00061
00062
00063 SparseMatrix* getJacobianStructure (int n, int m) const;
00064
00065
00066 SparseMatrix* getHessianStructure (int n) const;
00067
00068
00069 void computeJacobian (int m, const Iterate& x, SparseMatrix& J) const;
00070
00071
00072 void computeHessian (const Iterate& x, double sigma, int m,
00073 const double* lambda, SparseMatrix& H) const;
00074
00075
00076
00077 bool iterCallback (int t, double f,
00078 double inf_pr, double inf_du,
00079 double mu, double d_norm,
00080 double regularization_size,
00081 double alpha_du, double alpha_pr,
00082 int ls_trials, const Ipopt::IpoptData* ip_data,
00083 Ipopt::IpoptCalculatedQuantities* ip_cq,
00084 int n) const;
00085
00086 protected:
00087 MatlabFunctionHandle* objfunc;
00088 MatlabFunctionHandle* gradfunc;
00089 MatlabFunctionHandle* constraintfunc;
00090 MatlabFunctionHandle* jacobianfunc;
00091 MatlabFunctionHandle* jacstrucfunc;
00092 MatlabFunctionHandle* hessianfunc;
00093 MatlabFunctionHandle* hesstrucfunc;
00094 MatlabFunctionHandle* iterfunc;
00095 };
00096
00097 #endif