Ipopt  3.12.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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
12 #include "iterate.hpp"
13 #include "options.hpp"
14 #include "matlabinfo.hpp"
15 #include "callbackfunctions.hpp"
16 #include "IpTNLP.hpp"
18 using Ipopt::TNLP;
21 using Ipopt::IpoptData;
24 // Class MatlabProgram
25 // -----------------------------------------------------------------
26 class MatlabProgram : public TNLP {
27 public:
29  // The constructor.
31  const Options& options, Iterate& x, MatlabInfo& info);
33  // The destructor.
34  virtual ~MatlabProgram();
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);
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);
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);
50  // Compute the value of the objective.
51  virtual bool eval_f (int n, const double* vars, bool ignore, double& f);
53  // Compute the gradient of the objective.
54  virtual bool eval_grad_f (int n, const double* vars, bool ignore,
55  double* grad);
57  // Evaluate the constraint residuals.
58  virtual bool eval_g (int n, const double* vars, bool ignore, int m,
59  double* g);
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);
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);
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,
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,
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.
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 };
109 #endif
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.
Class for all IPOPT specific calculated quantities.
Number Number Index m
Number of constraints.
const CallbackFunctions & funcs
virtual bool get_nlp_info(int &n, int &m, int &sizeOfJ, int &sizeOfH, IndexStyleEnum &indexStyle)
Number Number * g
Values of constraint at final point (output only - ignored if set to NULL)
MatlabInfo & info
enum to indicate the mode in which the algorithm is
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
const Iterate & x0
virtual bool eval_f(int n, const double *vars, bool ignore, double &f)
overload this method to return the value of the objective function
enum to indicate the mode in which the algorithm is
enum for the return from the optimize algorithm (obviously we need to add more)
Definition: IpAlgTypes.hpp:22
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)
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.
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:83
virtual ~MatlabProgram()
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.
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)
const Options & options
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...
overload this method to return the number of variables and constraints, and the number of non-zeros i...
Definition: IpTNLP.hpp:80
Base class for all NLP's that use standard triplet matrix form and dense vectors. ...
Definition: IpTNLP.hpp:50
SparseMatrix * J
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. ...
SparseMatrix * H
MatlabProgram(const Iterate &x0, const CallbackFunctions &funcs, const Options &options, Iterate &x, MatlabInfo &info)