/home/coin/SVN-release/OS-2.3.2/OS/src/OSSolverInterfaces/OSBonminSolver.h

Go to the documentation of this file.
00001 /* $Id: OSBonminSolver.h 3938 2010-12-19 20:43:54Z stefan $ */
00017 #ifndef BONMINSOLVER_H 
00018 #define BONMINSOLVER_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 "OSrLReader.h"
00028 #include "OSoLReader.h"
00029 #include "OSInstance.h"
00030 #include "OSExpressionTree.h"
00031 #include "OSnLNode.h"
00032 #include "OSDataStructures.h"
00033 #include "OSFileUtil.h"  
00034 #include "OSErrorClass.h"
00035 
00036 #include "OSResult.h"
00037 #include "OSInstance.h"
00038 #include "OSOption.h"
00039 
00040 # include <cstddef>
00041 # include <cstdlib>
00042 # include <cctype>
00043 # include <cassert>
00044 # include <stack>
00045 #include <string>
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 
00073 #include "BonCbc.hpp"
00074 #include "BonTMINLP.hpp"
00075 #include "BonBonminSetup.hpp"
00076 
00077 
00078 using namespace  Ipopt;
00079 using namespace Bonmin;
00080 
00081 
00082 
00083 
00084 // for Stefan
00085 class BonminProblem : public TMINLP{  
00086 
00087 
00088         
00089 public:
00090         
00092         BonminProblem(OSInstance *osinstance_ , OSOption *osoption_);
00093         
00095         virtual ~BonminProblem();
00096                 
00097         OSInstance *osinstance;
00098 
00099         OSOption *osoption;
00100 
00101         TMINLP::SolverReturn status;
00102 
00103 
00113           virtual bool get_variables_types(Index n, VariableType* var_types);
00114          
00116           virtual bool get_variables_linearity(Index n, Ipopt::TNLP::LinearityType* var_types);
00117 
00122           virtual bool get_constraints_linearity(Index m, Ipopt::TNLP::LinearityType* const_types);
00124             
00137           virtual bool get_nlp_info(Index& n, Index&m, Index& nnz_jac_g,
00138                                     Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style);       
00139         
00140 
00141         
00143         //virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00144      //                       Index& nnz_h_lag, IndexStyleEnum& index_style);
00145 
00147         virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00148                                                                 Index m, Number* g_l, Number* g_u);
00149 
00151         virtual bool get_starting_point(Index n, bool init_x, Number* x,
00152                                                                         bool init_z, Number* z_L, Number* z_U,
00153                                                                         Index m, bool init_lambda,
00154                                                                         Number* lambda);
00155 
00157         virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00158 
00160         virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00161 
00163         virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00164 
00169         virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00170                                                         Index m, Index nele_jac, Index* iRow, Index *jCol,
00171                                                         Number* values);
00172 
00177         virtual bool eval_h(Index n, const Number* x, bool new_x,
00178                                                 Number obj_factor, Index m, const Number* lambda,
00179                                                 bool new_lambda, Index nele_hess, Index* iRow,
00180                                                 Index* jCol, Number* values);
00181 
00183         
00184         
00185         virtual bool get_scaling_parameters(Number& obj_scaling,
00186                                     bool& use_x_scaling, Index n,
00187                                     Number* x_scaling,
00188                                     bool& use_g_scaling, Index m,
00189                                     Number* g_scaling);
00190 
00193           virtual void finalize_solution(TMINLP::SolverReturn status_,
00194                                          Index n, const Number* x, Number obj_value);
00196 
00197           virtual const SosInfo * sosConstraints() const{return NULL;}
00198           virtual const BranchingInfo* branchingInfo() const{return NULL;}
00199           
00200           void printSolutionAtEndOfAlgorithm(){
00201           printSol_ = true;}
00202           
00203           
00204 
00205           
00206           
00207 private:
00208    bool printSol_;
00209         
00210 private:
00222   //  HS071_NLP();
00223 
00225         
00226 
00227         
00228         std::string bonminErrorMsg;
00229 
00230         
00231 };
00232 
00233 
00248 class BonminSolver : public DefaultSolver{      
00249 public:
00250         
00251 
00252 
00254         BonminSolver();
00255         
00257         ~BonminSolver();
00258         
00259         
00260         
00261         SmartPtr<BonminProblem> tminlp;
00262                 
00263         // this is a Bonmin BonCbc object;
00264         Bab bb;
00265         
00266         TMINLP::SolverReturn status;
00267         
00268         //SmartPtr<IpoptApplication> app;
00269         
00270         
00273         virtual void  solve() throw (ErrorClass) ;
00274         
00279         virtual void  buildSolverInstance() throw(ErrorClass);
00280         
00285         virtual void  setSolverOptions() throw(ErrorClass);
00286         
00292         void dataEchoCheck();
00293         
00298         OSiLReader *m_osilreader;
00299 
00304         OSoLReader *m_osolreader;
00305         
00306         
00307         
00312         void writeResult();
00313 
00314 
00315 private:
00316         OSrLWriter  *osrlwriter;
00317 
00318         BonminSetup bonminSetup;
00319 
00320         std::string bonminErrorMsg;
00321 };
00322 
00323 
00324 #endif /*BONMINSOLVER_H*/

Generated on Fri Jan 7 03:24:42 2011 by  doxygen 1.4.7