- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.5.1/Ipopt/src/Algorithm/IpOrigIpoptNLP.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2008 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpOrigIpoptNLP.hpp 1173 2008-02-29 09:41:11Z andreasw $
    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
    00266     void PrintTimingStatistics(Journalist& jnlst,
    00267                                EJournalLevel level,
    00268                                EJournalCategory category) const;
    00269
    00270     Number TotalFunctionEvaluationCPUTime() const;
    00271
    00272   private:
    00274     SmartPtr<const Journalist> jnlst_;
    00275
    00277     SmartPtr<NLP> nlp_;
    00278
    00281     SmartPtr<const VectorSpace> x_space_;
    00282     SmartPtr<const VectorSpace> c_space_;
    00283     SmartPtr<const VectorSpace> d_space_;
    00284     SmartPtr<const VectorSpace> x_l_space_;
    00285     SmartPtr<const MatrixSpace> px_l_space_;
    00286     SmartPtr<const VectorSpace> x_u_space_;
    00287     SmartPtr<const MatrixSpace> px_u_space_;
    00288     SmartPtr<const VectorSpace> d_l_space_;
    00289     SmartPtr<const MatrixSpace> pd_l_space_;
    00290     SmartPtr<const VectorSpace> d_u_space_;
    00291     SmartPtr<const MatrixSpace> pd_u_space_;
    00292     SmartPtr<const MatrixSpace> jac_c_space_;
    00293     SmartPtr<const MatrixSpace> jac_d_space_;
    00294     SmartPtr<const SymMatrixSpace> h_space_;
    00295
    00296     SmartPtr<const MatrixSpace> scaled_jac_c_space_;
    00297     SmartPtr<const MatrixSpace> scaled_jac_d_space_;
    00298     SmartPtr<const SymMatrixSpace> scaled_h_space_;
    00300
    00303     CachedResults<Number> f_cache_;
    00304
    00306     CachedResults<SmartPtr<const Vector> > grad_f_cache_;
    00307
    00309     CachedResults<SmartPtr<const Vector> > c_cache_;
    00310
    00313     CachedResults<SmartPtr<const Matrix> > jac_c_cache_;
    00314
    00317     CachedResults<SmartPtr<const Vector> > d_cache_;
    00318
    00321     CachedResults<SmartPtr<const Matrix> > jac_d_cache_;
    00322
    00325     CachedResults<SmartPtr<const SymMatrix> > h_cache_;
    00326
    00328     CachedResults<SmartPtr<const Vector> > unscaled_x_cache_;
    00329
    00331     SmartPtr<const Vector> x_L_;
    00332
    00334     SmartPtr<const Matrix> Px_L_;
    00335
    00337     SmartPtr<const Vector> x_U_;
    00338
    00340     SmartPtr<const Matrix> Px_U_;
    00341
    00343     SmartPtr<const Vector> d_L_;
    00344
    00346     SmartPtr<const Matrix> Pd_L_;
    00347
    00349     SmartPtr<const Vector> d_U_;
    00350
    00352     SmartPtr<const Matrix> Pd_U_;
    00353
    00355     SmartPtr<const Vector> orig_x_L_;
    00356
    00358     SmartPtr<const Vector> orig_x_U_;
    00360
    00370     OrigIpoptNLP();
    00371
    00373     OrigIpoptNLP(const OrigIpoptNLP&);
    00374
    00376     void operator=(const OrigIpoptNLP&);
    00378
    00385     void relax_bounds(Number bound_relax_factor, Vector& bounds);
    00387     SmartPtr<const Vector> get_unscaled_x(const Vector& x);
    00389
    00393     Number bound_relax_factor_;
    00396     bool honor_original_bounds_;
    00399     bool warm_start_same_structure_;
    00401     HessianApproximationType hessian_approximation_;
    00403     HessianApproximationSpace hessian_approximation_space_;
    00406     bool check_derivatives_for_naninf_;
    00409     bool jac_c_constant_;
    00412     bool jac_d_constant_;
    00414     bool hessian_constant_;
    00416
    00419     Index f_evals_;
    00420     Index grad_f_evals_;
    00421     Index c_evals_;
    00422     Index jac_c_evals_;
    00423     Index d_evals_;
    00424     Index jac_d_evals_;
    00425     Index h_evals_;
    00427
    00429     bool initialized_;
    00430
    00433     TimedTask f_eval_time_;
    00434     TimedTask grad_f_eval_time_;
    00435     TimedTask c_eval_time_;
    00436     TimedTask jac_c_eval_time_;
    00437     TimedTask d_eval_time_;
    00438     TimedTask jac_d_eval_time_;
    00439     TimedTask h_eval_time_;
    00441   };
    00442
    00443 } // namespace Ipopt
    00444
    00445 #endif