Ipopt Documentation  
IpOrigIpoptNLP.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2010 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 __IPORIGIPOPTNLP_HPP__
8 #define __IPORIGIPOPTNLP_HPP__
9 
10 #include "IpIpoptNLP.hpp"
11 #include "IpException.hpp"
12 #include "IpTimingStatistics.hpp"
13 
14 namespace Ipopt
15 {
16 
19 {
20  EXACT = 0,
22 };
23 
26 {
28  ALL_VARS
29 };
30 
66 {
67 public:
70 
72  const SmartPtr<const Journalist>& jnlst,
73  const SmartPtr<NLP>& nlp,
74  const SmartPtr<NLPScalingObject>& nlp_scaling,
75  TimingStatistics& timing_statistics
76  );
77 
79  virtual ~OrigIpoptNLP();
81 
82  virtual bool Initialize(
83  const Journalist& jnlst,
84  const OptionsList& options,
85  const std::string& prefix
86  );
87 
89  virtual bool InitializeStructures(
91  bool init_x,
92  SmartPtr<Vector>& y_c,
93  bool init_y_c,
94  SmartPtr<Vector>& y_d,
95  bool init_y_d,
96  SmartPtr<Vector>& z_L,
97  bool init_z_L,
98  SmartPtr<Vector>& z_U,
99  bool init_z_U,
100  SmartPtr<Vector>& v_L,
101  SmartPtr<Vector>& v_U
102  );
103 
105  virtual bool GetWarmStartIterate(
106  IteratesVector& warm_start_iterate
107  )
108  {
109  return nlp_->GetWarmStartIterate(warm_start_iterate);
110  }
111 
114 
115  virtual Number f(
116  const Vector& x
117  );
118 
122  virtual Number f(
123  const Vector& x,
124  Number mu
125  );
126 
129  const Vector& x
130  );
131 
136  const Vector& x,
137  Number mu
138  );
139 
142  const Vector& x
143  );
144 
147  const Vector& x
148  );
149 
154  const Vector& x
155  );
156 
159  const Vector& x
160  );
161 
164  const Vector& x,
165  Number obj_factor,
166  const Vector& yc,
167  const Vector& yd
168  );
169 
174  const Vector& x,
175  Number obj_factor,
176  const Vector& yc,
177  const Vector& yd,
178  Number mu
179  );
180 
187 
189  virtual SmartPtr<const Vector> x_L() const
190  {
191  return x_L_;
192  }
193 
195  virtual SmartPtr<const Matrix> Px_L() const
196  {
197  return Px_L_;
198  }
199 
206  {
207  return orig_x_L_;
208  }
209 
211  virtual SmartPtr<const Vector> x_U() const
212  {
213  return x_U_;
214  }
215 
217  virtual SmartPtr<const Matrix> Px_U() const
218  {
219  return Px_U_;
220  }
221 
228  {
229  return orig_x_U_;
230  }
231 
233  virtual SmartPtr<const Vector> d_L() const
234  {
235  return d_L_;
236  }
237 
239  virtual SmartPtr<const Matrix> Pd_L() const
240  {
241  return Pd_L_;
242  }
243 
245  virtual SmartPtr<const Vector> d_U() const
246  {
247  return d_U_;
248  }
249 
251  virtual SmartPtr<const Matrix> Pd_U() const
252  {
253  return Pd_U_;
254  }
255 
257  {
258  return h_space_;
259  }
260 
262  {
263  return x_space_;
264  }
266 
268  virtual void GetSpaces(
272  SmartPtr<const VectorSpace>& x_l_space,
273  SmartPtr<const MatrixSpace>& px_l_space,
274  SmartPtr<const VectorSpace>& x_u_space,
275  SmartPtr<const MatrixSpace>& px_u_space,
276  SmartPtr<const VectorSpace>& d_l_space,
277  SmartPtr<const MatrixSpace>& pd_l_space,
278  SmartPtr<const VectorSpace>& d_u_space,
279  SmartPtr<const MatrixSpace>& pd_u_space,
280  SmartPtr<const MatrixSpace>& Jac_c_space,
281  SmartPtr<const MatrixSpace>& Jac_d_space,
282  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space
283  );
284 
287  virtual void AdjustVariableBounds(
288  const Vector& new_x_L,
289  const Vector& new_x_U,
290  const Vector& new_d_L,
291  const Vector& new_d_U
292  );
293 
296  virtual Index f_evals() const
297  {
298  return f_evals_;
299  }
300  virtual Index grad_f_evals() const
301  {
302  return grad_f_evals_;
303  }
304  virtual Index c_evals() const
305  {
306  return c_evals_;
307  }
308  virtual Index jac_c_evals() const
309  {
310  return jac_c_evals_;
311  }
312  virtual Index d_evals() const
313  {
314  return d_evals_;
315  }
316  virtual Index jac_d_evals() const
317  {
318  return jac_d_evals_;
319  }
320  virtual Index h_evals() const
321  {
322  return h_evals_;
323  }
325 
329  SolverReturn status,
330  const Vector& x,
331  const Vector& z_L,
332  const Vector& z_U,
333  const Vector& c,
334  const Vector& d,
335  const Vector& y_c,
336  const Vector& y_d,
337  Number obj_value,
338  const IpoptData* ip_data,
340  );
341 
343  AlgorithmMode mode,
344  Index iter,
345  Number obj_value,
346  Number inf_pr,
347  Number inf_du,
348  Number mu,
349  Number d_norm,
350  Number regularization_size,
351  Number alpha_du,
352  Number alpha_pr,
353  Index ls_trials,
356  );
358 
360  static void RegisterOptions(
362  );
363 
366  {
367  return nlp_;
368  }
369 
370 private:
373 
376 
393 
398 
401 
403 
406 
409 
414 
419 
424 
429 
432 
435 
438 
441 
444 
447 
450 
453 
456 
459 
463 
474 
476 
479  const OrigIpoptNLP&
480  );
481 
483  void operator=(
484  const OrigIpoptNLP&
485  );
487 
490 
496  Number bound_relax_factor,
497  Vector& bounds
498  );
499 
502  const Vector& x
503  );
505 
508 
511 
514 
519 
524 
527 
530 
535 
540 
545 
549 
560 
563 
568 };
569 
570 } // namespace Ipopt
571 
572 #endif
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:36
Specialized CompoundVector class specifically for the algorithm iterates.
Class responsible for all message output.
This class stores a list of user set options.
This class maps the traditional NLP into something that is more useful for Ipopt.
void operator=(const OrigIpoptNLP &)
Overloaded Assignment Operator.
SmartPtr< const Matrix > Px_U_
Permutation matrix (x_U_ -> x)
virtual SmartPtr< const Vector > x_L() const
Lower bounds on x.
virtual Number f(const Vector &x)
Accessor methods for model data.
OrigIpoptNLP()
Default Constructor.
virtual SmartPtr< const SymMatrix > uninitialized_h()
Provides a Hessian matrix from the correct matrix space with uninitialized values.
SmartPtr< const VectorSpace > d_l_space_
CachedResults< Number > f_cache_
Objective function.
CachedResults< SmartPtr< const SymMatrix > > h_cache_
Hessian of the lagrangian (current iteration)
CachedResults< SmartPtr< const Vector > > unscaled_x_cache_
Unscaled version of x vector.
SmartPtr< const VectorSpace > x_u_space_
SmartPtr< const MatrixSpace > px_l_space_
SmartPtr< const Vector > orig_x_L_
Original unmodified lower bounds on x.
bool jac_d_constant_
Flag indicating if we need to ask for inequality constraint Jacobians only once.
virtual bool GetWarmStartIterate(IteratesVector &warm_start_iterate)
Method accessing the GetWarmStartIterate of the NLP.
Number constr_viol_tol_
constraint violation tolerance (from OptimalityErrorConvergenceCheck)
CachedResults< SmartPtr< const Matrix > > jac_d_cache_
Jacobian Matrix for inequality constraints (current iteration)
SmartPtr< const Vector > x_L_
Lower bounds on x.
CachedResults< SmartPtr< const Matrix > > jac_c_cache_
Jacobian Matrix for equality constraints (current iteration)
SmartPtr< NLP > nlp_
Pointer to the NLP.
virtual SmartPtr< const Matrix > jac_c(const Vector &x)
Jacobian Matrix for equality constraints.
bool honor_original_bounds_
Flag indicating whether the primal variables should be projected back into original bounds are optimi...
static void RegisterOptions(SmartPtr< RegisteredOptions > roptions)
Called to register the options.
SmartPtr< const Matrix > Pd_U_
Permutation matrix (d_U_ -> d)
TimingStatistics & timing_statistics_
HessianApproximationType hessian_approximation_
Flag indicating what Hessian information is to be used.
virtual Index grad_f_evals() const
virtual SmartPtr< const Vector > d_U() const
Upper bounds on d.
virtual SmartPtr< const Vector > grad_f(const Vector &x, Number mu)
Gradient of the objective (depending in mu) - incorrect version for OrigIpoptNLP.
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)
bool initialized_
Flag indicating if initialization method has been called.
void relax_bounds(Number bound_relax_factor, Vector &bounds)
relax the bounds by a relative move of relax_bound_factor.
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)
Accessor method for vector/matrix spaces pointers.
bool hessian_constant_
Flag indicating if we need to ask for Hessian only once.
virtual Index jac_c_evals() const
SmartPtr< const MatrixSpace > jac_d_space_
SmartPtr< const Vector > orig_x_U_
Original unmodified upper bounds on x.
CachedResults< SmartPtr< const Vector > > grad_f_cache_
Gradient of the objective function.
virtual ~OrigIpoptNLP()
Destructor.
SmartPtr< const Vector > get_unscaled_x(const Vector &x)
Method for getting the unscaled version of the x vector.
HessianApproximationSpace hessian_approximation_space_
Flag indicating in which space Hessian is to be approximated.
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)
Solution Routines - overloaded from IpoptNLP.
SmartPtr< const Vector > x_U_
Upper bounds on x.
virtual SmartPtr< const SymMatrixSpace > HessianMatrixSpace() const
Accessor method to obtain the MatrixSpace for the Hessian matrix (or it's approximation)
virtual void AdjustVariableBounds(const Vector &new_x_L, const Vector &new_x_U, const Vector &new_d_L, const Vector &new_d_U)
Method for adapting the variable bounds.
SmartPtr< const Vector > d_L_
Lower bounds on d.
SmartPtr< const Matrix > Pd_L_
Permutation matrix (d_L_ -> d)
virtual SmartPtr< const Vector > orig_x_U() const
Original upper bounds on x.
virtual Index h_evals() const
virtual SmartPtr< const Matrix > Px_L() const
Permutation matrix (x_L_ -> x)
SmartPtr< const VectorSpace > d_u_space_
bool jac_c_constant_
Flag indicating if we need to ask for equality constraint Jacobians only once.
virtual SmartPtr< const SymMatrix > h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd)
Hessian of the Lagrangian.
virtual SmartPtr< const SymMatrix > h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd, Number mu)
Hessian of the Lagrangian (depending in mu) - incorrect version for OrigIpoptNLP.
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)
Initialize (create) structures for the iteration data.
CachedResults< SmartPtr< const Vector > > c_cache_
Equality constraint residuals.
virtual SmartPtr< const Vector > d_L() const
Lower bounds on d.
virtual Number f(const Vector &x, Number mu)
Objective value (depending in mu) - incorrect version for OrigIpoptNLP.
virtual SmartPtr< const VectorSpace > x_space() const
x_space
virtual SmartPtr< const Vector > d(const Vector &x)
Inequality constraint residual (reformulated as equalities with slacks)
virtual bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
Initialization method.
SmartPtr< const MatrixSpace > pd_u_space_
virtual SmartPtr< const Matrix > Pd_U() const
Permutation matrix (d_U_ -> d)
SmartPtr< const SymMatrixSpace > h_space_
SmartPtr< const MatrixSpace > scaled_jac_d_space_
bool check_derivatives_for_naninf_
Flag indicating whether it is desired to check if there are Nan or Inf entries in first and second de...
virtual SmartPtr< const Matrix > jac_d(const Vector &x)
Jacobian Matrix for inequality constraints.
virtual SmartPtr< const Vector > orig_x_L() const
Original lower bounds on x.
SmartPtr< const Vector > d_U_
Upper bounds on d.
SmartPtr< const VectorSpace > x_space_
Necessary Vector/Matrix spaces.
SmartPtr< const Matrix > Px_L_
Permutation matrix (x_L_ -> x)
virtual SmartPtr< const Vector > x_U() const
Upper bounds on x.
virtual Index f_evals() const
SmartPtr< NLP > nlp()
Accessor method to the underlying NLP.
virtual Index d_evals() const
Number bound_relax_factor_
relaxation factor for the bounds
virtual SmartPtr< const Matrix > Px_U() const
Permutation matrix (x_U_ -> x)
virtual SmartPtr< const Vector > c(const Vector &x)
Equality constraint residual.
SmartPtr< const VectorSpace > c_space_
SmartPtr< const SymMatrixSpace > scaled_h_space_
OrigIpoptNLP(const SmartPtr< const Journalist > &jnlst, const SmartPtr< NLP > &nlp, const SmartPtr< NLPScalingObject > &nlp_scaling, TimingStatistics &timing_statistics)
Constructor.
SmartPtr< const MatrixSpace > pd_l_space_
virtual Index c_evals() const
virtual SmartPtr< const Vector > grad_f(const Vector &x)
Gradient of the objective.
SmartPtr< const Journalist > jnlst_
Journalist.
SmartPtr< const VectorSpace > d_space_
bool warm_start_same_structure_
Flag indicating whether the TNLP with identical structure has already been solved before.
SmartPtr< const VectorSpace > x_l_space_
SmartPtr< const MatrixSpace > jac_c_space_
virtual SmartPtr< const Matrix > Pd_L() const
Permutation matrix (d_L_ -> d)
SmartPtr< const MatrixSpace > scaled_jac_c_space_
virtual Index jac_d_evals() const
OrigIpoptNLP(const OrigIpoptNLP &)
Copy Constructor.
CachedResults< SmartPtr< const Vector > > d_cache_
Inequality constraint residual (reformulated as equalities with slacks.
SmartPtr< const MatrixSpace > px_u_space_
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:165
This class collects all timing statistics for Ipopt.
Vector Base Class.
Definition: IpVector.hpp:48
#define IPOPTLIB_EXPORT
Definition: config.h:94
This file contains a base class for all exceptions and a set of macros to help with exceptions.
HessianApproximationSpace
enumeration for the Hessian approximation space.
@ NONLINEAR_VARS
HessianApproximationType
enumeration for the Hessian information type.
@ LIMITED_MEMORY
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:20
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17