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 
27 {
28 public:
32  NLP()
33  { }
34 
36  virtual ~NLP()
37  { }
39 
42  DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED);
43  DECLARE_STD_EXCEPTION(INVALID_NLP);
45 
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 
122  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 
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 
229  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:
281  const NLP&
282  );
283 
285  void operator=(
286  const NLP&
287  );
289 };
290 
291 } // namespace Ipopt
292 
293 #endif
IpUtils.hpp
THROW_EXCEPTION
#define THROW_EXCEPTION(__except_type, __msg)
Definition: IpException.hpp:132
Ipopt::IpoptData
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:98
Ipopt::NLP::ProcessOptions
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
Ipopt::NLP::GetScalingParameters
virtual void GetScalingParameters(const SmartPtr< const VectorSpace >, const SmartPtr< const VectorSpace >, const SmartPtr< const VectorSpace >, Number &, SmartPtr< Vector > &, SmartPtr< Vector > &, SmartPtr< Vector > &) const
Routines to get the scaling parameters.
Definition: IpNLP.hpp:229
Ipopt::NLP::Eval_f
virtual bool Eval_f(const Vector &x, Number &f)=0
Ipopt::NLP::operator=
void operator=(const NLP &)
Default Assignment Operator.
IpAlgTypes.hpp
Ipopt::NLP::DECLARE_STD_EXCEPTION
DECLARE_STD_EXCEPTION(INVALID_NLP)
Ipopt::IpoptCalculatedQuantities
Class for all IPOPT specific calculated quantities.
Definition: IpIpoptCalculatedQuantities.hpp:89
IpSmartPtr.hpp
IpOptionsList.hpp
Ipopt
This file contains a base class for all exceptions and a set of macros to help with exceptions.
Definition: IpInexactAlgBuilder.hpp:14
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
Ipopt::Matrix
Matrix Base Class.
Definition: IpMatrix.hpp:28
IpReturnCodes.hpp
Ipopt::NLP::Eval_h
virtual bool Eval_h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd, SymMatrix &h)=0
Ipopt::NLP::Eval_grad_f
virtual bool Eval_grad_f(const Vector &x, Vector &g_f)=0
IPOPTLIB_EXPORT
#define IPOPTLIB_EXPORT
Definition: config_default.h:16
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
Ipopt::NLP::GetWarmStartIterate
virtual bool GetWarmStartIterate(IteratesVector &)
Method for obtaining an entire iterate as a warmstart point.
Definition: IpNLP.hpp:112
Ipopt::NLP::Eval_d
virtual bool Eval_d(const Vector &x, Vector &d)=0
Ipopt::NLP::Eval_jac_c
virtual bool Eval_jac_c(const Vector &x, Matrix &jac_c)=0
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::NLP::GetQuasiNewtonApproximationSpaces
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
Ipopt::NLP::FinalizeSolution
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
Ipopt::NLP::NLP
NLP(const NLP &)
Copy Constructor.
Ipopt::NLP
Definition: IpNLP.hpp:27
IpSymMatrix.hpp
Ipopt::NLP::GetSpaces
virtual bool 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
Method for creating the derived vector / matrix types.
Ipopt::NLP::NLP
NLP()
Default constructor.
Definition: IpNLP.hpp:32
Ipopt::SymMatrix
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:21
IpVector.hpp
IpMatrix.hpp
Ipopt::NLP::GetStartingPoint
virtual bool GetStartingPoint(SmartPtr< Vector > x, bool need_x, SmartPtr< Vector > y_c, bool need_y_c, SmartPtr< Vector > y_d, bool need_y_d, SmartPtr< Vector > z_L, bool need_z_L, SmartPtr< Vector > z_U, bool need_z_U)=0
Method for obtaining the starting point for all the iterates.
Ipopt::NLP::Eval_jac_d
virtual bool Eval_jac_d(const Vector &x, Matrix &jac_d)=0
Ipopt::NLP::DECLARE_STD_EXCEPTION
DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED)
Exceptions.
Ipopt::SolverReturn
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:20
Ipopt::OptionsList
This class stores a list of user set options.
Definition: IpOptionsList.hpp:33
Ipopt::NLP::IntermediateCallBack
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
Ipopt::ReferencedObject
Storing the reference count of all the smart pointers that currently reference it.
Definition: IpReferenced.hpp:170
Ipopt::NLP::~NLP
virtual ~NLP()
Default destructor.
Definition: IpNLP.hpp:36
Ipopt::NLP::GetBoundsInformation
virtual bool GetBoundsInformation(const Matrix &Px_L, Vector &x_L, const Matrix &Px_U, Vector &x_U, const Matrix &Pd_L, Vector &d_L, const Matrix &Pd_U, Vector &d_U)=0
Method for obtaining the bounds information.
Ipopt::NLP::Eval_c
virtual bool Eval_c(const Vector &x, Vector &c)=0
AlgorithmMode
AlgorithmMode
enum to indicate the mode in which the algorithm is
Definition: IpReturnCodes_inc.h:41
Ipopt::Vector
Vector Base Class.
Definition: IpVector.hpp:48
Ipopt::IteratesVector
Specialized CompoundVector class specifically for the algorithm iterates.
Definition: IpIteratesVector.hpp:26