00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __IPTNLP_HPP__
00010 #define __IPTNLP_HPP__
00011
00012 #include "IpUtils.hpp"
00013 #include "IpReferenced.hpp"
00014 #include "IpException.hpp"
00015 #include "IpAlgTypes.hpp"
00016 #include "IpReturnCodes.hpp"
00017
00018 #include <map>
00019
00020 namespace Ipopt
00021 {
00022
00023 class IpoptData;
00024 class IpoptCalculatedQuantities;
00025 class IteratesVector;
00026
00050 class TNLP : public ReferencedObject
00051 {
00052 public:
00054 enum LinearityType
00055 {
00056 LINEAR,
00057 NON_LINEAR
00058 };
00059
00062 TNLP()
00063 {}
00064
00066 virtual ~TNLP()
00067 {}
00069
00070 DECLARE_STD_EXCEPTION(INVALID_TNLP);
00071
00080 enum IndexStyleEnum { C_STYLE=0, FORTRAN_STYLE=1 };
00081 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00082 Index& nnz_h_lag, IndexStyleEnum& index_style)=0;
00083
00084 typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType;
00085 typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType;
00086 typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType;
00087
00090 virtual bool get_var_con_metadata(Index n,
00091 StringMetaDataMapType& var_string_md,
00092 IntegerMetaDataMapType& var_integer_md,
00093 NumericMetaDataMapType& var_numeric_md,
00094 Index m,
00095 StringMetaDataMapType& con_string_md,
00096 IntegerMetaDataMapType& con_integer_md,
00097 NumericMetaDataMapType& con_numeric_md)
00098
00099 {
00100 return false;
00101 }
00102
00109 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00110 Index m, Number* g_l, Number* g_u)=0;
00111
00119 virtual bool get_scaling_parameters(Number& obj_scaling,
00120 bool& use_x_scaling, Index n,
00121 Number* x_scaling,
00122 bool& use_g_scaling, Index m,
00123 Number* g_scaling)
00124 {
00125 return false;
00126 }
00127
00132 virtual bool get_variables_linearity(Index n, LinearityType* var_types)
00133 {
00134 return false;
00135 }
00136
00140 virtual bool get_constraints_linearity(Index m, LinearityType* const_types)
00141 {
00142 return false;
00143 }
00144
00152 virtual bool get_starting_point(Index n, bool init_x, Number* x,
00153 bool init_z, Number* z_L, Number* z_U,
00154 Index m, bool init_lambda,
00155 Number* lambda)=0;
00156
00161 virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate)
00162 {
00163 return false;
00164 }
00165
00167 virtual bool eval_f(Index n, const Number* x, bool new_x,
00168 Number& obj_value)=0;
00169
00172 virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
00173 Number* grad_f)=0;
00174
00176 virtual bool eval_g(Index n, const Number* x, bool new_x,
00177 Index m, Number* g)=0;
00183 virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00184 Index m, Index nele_jac, Index* iRow,
00185 Index *jCol, Number* values)=0;
00186
00196 virtual bool eval_h(Index n, const Number* x, bool new_x,
00197 Number obj_factor, Index m, const Number* lambda,
00198 bool new_lambda, Index nele_hess,
00199 Index* iRow, Index* jCol, Number* values)
00200 {
00201 return false;
00202 }
00204
00208 virtual void finalize_solution(SolverReturn status,
00209 Index n, const Number* x, const Number* z_L, const Number* z_U,
00210 Index m, const Number* g, const Number* lambda,
00211 Number obj_value,
00212 const IpoptData* ip_data,
00213 IpoptCalculatedQuantities* ip_cq)=0;
00214
00218 virtual bool intermediate_callback(AlgorithmMode mode,
00219 Index iter, Number obj_value,
00220 Number inf_pr, Number inf_du,
00221 Number mu, Number d_norm,
00222 Number regularization_size,
00223 Number alpha_du, Number alpha_pr,
00224 Index ls_trials,
00225 const IpoptData* ip_data,
00226 IpoptCalculatedQuantities* ip_cq)
00227 {
00228 return true;
00229 }
00231
00245 virtual Index get_number_of_nonlinear_variables()
00246 {
00247 return -1;
00248 }
00249
00250 virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars,
00251 Index* pos_nonlin_vars)
00252 {
00253 return false;
00254 }
00256
00257 private:
00267
00268
00270 TNLP(const TNLP&);
00271
00273 void operator=(const TNLP&);
00275 };
00276
00277 }
00278
00279 #endif