MeshKit  1.0
IANlp.hpp
Go to the documentation of this file.
00001 // IANnl.hpp
00002 // Interval Assignment for Meshkit
00003 //
00004 // This is the solver-translation from Meshkit to the ipopt library
00005 // Here we provide the functions that ipopt needs to solve the optimization problem
00006 //
00007 // Adapted from: 
00008 // Copyright (C) 2005, 2007 International Business Machines and others.
00009 // All Rights Reserved.
00010 // This code is published under the Eclipse Public License.
00011 //
00012 // $Id: hs071_nlp.hpp 1864 2010-12-22 19:21:02Z andreasw $
00013 //
00014 // Authors:  Carl Laird, Andreas Waechter     IBM    2005-08-09
00015 
00016 #ifndef MESHKIT_IA_IANLP_HP
00017 #define MESHKIT_IA_IANLP_HP
00018 
00046 #include "MKVersion.h"
00047 
00048 #include "IpTNLP.hpp"
00049 //using namespace Ipopt;
00050 using Ipopt::Index;
00051 using Ipopt::Number;
00052 using Ipopt::SolverReturn;
00053 using Ipopt::IpoptData;
00054 using Ipopt::IpoptCalculatedQuantities;
00055 using Ipopt::TNLP;
00056 // IndexStyleEnum defined by Ipopt in global space
00057 
00058 namespace MeshKit 
00059 {
00060     
00061 class IAData;
00062 class IASolution;
00063 
00064 class IANlp : public TNLP
00065 {
00066 public:
00068   IANlp(const IAData *data_ptr, IASolution *solution_ptr, const bool set_silent = true); 
00069 
00071   virtual ~IANlp();
00072   
00076   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00077                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00078 
00080   virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00081                                Index m, Number* g_l, Number* g_u);
00082 
00084   virtual bool get_starting_point(Index n, bool init_x, Number* x_init,
00085                                   bool init_z, Number* z_L, Number* z_U,
00086                                   Index m, bool init_lambda,
00087                                   Number* lambda);
00088 
00090   virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00091 
00093   virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00094 
00096   virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00097 
00102   virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00103                           Index m, Index nele_jac, Index* iRow, Index *jCol,
00104                           Number* values);
00105 
00110   virtual bool eval_h(Index n, const Number* x, bool new_x,
00111                       Number obj_factor, Index m, const Number* lambda,
00112                       bool new_lambda, Index nele_hess, Index* iRow,
00113                       Index* jCol, Number* values);
00114 
00116 
00120   virtual void finalize_solution(SolverReturn status,
00121                                  Index n, const Number* x, const Number* z_L, const Number* z_U,
00122                                  Index m, const Number* g, const Number* lambda,
00123                                  Number obj_value,
00124                                  const IpoptData *ip_data,
00125                                  IpoptCalculatedQuantities* ip_cq);
00127   
00128   // Common routines, could be used by other Nlp's 
00129   int get_neleJac() const { return neleJac; }
00130   
00131         // return the value of the ith sum-even constraint, given current values of x
00132   double eval_even_sum(const int i, const Number* x) const;
00133   
00134         // return the value of the ith sum-equal constraint, given current values of x
00135   double eval_equal_sum(const int i, const Number* x) const;
00136 
00137 private:  
00138   // hide untrusted default methods
00140   //  IA_NLP();
00141   IANlp();
00142   IANlp(const IANlp&);
00143   IANlp& operator=(const IANlp&);
00145   
00146   // input data
00147   const IAData *data;
00148   static const int p_norm;
00149   // solution data
00150   IASolution *solution;
00151   int neleJac;
00152   
00153   const bool silent;
00154   const bool debugging;
00155   const bool verbose; // verbose debugging
00156   
00157   // internally used methods
00158   // contributions of one variable to the objective function and gradient
00159   // underlying function 
00160 
00161 
00162   // r functions: if x>I then x-I / I else I-x / x
00163   static Number eval_r_i(const Number& I_i, const Number& x_i); 
00164   static Number eval_grad_r_i(const Number& I_i, const Number& x_i); 
00165   static Number eval_hess_r_i(const Number& I_i, const Number& x_i); 
00166 
00167   // s functions: r weighted by x: r*x
00168   static Number eval_s_i(const Number& I_i, const Number& x_i); 
00169   static Number eval_grad_s_i(const Number& I_i, const Number& x_i); 
00170   static Number eval_hess_s_i(const Number& I_i, const Number& x_i); 
00171 
00172   // Capital functions, l-p norms of the lowercase functions
00173 public:
00174   static Number eval_R_i(const Number& I_i, const Number& x_i); 
00175 private:
00176   static Number eval_grad_R_i(const Number& I_i, const Number& x_i); 
00177   static Number eval_hess_R_i(const Number& I_i, const Number& x_i); 
00178 
00179   static Number eval_S_i(const Number& I_i, const Number& x_i); 
00180   static Number eval_grad_S_i(const Number& I_i, const Number& x_i); 
00181   static Number eval_hess_S_i(const Number& I_i, const Number& x_i); 
00182   
00183 
00184 };
00185 
00186 } // namespace MeshKit 
00187 
00188 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines