• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/build/buildd/coinor-ipopt-3.8.3/Ipopt/contrib/MatlabInterface/src/matlabprogram.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2008 Peter Carbonetto. All Rights Reserved.
00002 // This code is published under the Common Public License.
00003 //
00004 // Author: Peter Carbonetto
00005 //         Dept. of Computer Science
00006 //         University of British Columbia
00007 //         September 25, 2008
00008 
00009 #ifndef INCLUDE_MATLABPROGRAM
00010 #define INCLUDE_MATLABPROGRAM
00011 
00012 #include "iterate.hpp"
00013 #include "options.hpp"
00014 #include "matlabinfo.hpp"
00015 #include "callbackfunctions.hpp"
00016 #include "IpTNLP.hpp"
00017 
00018 using Ipopt::TNLP;
00019 using Ipopt::SolverReturn;
00020 using Ipopt::AlgorithmMode;
00021 using Ipopt::IpoptData;
00022 using Ipopt::IpoptCalculatedQuantities;
00023 
00024 // Class MatlabProgram
00025 // -----------------------------------------------------------------
00026 class MatlabProgram : public TNLP {
00027 public:
00028     
00029   // The constructor.
00030   MatlabProgram (const Iterate& x0, const CallbackFunctions& funcs,
00031                  const Options& options, Iterate& x, const mxArray* auxdata,
00032                  MatlabInfo& info);
00033     
00034   // The destructor.
00035   virtual ~MatlabProgram();
00036   
00037   // Method to return some info about the nonlinear program.
00038   virtual bool get_nlp_info (int& n, int& m, int& sizeOfJ, int& sizeOfH, 
00039                              IndexStyleEnum& indexStyle);
00040   
00041   // Return the bounds for the problem.
00042   virtual bool get_bounds_info (int n, double* lb, double* ub, int m,
00043                                 double* cl, double* cu);
00044     
00045   // Return the starting point for the algorithm.
00046   virtual bool get_starting_point (int n, bool initializeVars, double* vars, 
00047                                    bool initializez, double* zl, double* zu, 
00048                                    int m, bool initializeLambda,
00049                                    double* lambda);
00050     
00051   // Compute the value of the objective.
00052   virtual bool eval_f (int n, const double* vars, bool ignore, double& f);
00053     
00054   // Compute the gradient of the objective.
00055   virtual bool eval_grad_f (int n, const double* vars, bool ignore, 
00056                             double* grad);
00057     
00058   // Evaluate the constraint residuals.
00059   virtual bool eval_g (int n, const double* vars, bool ignore, int m, 
00060                        double* g);
00061     
00062   // This method either returns: 1.) The structure of the Jacobian
00063   // (if "Jacobian" is zero), or 2.) The values of the Jacobian (if
00064   // "Jacobian" is not zero).
00065   virtual bool eval_jac_g (int numVariables, const double* variables, 
00066                            bool ignoreThis, int numConstraints, 
00067                            int sizeOfJ, int* rows, int *cols, double* Jx);
00068     
00069   // This method either returns: 1.) the structure of the Hessian of
00070   // the Lagrangian (if "Hessian" is zero), or 2.) the values of the
00071   // Hessian of the Lagrangian (if "Hesson" is not zero).
00072   virtual bool eval_h (int n, const double* vars, bool ignore, double sigma, 
00073                        int m, const double* lambda, bool ignoretoo, 
00074                        int sizeOfH, int* rows, int* cols, double* Hx);
00075 
00076   // This method is called when the algorithm is complete.
00077   virtual void finalize_solution (SolverReturn status, int numVariables, 
00078                                   const double* variables, const double* zl, 
00079                                   const double* zu, int numConstraints, 
00080                                   const double* constraints, 
00081                                   const double* lambda, double objective,
00082                                   const IpoptData* ip_data,
00083                                   IpoptCalculatedQuantities* ip_cq);
00084 
00085   // Intermediate callback method. It is called once per iteration
00086   // of the IPOPT algorithm.
00087   virtual bool intermediate_callback (AlgorithmMode mode, int t, double f,
00088                                       double inf_pr, double inf_du,
00089                                       double mu, double d_norm,
00090                                       double regularization_ize,
00091                                       double alpha_du, double alpha_pr,
00092                                       int ls_trials,
00093                                       const IpoptData* ip_data,
00094                                       IpoptCalculatedQuantities* ip_cq);
00095 
00096 protected:
00097   const Iterate&           x0;       // The initial point.
00098   const CallbackFunctions& funcs;    // Callback routines.
00099   const Options&           options;  // Further program info.
00100   Iterate&                 x;        // Current point.
00101   const mxArray*           auxdata;  // The auxiliary data.
00102   MatlabInfo&              info;     // Info passed back to MATLAB.
00103 
00104   // These next two members store information about the structure of
00105   // the sparse Matlab matrix for the Jacobian of the constraints
00106   // and the Hessian of the Lagragian.
00107   SparseMatrix* J;
00108   SparseMatrix* H;
00109 };
00110 
00111 #endif

Generated on Sat Oct 16 2010 02:54:49 by  doxygen 1.7.1