Ipopt Documentation  
IpAlgStrategy.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2006 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPALGSTRATEGY_HPP__
8 #define __IPALGSTRATEGY_HPP__
9 
10 #include "IpOptionsList.hpp"
11 #include "IpJournalist.hpp"
13 #include "IpIpoptNLP.hpp"
14 #include "IpIpoptData.hpp"
15 
16 namespace Ipopt
17 {
18 
35 {
36 public:
38 
41  : initialize_called_(false)
42  { }
43 
46  { }
48 
66  bool Initialize(
67  const Journalist& jnlst,
68  IpoptNLP& ip_nlp,
69  IpoptData& ip_data,
71  const OptionsList& options,
72  const std::string& prefix
73  )
74  {
75  initialize_called_ = true;
76  // Copy the pointers for the problem defining objects
77  jnlst_ = &jnlst;
78  ip_nlp_ = &ip_nlp;
79  ip_data_ = &ip_data;
80  ip_cq_ = &ip_cq;
81 
82  bool retval = InitializeImpl(options, prefix);
83  if( !retval )
84  {
85  initialize_called_ = false;
86  }
87 
88  return retval;
89  }
90 
98  const Journalist& jnlst,
99  const OptionsList& options,
100  const std::string& prefix
101  )
102  {
103  initialize_called_ = true;
104  // Copy the pointers for the problem defining objects
105  jnlst_ = &jnlst;
106  ip_nlp_ = NULL;
107  ip_data_ = NULL;
108  ip_cq_ = NULL;
109 
110  bool retval = InitializeImpl(options, prefix);
111  if( !retval )
112  {
113  initialize_called_ = false;
114  }
115 
116  return retval;
117  }
118 
119 protected:
123  virtual bool InitializeImpl(
124  const OptionsList& options,
125  const std::string& prefix
126  ) = 0;
127 
132  const Journalist& Jnlst() const
134  {
135  DBG_ASSERT(initialize_called_);
136  return *jnlst_;
137  }
138  IpoptNLP& IpNLP() const
139  {
140  DBG_ASSERT(initialize_called_);
141  DBG_ASSERT(IsValid(ip_nlp_));
142  return *ip_nlp_;
143  }
144  IpoptData& IpData() const
145  {
146  DBG_ASSERT(initialize_called_);
147  DBG_ASSERT(IsValid(ip_data_));
148  return *ip_data_;
149  }
151  {
152  DBG_ASSERT(initialize_called_);
153  DBG_ASSERT(IsValid(ip_cq_));
154  return *ip_cq_;
155  }
156  bool HaveIpData() const
157  {
158  return IsValid(ip_data_);
159  }
161 
162 private:
172 
174  //AlgorithmStrategyObject();
175 
179  );
180 
182  void operator=(
184  );
186 
194 
197 };
198 
199 } // namespace Ipopt
200 
201 #endif
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:674
virtual ~AlgorithmStrategyObject()
Destructor.
Class for all IPOPT specific calculated quantities.
SmartPtr< IpoptNLP > ip_nlp_
This is the base class for all algorithm strategy objects.
AlgorithmStrategyObject()
Default Constructor.
IpoptCalculatedQuantities & IpCq() const
SmartPtr< IpoptData > ip_data_
This file contains a base class for all exceptions and a set of macros to help with exceptions...
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:171
Storing the reference count of all the smart pointers that currently reference it.
This class stores a list of user set options.
bool Initialize(const Journalist &jnlst, IpoptNLP &ip_nlp, IpoptData &ip_data, IpoptCalculatedQuantities &ip_cq, const OptionsList &options, const std::string &prefix)
This method is called every time the algorithm starts again - it is used to reset any internal state...
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:97
bool ReducedInitialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
Reduced version of the Initialize method, which does not require special Ipopt information.
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
#define IPOPTLIB_EXPORT
Class responsible for all message output.
bool initialize_called_
flag indicating if Initialize method has been called (for debugging)
This is the abstract base class for classes that map the traditional NLP into something that is more ...
Definition: IpIpoptNLP.hpp:27
SmartPtr< IpoptCalculatedQuantities > ip_cq_