00001 // Copyright (C) 2004, 2006 International Business Machines and others. 00002 // All Rights Reserved. 00003 // This code is published under the Common Public License. 00004 // 00005 // $Id: IpIpoptApplication.hpp 759 2006-07-07 03:07:08Z andreasw $ 00006 // 00007 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 00008 00009 #ifndef __IPIPOPTAPPLICATION_HPP__ 00010 #define __IPIPOPTAPPLICATION_HPP__ 00011 00012 #include <iostream> 00013 00014 #include "IpJournalist.hpp" 00015 #include "IpTNLP.hpp" 00016 #include "IpNLP.hpp" 00017 /* Return codes for the Optimize call for an application */ 00018 #include "IpReturnCodes.hpp" 00019 00020 namespace Ipopt 00021 { 00022 DECLARE_STD_EXCEPTION(IPOPT_APPLICATION_ERROR); 00023 00024 /* forward declarations */ 00025 class IpoptAlgorithm; 00026 class IpoptNLP; 00027 class IpoptData; 00028 class IpoptCalculatedQuantities; 00029 class AlgorithmBuilder; 00030 class RegisteredOptions; 00031 class OptionsList; 00032 class SolveStatistics; 00033 00035 class IpoptApplication : public ReferencedObject 00036 { 00037 public: 00038 IpoptApplication(bool create_console_out = true); 00039 00040 virtual ~IpoptApplication(); 00041 00047 void Initialize(std::string params_file = "ipopt.opt"); 00048 void Initialize(std::istream& is); 00049 00053 ApplicationReturnStatus OptimizeTNLP(const SmartPtr<TNLP>& tnlp); 00054 00056 ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp, SmartPtr<AlgorithmBuilder> alg_builder=NULL); 00057 00063 ApplicationReturnStatus ReOptimizeTNLP(const SmartPtr<TNLP>& tnlp); 00064 00070 ApplicationReturnStatus ReOptimizeNLP(const SmartPtr<NLP>& nlp); 00072 00075 bool OpenOutputFile(std::string file_name, EJournalLevel print_level); 00076 00080 SmartPtr<Journalist> Jnlst() 00081 { 00082 return jnlst_; 00083 } 00084 00087 SmartPtr<RegisteredOptions> RegOptions() 00088 { 00089 return reg_options_; 00090 } 00091 00093 SmartPtr<OptionsList> Options() 00094 { 00095 return options_; 00096 } 00097 00099 SmartPtr<const OptionsList> Options() const 00100 { 00101 return ConstPtr(options_); 00102 } 00103 00106 SmartPtr<SolveStatistics> Statistics(); 00108 00111 static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); 00113 00114 private: 00124 // IpoptApplication(); 00125 00127 IpoptApplication(const IpoptApplication&); 00128 00130 void operator=(const IpoptApplication&); 00132 00134 void RegisterAllOptions(const SmartPtr<RegisteredOptions>& roptions); 00135 00138 ApplicationReturnStatus call_optimize(); 00139 00143 bool read_params_dat_; 00145 00147 SmartPtr<Journalist> jnlst_; 00148 00150 SmartPtr<RegisteredOptions> reg_options_; 00151 00153 SmartPtr<OptionsList> options_; 00154 00157 SmartPtr<SolveStatistics> statistics_; 00158 00161 SmartPtr<IpoptAlgorithm> alg_; 00162 00165 SmartPtr<IpoptNLP> ip_nlp_; 00166 00170 SmartPtr<IpoptData> ip_data_; 00171 00175 SmartPtr<IpoptCalculatedQuantities> ip_cq_; 00176 00179 SmartPtr<NLP> nlp_adapter_; 00180 }; 00181 00182 } // namespace Ipopt 00183 00184 #endif