- Main Page
- Classes
- Files

- File List
- File Members

# src/Algorithm/IpOrigIpoptNLP.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2010 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Eclipse Public License.
    00004 //
    00005 // $Id: IpOrigIpoptNLP.hpp 2160 2012-12-26 19:14:42Z stefan $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    00008
    00009 #ifndef __IPORIGIPOPTNLP_HPP__
    00010 #define __IPORIGIPOPTNLP_HPP__
    00011
    00012 #include "IpIpoptNLP.hpp"
    00013 #include "IpException.hpp"
    00014 #include "IpTimingStatistics.hpp"
    00015
    00016 namespace Ipopt
    00017 {
    00018
    00020   enum HessianApproximationType {
    00021     EXACT=0,
    00022     LIMITED_MEMORY
    00023   };
    00024
    00026   enum HessianApproximationSpace {
    00027     NONLINEAR_VARS=0,
    00028     ALL_VARS
    00029   };
    00030
    00037   class OrigIpoptNLP : public IpoptNLP
    00038   {
    00039   public:
    00042     OrigIpoptNLP(const SmartPtr<const Journalist>& jnlst,
    00043                  const SmartPtr<NLP>& nlp,
    00044                  const SmartPtr<NLPScalingObject>& nlp_scaling);
    00045
    00047     virtual ~OrigIpoptNLP();
    00049
    00051     virtual bool Initialize(const Journalist& jnlst,
    00052                             const OptionsList& options,
    00053                             const std::string& prefix);
    00054
    00057     virtual bool InitializeStructures(SmartPtr<Vector>& x,
    00058                                       bool init_x,
    00059                                       SmartPtr<Vector>& y_c,
    00060                                       bool init_y_c,
    00061                                       SmartPtr<Vector>& y_d,
    00062                                       bool init_y_d,
    00063                                       SmartPtr<Vector>& z_L,
    00064                                       bool init_z_L,
    00065                                       SmartPtr<Vector>& z_U,
    00066                                       bool init_z_U,
    00067                                       SmartPtr<Vector>& v_L,
    00068                                       SmartPtr<Vector>& v_U
    00069                                      );
    00070
    00072     virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)
    00073     {
    00074       return nlp_->GetWarmStartIterate(warm_start_iterate);
    00075     }
    00079     virtual Number f(const Vector& x);
    00080
    00083     virtual Number f(const Vector& x, Number mu);
    00084
    00086     virtual SmartPtr<const Vector> grad_f(const Vector& x);
    00087
    00090     virtual SmartPtr<const Vector> grad_f(const Vector& x, Number mu);
    00091
    00093     virtual SmartPtr<const Vector> c(const Vector& x);
    00094
    00096     virtual SmartPtr<const Matrix> jac_c(const Vector& x);
    00097
    00100     virtual SmartPtr<const Vector> d(const Vector& x);
    00101
    00103     virtual SmartPtr<const Matrix> jac_d(const Vector& x);
    00104
    00106     virtual SmartPtr<const SymMatrix> h(const Vector& x,
    00107                                         Number obj_factor,
    00108                                         const Vector& yc,
    00109                                         const Vector& yd
    00110                                        );
    00111
    00114     virtual SmartPtr<const SymMatrix> h(const Vector& x,
    00115                                         Number obj_factor,
    00116                                         const Vector& yc,
    00117                                         const Vector& yd,
    00118                                         Number mu);
    00119
    00123     virtual SmartPtr<const SymMatrix> uninitialized_h();
    00124
    00126     virtual SmartPtr<const Vector> x_L() const
    00127     {
    00128       return x_L_;
    00129     }
    00130
    00132     virtual SmartPtr<const Matrix> Px_L() const
    00133     {
    00134       return Px_L_;
    00135     }
    00136
    00138     virtual SmartPtr<const Vector> x_U() const
    00139     {
    00140       return x_U_;
    00141     }
    00142
    00144     virtual SmartPtr<const Matrix> Px_U() const
    00145     {
    00146       return Px_U_;
    00147     }
    00148
    00150     virtual SmartPtr<const Vector> d_L() const
    00151     {
    00152       return d_L_;
    00153     }
    00154
    00156     virtual SmartPtr<const Matrix> Pd_L() const
    00157     {
    00158       return Pd_L_;
    00159     }
    00160
    00162     virtual SmartPtr<const Vector> d_U() const
    00163     {
    00164       return d_U_;
    00165     }
    00166
    00168     virtual SmartPtr<const Matrix> Pd_U() const
    00169     {
    00170       return Pd_U_;
    00171     }
    00172
    00173     virtual SmartPtr<const SymMatrixSpace> HessianMatrixSpace() const
    00174     {
    00175       return h_space_;
    00176     }
    00178
    00180     virtual void GetSpaces(SmartPtr<const VectorSpace>& x_space,
    00181                            SmartPtr<const VectorSpace>& c_space,
    00182                            SmartPtr<const VectorSpace>& d_space,
    00183                            SmartPtr<const VectorSpace>& x_l_space,
    00184                            SmartPtr<const MatrixSpace>& px_l_space,
    00185                            SmartPtr<const VectorSpace>& x_u_space,
    00186                            SmartPtr<const MatrixSpace>& px_u_space,
    00187                            SmartPtr<const VectorSpace>& d_l_space,
    00188                            SmartPtr<const MatrixSpace>& pd_l_space,
    00189                            SmartPtr<const VectorSpace>& d_u_space,
    00190                            SmartPtr<const MatrixSpace>& pd_u_space,
    00191                            SmartPtr<const MatrixSpace>& Jac_c_space,
    00192                            SmartPtr<const MatrixSpace>& Jac_d_space,
    00193                            SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space);
    00194
    00197     virtual void AdjustVariableBounds(const Vector& new_x_L,
    00198                                       const Vector& new_x_U,
    00199                                       const Vector& new_d_L,
    00200                                       const Vector& new_d_U);
    00201
    00204     virtual Index f_evals() const
    00205     {
    00206       return f_evals_;
    00207     }
    00208     virtual Index grad_f_evals() const
    00209     {
    00210       return grad_f_evals_;
    00211     }
    00212     virtual Index c_evals() const
    00213     {
    00214       return c_evals_;
    00215     }
    00216     virtual Index jac_c_evals() const
    00217     {
    00218       return jac_c_evals_;
    00219     }
    00220     virtual Index d_evals() const
    00221     {
    00222       return d_evals_;
    00223     }
    00224     virtual Index jac_d_evals() const
    00225     {
    00226       return jac_d_evals_;
    00227     }
    00228     virtual Index h_evals() const
    00229     {
    00230       return h_evals_;
    00231     }
    00233
    00236     void FinalizeSolution(SolverReturn status,
    00237                           const Vector& x, const Vector& z_L, const Vector& z_U,
    00238                           const Vector& c, const Vector& d,
    00239                           const Vector& y_c, const Vector& y_d,
    00240                           Number obj_value,
    00241                           const IpoptData* ip_data,
    00242                           IpoptCalculatedQuantities* ip_cq);
    00243     bool IntermediateCallBack(AlgorithmMode mode,
    00244                               Index iter, Number obj_value,
    00245                               Number inf_pr, Number inf_du,
    00246                               Number mu, Number d_norm,
    00247                               Number regularization_size,
    00248                               Number alpha_du, Number alpha_pr,
    00249                               Index ls_trials,
    00250                               SmartPtr<const IpoptData> ip_data,
    00251                               SmartPtr<IpoptCalculatedQuantities> ip_cq);
    00253
    00257     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
    00259
    00261     SmartPtr<NLP> nlp()
    00262     {
    00263       return nlp_;
    00264     }
    00265
    00268
    00270     void ResetTimes();
    00271
    00272     void PrintTimingStatistics(Journalist& jnlst,
    00273                                EJournalLevel level,
    00274                                EJournalCategory category) const;
    00275
    00276     const TimedTask& f_eval_time() const
    00277     {
    00278       return f_eval_time_;
    00279     }
    00280     const TimedTask& grad_f_eval_time() const
    00281     {
    00282       return grad_f_eval_time_;
    00283     }
    00284     const TimedTask& c_eval_time() const
    00285     {
    00286       return c_eval_time_;
    00287     }
    00288     const TimedTask& jac_c_eval_time() const
    00289     {
    00290       return jac_c_eval_time_;
    00291     }
    00292     const TimedTask& d_eval_time() const
    00293     {
    00294       return d_eval_time_;
    00295     }
    00296     const TimedTask& jac_d_eval_time() const
    00297     {
    00298       return jac_d_eval_time_;
    00299     }
    00300     const TimedTask& h_eval_time() const
    00301     {
    00302       return h_eval_time_;
    00303     }
    00304
    00305     Number TotalFunctionEvaluationCpuTime() const;
    00306     Number TotalFunctionEvaluationSysTime() const;
    00307     Number TotalFunctionEvaluationWallclockTime() const;
    00309
    00310   private:
    00312     SmartPtr<const Journalist> jnlst_;
    00313
    00315     SmartPtr<NLP> nlp_;
    00316
    00319     SmartPtr<const VectorSpace> x_space_;
    00320     SmartPtr<const VectorSpace> c_space_;
    00321     SmartPtr<const VectorSpace> d_space_;
    00322     SmartPtr<const VectorSpace> x_l_space_;
    00323     SmartPtr<const MatrixSpace> px_l_space_;
    00324     SmartPtr<const VectorSpace> x_u_space_;
    00325     SmartPtr<const MatrixSpace> px_u_space_;
    00326     SmartPtr<const VectorSpace> d_l_space_;
    00327     SmartPtr<const MatrixSpace> pd_l_space_;
    00328     SmartPtr<const VectorSpace> d_u_space_;
    00329     SmartPtr<const MatrixSpace> pd_u_space_;
    00330     SmartPtr<const MatrixSpace> jac_c_space_;
    00331     SmartPtr<const MatrixSpace> jac_d_space_;
    00332     SmartPtr<const SymMatrixSpace> h_space_;
    00333
    00334     SmartPtr<const MatrixSpace> scaled_jac_c_space_;
    00335     SmartPtr<const MatrixSpace> scaled_jac_d_space_;
    00336     SmartPtr<const SymMatrixSpace> scaled_h_space_;
    00338
    00341     CachedResults<Number> f_cache_;
    00342
    00344     CachedResults<SmartPtr<const Vector> > grad_f_cache_;
    00345
    00347     CachedResults<SmartPtr<const Vector> > c_cache_;
    00348
    00351     CachedResults<SmartPtr<const Matrix> > jac_c_cache_;
    00352
    00355     CachedResults<SmartPtr<const Vector> > d_cache_;
    00356
    00359     CachedResults<SmartPtr<const Matrix> > jac_d_cache_;
    00360
    00363     CachedResults<SmartPtr<const SymMatrix> > h_cache_;
    00364
    00366     CachedResults<SmartPtr<const Vector> > unscaled_x_cache_;
    00367
    00369     SmartPtr<const Vector> x_L_;
    00370
    00372     SmartPtr<const Matrix> Px_L_;
    00373
    00375     SmartPtr<const Vector> x_U_;
    00376
    00378     SmartPtr<const Matrix> Px_U_;
    00379
    00381     SmartPtr<const Vector> d_L_;
    00382
    00384     SmartPtr<const Matrix> Pd_L_;
    00385
    00387     SmartPtr<const Vector> d_U_;
    00388
    00390     SmartPtr<const Matrix> Pd_U_;
    00391
    00393     SmartPtr<const Vector> orig_x_L_;
    00394
    00396     SmartPtr<const Vector> orig_x_U_;
    00398
    00408     OrigIpoptNLP();
    00409
    00411     OrigIpoptNLP(const OrigIpoptNLP&);
    00412
    00414     void operator=(const OrigIpoptNLP&);
    00416
    00423     void relax_bounds(Number bound_relax_factor, Vector& bounds);
    00425     SmartPtr<const Vector> get_unscaled_x(const Vector& x);
    00427
    00431     Number bound_relax_factor_;
    00434     bool honor_original_bounds_;
    00437     bool warm_start_same_structure_;
    00439     HessianApproximationType hessian_approximation_;
    00441     HessianApproximationSpace hessian_approximation_space_;
    00444     bool check_derivatives_for_naninf_;
    00447     bool jac_c_constant_;
    00450     bool jac_d_constant_;
    00452     bool hessian_constant_;
    00454
    00457     Index f_evals_;
    00458     Index grad_f_evals_;
    00459     Index c_evals_;
    00460     Index jac_c_evals_;
    00461     Index d_evals_;
    00462     Index jac_d_evals_;
    00463     Index h_evals_;
    00465
    00467     bool initialized_;
    00468
    00471     TimedTask f_eval_time_;
    00472     TimedTask grad_f_eval_time_;
    00473     TimedTask c_eval_time_;
    00474     TimedTask jac_c_eval_time_;
    00475     TimedTask d_eval_time_;
    00476     TimedTask jac_d_eval_time_;
    00477     TimedTask h_eval_time_;
    00479   };
    00480
    00481 } // namespace Ipopt
    00482
    00483 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines