Ipopt Documentation  
IpNLP.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 __IPNLP_HPP__
8 #define __IPNLP_HPP__
9 
10 #include "IpUtils.hpp"
11 #include "IpVector.hpp"
12 #include "IpSmartPtr.hpp"
13 #include "IpMatrix.hpp"
14 #include "IpSymMatrix.hpp"
15 #include "IpOptionsList.hpp"
16 #include "IpAlgTypes.hpp"
17 #include "IpReturnCodes.hpp"
18 
19 namespace Ipopt
20 {
21 // forward declarations
22 class IpoptData;
23 class IpoptCalculatedQuantities;
24 class IteratesVector;
25 
42 {
43 public:
45 
47  NLP()
48  { }
49 
51  virtual ~NLP()
52  { }
54 
56  DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED);
58  DECLARE_STD_EXCEPTION(INVALID_NLP);
60 
62 
64  virtual bool ProcessOptions(
65  const OptionsList& /*options*/,
66  const std::string& /*prefix*/
67  )
68  {
69  return true;
70  }
71 
76  virtual bool GetSpaces(
80  SmartPtr<const VectorSpace>& x_l_space,
81  SmartPtr<const MatrixSpace>& px_l_space,
82  SmartPtr<const VectorSpace>& x_u_space,
83  SmartPtr<const MatrixSpace>& px_u_space,
84  SmartPtr<const VectorSpace>& d_l_space,
85  SmartPtr<const MatrixSpace>& pd_l_space,
86  SmartPtr<const VectorSpace>& d_u_space,
87  SmartPtr<const MatrixSpace>& pd_u_space,
88  SmartPtr<const MatrixSpace>& Jac_c_space,
89  SmartPtr<const MatrixSpace>& Jac_d_space,
90  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space
91  ) = 0;
92 
94  virtual bool GetBoundsInformation(
95  const Matrix& Px_L,
96  Vector& x_L,
97  const Matrix& Px_U,
98  Vector& x_U,
99  const Matrix& Pd_L,
100  Vector& d_L,
101  const Matrix& Pd_U,
102  Vector& d_U
103  ) = 0;
104 
106  // ToDo it might not make sense to ask for initial values for v_L and v_U?
107  virtual bool GetStartingPoint(
109  bool need_x,
110  SmartPtr<Vector> y_c,
111  bool need_y_c,
112  SmartPtr<Vector> y_d,
113  bool need_y_d,
114  SmartPtr<Vector> z_L,
115  bool need_z_L,
116  SmartPtr<Vector> z_U,
117  bool need_z_U
118  ) = 0;
119 
125  virtual bool GetWarmStartIterate(
126  IteratesVector& /*warm_start_iterate*/
127  )
128  {
129  return false;
130  }
132 
134  virtual bool Eval_f(
136  const Vector& x,
137  Number& f
138  ) = 0;
139 
140  virtual bool Eval_grad_f(
141  const Vector& x,
142  Vector& g_f
143  ) = 0;
144 
145  virtual bool Eval_c(
146  const Vector& x,
147  Vector& c
148  ) = 0;
149 
150  virtual bool Eval_jac_c(
151  const Vector& x,
152  Matrix& jac_c
153  ) = 0;
154 
155  virtual bool Eval_d(
156  const Vector& x,
157  Vector& d
158  ) = 0;
159 
160  virtual bool Eval_jac_d(
161  const Vector& x,
162  Matrix& jac_d
163  ) = 0;
164 
165  virtual bool Eval_h(
166  const Vector& x,
167  Number obj_factor,
168  const Vector& yc,
169  const Vector& yd,
170  SymMatrix& h
171  ) = 0;
173 
177 
184  virtual void FinalizeSolution(
185  SolverReturn /*status*/,
186  const Vector& /*x*/,
187  const Vector& /*z_L*/,
188  const Vector& /*z_U*/,
189  const Vector& /*c*/,
190  const Vector& /*d*/,
191  const Vector& /*y_c*/,
192  const Vector& /*y_d*/,
193  Number /*obj_value*/,
194  const IpoptData* /*ip_data*/,
195  IpoptCalculatedQuantities* /*ip_cq*/
196  )
197  { }
198 
217  virtual bool IntermediateCallBack(
218  AlgorithmMode /*mode*/,
219  Index /*iter*/,
220  Number /*obj_value*/,
221  Number /*inf_pr*/,
222  Number /*inf_du*/,
223  Number /*mu*/,
224  Number /*d_norm*/,
225  Number /*regularization_size*/,
226  Number /*alpha_du*/,
227  Number /*alpha_pr*/,
228  Index /*ls_trials*/,
229  const IpoptData* /*ip_data*/,
230  IpoptCalculatedQuantities* /*ip_cq*/
231  )
232  {
233  return true;
234  }
236 
241  virtual void GetScalingParameters(
243  const SmartPtr<const VectorSpace> /*x_space*/,
244  const SmartPtr<const VectorSpace> /*c_space*/,
245  const SmartPtr<const VectorSpace> /*d_space*/,
246  Number& /*obj_scaling*/,
247  SmartPtr<Vector>& /*x_scaling*/,
248  SmartPtr<Vector>& /*c_scaling*/,
249  SmartPtr<Vector>& /*d_scaling*/
250  ) const
251  {
252  THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED,
253  "You have set options for user provided scaling, but have not implemented GetScalingParameters in the NLP interface");
254  }
256 
274  SmartPtr<VectorSpace>& approx_space,
275  SmartPtr<Matrix>& P_approx
276  )
277  {
278  approx_space = NULL;
279  P_approx = NULL;
280  }
281 
282 private:
291 
293  NLP(
294  const NLP&
295  );
296 
298  void operator=(
299  const NLP&
300  );
302 };
303 
304 } // namespace Ipopt
305 
306 #endif
virtual bool GetWarmStartIterate(IteratesVector &)
Method for obtaining an entire iterate as a warmstart point.
Definition: IpNLP.hpp:125
Specialized CompoundVector class specifically for the algorithm iterates.
Class for all IPOPT specific calculated quantities.
#define IPOPTLIB_EXPORT
Definition: config.h:94
AlgorithmMode
enum to indicate the mode in which the algorithm is
NLP()
Default constructor.
Definition: IpNLP.hpp:47
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
Vector Base Class.
Definition: IpVector.hpp:47
virtual ~NLP()
Default destructor.
Definition: IpNLP.hpp:51
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
This file contains a base class for all exceptions and a set of macros to help with exceptions...
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:20
virtual bool IntermediateCallBack(AlgorithmMode, Index, Number, Number, Number, Number, Number, Number, Number, Number, Index, const IpoptData *, IpoptCalculatedQuantities *)
This method is called once per iteration, after the iteration summary output has been printed...
Definition: IpNLP.hpp:217
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.
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:19
Matrix Base Class.
Definition: IpMatrix.hpp:27
virtual void FinalizeSolution(SolverReturn, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, Number, const IpoptData *, IpoptCalculatedQuantities *)
This method is called at the very end of the optimization.
Definition: IpNLP.hpp:184
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:97
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
Traditional NLP.
Definition: IpNLP.hpp:41
virtual void GetQuasiNewtonApproximationSpaces(SmartPtr< VectorSpace > &approx_space, SmartPtr< Matrix > &P_approx)
Method for obtaining the subspace in which the limited-memory Hessian approximation should be done...
Definition: IpNLP.hpp:273
#define THROW_EXCEPTION(__except_type, __msg)
virtual bool ProcessOptions(const OptionsList &, const std::string &)
Overload if you want the chance to process options or parameters that may be specific to the NLP...
Definition: IpNLP.hpp:64