00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __IpoptRNLP_HPP__
00018 #define __IpoptRNLP_HPP__
00019
00020 #include "IpTNLP.hpp"
00021
00022 #include <assert.h>
00023
00024 #include <R.h>
00025 #include <Rdefines.h>
00026 #include <R_ext/Utils.h>
00027
00028
00029
00030
00031 class IpoptRNLP : public Ipopt::TNLP
00032 {
00033 SEXP R_environment;
00034
00035 SEXP R_eval_f;
00036 SEXP R_eval_grad_f;
00037
00038 SEXP R_init_values;
00039
00040 SEXP R_lower_bounds;
00041 SEXP R_upper_bounds;
00042
00043 SEXP R_eval_g;
00044 SEXP R_eval_jac_g;
00045 SEXP R_eval_jac_g_structure;
00046
00047 SEXP R_constraint_lower_bounds;
00048 SEXP R_constraint_upper_bounds;
00049
00050 SEXP R_eval_h;
00051 SEXP R_eval_h_structure;
00052
00053 SEXP R_result_list;
00054
00055 bool d_hessian_approximation;
00056
00057 int d_num_protected_members;
00058 public:
00060 IpoptRNLP();
00061
00063 virtual ~IpoptRNLP();
00064
00065 void set_R_environment( SEXP env );
00066
00067
00068 void set_R_eval_f( SEXP f );
00069 void set_R_eval_grad_f( SEXP f );
00070
00071 void set_R_init_values( SEXP x0 );
00072 void set_R_lower_bounds( SEXP lb );
00073 void set_R_upper_bounds( SEXP ub );
00074
00075 void set_R_eval_g( SEXP g );
00076 void set_R_eval_jac_g( SEXP g );
00077 void set_R_eval_jac_g_structure( SEXP s );
00078
00079 void set_R_constraint_lower_bounds( SEXP lb );
00080 void set_R_constraint_upper_bounds( SEXP ub );
00081
00082 void set_R_eval_h( SEXP h );
00083 void set_R_eval_h_structure( SEXP s );
00084
00085 void set_hessian_approximation( bool b );
00086
00087 SEXP get_R_result_list();
00088
00092 virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
00093 Ipopt::Index& nnz_h_lag, IndexStyleEnum& Index_style);
00094
00096 virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
00097 Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
00098
00100 virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
00101 bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
00102 Ipopt::Index m, bool init_lambda,
00103 Ipopt::Number* lambda);
00104
00106 virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
00107
00109 virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
00110
00112 virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
00113
00118 virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00119 Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
00120 Ipopt::Number* values);
00121
00126 virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00127 Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
00128 bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow,
00129 Ipopt::Index* jCol, Ipopt::Number* values);
00130
00132
00136 virtual void finalize_solution(Ipopt::SolverReturn status,
00137 Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
00138 Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
00139 Ipopt::Number obj_value,
00140 const Ipopt::IpoptData* ip_data,
00141 Ipopt::IpoptCalculatedQuantities* ip_cq);
00143
00144 private:
00156
00157 IpoptRNLP(const IpoptRNLP&);
00158 IpoptRNLP& operator=(const IpoptRNLP&);
00160 };
00161
00162
00163 #endif