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: IpAlgStrategy.hpp 759 2006-07-07 03:07:08Z andreasw $ 00006 // 00007 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 00008 00009 #ifndef __IPALGSTRATEGY_HPP__ 00010 #define __IPALGSTRATEGY_HPP__ 00011 00012 #include "IpOptionsList.hpp" 00013 #include "IpJournalist.hpp" 00014 #include "IpIpoptCalculatedQuantities.hpp" 00015 00016 namespace Ipopt 00017 { 00018 00033 class AlgorithmStrategyObject : public ReferencedObject 00034 { 00035 public: 00039 AlgorithmStrategyObject() 00040 : 00041 initialize_called_(false) 00042 {} 00043 00045 virtual ~AlgorithmStrategyObject() 00046 {} 00048 00064 bool Initialize(const Journalist& jnlst, 00065 IpoptNLP& ip_nlp, 00066 IpoptData& ip_data, 00067 IpoptCalculatedQuantities& ip_cq, 00068 const OptionsList& options, 00069 const std::string& prefix) 00070 { 00071 initialize_called_ = true; 00072 // Copy the pointers for the problem defining objects 00073 jnlst_ = &jnlst; 00074 ip_nlp_ = &ip_nlp; 00075 ip_data_ = &ip_data; 00076 ip_cq_ = &ip_cq; 00077 00078 bool retval = InitializeImpl(options, prefix); 00079 if (!retval) { 00080 initialize_called_ = false; 00081 } 00082 00083 return retval; 00084 } 00085 00086 protected: 00089 virtual bool InitializeImpl(const OptionsList& options, 00090 const std::string& prefix)=0; 00091 00095 const Journalist& Jnlst() const 00096 { 00097 DBG_ASSERT(initialize_called_); 00098 return *jnlst_; 00099 } 00100 IpoptNLP& IpNLP() const 00101 { 00102 DBG_ASSERT(initialize_called_); 00103 return *ip_nlp_; 00104 } 00105 IpoptData& IpData() const 00106 { 00107 DBG_ASSERT(initialize_called_); 00108 return *ip_data_; 00109 } 00110 IpoptCalculatedQuantities& IpCq() const 00111 { 00112 DBG_ASSERT(initialize_called_); 00113 return *ip_cq_; 00114 } 00116 00117 private: 00127 //AlgorithmStrategyObject(); 00128 00129 00131 AlgorithmStrategyObject(const AlgorithmStrategyObject&); 00132 00134 void operator=(const AlgorithmStrategyObject&); 00136 00140 SmartPtr<const Journalist> jnlst_; 00141 SmartPtr<IpoptNLP> ip_nlp_; 00142 SmartPtr<IpoptData> ip_data_; 00143 SmartPtr<IpoptCalculatedQuantities> ip_cq_; 00145 00148 bool initialize_called_; 00149 }; 00150 00151 } // namespace Ipopt 00152 00153 #endif