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 private:
00094 smagHandle_t prob;
00095 double clockStart;
00096 double *negLambda;
00097 double isMin;
00098 double timelimit;
00099 int domviollimit;
00100 long int domviolations;
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 SMAG_NLP();
00112 SMAG_NLP(const SMAG_NLP&);
00113 SMAG_NLP& operator=(const SMAG_NLP&);
00114 };
00115
00116
00117 #endif