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 <R.h>
00023 #include <Rdefines.h>
00024 #include <R_ext/Utils.h>
00025
00026
00027
00028
00029 class IpoptRNLP : public Ipopt::TNLP
00030 {
00031 SEXP R_environment;
00032
00033 SEXP R_eval_f;
00034 SEXP R_eval_grad_f;
00035
00036 SEXP R_init_values;
00037
00038 SEXP R_lower_bounds;
00039 SEXP R_upper_bounds;
00040
00041 SEXP R_eval_g;
00042 SEXP R_eval_jac_g;
00043 SEXP R_eval_jac_g_structure;
00044
00045 SEXP R_constraint_lower_bounds;
00046 SEXP R_constraint_upper_bounds;
00047
00048 SEXP R_eval_h;
00049 SEXP R_eval_h_structure;
00050
00051 SEXP R_result_list;
00052
00053 bool d_hessian_approximation;
00054
00055 int d_num_protected_members;
00056 public:
00058 IpoptRNLP();
00059
00061 virtual ~IpoptRNLP();
00062
00063 void set_R_environment( SEXP env );
00064
00065
00066 void set_R_eval_f( SEXP f );
00067 void set_R_eval_grad_f( SEXP f );
00068
00069 void set_R_init_values( SEXP x0 );
00070 void set_R_lower_bounds( SEXP lb );
00071 void set_R_upper_bounds( SEXP ub );
00072
00073 void set_R_eval_g( SEXP g );
00074 void set_R_eval_jac_g( SEXP g );
00075 void set_R_eval_jac_g_structure( SEXP s );
00076
00077 void set_R_constraint_lower_bounds( SEXP lb );
00078 void set_R_constraint_upper_bounds( SEXP ub );
00079
00080 void set_R_eval_h( SEXP h );
00081 void set_R_eval_h_structure( SEXP s );
00082
00083 void set_hessian_approximation( bool b );
00084
00085 SEXP get_R_result_list();
00086
00090 virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
00091 Ipopt::Index& nnz_h_lag, IndexStyleEnum& Index_style);
00092
00094 virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
00095 Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
00096
00098 virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
00099 bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
00100 Ipopt::Index m, bool init_lambda,
00101 Ipopt::Number* lambda);
00102
00104 virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
00105
00107 virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
00108
00110 virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
00111
00116 virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00117 Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
00118 Ipopt::Number* values);
00119
00124 virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00125 Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
00126 bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow,
00127 Ipopt::Index* jCol, Ipopt::Number* values);
00128
00130
00134 virtual void finalize_solution(Ipopt::SolverReturn status,
00135 Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
00136 Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
00137 Ipopt::Number obj_value,
00138 const Ipopt::IpoptData* ip_data,
00139 Ipopt::IpoptCalculatedQuantities* ip_cq);
00141
00142 private:
00154
00155 IpoptRNLP(const IpoptRNLP&);
00156 IpoptRNLP& operator=(const IpoptRNLP&);
00158 };
00159
00160
00161 #endif