Ipopt  3.11.4
 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;
21 using Ipopt::IpoptData;
23 
24 // Class MatlabProgram
25 // -----------------------------------------------------------------
26 class MatlabProgram : public TNLP {
27 public:
28 
29  // The constructor.
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,
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,
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.
107 };
108 
109 #endif