Ipopt Documentation  
IpIpoptNLP.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 __IPIPOPTNLP_HPP__
8 #define __IPIPOPTNLP_HPP__
9 
10 #include "IpNLP.hpp"
11 #include "IpJournalist.hpp"
12 #include "IpNLPScaling.hpp"
13 
14 namespace Ipopt
15 {
16 // forward declarations
17 class IteratesVector;
18 
36 {
37 public:
39  IpoptNLP(
41  const SmartPtr<NLPScalingObject> nlp_scaling
42  )
43  : nlp_scaling_(nlp_scaling)
44  { }
45 
47  virtual ~IpoptNLP()
48  { }
50 
55  virtual bool Initialize(
56  const Journalist& jnlst,
57  const OptionsList& options,
58  const std::string& prefix
59  )
60  {
61  bool ret = true;
62  if( IsValid(nlp_scaling_) )
63  {
64  ret = nlp_scaling_->Initialize(jnlst, options, prefix);
65  }
66  return ret;
67  }
68 
70 
72  DECLARE_STD_EXCEPTION(Eval_Error);
73 
75 
76  virtual bool InitializeStructures(
78  bool init_x,
79  SmartPtr<Vector>& y_c,
80  bool init_y_c,
81  SmartPtr<Vector>& y_d,
82  bool init_y_d,
83  SmartPtr<Vector>& z_L,
84  bool init_z_L,
85  SmartPtr<Vector>& z_U,
86  bool init_z_U,
87  SmartPtr<Vector>& v_L,
88  SmartPtr<Vector>& v_U
89  ) = 0;
90 
92  virtual bool GetWarmStartIterate(
93  IteratesVector& warm_start_iterate
94  ) = 0;
95 
97 
99  virtual Number f(
100  const Vector& x
101  ) = 0;
102 
104  virtual SmartPtr<const Vector> grad_f(
105  const Vector& x
106  ) = 0;
107 
109  virtual SmartPtr<const Vector> c(
110  const Vector& x
111  ) = 0;
112 
114  virtual SmartPtr<const Matrix> jac_c(
115  const Vector& x
116  ) = 0;
117 
121  virtual SmartPtr<const Vector> d(
122  const Vector& x
123  ) = 0;
124 
126  virtual SmartPtr<const Matrix> jac_d(
127  const Vector& x
128  ) = 0;
129 
131  virtual SmartPtr<const SymMatrix> h(
132  const Vector& x,
133  Number obj_factor,
134  const Vector& yc,
135  const Vector& yd
136  ) = 0;
137 
139  virtual SmartPtr<const Vector> x_L() const = 0;
140 
142  virtual SmartPtr<const Matrix> Px_L() const = 0;
143 
145  virtual SmartPtr<const Vector> x_U() const = 0;
146 
148  virtual SmartPtr<const Matrix> Px_U() const = 0;
149 
151  virtual SmartPtr<const Vector> d_L() const = 0;
152 
154  virtual SmartPtr<const Matrix> Pd_L() const = 0;
155 
157  virtual SmartPtr<const Vector> d_U() const = 0;
158 
160  virtual SmartPtr<const Matrix> Pd_U() const = 0;
161 
163  virtual SmartPtr<const VectorSpace> x_space() const = 0;
164 
168  virtual SmartPtr<const SymMatrixSpace> HessianMatrixSpace() const = 0;
170 
172  virtual void GetSpaces(
176  SmartPtr<const VectorSpace>& x_l_space,
177  SmartPtr<const MatrixSpace>& px_l_space,
178  SmartPtr<const VectorSpace>& x_u_space,
179  SmartPtr<const MatrixSpace>& px_u_space,
180  SmartPtr<const VectorSpace>& d_l_space,
181  SmartPtr<const MatrixSpace>& pd_l_space,
182  SmartPtr<const VectorSpace>& d_u_space,
183  SmartPtr<const MatrixSpace>& pd_u_space,
184  SmartPtr<const MatrixSpace>& Jac_c_space,
185  SmartPtr<const MatrixSpace>& Jac_d_space,
186  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space
187  ) = 0;
188 
191  virtual void AdjustVariableBounds(
192  const Vector& new_x_L,
193  const Vector& new_x_U,
194  const Vector& new_d_L,
195  const Vector& new_d_U
196  ) = 0;
197 
199  virtual Index f_evals() const = 0;
201  virtual Index grad_f_evals() const = 0;
202  virtual Index c_evals() const = 0;
203  virtual Index jac_c_evals() const = 0;
204  virtual Index d_evals() const = 0;
205  virtual Index jac_d_evals() const = 0;
206  virtual Index h_evals() const = 0;
208 
212 
220  virtual bool objective_depends_on_mu() const
221  {
222  return false;
223  }
224 
228  virtual Number f(
229  const Vector& x,
230  Number mu
231  ) = 0;
232 
236  virtual SmartPtr<const Vector> grad_f(
237  const Vector& x,
238  Number mu
239  ) = 0;
240 
244  virtual SmartPtr<const SymMatrix> h(
245  const Vector& x,
246  Number obj_factor,
247  const Vector& yc,
248  const Vector& yd,
249  Number mu
250  ) = 0;
251 
257  virtual SmartPtr<const SymMatrix> uninitialized_h() = 0;
259 
261  virtual void FinalizeSolution(
263  SolverReturn status,
264  const Vector& x,
265  const Vector& z_L,
266  const Vector& z_U,
267  const Vector& c,
268  const Vector& d,
269  const Vector& y_c,
270  const Vector& y_d,
271  Number obj_value,
272  const IpoptData* ip_data,
274  ) = 0;
275 
276  virtual bool IntermediateCallBack(
277  AlgorithmMode mode,
278  Index iter,
279  Number obj_value,
280  Number inf_pr,
281  Number inf_du,
282  Number mu,
283  Number d_norm,
284  Number regularization_size,
285  Number alpha_du,
286  Number alpha_pr,
287  Index ls_trials,
290  ) = 0;
292 
295  {
296  DBG_ASSERT(IsValid(nlp_scaling_));
297  return nlp_scaling_;
298  }
299 
300 private:
301 
311 
313  IpoptNLP(
314  const IpoptNLP&
315  );
316 
318  void operator=(
319  const IpoptNLP&
320  );
322 
324 };
325 
326 } // namespace Ipopt
327 
328 #endif
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:672
Specialized CompoundVector class specifically for the algorithm iterates.
Class for all IPOPT specific calculated quantities.
virtual bool objective_depends_on_mu() const
Method for telling the IpoptCalculatedQuantities class whether the objective function depends on the ...
Definition: IpIpoptNLP.hpp:220
#define IPOPTLIB_EXPORT
Definition: config.h:94
AlgorithmMode
enum to indicate the mode in which the algorithm is
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
Vector Base Class.
Definition: IpVector.hpp:47
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
virtual ~IpoptNLP()
Destructor.
Definition: IpIpoptNLP.hpp:47
This file contains a base class for all exceptions and a set of macros to help with exceptions...
SmartPtr< NLPScalingObject > nlp_scaling_
Definition: IpIpoptNLP.hpp:323
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:164
Storing the reference count of all the smart pointers that currently reference it.
This class stores a list of user set options.
virtual bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
Initialization method.
Definition: IpIpoptNLP.hpp:55
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:19
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:97
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
Class responsible for all message output.
This is the abstract base class for classes that map the traditional NLP into something that is more ...
Definition: IpIpoptNLP.hpp:35
SmartPtr< NLPScalingObject > NLP_scaling() const
Returns the scaling strategy object.
Definition: IpIpoptNLP.hpp:294