/home/coin/SVN-release/OS-2.4.0/OS/src/OSSolverInterfaces/OSIpoptSolver.h

Go to the documentation of this file.
00001 /* $Id: OSIpoptSolver.h 4292 2011-09-21 05:47:18Z kmartin $ */
00015 #ifndef IPOPTSOLVER_H
00016 #define IPOPTSOLVER_H
00017 
00018 #include "OSConfig.h"
00019 #include "OSDefaultSolver.h"
00020 #include "OSrLWriter.h"
00021 #include "OSInstance.h"
00022 #include "OSParameters.h"
00023 #include "OSnLNode.h"
00024 #include "OSiLReader.h"
00025 #include "OSoLReader.h"
00026 #include "OSInstance.h"
00027 #include "OSExpressionTree.h"
00028 #include "OSnLNode.h"
00029 #include "OSGeneral.h"
00030 #include "OSFileUtil.h"
00031 #include "OSErrorClass.h"
00032 
00033 #include "OSResult.h"
00034 #include "OSInstance.h"
00035 #include "OSOption.h"
00036 
00037 #include <cstddef>
00038 #include <cstdlib>
00039 #include <cctype>
00040 #include <cassert>
00041 #include <stack>
00042 #include <string>
00043 #include <iostream>
00044 #include <vector>
00045 #include <map>
00046 
00047 
00048 #include "IpTNLP.hpp"
00049 #include "IpIpoptApplication.hpp"
00050 
00051 // for Stefan
00052 class IpoptProblem : public Ipopt::TNLP
00053 {
00054 public:
00055 
00057     IpoptProblem(OSInstance *osinstance_ , OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_);
00058 
00060     virtual ~IpoptProblem();
00061 
00062 
00063     OSInstance *osinstance;
00064 
00065     OSOption *osoption;
00066 
00067     OSResult *osresult;
00068 
00069     std::string *ipoptErrorMsg;
00070 
00072     virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
00073                               Ipopt::Index& nnz_h_lag, IndexStyleEnum& index_style);
00074 
00076     virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
00077                                  Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
00078 
00080     virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
00081                                     bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
00082                                     Ipopt::Index m, bool init_lambda,
00083                                     Ipopt::Number* lambda);
00084 
00086     virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
00087 
00089     virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
00090 
00092     virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
00093 
00098     virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00099                             Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
00100                             Ipopt::Number* values);
00101 
00106     virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00107                         Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
00108                         bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow,
00109                         Ipopt::Index* jCol, Ipopt::Number* values);
00110 
00112 
00113 
00114     virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
00115                                         bool& use_x_scaling, Ipopt::Index n,
00116                                         Ipopt::Number* x_scaling,
00117                                         bool& use_g_scaling, Ipopt::Index m,
00118                                         Ipopt::Number* g_scaling);
00119 
00123     virtual void finalize_solution(Ipopt::SolverReturn status,
00124                                    Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
00125                                    Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
00126                                    Ipopt::Number obj_value,
00127                                    const Ipopt::IpoptData* ip_data,
00128                                    Ipopt::IpoptCalculatedQuantities* ip_cq);
00130 
00131 
00132 
00133 private:
00145     //  HS071_NLP();
00146     IpoptProblem(const IpoptProblem&);
00147     IpoptProblem& operator=(const IpoptProblem&);
00149 
00150 
00151 
00152 
00153 };
00154 
00155 
00168 //class IpoptSolver : public DefaultSolver, public TNLP{
00169 
00170 class IpoptSolver : public DefaultSolver
00171 {
00172 public:
00173 
00174 
00175 
00177     IpoptSolver();
00178 
00180     ~IpoptSolver();
00181 
00182     Ipopt::SmartPtr<Ipopt::TNLP> nlp;
00183 
00184     Ipopt::SmartPtr<Ipopt::IpoptApplication> app;
00185 
00186 
00189     virtual void  solve() throw (ErrorClass) ;
00190 
00195     virtual void  buildSolverInstance() throw(ErrorClass);
00196 
00201     virtual void  setSolverOptions() throw(ErrorClass);
00202 
00208     void dataEchoCheck();
00209 
00214     OSiLReader *m_osilreader;
00215 
00220     OSoLReader *m_osolreader;
00221 
00222 
00223 private:
00224     OSrLWriter  *osrlwriter;
00225 
00237     //  IpoptSolver();
00238     //IpoptSolver(const IpoptSolver&);
00239     //IpoptSolver& operator=(const IpoptSolver&);
00241     //std::string ipoptErrorMsg;
00242     std::string *ipoptErrorMsg;
00243 };
00244 
00245 
00246 #endif /*IPOPTSOLVER_H*/

Generated on Thu Sep 22 03:06:04 2011 by  doxygen 1.4.7