# CouenneTNLP.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneTNLP.hpp 893 2012-08-09 14:48:19Z pbelotti $
    00002  *
    00003  * Name:    CouenneTNLP.hpp
    00004  * Authors: Pietro Belotti, Lehigh University
    00005  * Purpose: Definition of an NLP interface with gradient/Jacobian/etc
    00006  *
    00007  * This file is licensed under the Eclipse Public License (EPL)
    00008  */
    00009
    00010 #ifndef COUENNETNLP_HPP
    00011 #define COUENNETNLP_HPP
    00012
    00013 #include "IpTNLP.hpp"
    00014 #include "CouenneExprJac.hpp"
    00015 #include "CouenneExprHess.hpp"
    00016 #include "CouenneTypes.hpp"
    00017
    00018 #include <vector>
    00019 #include <set>
    00020
    00021 namespace Couenne {
    00022
    00023   class CouenneProblem;
    00024   class CouenneSparseMatrix;
    00025
    00027   class CouenneTNLP: public Ipopt::TNLP {
    00028
    00029   public:
    00030
    00032     CouenneTNLP ();
    00033
    00035     CouenneTNLP (CouenneProblem *);
    00036
    00038     CouenneTNLP (const CouenneTNLP &);
    00039
    00041     CouenneTNLP &operator= (const CouenneTNLP &rhs);
    00042
    00044     CouenneTNLP *clone ();
    00045
    00047     virtual ~CouenneTNLP ();
    00048
    00050     void setInitSol (const double *sol);
    00051
    00053     CouNumber *getSolution ()
    00054     {return sol_;}
    00055
    00057     CouNumber getSolValue ()
    00058     {return bestZ_;}
    00059
    00065     virtual bool get_nlp_info (Ipopt::Index& n,
    00066                                Ipopt::Index& m,
    00067                                Ipopt::Index& nnz_jac_g,
    00068                                Ipopt::Index& nnz_h_lag,
    00069                                enum Ipopt::TNLP::IndexStyleEnum& index_style);
    00070
    00076     virtual bool get_bounds_info (Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
    00077                                   Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
    00078
    00083     virtual bool get_variables_linearity (Ipopt::Index n, Ipopt::TNLP::LinearityType* var_types);
    00084
    00088     virtual bool get_constraints_linearity (Ipopt::Index m, Ipopt::TNLP::LinearityType* const_types);
    00089
    00096     virtual bool get_starting_point (Ipopt::Index n,
    00097                                      bool init_x, Ipopt::Number* x,
    00098                                      bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
    00099                                      Ipopt::Index m,
    00100                                      bool init_lambda, Ipopt::Number* lambda);
    00101
    00103     virtual bool eval_f (Ipopt::Index n, const Ipopt::Number* x, bool new_x,
    00104                          Ipopt::Number& obj_value);
    00105
    00107     virtual bool eval_grad_f (Ipopt::Index n, const Ipopt::Number* x,
    00108                               bool new_x,
    00109                               Ipopt::Number* grad_f);
    00110
    00112     virtual bool eval_g (Ipopt::Index n, const Ipopt::Number* x, bool new_x,
    00113                          Ipopt::Index m, Ipopt::Number* g);
    00114
    00120     virtual bool eval_jac_g (Ipopt::Index n, const Ipopt::Number* x, bool new_x,
    00121                              Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow,
    00122                              Ipopt::Index *jCol, Ipopt::Number* values);
    00123
    00133     virtual bool eval_h (Ipopt::Index n, const Ipopt::Number* x, bool new_x,
    00134                          Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
    00135                          bool new_lambda, Ipopt::Index nele_hess,
    00136                          Ipopt::Index* iRow, Ipopt::Index* jCol, Ipopt::Number* values);
    00137
    00139     virtual void finalize_solution (Ipopt::SolverReturn status,
    00140                                     Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
    00141                                     Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
    00142                                     Ipopt::Number obj_value,
    00143                                     const Ipopt::IpoptData* ip_data,
    00144                                     Ipopt::IpoptCalculatedQuantities* ip_cq);
    00145
    00149     virtual bool intermediate_callback (Ipopt::AlgorithmMode mode,
    00150                                         Ipopt::Index iter, Ipopt::Number obj_value,
    00151                                         Ipopt::Number inf_pr, Ipopt::Number inf_du,
    00152                                         Ipopt::Number mu, Ipopt::Number d_norm,
    00153                                         Ipopt::Number regularization_size,
    00154                                         Ipopt::Number alpha_du, Ipopt::Number alpha_pr,
    00155                                         Ipopt::Index ls_trials,
    00156                                         const Ipopt::IpoptData* ip_data,
    00157                                         Ipopt::IpoptCalculatedQuantities* ip_cq);
    00158
    00171     virtual Ipopt::Index get_number_of_nonlinear_variables ();
    00172
    00174     virtual bool get_list_of_nonlinear_variables (Ipopt::Index num_nonlin_vars,
    00175                                                   Ipopt::Index* pos_nonlin_vars);
    00176
    00179     virtual void setObjective (expression *newObj);
    00180
    00182     inline CouenneSparseMatrix *&optHessian ()
    00183     {return optHessian_;}
    00184
    00186     inline bool &getSaveOptHessian ()
    00187     {return saveOptHessian_;}
    00188
    00189   private:
    00190
    00192     CouenneProblem *problem_;
    00193
    00195     CouNumber *sol0_;
    00196
    00198     CouNumber *sol_;
    00199
    00201     CouNumber bestZ_;
    00202
    00204     std::vector <std::pair <int, expression *> > gradient_;
    00205
    00207     std::set <int> nonLinVars_;
    00208
    00210     ExprJac Jac_;
    00211
    00214     ExprHess *HLa_;
    00215
    00217     CouenneSparseMatrix *optHessian_;
    00218
    00220     bool saveOptHessian_;
    00221   };
    00222 }
    00223
    00224 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines