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 1861 2010-12-21 21:34:47Z andreasw $
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