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

/tmp/buildd/coinor-ipopt-3.8.3/Ipopt/contrib/MatlabInterface/src/options.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_OPTIONS
00010 #define INCLUDE_OPTIONS
00011 
00012 #include "mex.h"
00013 #include "iterate.hpp"
00014 #include "ipoptoptions.hpp"
00015 
00016 // Class Options.
00017 // -----------------------------------------------------------------
00018 // This class processes the options input from MATLAB.
00019 class Options {
00020 public:
00021 
00022   // The constructor expects as input a point to a MATLAB array, in
00023   // particular a structure array with the appropriate fields. Note
00024   // that the Options object does *not* possess an independent copy of
00025   // some of the MATLAB data (such as the auxiliary data).
00026   Options (const Iterate& x, Ipopt::IpoptApplication& app, 
00027            const mxArray* ptr);
00028   
00029   // The destructor.
00030   ~Options();
00031 
00032   // Get the number of variables and the number of constraints.
00033   friend int numvars        (const Options& options) { return options.n; };
00034   friend int numconstraints (const Options& options) { return options.m; };
00035 
00036   // Access the lower and upper bounds on the variables and constraints. 
00037   const double* lowerbounds () const { return lb; };
00038   const double* upperbounds () const { return ub; };
00039   const double* constraintlb() const { return cl; };
00040   const double* constraintub() const { return cu; };
00041 
00042   // Access the auxiliary data.
00043   const mxArray* getAuxData() const { return auxdata; };
00044 
00045   // Access the IPOPT options object.
00046   const IpoptOptions ipoptOptions() const { return ipopt; };
00047 
00048   // Access the Lagrange multpliers.
00049   const double* multlb    () const { return zl;     };
00050   const double* multub    () const { return zu;     };
00051   const double* multconstr() const { return lambda; };
00052 
00053 protected:
00054   int            n;       // The number of optimization variables.
00055   int            m;       // The number of constraints.
00056   double*        lb;      // Lower bounds on the variables.
00057   double*        ub;      // Upper bounds on the variables.
00058   double*        cl;      // Lower bounds on constraints.
00059   double*        cu;      // Upper bounds on constraints.
00060   double*        zl;      // Lagrange multipliers for lower bounds.
00061   double*        zu;      // Lagrange multipliers for upper bounds.
00062   double*        lambda;  // Lagrange multipliers for constraints.
00063   const mxArray* auxdata; // MATLAB array containing the auxiliary data.
00064   IpoptOptions   ipopt;   // The IPOPT options.
00065 
00066   // These are helper functions used by the class constructor.
00067   static double* loadLowerBounds      (int n, const mxArray* ptr, 
00068                                        double neginfty);
00069   static double* loadUpperBounds      (int n, const mxArray* ptr, 
00070                                        double posinfty);
00071   static int     loadConstraintBounds (const mxArray* ptr, double*& cl, 
00072                                        double*& cu, double neginfty,
00073                                        double posinfty);
00074   static void    loadMultipliers      (int n, int m, const mxArray* ptr, 
00075                                        double*& zl, double*& zu, 
00076                                        double*& lambda);
00077 };
00078 
00079 #endif

Generated on Thu Jul 29 2010 19:56:08 by  doxygen 1.7.1