Ipopt
trunk
|
00001 // Copyright (C) 2004, 2010 International Business Machines and others. 00002 // All Rights Reserved. 00003 // This code is published under the Eclipse Public License. 00004 // 00005 // $Id$ 00006 // 00007 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 00008 00009 #ifndef __IPSTDINTERFACETNLP_HPP__ 00010 #define __IPSTDINTERFACETNLP_HPP__ 00011 00012 #include "IpUtils.hpp" 00013 #include "IpTNLP.hpp" 00014 #include "IpJournalist.hpp" 00015 #include "IpException.hpp" 00016 #include "IpStdCInterface.h" 00017 #include "IpSmartPtr.hpp" 00018 00019 namespace Ipopt 00020 { 00023 DECLARE_STD_EXCEPTION(INVALID_STDINTERFACE_NLP); 00024 00030 class StdInterfaceTNLP : public TNLP 00031 { 00032 public: 00039 StdInterfaceTNLP(Index n_var, 00040 const Number* x_L, const Number* x_U, 00041 Index n_con, 00042 const Number* g_L, const Number* g_U, 00043 Index nele_jac, 00044 Index nele_hess, 00045 Index index_style, 00046 const Number* start_x, 00047 const Number* start_lam, 00048 const Number* start_z_L, 00049 const Number* start_z_U, 00050 Eval_F_CB eval_f, 00051 Eval_G_CB eval_g, 00052 Eval_Grad_F_CB eval_grad_f, 00053 Eval_Jac_G_CB eval_jac_g, 00054 Eval_H_CB eval_h, 00055 Intermediate_CB intermediate_cb, 00056 Number* x_sol, 00057 Number* z_L_sol, 00058 Number* z_U_sol, 00059 Number* g_sol, 00060 Number* lam_sol, 00061 Number* obj_sol, 00062 UserDataPtr user_data, 00063 Number obj_scaling=1, 00064 const Number* x_scaling = NULL, 00065 const Number* g_scaling = NULL); 00066 00068 virtual ~StdInterfaceTNLP(); 00070 00075 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, 00076 Index& nnz_h_lag, IndexStyleEnum& index_style); 00077 00079 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, 00080 Index m, Number* g_l, Number* g_u); 00081 00084 virtual bool get_scaling_parameters(Number& obj_scaling, 00085 bool& use_x_scaling, Index n, 00086 Number* x_scaling, 00087 bool& use_g_scaling, Index m, 00088 Number* g_scaling); 00089 00091 virtual bool get_starting_point(Index n, bool init_x, Number* x, 00092 bool init_z, Number* z_L, Number* z_U, 00093 Index m, bool init_lambda, Number* lambda); 00094 00096 virtual bool eval_f(Index n, const Number* x, bool new_x, 00097 Number& obj_value); 00098 00101 virtual bool eval_grad_f(Index n, const Number* x, bool new_x, 00102 Number* grad_f); 00103 00105 virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, 00106 Number* g); 00107 00111 virtual bool eval_jac_g(Index n, const Number* x, bool new_x, Index m, 00112 Index nele_jac, Index* iRow, Index *jCol, 00113 Number* values); 00114 00117 virtual bool eval_h(Index n, const Number* x, bool new_x, 00118 Number obj_factor, Index m, const Number* lambda, 00119 bool new_lambda, Index nele_hess, Index* iRow, 00120 Index* jCol, Number* values); 00121 00123 virtual bool intermediate_callback(AlgorithmMode mode, 00124 Index iter, Number obj_value, 00125 Number inf_pr, Number inf_du, 00126 Number mu, Number d_norm, 00127 Number regularization_size, 00128 Number alpha_du, Number alpha_pr, 00129 Index ls_trials, 00130 const IpoptData* ip_data, 00131 IpoptCalculatedQuantities* ip_cq); 00133 00136 virtual void finalize_solution(SolverReturn status, 00137 Index n, const Number* x, const Number* z_L, const Number* z_U, 00138 Index m, const Number* g, const Number* lambda, 00139 Number obj_value, 00140 const IpoptData* ip_data, 00141 IpoptCalculatedQuantities* ip_cq); 00143 00144 private: 00146 SmartPtr<const Journalist> jnlst_; 00147 00151 const Index n_var_; 00153 const Index n_con_; 00155 const Number* x_L_; 00157 const Number* x_U_; 00159 const Number* g_L_; 00161 const Number* g_U_; 00163 const Index nele_jac_; 00165 const Index nele_hess_; 00167 const Index index_style_; 00169 const Number* start_x_; 00172 const Number* start_lam_; 00175 const Number* start_z_L_; 00178 const Number* start_z_U_; 00180 Eval_F_CB eval_f_; 00182 Eval_G_CB eval_g_; 00185 Eval_Grad_F_CB eval_grad_f_; 00187 Eval_Jac_G_CB eval_jac_g_; 00189 Eval_H_CB eval_h_; 00191 Intermediate_CB intermediate_cb_; 00193 UserDataPtr user_data_; 00195 Number obj_scaling_; 00197 const Number* x_scaling_; 00199 const Number* g_scaling_; 00201 00202 00204 Number* non_const_x_; 00205 00207 Number* x_sol_; 00208 Number* z_L_sol_; 00209 Number* z_U_sol_; 00210 Number* g_sol_; 00211 Number* lambda_sol_; 00212 Number* obj_sol_; 00213 00216 void apply_new_x(bool new_x, Index n, const Number* x); 00217 00227 StdInterfaceTNLP(); 00228 00230 StdInterfaceTNLP(const StdInterfaceTNLP&); 00231 00233 void operator=(const StdInterfaceTNLP&); 00235 00236 }; 00237 00238 } // namespace Ipopt 00239 00240 #endif