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

Go to the documentation of this file.
00001 /* $Id: OSIpoptSolver.h 2698 2009-06-09 04:14:07Z kmartin $ */
00017 #ifndef IPOPTSOLVER_H 
00018 #define IPOPTSOLVER_H
00019 
00020 #include "OSConfig.h" 
00021 #include "OSDefaultSolver.h"
00022 #include "OSrLWriter.h"
00023 #include "OSInstance.h"
00024 #include "OSParameters.h"
00025 #include "OSnLNode.h"
00026 #include "OSiLReader.h"
00027 #include "OSoLReader.h"
00028 #include "OSInstance.h"
00029 #include "OSExpressionTree.h"
00030 #include "OSnLNode.h"
00031 #include "OSDataStructures.h"
00032 #include "OSFileUtil.h"  
00033 #include "OSErrorClass.h"
00034 
00035 #include "OSResult.h"
00036 #include "OSInstance.h"
00037 #include "OSOption.h"
00038 
00039 # include <cstddef>
00040 # include <cstdlib>
00041 # include <cctype>
00042 # include <cassert>
00043 # include <stack>
00044 #include <string>
00045 # include <cppad/cppad.hpp>
00046 #include<iostream>
00047 
00048 #ifdef HAVE_CTIME
00049 # include <ctime>
00050 #else
00051 # ifdef HAVE_TIME_H
00052 #  include <time.h>
00053 # else
00054 #  error "don't have header file for time"
00055 # endif
00056 #endif 
00057 
00058  
00059 #ifdef HAVE_CMATH
00060 # include <cmath>
00061 #else
00062 # ifdef HAVE_MATH_H
00063 #  include <math.h>
00064 # else
00065 #  error "don't have header file for math"
00066 # endif
00067 #endif
00068 #include<vector>
00069 #include <map>  
00070 
00071 
00072 #include "IpTNLP.hpp"
00073 #include "IpIpoptApplication.hpp"
00074 
00075 using namespace Ipopt;
00076 
00077 
00078 
00079 // for Stefan
00080 class IpoptProblem : public TNLP{  
00081 public:
00082         
00084         IpoptProblem(OSInstance *osinstance_ , OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_);
00085         
00087         virtual ~IpoptProblem();
00088         
00089 
00090         OSInstance *osinstance;
00091         
00092         OSOption *osoption;
00093 
00094         OSResult *osresult;
00095         
00096         std::string *ipoptErrorMsg;
00097         
00099         virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00100                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00101 
00103         virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00104                                                                 Index m, Number* g_l, Number* g_u);
00105 
00107         virtual bool get_starting_point(Index n, bool init_x, Number* x,
00108                                                                         bool init_z, Number* z_L, Number* z_U,
00109                                                                         Index m, bool init_lambda,
00110                                                                         Number* lambda);
00111 
00113         virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00114 
00116         virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00117 
00119         virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00120 
00125         virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00126                                                         Index m, Index nele_jac, Index* iRow, Index *jCol,
00127                                                         Number* values);
00128 
00133         virtual bool eval_h(Index n, const Number* x, bool new_x,
00134                                                 Number obj_factor, Index m, const Number* lambda,
00135                                                 bool new_lambda, Index nele_hess, Index* iRow,
00136                                                 Index* jCol, Number* values);
00137 
00139         
00140         
00141         virtual bool get_scaling_parameters(Number& obj_scaling,
00142                                     bool& use_x_scaling, Index n,
00143                                     Number* x_scaling,
00144                                     bool& use_g_scaling, Index m,
00145                                     Number* g_scaling);
00146 
00150         virtual void finalize_solution(SolverReturn status,
00151                                                                         Index n, const Number* x, const Number* z_L, const Number* z_U,
00152                                                                         Index m, const Number* g, const Number* lambda,
00153                                                                         Number obj_value,
00154                                    const IpoptData* ip_data,
00155                                    IpoptCalculatedQuantities* ip_cq);
00157 
00158 
00159         
00160 private:
00172   //  HS071_NLP();
00173         IpoptProblem(const IpoptProblem&);
00174         IpoptProblem& operator=(const IpoptProblem&);
00176         
00177         
00178 
00179         
00180 };
00181 
00182 
00195 //class IpoptSolver : public DefaultSolver, public TNLP{  
00196 
00197 class IpoptSolver : public DefaultSolver{       
00198 public:
00199         
00200 
00201 
00203         IpoptSolver();
00204         
00206         ~IpoptSolver();
00207         
00208         SmartPtr<TNLP> nlp;
00209         
00210         SmartPtr<IpoptApplication> app;
00211         
00212         
00215         virtual void  solve() throw (ErrorClass) ;
00216         
00221         virtual void  buildSolverInstance() throw(ErrorClass);
00222         
00227         virtual void  setSolverOptions() throw(ErrorClass);
00228         
00234         void dataEchoCheck();
00235         
00240         OSiLReader *m_osilreader;
00241 
00246         OSoLReader *m_osolreader;
00247 
00248 
00249 private:
00250         OSrLWriter  *osrlwriter;
00251 
00263         //  IpoptSolver();
00264         //IpoptSolver(const IpoptSolver&);
00265         //IpoptSolver& operator=(const IpoptSolver&);
00267         //std::string ipoptErrorMsg;
00268         std::string *ipoptErrorMsg;
00269 };
00270 
00271 
00272 #endif /*IPOPTSOLVER_H*/

Generated on Mon Aug 3 03:02:25 2009 by  doxygen 1.4.7