Ipopt  3.12.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 // $Id: IpNLP.hpp 2269 2013-05-05 11:32:40Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPNLP_HPP__
10 #define __IPNLP_HPP__
11 
12 #include "IpUtils.hpp"
13 #include "IpVector.hpp"
14 #include "IpSmartPtr.hpp"
15 #include "IpMatrix.hpp"
16 #include "IpSymMatrix.hpp"
17 #include "IpOptionsList.hpp"
18 #include "IpAlgTypes.hpp"
19 #include "IpReturnCodes.hpp"
20 
21 namespace Ipopt
22 {
23  // forward declarations
24  class IpoptData;
25  class IpoptCalculatedQuantities;
26  class IteratesVector;
27 
31  class NLP : public ReferencedObject
32  {
33  public:
37  NLP()
38  {}
39 
41  virtual ~NLP()
42  {}
44 
47  DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED);
48  DECLARE_STD_EXCEPTION(INVALID_NLP);
50 
56  virtual bool ProcessOptions(const OptionsList& options,
57  const std::string& prefix)
58  {
59  return true;
60  }
61 
65  virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space,
68  SmartPtr<const VectorSpace>& x_l_space,
69  SmartPtr<const MatrixSpace>& px_l_space,
70  SmartPtr<const VectorSpace>& x_u_space,
71  SmartPtr<const MatrixSpace>& px_u_space,
72  SmartPtr<const VectorSpace>& d_l_space,
73  SmartPtr<const MatrixSpace>& pd_l_space,
74  SmartPtr<const VectorSpace>& d_u_space,
75  SmartPtr<const MatrixSpace>& pd_u_space,
76  SmartPtr<const MatrixSpace>& Jac_c_space,
77  SmartPtr<const MatrixSpace>& Jac_d_space,
78  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space)=0;
79 
81  virtual bool GetBoundsInformation(const Matrix& Px_L,
82  Vector& x_L,
83  const Matrix& Px_U,
84  Vector& x_U,
85  const Matrix& Pd_L,
86  Vector& d_L,
87  const Matrix& Pd_U,
88  Vector& d_U)=0;
89 
93  virtual bool GetStartingPoint(
95  bool need_x,
96  SmartPtr<Vector> y_c,
97  bool need_y_c,
98  SmartPtr<Vector> y_d,
99  bool need_y_d,
100  SmartPtr<Vector> z_L,
101  bool need_z_L,
102  SmartPtr<Vector> z_U,
103  bool need_z_U
104  )=0;
105 
109  virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)
110  {
111  return false;
112  }
114 
118  virtual bool Eval_f(const Vector& x, Number& f) = 0;
119 
120  virtual bool Eval_grad_f(const Vector& x, Vector& g_f) = 0;
121 
122  virtual bool Eval_c(const Vector& x, Vector& c) = 0;
123 
124  virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c) = 0;
125 
126  virtual bool Eval_d(const Vector& x, Vector& d) = 0;
127 
128  virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d) = 0;
129 
130  virtual bool Eval_h(const Vector& x,
131  Number obj_factor,
132  const Vector& yc,
133  const Vector& yd,
134  SymMatrix& h) = 0;
136 
145  virtual void FinalizeSolution(SolverReturn status,
146  const Vector& x, const Vector& z_L,
147  const Vector& z_U,
148  const Vector& c, const Vector& d,
149  const Vector& y_c, const Vector& y_d,
150  Number obj_value,
151  const IpoptData* ip_data,
153  {}
154 
171  Index iter, Number obj_value,
172  Number inf_pr, Number inf_du,
173  Number mu, Number d_norm,
174  Number regularization_size,
175  Number alpha_du, Number alpha_pr,
176  Index ls_trials,
177  const IpoptData* ip_data,
179  {
180  return true;
181  }
183 
188  virtual void GetScalingParameters(
189  const SmartPtr<const VectorSpace> x_space,
190  const SmartPtr<const VectorSpace> c_space,
191  const SmartPtr<const VectorSpace> d_space,
194  SmartPtr<Vector>& c_scaling,
195  SmartPtr<Vector>& d_scaling) const
196  {
197  THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED,
198  "You have set options for user provided scaling, but have"
199  " not implemented GetScalingParameters in the NLP interface");
200  }
202 
216  virtual void
218  SmartPtr<Matrix>& P_approx)
219  {
220  approx_space = NULL;
221  P_approx = NULL;
222  }
223 
224  private:
234  NLP(const NLP&);
235 
237  void operator=(const NLP&);
239  };
240 
241 } // namespace Ipopt
242 
243 #endif
Number * x
Input: Starting point Output: Optimal solution.
virtual bool Eval_c(const Vector &x, Vector &c)=0
Specialized CompoundVector class specifically for the algorithm iterates.
Class for all IPOPT specific calculated quantities.
virtual bool Eval_h(const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd, SymMatrix &h)=0
void operator=(const NLP &)
Overloaded Equals Operator.
virtual bool GetWarmStartIterate(IteratesVector &warm_start_iterate)
Method for obtaining an entire iterate as a warmstart point.
Definition: IpNLP.hpp:109
AlgorithmMode
enum to indicate the mode in which the algorithm is
NLP()
Default constructor.
Definition: IpNLP.hpp:37
virtual bool Eval_jac_d(const Vector &x, Matrix &jac_d)=0
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Vector Base Class.
Definition: IpVector.hpp:47
DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED)
Exceptions.
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.
virtual 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, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
This method is called once per iteration, after the iteration summary output has been printed...
Definition: IpNLP.hpp:170
virtual ~NLP()
Default destructor.
Definition: IpNLP.hpp:41
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:23
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
ReferencedObject class.
This class stores a list of user set options.
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
Definition: IpAlgTypes.hpp:22
Matrix Base Class.
Definition: IpMatrix.hpp:27
virtual bool ProcessOptions(const OptionsList &options, const std::string &prefix)
Overload if you want the chance to process options or parameters that may be specific to the NLP...
Definition: IpNLP.hpp:56
virtual 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)
This method is called at the very end of the optimization.
Definition: IpNLP.hpp:145
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:83
virtual bool Eval_f(const Vector &x, Number &f)=0
Number * x_L
Lower bounds on variables.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Number Number * x_U
Upper bounds on variables.
Number Number * x_scaling
Brief Class Description.
Definition: IpNLP.hpp:31
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.
virtual void GetScalingParameters(const SmartPtr< const VectorSpace > x_space, const SmartPtr< const VectorSpace > c_space, const SmartPtr< const VectorSpace > d_space, Number &obj_scaling, SmartPtr< Vector > &x_scaling, SmartPtr< Vector > &c_scaling, SmartPtr< Vector > &d_scaling) const
Routines to get the scaling parameters.
Definition: IpNLP.hpp:188
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.
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:217
virtual bool Eval_jac_c(const Vector &x, Matrix &jac_c)=0
virtual bool Eval_grad_f(const Vector &x, Vector &g_f)=0
virtual bool Eval_d(const Vector &x, Vector &d)=0
#define THROW_EXCEPTION(__except_type, __msg)
Number obj_scaling