# IpTNLP.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2009 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Eclipse Public License.
    00004 //
    00005 // $Id: IpTNLP.hpp 2212 2013-04-14 14:51:52Z stefan $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    00008
    00009 #ifndef __IPTNLP_HPP__
    00010 #define __IPTNLP_HPP__
    00011
    00012 #include "IpUtils.hpp"
    00013 #include "IpReferenced.hpp"
    00014 #include "IpException.hpp"
    00015 #include "IpAlgTypes.hpp"
    00016 #include "IpReturnCodes.hpp"
    00017
    00018 #include <map>
    00019
    00020 namespace Ipopt
    00021 {
    00022   // forward declarations
    00023   class IpoptData;
    00024   class IpoptCalculatedQuantities;
    00025   class IteratesVector;
    00026
    00050   class TNLP : public ReferencedObject
    00051   {
    00052   public:
    00054     enum LinearityType
    00055     {
    00056       LINEAR,
    00057       NON_LINEAR
    00058     };
    00059
    00062     TNLP()
    00063     {}
    00064
    00066     virtual ~TNLP()
    00067     {}
    00069
    00070     DECLARE_STD_EXCEPTION(INVALID_TNLP);
    00071
    00080     enum IndexStyleEnum { C_STYLE=0, FORTRAN_STYLE=1 };
    00081     virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
    00082                               Index& nnz_h_lag, IndexStyleEnum& index_style)=0;
    00083
    00084     typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType;
    00085     typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType;
    00086     typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType;
    00087
    00090     virtual bool get_var_con_metadata(Index n,
    00091                                       StringMetaDataMapType& var_string_md,
    00092                                       IntegerMetaDataMapType& var_integer_md,
    00093                                       NumericMetaDataMapType& var_numeric_md,
    00094                                       Index m,
    00095                                       StringMetaDataMapType& con_string_md,
    00096                                       IntegerMetaDataMapType& con_integer_md,
    00097                                       NumericMetaDataMapType& con_numeric_md)
    00098
    00099     {
    00100       return false;
    00101     }
    00102
    00109     virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
    00110                                  Index m, Number* g_l, Number* g_u)=0;
    00111
    00119     virtual bool get_scaling_parameters(Number& obj_scaling,
    00120                                         bool& use_x_scaling, Index n,
    00121                                         Number* x_scaling,
    00122                                         bool& use_g_scaling, Index m,
    00123                                         Number* g_scaling)
    00124     {
    00125       return false;
    00126     }
    00127
    00132     virtual bool get_variables_linearity(Index n, LinearityType* var_types)
    00133     {
    00134       return false;
    00135     }
    00136
    00140     virtual bool get_constraints_linearity(Index m, LinearityType* const_types)
    00141     {
    00142       return false;
    00143     }
    00144
    00152     virtual bool get_starting_point(Index n, bool init_x, Number* x,
    00153                                     bool init_z, Number* z_L, Number* z_U,
    00154                                     Index m, bool init_lambda,
    00155                                     Number* lambda)=0;
    00156
    00161     virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate)
    00162     {
    00163       return false;
    00164     }
    00165
    00167     virtual bool eval_f(Index n, const Number* x, bool new_x,
    00168                         Number& obj_value)=0;
    00169
    00172     virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
    00173                              Number* grad_f)=0;
    00174
    00176     virtual bool eval_g(Index n, const Number* x, bool new_x,
    00177                         Index m, Number* g)=0;
    00183     virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
    00184                             Index m, Index nele_jac, Index* iRow,
    00185                             Index *jCol, Number* values)=0;
    00186
    00196     virtual bool eval_h(Index n, const Number* x, bool new_x,
    00197                         Number obj_factor, Index m, const Number* lambda,
    00198                         bool new_lambda, Index nele_hess,
    00199                         Index* iRow, Index* jCol, Number* values)
    00200     {
    00201       return false;
    00202     }
    00204
    00208     virtual void finalize_solution(SolverReturn status,
    00209                                    Index n, const Number* x, const Number* z_L, const Number* z_U,
    00210                                    Index m, const Number* g, const Number* lambda,
    00211                                    Number obj_value,
    00212                                    const IpoptData* ip_data,
    00213                                    IpoptCalculatedQuantities* ip_cq)=0;
    00226     virtual void finalize_metadata(Index n,
    00227                                    const StringMetaDataMapType& var_string_md,
    00228                                    const IntegerMetaDataMapType& var_integer_md,
    00229                                    const NumericMetaDataMapType& var_numeric_md,
    00230                                    Index m,
    00231                                    const StringMetaDataMapType& con_string_md,
    00232                                    const IntegerMetaDataMapType& con_integer_md,
    00233                                    const NumericMetaDataMapType& con_numeric_md)
    00234     {}
    00235
    00236
    00240     virtual bool intermediate_callback(AlgorithmMode mode,
    00241                                        Index iter, Number obj_value,
    00242                                        Number inf_pr, Number inf_du,
    00243                                        Number mu, Number d_norm,
    00244                                        Number regularization_size,
    00245                                        Number alpha_du, Number alpha_pr,
    00246                                        Index ls_trials,
    00247                                        const IpoptData* ip_data,
    00248                                        IpoptCalculatedQuantities* ip_cq)
    00249     {
    00250       return true;
    00251     }
    00253
    00267     virtual Index get_number_of_nonlinear_variables()
    00268     {
    00269       return -1;
    00270     }
    00271
    00272     virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars,
    00273         Index* pos_nonlin_vars)
    00274     {
    00275       return false;
    00276     }
    00278
    00279   private:
    00289     //TNLP();
    00290
    00292     TNLP(const TNLP&);
    00293
    00295     void operator=(const TNLP&);
    00297   };
    00298
    00299 } // namespace Ipopt
    00300
    00301 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines