00001
00002
00003
00004
00005
00006
00007
00008
00009 #if ! defined(__SMAGNLP_HPP__)
00010 #define __SMAGNLP_HPP__
00011
00012 #include "GAMSlinksConfig.h"
00013
00014 #include "IpTNLP.hpp"
00015
00016
00017
00018 #ifdef HAVE_CSTDIO
00019 #include <cstdio>
00020 #endif
00021 #ifdef HAVE_CSTDARG
00022 #include <cstdarg>
00023 #endif
00024 #include "smag.h"
00025
00026 using namespace Ipopt;
00027
00030 class SMAG_NLP : public TNLP {
00031 public:
00035 SMAG_NLP (smagHandle_t prob);
00036
00038 virtual ~SMAG_NLP();
00039
00041 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00042 Index& nnz_h_lag, IndexStyleEnum& index_style);
00043
00045 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00046 Index m, Number* g_l, Number* g_u);
00047
00049 virtual bool get_starting_point(Index n, bool init_x, Number* x,
00050 bool init_z, Number* z_L, Number* z_U,
00051 Index m, bool init_lambda,
00052 Number* lambda);
00053
00055 virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00056
00058 virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00059
00061 virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00062
00067 virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00068 Index m, Index nele_jac, Index* iRow, Index *jCol,
00069 Number* values);
00070
00075 virtual bool eval_h(Index n, const Number* x, bool new_x,
00076 Number obj_factor, Index m, const Number* lambda,
00077 bool new_lambda, Index nele_hess, Index* iRow,
00078 Index* jCol, Number* values);
00079
00083 virtual bool intermediate_callback (AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq);
00084
00087 virtual void finalize_solution(SolverReturn status,
00088 Index n, const Number* x, const Number* z_L,
00089 const Number* z_U,
00090 Index m, const Number* g, const Number* lambda,
00091 Number obj_value);
00092
00093 double div_iter_tol;
00094 double scaled_conviol_tol;
00095 double unscaled_conviol_tol;
00096 private:
00097 smagHandle_t prob;
00098 double clockStart;
00099 double *negLambda;
00100 double isMin;
00101 double timelimit;
00102 int domviollimit;
00103 long int domviolations;
00104
00105 int last_iterationnumber;
00106 double last_scaled_conviol;
00107 double last_unscaled_conviol;
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 SMAG_NLP();
00119 SMAG_NLP(const SMAG_NLP&);
00120 SMAG_NLP& operator=(const SMAG_NLP&);
00121 };
00122
00123
00124 #endif