Ipopt  3.11.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpTNLPAdapter.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2008 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpTNLPAdapter.hpp 1861 2010-12-21 21:34:47Z andreasw $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPTNLPADAPTER_HPP__
10 #define __IPTNLPADAPTER_HPP__
11 
12 #include "IpNLP.hpp"
13 #include "IpTNLP.hpp"
14 #include "IpOrigIpoptNLP.hpp"
15 #include <list>
16 
17 namespace Ipopt
18 {
19 
20  // forward declarations
21  class ExpansionMatrix;
22  class ExpansionMatrixSpace;
23  class IteratesVector;
24  class TDependencyDetector;
25 
30  class TNLPAdapter : public NLP
31  {
32  public:
37  const SmartPtr<const Journalist> jnlst = NULL);
38 
40  virtual ~TNLPAdapter();
42 
45  DECLARE_STD_EXCEPTION(INVALID_TNLP);
46  DECLARE_STD_EXCEPTION(ERROR_IN_TNLP_DERIVATIVE_TEST);
48 
51  virtual bool ProcessOptions(const OptionsList& options,
52  const std::string& prefix);
53 
56  virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space,
59  SmartPtr<const VectorSpace>& x_l_space,
60  SmartPtr<const MatrixSpace>& px_l_space,
61  SmartPtr<const VectorSpace>& x_u_space,
62  SmartPtr<const MatrixSpace>& px_u_space,
63  SmartPtr<const VectorSpace>& d_l_space,
64  SmartPtr<const MatrixSpace>& pd_l_space,
65  SmartPtr<const VectorSpace>& d_u_space,
66  SmartPtr<const MatrixSpace>& pd_u_space,
67  SmartPtr<const MatrixSpace>& Jac_c_space,
68  SmartPtr<const MatrixSpace>& Jac_d_space,
69  SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space);
70 
72  virtual bool GetBoundsInformation(const Matrix& Px_L,
73  Vector& x_L,
74  const Matrix& Px_U,
75  Vector& x_U,
76  const Matrix& Pd_L,
77  Vector& d_L,
78  const Matrix& Pd_U,
79  Vector& d_U);
80 
83  virtual bool GetStartingPoint(
85  bool need_x,
86  SmartPtr<Vector> y_c,
87  bool need_y_c,
88  SmartPtr<Vector> y_d,
89  bool need_y_d,
90  SmartPtr<Vector> z_L,
91  bool need_z_L,
92  SmartPtr<Vector> z_U,
93  bool need_z_U
94  );
95 
98  virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate);
100 
103  virtual bool Eval_f(const Vector& x, Number& f);
104 
105  virtual bool Eval_grad_f(const Vector& x, Vector& g_f);
106 
107  virtual bool Eval_c(const Vector& x, Vector& c);
108 
109  virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c);
110 
111  virtual bool Eval_d(const Vector& x, Vector& d);
112 
113  virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d);
114 
115  virtual bool Eval_h(const Vector& x,
116  Number obj_factor,
117  const Vector& yc,
118  const Vector& yd,
119  SymMatrix& h);
120 
121  virtual void GetScalingParameters(
122  const SmartPtr<const VectorSpace> x_space,
123  const SmartPtr<const VectorSpace> c_space,
124  const SmartPtr<const VectorSpace> d_space,
127  SmartPtr<Vector>& c_scaling,
128  SmartPtr<Vector>& d_scaling) const;
130 
133  virtual void FinalizeSolution(SolverReturn status,
134  const Vector& x,
135  const Vector& z_L, const Vector& z_U,
136  const Vector& c, const Vector& d,
137  const Vector& y_c, const Vector& y_d,
138  Number obj_value,
139  const IpoptData* ip_data,
141 
142  virtual bool IntermediateCallBack(AlgorithmMode mode,
143  Index iter, Number obj_value,
144  Number inf_pr, Number inf_du,
145  Number mu, Number d_norm,
146  Number regularization_size,
147  Number alpha_du, Number alpha_pr,
148  Index ls_trials,
149  const IpoptData* ip_data,
152 
154  virtual void
156  SmartPtr<Matrix>& P_approx);
157 
160  {
164  };
165 
168  {
173  };
174 
177  {
180  };
181 
183  bool CheckDerivatives(DerivativeTestEnum deriv_test,
184  Index deriv_test_start_index);
185 
188  static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
190 
193  {
194  return tnlp_;
195  }
196 
203  void ResortX(const Vector& x, Number* x_orig);
204  void ResortG(const Vector& c, const Vector& d, Number *g_orig);
205  void ResortBnds(const Vector& x_L, Number* x_L_orig,
206  const Vector& x_U, Number* x_U_orig);
208 
209  private:
219  TNLPAdapter(const TNLPAdapter&);
220 
222  void operator=(const TNLPAdapter&);
224 
228  const Index* x_not_fixed_map,
229  const Number* x_l, const Number* x_u,
230  const Number* g_l, const Number* g_u,
231  Index n_c, const Index* c_map,
232  std::list<Index>& c_deps);
233 
237 
240 
244 
253  /* Determines relaxation of fixing bound for RELAX_BOUNDS. */
255  /* Maximal slack for one-sidedly bounded variables. If a
256  * variable has only one bound, say a lower bound xL, then an
257  * upper bound xL + max_onesided_bound_slack_. If this value is
258  * zero, no upper bound is added. */
259  /* Took this out: Number max_onesided_bound_slack_; */
289 
293 
316 
319 
337 
346 
355 
358  bool update_local_x(const Vector& x);
359  bool update_local_lambda(const Vector& y_c, const Vector& y_d);
361 
365  bool internal_eval_g(bool new_x);
366  bool internal_eval_jac_g(bool new_x);
368 
373  void initialize_findiff_jac(const Index* iRow, const Index* jCol);
375 
382 
386 
390 
394 
398 
401 
405 
423  };
424 
425 } // namespace Ipopt
426 
427 #endif