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

Go to the documentation of this file.
00001 
00016 #ifndef IPOPTSOLVER_H 
00017 #define IPOPTSOLVER_H
00018 
00019 #include "OSConfig.h" 
00020 #include "OSDefaultSolver.h"
00021 #include "OSrLWriter.h"
00022 #include "OSInstance.h"
00023 #include "OSParameters.h"
00024 #include "OSnLNode.h"
00025 #include "OSiLReader.h"
00026 #include "OSInstance.h"
00027 #include "OSExpressionTree.h"
00028 #include "OSnLNode.h"
00029 #include "OSDataStructures.h"
00030 #include "OSFileUtil.h"  
00031 #include "OSErrorClass.h"
00032 
00033 #include "OSResult.h"
00034 #include "OSInstance.h"
00035 
00036 # include <cstddef>
00037 # include <cstdlib>
00038 # include <cctype>
00039 # include <cassert>
00040 # include <stack>
00041 #include <string>
00042 # include <cppad/cppad.hpp>
00043 #include<iostream>
00044 
00045 #ifdef HAVE_CTIME
00046 # include <ctime>
00047 #else
00048 # ifdef HAVE_TIME_H
00049 #  include <time.h>
00050 # else
00051 #  error "don't have header file for time"
00052 # endif
00053 #endif 
00054 
00055  
00056 #ifdef HAVE_CMATH
00057 # include <cmath>
00058 #else
00059 # ifdef HAVE_MATH_H
00060 #  include <math.h>
00061 # else
00062 #  error "don't have header file for math"
00063 # endif
00064 #endif
00065 #include<vector>
00066 #include <map>  
00067 
00068 
00069 #include "IpTNLP.hpp"
00070 #include "IpIpoptApplication.hpp"
00071 
00072 using namespace Ipopt;
00073 
00074 
00075 
00076 // for Stefan
00077 class IpoptProblem : public TNLP{  
00078 public:
00079         
00081         IpoptProblem(OSInstance *osinstance_ , OSResult *osresult_);
00082         
00084         virtual ~IpoptProblem();
00085         
00086         OSResult *osresult;
00087         
00088         OSInstance *osinstance;
00089         
00090 
00091         
00093         virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00094                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00095 
00097         virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00098                                                                 Index m, Number* g_l, Number* g_u);
00099 
00101         virtual bool get_starting_point(Index n, bool init_x, Number* x,
00102                                                                         bool init_z, Number* z_L, Number* z_U,
00103                                                                         Index m, bool init_lambda,
00104                                                                         Number* lambda);
00105 
00107         virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00108 
00110         virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00111 
00113         virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00114 
00119         virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00120                                                         Index m, Index nele_jac, Index* iRow, Index *jCol,
00121                                                         Number* values);
00122 
00127         virtual bool eval_h(Index n, const Number* x, bool new_x,
00128                                                 Number obj_factor, Index m, const Number* lambda,
00129                                                 bool new_lambda, Index nele_hess, Index* iRow,
00130                                                 Index* jCol, Number* values);
00131 
00133         
00134         
00135         virtual bool get_scaling_parameters(Number& obj_scaling,
00136                                     bool& use_x_scaling, Index n,
00137                                     Number* x_scaling,
00138                                     bool& use_g_scaling, Index m,
00139                                     Number* g_scaling);
00140 
00144         virtual void finalize_solution(SolverReturn status,
00145                                                                         Index n, const Number* x, const Number* z_L, const Number* z_U,
00146                                                                         Index m, const Number* g, const Number* lambda,
00147                                                                         Number obj_value,
00148                                    const IpoptData* ip_data,
00149                                    IpoptCalculatedQuantities* ip_cq);
00151 
00152 
00153         
00154 private:
00166   //  HS071_NLP();
00167         IpoptProblem(const IpoptProblem&);
00168         IpoptProblem& operator=(const IpoptProblem&);
00170         
00171         std::string ipoptErrorMsg;
00172         
00173 };
00174 
00175 
00188 //class IpoptSolver : public DefaultSolver, public TNLP{  
00189 
00190 class IpoptSolver : public DefaultSolver{       
00191 public:
00192         
00193 
00194 
00196         IpoptSolver();
00197         
00199         ~IpoptSolver();
00200         
00201         SmartPtr<TNLP> nlp;
00202         
00203         SmartPtr<IpoptApplication> app;
00204         
00205         
00208         virtual void  solve() throw (ErrorClass) ;
00209         
00214         virtual void  buildSolverInstance() throw(ErrorClass);
00215         
00221         void dataEchoCheck();
00222         
00227         OSiLReader *m_osilreader;
00228 
00229 
00230 private:
00231         OSrLWriter  *osrlwriter;
00232 
00244         //  IpoptSolver();
00245         //IpoptSolver(const IpoptSolver&);
00246         //IpoptSolver& operator=(const IpoptSolver&);
00248         //std::string ipoptErrorMsg;
00249         std::string ipoptErrorMsg;
00250 };
00251 
00252 
00253 #endif /*IPOPTSOLVER_H*/

Generated on Sun Nov 14 14:06:39 2010 for Coin-All by  doxygen 1.4.7