- Main Page
- Classes
- Files

- File List
- File Members

# 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 Eclipse 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 IPOPT options object.
    00043   const IpoptOptions ipoptOptions() const { return ipopt; };
    00044
    00045   // Access the Lagrange multpliers.
    00046   const double* multlb    () const { return zl;     };
    00047   const double* multub    () const { return zu;     };
    00048   const double* multconstr() const { return lambda; };
    00049
    00050 protected:
    00051   int            n;       // The number of optimization variables.
    00052   int            m;       // The number of constraints.
    00053   double*        lb;      // Lower bounds on the variables.
    00054   double*        ub;      // Upper bounds on the variables.
    00055   double*        cl;      // Lower bounds on constraints.
    00056   double*        cu;      // Upper bounds on constraints.
    00057   double*        zl;      // Lagrange multipliers for lower bounds.
    00058   double*        zu;      // Lagrange multipliers for upper bounds.
    00059   double*        lambda;  // Lagrange multipliers for constraints.
    00060   IpoptOptions   ipopt;   // The IPOPT options.
    00061
    00062   // These are helper functions used by the class constructor.
    00063   static double* loadLowerBounds      (int n, const mxArray* ptr,
    00064                        double neginfty);
    00065   static double* loadUpperBounds      (int n, const mxArray* ptr,
    00066                        double posinfty);
    00067   static int     loadConstraintBounds (const mxArray* ptr, double*& cl,
    00068                        double*& cu, double neginfty,
    00069                        double posinfty);
    00070   static void    loadMultipliers      (int n, int m, const mxArray* ptr,
    00071                        double*& zl, double*& zu,
    00072                        double*& lambda);
    00073 };
    00074
    00075 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines