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 
28 {
29 public:
33  const SmartPtr<NLPScalingObject> nlp_scaling
34  )
35  : nlp_scaling_(nlp_scaling)
36  { }
37 
39  virtual ~IpoptNLP()
40  { }
42 
47  virtual bool Initialize(
48  const Journalist& jnlst,
49  const OptionsList& options,
50  const std::string& prefix
51  )
52  {
53  bool ret = true;
54  if( IsValid(nlp_scaling_) )
55  {
56  ret = nlp_scaling_->Initialize(jnlst, options, prefix);
57  }
58  return ret;
59  }
60 
64  DECLARE_STD_EXCEPTION(Eval_Error);
65 
67 
68  virtual bool InitializeStructures(
70  bool init_x,
71  SmartPtr<Vector>& y_c,
72  bool init_y_c,
73  SmartPtr<Vector>& y_d,
74  bool init_y_d,
75  SmartPtr<Vector>& z_L,
76  bool init_z_L,
77  SmartPtr<Vector>& z_U,
78  bool init_z_U,
79  SmartPtr<Vector>& v_L,
80  SmartPtr<Vector>& v_U
81  ) = 0;
82 
84  virtual bool GetWarmStartIterate(
85  IteratesVector& warm_start_iterate
86  ) = 0;
87 
91  virtual Number f(
92  const Vector& x
93  ) = 0;
94 
97  const Vector& x
98  ) = 0;
99 
102  const Vector& x
103  ) = 0;
104 
107  const Vector& x
108  ) = 0;
109 
114  const Vector& x
115  ) = 0;
116 
119  const Vector& x
120  ) = 0;
121 
124  const Vector& x,
125  Number obj_factor,
126  const Vector& yc,
127  const Vector& yd
128  ) = 0;
129 
131  virtual SmartPtr<const Vector> x_L() const = 0;
132 
134  virtual SmartPtr<const Matrix> Px_L() const = 0;
135 
137  virtual SmartPtr<const Vector> x_U() const = 0;
138 
140  virtual SmartPtr<const Matrix> Px_U() const = 0;
141 
143  virtual SmartPtr<const Vector> d_L() const = 0;
144 
146  virtual SmartPtr<const Matrix> Pd_L() const = 0;
147 
149  virtual SmartPtr<const Vector> d_U() const = 0;
150 
152  virtual SmartPtr<const Matrix> Pd_U() const = 0;
153 
156 
162 
164  virtual void GetSpaces(
168  SmartPtr<const VectorSpace>& x_l_space,
169  SmartPtr<const MatrixSpace>& px_l_space,
170  SmartPtr<const VectorSpace>& x_u_space,
171  SmartPtr<const MatrixSpace>& px_u_space,
172  SmartPtr<const VectorSpace>& d_l_space,
173  SmartPtr<const MatrixSpace>& pd_l_space,
174  SmartPtr<const VectorSpace>& d_u_space,
175  SmartPtr<const MatrixSpace>& pd_u_space,
176  SmartPtr<const MatrixSpace>& Jac_c_space,
177  SmartPtr<const MatrixSpace>& Jac_d_space,
178  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space
179  ) = 0;
180 
183  virtual void AdjustVariableBounds(
184  const Vector& new_x_L,
185  const Vector& new_x_U,
186  const Vector& new_d_L,
187  const Vector& new_d_U
188  ) = 0;
189 
192  virtual Index f_evals() const = 0;
193  virtual Index grad_f_evals() const = 0;
194  virtual Index c_evals() const = 0;
195  virtual Index jac_c_evals() const = 0;
196  virtual Index d_evals() const = 0;
197  virtual Index jac_d_evals() const = 0;
198  virtual Index h_evals() const = 0;
200 
212  virtual bool objective_depends_on_mu() const
213  {
214  return false;
215  }
216 
220  virtual Number f(
221  const Vector& x,
222  Number mu
223  ) = 0;
224 
229  const Vector& x,
230  Number mu
231  ) = 0;
232 
237  const Vector& x,
238  Number obj_factor,
239  const Vector& yc,
240  const Vector& yd,
241  Number mu
242  ) = 0;
243 
251 
254  virtual void FinalizeSolution(
255  SolverReturn status,
256  const Vector& x,
257  const Vector& z_L,
258  const Vector& z_U,
259  const Vector& c,
260  const Vector& d,
261  const Vector& y_c,
262  const Vector& y_d,
263  Number obj_value,
264  const IpoptData* ip_data,
266  ) = 0;
267 
268  virtual bool IntermediateCallBack(
269  AlgorithmMode mode,
270  Index iter,
271  Number obj_value,
272  Number inf_pr,
273  Number inf_du,
274  Number mu,
275  Number d_norm,
276  Number regularization_size,
277  Number alpha_du,
278  Number alpha_pr,
279  Index ls_trials,
282  ) = 0;
284 
287  {
288  DBG_ASSERT(IsValid(nlp_scaling_));
289  return nlp_scaling_;
290  }
291 
292 private:
293 
306  const IpoptNLP&
307  );
308 
310  void operator=(
311  const IpoptNLP&
312  );
314 
316 };
317 
318 } // namespace Ipopt
319 
320 #endif
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:28
AlgorithmMode
enum to indicate the mode in which the algorithm is
Class for all IPOPT specific calculated quantities.
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:98
This is the abstract base class for classes that map the traditional NLP into something that is more ...
Definition: IpIpoptNLP.hpp:28
virtual SmartPtr< const Vector > x_L() const =0
Lower bounds on x.
virtual SmartPtr< const Matrix > jac_d(const Vector &x)=0
Jacobian Matrix for inequality constraints.
virtual bool objective_depends_on_mu() const
Method for telling the IpoptCalculatedQuantities class whether the objective function depends on the ...
Definition: IpIpoptNLP.hpp:212
IpoptNLP(const IpoptNLP &)
Copy Constructor.
virtual void GetSpaces(SmartPtr< const VectorSpace > &x_space, SmartPtr< const VectorSpace > &c_space, SmartPtr< const VectorSpace > &d_space, SmartPtr< const VectorSpace > &x_l_space, SmartPtr< const MatrixSpace > &px_l_space, SmartPtr< const VectorSpace > &x_u_space, SmartPtr< const MatrixSpace > &px_u_space, SmartPtr< const VectorSpace > &d_l_space, SmartPtr< const MatrixSpace > &pd_l_space, SmartPtr< const VectorSpace > &d_u_space, SmartPtr< const MatrixSpace > &pd_u_space, SmartPtr< const MatrixSpace > &Jac_c_space, SmartPtr< const MatrixSpace > &Jac_d_space, SmartPtr< const SymMatrixSpace > &Hess_lagrangian_space)=0
Accessor method for vector/matrix spaces pointers.
virtual Index f_evals() const =0
DECLARE_STD_EXCEPTION(Eval_Error)
thrown if there is any error evaluating values from the nlp
virtual bool IntermediateCallBack(AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, SmartPtr< const IpoptData > ip_data, SmartPtr< IpoptCalculatedQuantities > ip_cq)=0
void operator=(const IpoptNLP &)
Default Assignment Operator.
virtual SmartPtr< const Vector > x_U() const =0
Upper bounds on x.
virtual SmartPtr< const VectorSpace > x_space() const =0
x_space
virtual SmartPtr< const Vector > d_L() const =0
Lower bounds on d.
virtual Number f(const Vector &x)=0
Accessor methods for model data.
virtual SmartPtr< const SymMatrix > h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd)=0
Hessian of the Lagrangian.
virtual Index d_evals() const =0
virtual ~IpoptNLP()
Destructor.
Definition: IpIpoptNLP.hpp:39
virtual void FinalizeSolution(SolverReturn status, const Vector &x, const Vector &z_L, const Vector &z_U, const Vector &c, const Vector &d, const Vector &y_c, const Vector &y_d, Number obj_value, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)=0
virtual bool GetWarmStartIterate(IteratesVector &warm_start_iterate)=0
Method accessing the GetWarmStartIterate of the NLP.
virtual SmartPtr< const Vector > grad_f(const Vector &x)=0
Gradient of the objective.
virtual SmartPtr< const Matrix > Pd_L() const =0
Permutation matrix (d_L_ -> d)
virtual bool InitializeStructures(SmartPtr< Vector > &x, bool init_x, SmartPtr< Vector > &y_c, bool init_y_c, SmartPtr< Vector > &y_d, bool init_y_d, SmartPtr< Vector > &z_L, bool init_z_L, SmartPtr< Vector > &z_U, bool init_z_U, SmartPtr< Vector > &v_L, SmartPtr< Vector > &v_U)=0
Initialize (create) structures for the iteration data.
virtual SmartPtr< const SymMatrix > h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd, Number mu)=0
Replacement for the default Lagrangian Hessian method which knows about the barrier parameter.
virtual Index c_evals() const =0
virtual SmartPtr< const Vector > d_U() const =0
Upper bounds on d.
virtual SmartPtr< const Vector > c(const Vector &x)=0
Equality constraint residual.
virtual SmartPtr< const Matrix > Px_U() const =0
Permutation matrix (x_U_ -> x.
virtual SmartPtr< const Matrix > Pd_U() const =0
Permutation matrix (d_U_ -> d.
virtual Index jac_d_evals() const =0
virtual SmartPtr< const Matrix > Px_L() const =0
Permutation matrix (x_L_ -> x)
virtual void AdjustVariableBounds(const Vector &new_x_L, const Vector &new_x_U, const Vector &new_d_L, const Vector &new_d_U)=0
Method for adapting the variable bounds.
virtual SmartPtr< const SymMatrixSpace > HessianMatrixSpace() const =0
Accessor method to obtain the MatrixSpace for the Hessian matrix (or it's approximation)
IpoptNLP(const SmartPtr< NLPScalingObject > nlp_scaling)
Definition: IpIpoptNLP.hpp:32
SmartPtr< NLPScalingObject > nlp_scaling_
Definition: IpIpoptNLP.hpp:315
virtual bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
Initialization method.
Definition: IpIpoptNLP.hpp:47
virtual Number f(const Vector &x, Number mu)=0
Replacement for the default objective function method which knows about the barrier parameter.
SmartPtr< NLPScalingObject > NLP_scaling() const
Returns the scaling strategy object.
Definition: IpIpoptNLP.hpp:286
virtual SmartPtr< const SymMatrix > uninitialized_h()=0
Provides a Hessian matrix from the correct matrix space with uninitialized values.
virtual SmartPtr< const Vector > grad_f(const Vector &x, Number mu)=0
Replacement for the default objective gradient method which knows about the barrier parameter.
virtual Index grad_f_evals() const =0
virtual Index jac_c_evals() const =0
virtual SmartPtr< const Vector > d(const Vector &x)=0
Inequality constraint residual (reformulated as equalities with slacks.
virtual SmartPtr< const Matrix > jac_c(const Vector &x)=0
Jacobian Matrix for equality constraints.
virtual Index h_evals() const =0
Specialized CompoundVector class specifically for the algorithm iterates.
Class responsible for all message output.
This class stores a list of user set options.
Storing the reference count of all the smart pointers that currently reference it.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Vector Base Class.
Definition: IpVector.hpp:48
#define IPOPTLIB_EXPORT
This file contains a base class for all exceptions and a set of macros to help with exceptions.
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:674
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:20
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
double Number
Type of all numbers.
Definition: IpTypes.hpp:15