Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
matlabprogram.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008 Peter Carbonetto. All Rights Reserved.
2 // This code is published under the Eclipse Public License.
3 //
4 // Author: Peter Carbonetto
5 // Dept. of Computer Science
6 // University of British Columbia
7 // September 25, 2008
8
9 #ifndef INCLUDE_MATLABPROGRAM
10 #define INCLUDE_MATLABPROGRAM
11
12 #include "iterate.hpp"
13 #include "options.hpp"
14 #include "matlabinfo.hpp"
15 #include "callbackfunctions.hpp"
16 #include "IpTNLP.hpp"
17
18 using Ipopt::TNLP;
19 using Ipopt::SolverReturn;
20 using Ipopt::AlgorithmMode;
21 using Ipopt::IpoptData;
22 using Ipopt::IpoptCalculatedQuantities;
23
24 // Class MatlabProgram
25 // -----------------------------------------------------------------
26 class MatlabProgram : public TNLP {
27 public:
28
29 // The constructor.
30 MatlabProgram (const Iterate& x0, const CallbackFunctions& funcs,
31 const Options& options, Iterate& x, MatlabInfo& info);
32
33 // The destructor.
34 virtual ~MatlabProgram();
35
36 // Method to return some info about the nonlinear program.
37 virtual bool get_nlp_info (int& n, int& m, int& sizeOfJ, int& sizeOfH,
38 IndexStyleEnum& indexStyle);
39
40 // Return the bounds for the problem.
41 virtual bool get_bounds_info (int n, double* lb, double* ub, int m,
42 double* cl, double* cu);
43
44 // Return the starting point for the algorithm.
45 virtual bool get_starting_point (int n, bool initializeVars, double* vars,
46 bool initializez, double* zl, double* zu,
47 int m, bool initializeLambda,
48 double* lambda);
49
50 // Compute the value of the objective.
51 virtual bool eval_f (int n, const double* vars, bool ignore, double& f);
52
53 // Compute the gradient of the objective.
54 virtual bool eval_grad_f (int n, const double* vars, bool ignore,
55 double* grad);
56
57 // Evaluate the constraint residuals.
58 virtual bool eval_g (int n, const double* vars, bool ignore, int m,
59 double* g);
60
61 // This method either returns: 1.) The structure of the Jacobian
62 // (if "Jacobian" is zero), or 2.) The values of the Jacobian (if
63 // "Jacobian" is not zero).
64 virtual bool eval_jac_g (int numVariables, const double* variables,
65 bool ignoreThis, int numConstraints,
66 int sizeOfJ, int* rows, int *cols, double* Jx);
67
68 // This method either returns: 1.) the structure of the Hessian of
69 // the Lagrangian (if "Hessian" is zero), or 2.) the values of the
70 // Hessian of the Lagrangian (if "Hesson" is not zero).
71 virtual bool eval_h (int n, const double* vars, bool ignore, double sigma,
72 int m, const double* lambda, bool ignoretoo,
73 int sizeOfH, int* rows, int* cols, double* Hx);
74
75 // This method is called when the algorithm is complete.
76 virtual void finalize_solution (SolverReturn status, int numVariables,
77 const double* variables, const double* zl,
78 const double* zu, int numConstraints,
79 const double* constraints,
80 const double* lambda, double objective,
81 const IpoptData* ip_data,
82 IpoptCalculatedQuantities* ip_cq);
83
84 // Intermediate callback method. It is called once per iteration
85 // of the IPOPT algorithm.
86 virtual bool intermediate_callback (AlgorithmMode mode, int t, double f,
87 double inf_pr, double inf_du,
88 double mu, double d_norm,
89 double regularization_size,
90 double alpha_du, double alpha_pr,
91 int ls_trials,
92 const IpoptData* ip_data,
93 IpoptCalculatedQuantities* ip_cq);
94
95 protected:
96 const Iterate& x0; // The initial point.
97 const CallbackFunctions& funcs; // Callback routines.
98 const Options& options; // Further program info.
99 Iterate& x; // Current point.
100 MatlabInfo& info; // Info passed back to MATLAB.
101
102 // These next two members store information about the structure of
103 // the sparse Matlab matrix for the Jacobian of the constraints
104 // and the Hessian of the Lagragian.
105 SparseMatrix* J;
106 SparseMatrix* H;
107 };
108
109 #endif
MatlabProgram
Definition: matlabprogram.hpp:26
MatlabProgram::eval_h
virtual bool eval_h(int n, const double *vars, bool ignore, double sigma, int m, const double *lambda, bool ignoretoo, int sizeOfH, int *rows, int *cols, double *Hx)
overload this method to return the hessian of the lagrangian.
iterate.hpp
Ipopt::IpoptCalculatedQuantities
Class for all IPOPT specific calculated quantities.
Definition: IpIpoptCalculatedQuantities.hpp:81
m
Number Number Index m
Number of constraints.
Definition: IpStdCInterface.h:137
MatlabProgram::funcs
const CallbackFunctions & funcs
Definition: matlabprogram.hpp:97
MatlabProgram::get_nlp_info
virtual bool get_nlp_info(int &n, int &m, int &sizeOfJ, int &sizeOfH, IndexStyleEnum &indexStyle)
g
Number Number * g
Values of constraint at final point (output only - ignored if set to NULL)
Definition: IpStdCInterface.h:238
MatlabProgram::info
MatlabInfo & info
Definition: matlabprogram.hpp:100
Ipopt::AlgorithmMode
AlgorithmMode
enum to indicate the mode in which the algorithm is
Definition: IpReturnCodes.hpp:43
CallbackFunctions
Definition: callbackfunctions.hpp:29
MatlabProgram::eval_g
virtual bool eval_g(int n, const double *vars, bool ignore, int m, double *g)
overload this method to return the vector of constraint values
MatlabProgram::x0
const Iterate & x0
Definition: matlabprogram.hpp:96
MatlabProgram::eval_f
virtual bool eval_f(int n, const double *vars, bool ignore, double &f)
overload this method to return the value of the objective function
AlgorithmMode
AlgorithmMode
enum to indicate the mode in which the algorithm is
Definition: IpReturnCodes_inc.h:42
Ipopt::SolverReturn
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
Definition: IpAlgTypes.hpp:22
MatlabProgram::finalize_solution
virtual void finalize_solution(SolverReturn status, int numVariables, const double *variables, const double *zl, const double *zu, int numConstraints, const double *constraints, const double *lambda, double objective, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
MatlabProgram::get_starting_point
virtual bool get_starting_point(int n, bool initializeVars, double *vars, bool initializez, double *zl, double *zu, int m, bool initializeLambda, double *lambda)
overload this method to return the starting point.
SparseMatrix
Definition: sparsematrix.hpp:34
matlabinfo.hpp
callbackfunctions.hpp
Options
Definition: options.hpp:19
Ipopt::IpoptData
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:83
IpTNLP.hpp
MatlabProgram::~MatlabProgram
virtual ~MatlabProgram()
MatlabProgram::eval_jac_g
virtual bool eval_jac_g(int numVariables, const double *variables, bool ignoreThis, int numConstraints, int sizeOfJ, int *rows, int *cols, double *Jx)
overload this method to return the jacobian of the constraints.
MatlabProgram::intermediate_callback
virtual bool intermediate_callback(AlgorithmMode mode, int t, double f, double inf_pr, double inf_du, double mu, double d_norm, double regularization_size, double alpha_du, double alpha_pr, int ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
MatlabProgram::options
const Options & options
Definition: matlabprogram.hpp:98
Iterate
Definition: iterate.hpp:31
MatlabProgram::get_bounds_info
virtual bool get_bounds_info(int n, double *lb, double *ub, int m, double *cl, double *cu)
overload this method to return the information about the bound on the variables and constraints...
MatlabProgram::x
Iterate & x
Definition: matlabprogram.hpp:99
Ipopt::TNLP::IndexStyleEnum
IndexStyleEnum
overload this method to return the number of variables and constraints, and the number of non-zeros i...
Definition: IpTNLP.hpp:80
options.hpp
Ipopt::TNLP
Base class for all NLP&#39;s that use standard triplet matrix form and dense vectors. ...
Definition: IpTNLP.hpp:50
MatlabInfo
Definition: matlabinfo.hpp:21
MatlabProgram::J
SparseMatrix * J
Definition: matlabprogram.hpp:105
MatlabProgram::eval_grad_f
virtual bool eval_grad_f(int n, const double *vars, bool ignore, double *grad)
overload this method to return the vector of the gradient of the objective w.r.t. ...
MatlabProgram::H
SparseMatrix * H
Definition: matlabprogram.hpp:106
MatlabProgram::MatlabProgram
MatlabProgram(const Iterate &x0, const CallbackFunctions &funcs, const Options &options, Iterate &x, MatlabInfo &info)