Ipopt Documentation  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
27 {
28 public:
30 
32  NLP()
33  { }
34 
36  virtual ~NLP()
37  { }
39 
41  DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED);
43  DECLARE_STD_EXCEPTION(INVALID_NLP);
45 
47 
49  virtual bool ProcessOptions(
50  const OptionsList& /*options*/,
51  const std::string& /*prefix*/
52  )
53  {
54  return true;
55  }
56 
61  virtual bool GetSpaces(
65  SmartPtr<const VectorSpace>& x_l_space,
66  SmartPtr<const MatrixSpace>& px_l_space,
67  SmartPtr<const VectorSpace>& x_u_space,
68  SmartPtr<const MatrixSpace>& px_u_space,
69  SmartPtr<const VectorSpace>& d_l_space,
70  SmartPtr<const MatrixSpace>& pd_l_space,
71  SmartPtr<const VectorSpace>& d_u_space,
72  SmartPtr<const MatrixSpace>& pd_u_space,
73  SmartPtr<const MatrixSpace>& Jac_c_space,
74  SmartPtr<const MatrixSpace>& Jac_d_space,
75  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space
76  ) = 0;
77 
79  virtual bool GetBoundsInformation(
80  const Matrix& Px_L,
81  Vector& x_L,
82  const Matrix& Px_U,
83  Vector& x_U,
84  const Matrix& Pd_L,
85  Vector& d_L,
86  const Matrix& Pd_U,
87  Vector& d_U
88  ) = 0;
89 
94  virtual bool GetStartingPoint(
96  bool need_x,
97  SmartPtr<Vector> y_c,
98  bool need_y_c,
99  SmartPtr<Vector> y_d,
100  bool need_y_d,
101  SmartPtr<Vector> z_L,
102  bool need_z_L,
103  SmartPtr<Vector> z_U,
104  bool need_z_U
105  ) = 0;
106 
112  virtual bool GetWarmStartIterate(
113  IteratesVector& /*warm_start_iterate*/
114  )
115  {
116  return false;
117  }
119 
121  virtual bool Eval_f(
123  const Vector& x,
124  Number& f
125  ) = 0;
126 
127  virtual bool Eval_grad_f(
128  const Vector& x,
129  Vector& g_f
130  ) = 0;
131 
132  virtual bool Eval_c(
133  const Vector& x,
134  Vector& c
135  ) = 0;
136 
137  virtual bool Eval_jac_c(
138  const Vector& x,
139  Matrix& jac_c
140  ) = 0;
141 
142  virtual bool Eval_d(
143  const Vector& x,
144  Vector& d
145  ) = 0;
146 
147  virtual bool Eval_jac_d(
148  const Vector& x,
149  Matrix& jac_d
150  ) = 0;
151 
152  virtual bool Eval_h(
153  const Vector& x,
154  Number obj_factor,
155  const Vector& yc,
156  const Vector& yd,
157  SymMatrix& h
158  ) = 0;
160 
164 
171  virtual void FinalizeSolution(
172  SolverReturn /*status*/,
173  const Vector& /*x*/,
174  const Vector& /*z_L*/,
175  const Vector& /*z_U*/,
176  const Vector& /*c*/,
177  const Vector& /*d*/,
178  const Vector& /*y_c*/,
179  const Vector& /*y_d*/,
180  Number /*obj_value*/,
181  const IpoptData* /*ip_data*/,
182  IpoptCalculatedQuantities* /*ip_cq*/
183  )
184  { }
185 
204  virtual bool IntermediateCallBack(
205  AlgorithmMode /*mode*/,
206  Index /*iter*/,
207  Number /*obj_value*/,
208  Number /*inf_pr*/,
209  Number /*inf_du*/,
210  Number /*mu*/,
211  Number /*d_norm*/,
212  Number /*regularization_size*/,
213  Number /*alpha_du*/,
214  Number /*alpha_pr*/,
215  Index /*ls_trials*/,
216  const IpoptData* /*ip_data*/,
217  IpoptCalculatedQuantities* /*ip_cq*/
218  )
219  {
220  return true;
221  }
223 
228  virtual void GetScalingParameters(
230  const SmartPtr<const VectorSpace> /*x_space*/,
231  const SmartPtr<const VectorSpace> /*c_space*/,
232  const SmartPtr<const VectorSpace> /*d_space*/,
233  Number& /*obj_scaling*/,
234  SmartPtr<Vector>& /*x_scaling*/,
235  SmartPtr<Vector>& /*c_scaling*/,
236  SmartPtr<Vector>& /*d_scaling*/
237  ) const
238  {
239  THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED,
240  "You have set options for user provided scaling, but have not implemented GetScalingParameters in the NLP interface");
241  }
243 
261  SmartPtr<VectorSpace>& approx_space,
262  SmartPtr<Matrix>& P_approx
263  )
264  {
265  approx_space = NULL;
266  P_approx = NULL;
267  }
268 
269 private:
278 
280  NLP(
281  const NLP&
282  );
283 
285  void operator=(
286  const NLP&
287  );
289 };
290 
291 } // namespace Ipopt
292 
293 #endif
virtual bool GetWarmStartIterate(IteratesVector &)
Method for obtaining an entire iterate as a warmstart point.
Definition: IpNLP.hpp:112
Specialized CompoundVector class specifically for the algorithm iterates.
Class for all IPOPT specific calculated quantities.
AlgorithmMode
enum to indicate the mode in which the algorithm is
NLP()
Default constructor.
Definition: IpNLP.hpp:32
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
Vector Base Class.
Definition: IpVector.hpp:47
virtual ~NLP()
Default destructor.
Definition: IpNLP.hpp:36
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:204
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:171
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:171
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:97
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
#define IPOPTLIB_EXPORT
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:260
#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:49