Ipopt  3.12.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 // $Id: IpOrigIpoptNLP.hpp 2594 2015-08-09 14:31:05Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPORIGIPOPTNLP_HPP__
10 #define __IPORIGIPOPTNLP_HPP__
11 
12 #include "IpIpoptNLP.hpp"
13 #include "IpException.hpp"
14 #include "IpTimingStatistics.hpp"
15 
16 namespace Ipopt
17 {
18 
21  EXACT=0,
23  };
24 
29  };
30 
37  class OrigIpoptNLP : public IpoptNLP
38  {
39  public:
43  const SmartPtr<NLP>& nlp,
44  const SmartPtr<NLPScalingObject>& nlp_scaling);
45 
47  virtual ~OrigIpoptNLP();
49 
51  virtual bool Initialize(const Journalist& jnlst,
52  const OptionsList& options,
53  const std::string& prefix);
54 
58  bool init_x,
59  SmartPtr<Vector>& y_c,
60  bool init_y_c,
61  SmartPtr<Vector>& y_d,
62  bool init_y_d,
63  SmartPtr<Vector>& z_L,
64  bool init_z_L,
65  SmartPtr<Vector>& z_U,
66  bool init_z_U,
67  SmartPtr<Vector>& v_L,
68  SmartPtr<Vector>& v_U
69  );
70 
72  virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)
73  {
74  return nlp_->GetWarmStartIterate(warm_start_iterate);
75  }
79  virtual Number f(const Vector& x);
80 
83  virtual Number f(const Vector& x, Number mu);
84 
86  virtual SmartPtr<const Vector> grad_f(const Vector& x);
87 
90  virtual SmartPtr<const Vector> grad_f(const Vector& x, Number mu);
91 
93  virtual SmartPtr<const Vector> c(const Vector& x);
94 
96  virtual SmartPtr<const Matrix> jac_c(const Vector& x);
97 
100  virtual SmartPtr<const Vector> d(const Vector& x);
101 
103  virtual SmartPtr<const Matrix> jac_d(const Vector& x);
104 
106  virtual SmartPtr<const SymMatrix> h(const Vector& x,
107  Number obj_factor,
108  const Vector& yc,
109  const Vector& yd
110  );
111 
114  virtual SmartPtr<const SymMatrix> h(const Vector& x,
115  Number obj_factor,
116  const Vector& yc,
117  const Vector& yd,
118  Number mu);
119 
124 
126  virtual SmartPtr<const Vector> x_L() const
127  {
128  return x_L_;
129  }
130 
132  virtual SmartPtr<const Matrix> Px_L() const
133  {
134  return Px_L_;
135  }
136 
138  virtual SmartPtr<const Vector> x_U() const
139  {
140  return x_U_;
141  }
142 
144  virtual SmartPtr<const Matrix> Px_U() const
145  {
146  return Px_U_;
147  }
148 
150  virtual SmartPtr<const Vector> d_L() const
151  {
152  return d_L_;
153  }
154 
156  virtual SmartPtr<const Matrix> Pd_L() const
157  {
158  return Pd_L_;
159  }
160 
162  virtual SmartPtr<const Vector> d_U() const
163  {
164  return d_U_;
165  }
166 
168  virtual SmartPtr<const Matrix> Pd_U() const
169  {
170  return Pd_U_;
171  }
172 
174  {
175  return h_space_;
176  }
177 
179  {
180  return x_space_;
181  }
183 
188  SmartPtr<const VectorSpace>& x_l_space,
189  SmartPtr<const MatrixSpace>& px_l_space,
190  SmartPtr<const VectorSpace>& x_u_space,
191  SmartPtr<const MatrixSpace>& px_u_space,
192  SmartPtr<const VectorSpace>& d_l_space,
193  SmartPtr<const MatrixSpace>& pd_l_space,
194  SmartPtr<const VectorSpace>& d_u_space,
195  SmartPtr<const MatrixSpace>& pd_u_space,
196  SmartPtr<const MatrixSpace>& Jac_c_space,
197  SmartPtr<const MatrixSpace>& Jac_d_space,
198  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space);
199 
202  virtual void AdjustVariableBounds(const Vector& new_x_L,
203  const Vector& new_x_U,
204  const Vector& new_d_L,
205  const Vector& new_d_U);
206 
209  virtual Index f_evals() const
210  {
211  return f_evals_;
212  }
213  virtual Index grad_f_evals() const
214  {
215  return grad_f_evals_;
216  }
217  virtual Index c_evals() const
218  {
219  return c_evals_;
220  }
221  virtual Index jac_c_evals() const
222  {
223  return jac_c_evals_;
224  }
225  virtual Index d_evals() const
226  {
227  return d_evals_;
228  }
229  virtual Index jac_d_evals() const
230  {
231  return jac_d_evals_;
232  }
233  virtual Index h_evals() const
234  {
235  return h_evals_;
236  }
238 
241  void FinalizeSolution(SolverReturn status,
242  const Vector& x, const Vector& z_L, const Vector& z_U,
243  const Vector& c, const Vector& d,
244  const Vector& y_c, const Vector& y_d,
245  Number obj_value,
246  const IpoptData* ip_data,
249  Index iter, Number obj_value,
250  Number inf_pr, Number inf_du,
251  Number mu, Number d_norm,
252  Number regularization_size,
253  Number alpha_du, Number alpha_pr,
254  Index ls_trials,
258 
262  static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
264 
267  {
268  return nlp_;
269  }
270 
273 
275  void ResetTimes();
276 
277  void PrintTimingStatistics(Journalist& jnlst,
278  EJournalLevel level,
279  EJournalCategory category) const;
280 
281  const TimedTask& f_eval_time() const
282  {
283  return f_eval_time_;
284  }
286  {
287  return grad_f_eval_time_;
288  }
289  const TimedTask& c_eval_time() const
290  {
291  return c_eval_time_;
292  }
293  const TimedTask& jac_c_eval_time() const
294  {
295  return jac_c_eval_time_;
296  }
297  const TimedTask& d_eval_time() const
298  {
299  return d_eval_time_;
300  }
301  const TimedTask& jac_d_eval_time() const
302  {
303  return jac_d_eval_time_;
304  }
305  const TimedTask& h_eval_time() const
306  {
307  return h_eval_time_;
308  }
309 
314 
315  private:
318 
321 
338 
343 
347 
350 
353 
357 
361 
365 
369 
372 
375 
378 
381 
384 
387 
390 
393 
396 
399 
403 
413  OrigIpoptNLP();
414 
416  OrigIpoptNLP(const OrigIpoptNLP&);
417 
419  void operator=(const OrigIpoptNLP&);
421 
428  void relax_bounds(Number bound_relax_factor, Vector& bounds);
432 
459 
470 
473 
484  };
485 
486 } // namespace Ipopt
487 
488 #endif
virtual Index f_evals() const
const TimedTask & jac_c_eval_time() const
virtual Index h_evals() const
Number * x
Input: Starting point Output: Optimal solution.
CachedResults< SmartPtr< const Vector > > c_cache_
Equality constraint residuals.
SmartPtr< const Vector > orig_x_U_
Original unmodified upper bounds on x.
virtual SmartPtr< const Matrix > Pd_L() const
Permutation matrix (d_L_ -&gt; d)
virtual SmartPtr< const Vector > c(const Vector &x)
Equality constraint residual.
bool jac_d_constant_
Flag indicating if we need to ask for inequality constraint Jacobians only once.
virtual SmartPtr< const Matrix > jac_d(const Vector &x)
Jacobian Matrix for inequality constraints.
Specialized CompoundVector class specifically for the algorithm iterates.
Class for all IPOPT specific calculated quantities.
CachedResults< SmartPtr< const Vector > > d_cache_
Inequality constraint residual (reformulated as equalities with slacks.
virtual SmartPtr< const SymMatrixSpace > HessianMatrixSpace() const
Accessor method to obtain the MatrixSpace for the Hessian matrix (or it&#39;s approximation) ...
void ResetTimes()
Reset the timing statistics.
SmartPtr< const Matrix > Px_L_
Permutation matrix (x_L_ -&gt; x)
const TimedTask & d_eval_time() const
bool jac_c_constant_
Flag indicating if we need to ask for equality constraint Jacobians only once.
virtual Index grad_f_evals() const
virtual Index d_evals() const
SmartPtr< const MatrixSpace > jac_d_space_
This class is used to collect timing information for a particular task.
Definition: IpTimedTask.hpp:18
virtual Index c_evals() const
SmartPtr< const MatrixSpace > px_u_space_
virtual bool GetWarmStartIterate(IteratesVector &warm_start_iterate)
Method accessing the GetWarmStartIterate of the NLP.
AlgorithmMode
enum to indicate the mode in which the algorithm is
const TimedTask & c_eval_time() const
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Vector Base Class.
Definition: IpVector.hpp:47
SmartPtr< const VectorSpace > d_l_space_
SmartPtr< const SymMatrixSpace > scaled_h_space_
SmartPtr< const VectorSpace > x_u_space_
SmartPtr< const MatrixSpace > scaled_jac_c_space_
bool initialized_
Flag indicating if initialization method has been called.
EJournalLevel
Print Level Enum.
SmartPtr< const VectorSpace > x_l_space_
virtual SmartPtr< const Vector > d(const Vector &x)
Inequality constraint residual (reformulated as equalities with slacks.
const TimedTask & f_eval_time() const
CachedResults< SmartPtr< const Vector > > unscaled_x_cache_
Unscaled version of x vector.
virtual SmartPtr< const Matrix > Pd_U() const
Permutation matrix (d_U_ -&gt; d.
HessianApproximationType hessian_approximation_
Flag indicating what Hessian information is to be used.
virtual ~OrigIpoptNLP()
Default destructor.
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 MatrixSpace > scaled_jac_d_space_
CachedResults< SmartPtr< const Matrix > > jac_d_cache_
Jacobian Matrix for inequality constraints (current iteration)
bool honor_original_bounds_
Flag indicating whether the primal variables should be projected back into original bounds are optimi...
virtual bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
Initialize - overloaded from IpoptNLP.
Number TotalFunctionEvaluationWallclockTime() const
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
void PrintTimingStatistics(Journalist &jnlst, EJournalLevel level, EJournalCategory category) const
This class stores a list of user set options.
virtual SmartPtr< const SymMatrix > uninitialized_h()
Provides a Hessian matrix from the correct matrix space with uninitialized values.
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
Definition: IpAlgTypes.hpp:22
virtual SmartPtr< const Vector > d_L() const
Lower bounds on d.
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)
SmartPtr< const Vector > x_L_
Lower bounds on x.
SmartPtr< const Vector > d_L_
Lower bounds on d.
Number TotalFunctionEvaluationSysTime() const
SmartPtr< NLP > nlp_
Pointer to the NLP.
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.
HessianApproximationType
enumeration for the Hessian information type.
SmartPtr< const Matrix > Pd_L_
Permutation matrix (d_L_ -&gt; d)
SmartPtr< const Journalist > jnlst_
journalist
SmartPtr< const Vector > d_U_
Upper bounds on d.
virtual SmartPtr< const Vector > x_U() const
Upper bounds on x.
HessianApproximationSpace
enumeration for the Hessian approximation space.
SmartPtr< const MatrixSpace > pd_u_space_
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:83
SmartPtr< const SymMatrixSpace > h_space_
SmartPtr< NLP > nlp()
Accessor method to the underlying NLP.
virtual Number f(const Vector &x)
Accessor methods for model data.
SmartPtr< const Vector > get_unscaled_x(const Vector &x)
Method for getting the unscaled version of the x vector.
const TimedTask & grad_f_eval_time() const
void operator=(const OrigIpoptNLP &)
Overloaded Equals Operator.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
virtual SmartPtr< const SymMatrix > h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd)
Hessian of the Lagrangian.
SmartPtr< const VectorSpace > d_space_
virtual Index jac_d_evals() const
CachedResults< SmartPtr< const Matrix > > jac_c_cache_
Jacobian Matrix for equality constraints (current iteration)
SmartPtr< const Matrix > Px_U_
Permutation matrix (x_U_ -&gt; x.
Number TotalFunctionEvaluationCpuTime() const
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.
CachedResults< SmartPtr< const Vector > > grad_f_cache_
Gradient of the objective function.
CachedResults< Number > f_cache_
Objective function.
virtual SmartPtr< const Vector > x_L() const
Lower bounds on x.
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.
This class maps the traditional NLP into something that is more useful by Ipopt.
Class responsible for all message output.
OrigIpoptNLP()
Default Constructor.
bool hessian_constant_
Flag indicating if we need to ask for Hessian only once.
SmartPtr< const Vector > orig_x_L_
Original unmodified lower bounds on x.
static void RegisterOptions(SmartPtr< RegisteredOptions > roptions)
Called by IpoptType to register the options.
virtual SmartPtr< const VectorSpace > x_space() const
x_space
const TimedTask & h_eval_time() const
SmartPtr< const VectorSpace > d_u_space_
void relax_bounds(Number bound_relax_factor, Vector &bounds)
relax the bounds by a relative move of relax_bound_factor.
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...
bool warm_start_same_structure_
Flag indicating whether the TNLP with identical structure has already been solved before...
CachedResults< SmartPtr< const SymMatrix > > h_cache_
Hessian of the lagrangian (current iteration)
SmartPtr< const MatrixSpace > px_l_space_
const TimedTask & jac_d_eval_time() const
SmartPtr< const VectorSpace > x_space_
Necessary Vector/Matrix spaces.
virtual SmartPtr< const Vector > d_U() const
Upper bounds on d.
virtual SmartPtr< const Matrix > Px_U() const
Permutation matrix (x_U_ -&gt; x.
SmartPtr< const MatrixSpace > pd_l_space_
virtual SmartPtr< const Vector > grad_f(const Vector &x)
Gradient of the objective.
SmartPtr< const MatrixSpace > jac_c_space_
This is the abstract base class for classes that map the traditional NLP into something that is more ...
Definition: IpIpoptNLP.hpp:28
Number bound_relax_factor_
relaxation factor for the bounds
SmartPtr< const VectorSpace > c_space_
virtual Index jac_c_evals() const
HessianApproximationSpace hessian_approximation_space_
Flag indicating in which space Hessian is to be approximated.
EJournalCategory
Category Selection Enum.
virtual SmartPtr< const Matrix > jac_c(const Vector &x)
Jacobian Matrix for equality constraints.
virtual SmartPtr< const Matrix > Px_L() const
Permutation matrix (x_L_ -&gt; x)
SmartPtr< const Vector > x_U_
Upper bounds on x.
SmartPtr< const Matrix > Pd_U_
Permutation matrix (d_U_ -&gt; d.