- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.5.1/Ipopt/src/Interfaces/IpTNLPAdapter.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: IpTNLPAdapter.hpp 1210 2008-04-05 03:01:56Z andreasw $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    00008
    00009 #ifndef __IPTNLPADAPTER_HPP__
    00010 #define __IPTNLPADAPTER_HPP__
    00011
    00012 #include "IpNLP.hpp"
    00013 #include "IpTNLP.hpp"
    00014 #include "IpOrigIpoptNLP.hpp"
    00015 #include <list>
    00016
    00017 namespace Ipopt
    00018 {
    00019
    00020   // forward declarations
    00021   class ExpansionMatrix;
    00022   class ExpansionMatrixSpace;
    00023   class IteratesVector;
    00024   class TDependencyDetector;
    00025
    00030   class TNLPAdapter : public NLP
    00031   {
    00032   public:
    00036     TNLPAdapter(const SmartPtr<TNLP> tnlp,
    00037                 const SmartPtr<const Journalist> jnlst = NULL);
    00038
    00040     virtual ~TNLPAdapter();
    00042
    00045     DECLARE_STD_EXCEPTION(INVALID_TNLP);
    00046     DECLARE_STD_EXCEPTION(ERROR_IN_TNLP_DERIVATIVE_TEST);
    00048
    00051     virtual bool ProcessOptions(const OptionsList& options,
    00052                                 const std::string& prefix);
    00053
    00056     virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space,
    00057                            SmartPtr<const VectorSpace>& c_space,
    00058                            SmartPtr<const VectorSpace>& d_space,
    00059                            SmartPtr<const VectorSpace>& x_l_space,
    00060                            SmartPtr<const MatrixSpace>& px_l_space,
    00061                            SmartPtr<const VectorSpace>& x_u_space,
    00062                            SmartPtr<const MatrixSpace>& px_u_space,
    00063                            SmartPtr<const VectorSpace>& d_l_space,
    00064                            SmartPtr<const MatrixSpace>& pd_l_space,
    00065                            SmartPtr<const VectorSpace>& d_u_space,
    00066                            SmartPtr<const MatrixSpace>& pd_u_space,
    00067                            SmartPtr<const MatrixSpace>& Jac_c_space,
    00068                            SmartPtr<const MatrixSpace>& Jac_d_space,
    00069                            SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space);
    00070
    00072     virtual bool GetBoundsInformation(const Matrix& Px_L,
    00073                                       Vector& x_L,
    00074                                       const Matrix& Px_U,
    00075                                       Vector& x_U,
    00076                                       const Matrix& Pd_L,
    00077                                       Vector& d_L,
    00078                                       const Matrix& Pd_U,
    00079                                       Vector& d_U);
    00080
    00083     virtual bool GetStartingPoint(
    00084       SmartPtr<Vector> x,
    00085       bool need_x,
    00086       SmartPtr<Vector> y_c,
    00087       bool need_y_c,
    00088       SmartPtr<Vector> y_d,
    00089       bool need_y_d,
    00090       SmartPtr<Vector> z_L,
    00091       bool need_z_L,
    00092       SmartPtr<Vector> z_U,
    00093       bool need_z_U
    00094     );
    00095
    00098     virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate);
    00100
    00103     virtual bool Eval_f(const Vector& x, Number& f);
    00104
    00105     virtual bool Eval_grad_f(const Vector& x, Vector& g_f);
    00106
    00107     virtual bool Eval_c(const Vector& x, Vector& c);
    00108
    00109     virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c);
    00110
    00111     virtual bool Eval_d(const Vector& x, Vector& d);
    00112
    00113     virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d);
    00114
    00115     virtual bool Eval_h(const Vector& x,
    00116                         Number obj_factor,
    00117                         const Vector& yc,
    00118                         const Vector& yd,
    00119                         SymMatrix& h);
    00120
    00121     virtual void GetScalingParameters(
    00122       const SmartPtr<const VectorSpace> x_space,
    00123       const SmartPtr<const VectorSpace> c_space,
    00124       const SmartPtr<const VectorSpace> d_space,
    00125       Number& obj_scaling,
    00126       SmartPtr<Vector>& x_scaling,
    00127       SmartPtr<Vector>& c_scaling,
    00128       SmartPtr<Vector>& d_scaling) const;
    00130
    00133     virtual void FinalizeSolution(SolverReturn status,
    00134                                   const Vector& x,
    00135                                   const Vector& z_L, const Vector& z_U,
    00136                                   const Vector& c, const Vector& d,
    00137                                   const Vector& y_c, const Vector& y_d,
    00138                                   Number obj_value,
    00139                                   const IpoptData* ip_data,
    00140                                   IpoptCalculatedQuantities* ip_cq);
    00141
    00142     virtual bool IntermediateCallBack(AlgorithmMode mode,
    00143                                       Index iter, Number obj_value,
    00144                                       Number inf_pr, Number inf_du,
    00145                                       Number mu, Number d_norm,
    00146                                       Number regularization_size,
    00147                                       Number alpha_du, Number alpha_pr,
    00148                                       Index ls_trials,
    00149                                       const IpoptData* ip_data,
    00150                                       IpoptCalculatedQuantities* ip_cq);
    00152
    00154     virtual void
    00155     GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space,
    00156                                       SmartPtr<Matrix>& P_approx);
    00157
    00159     enum FixedVariableTreatmentEnum
    00160     {
    00161       MAKE_PARAMETER=0,
    00162       MAKE_CONSTRAINT,
    00163       RELAX_BOUNDS
    00164     };
    00165
    00167     enum DerivativeTestEnum
    00168     {
    00169       NO_TEST=0,
    00170       FIRST_ORDER_TEST,
    00171       SECOND_ORDER_TEST
    00172     };
    00173
    00175     enum JacobianApproxEnum
    00176     {
    00177       JAC_EXACT=0,
    00178       JAC_FINDIFF_VALUES
    00179     };
    00180
    00182     bool CheckDerivatives(DerivativeTestEnum deriv_test);
    00183
    00186     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
    00188
    00190     SmartPtr<TNLP> tnlp() const
    00191     {
    00192       return tnlp_;
    00193     }
    00194
    00201     void ResortX(const Vector& x, Number* x_orig);
    00202     void ResortG(const Vector& c, const Vector& d, Number *g_orig);
    00203     void ResortBnds(const Vector& x_L, Number* x_L_orig,
    00204                     const Vector& x_U, Number* x_U_orig);
    00206
    00207   private:
    00217     TNLPAdapter(const TNLPAdapter&);
    00218
    00220     void operator=(const TNLPAdapter&);
    00222
    00225     bool DetermineDependentConstraints(Index n_x_var,
    00226                                        const Index* x_not_fixed_map,
    00227                                        const Number* x_l, const Number* x_u,
    00228                                        const Number* g_l, const Number* g_u,
    00229                                        Index n_c, const Index* c_map,
    00230                                        std::list<Index>& c_deps);
    00231
    00234     SmartPtr<TNLP> tnlp_;
    00235
    00237     SmartPtr<const Journalist> jnlst_;
    00238
    00241     SmartPtr<TDependencyDetector> dependency_detector_;
    00242
    00246     Number nlp_lower_bound_inf_;
    00248     Number nlp_upper_bound_inf_;
    00250     FixedVariableTreatmentEnum fixed_variable_treatment_;
    00251     /* Determines relaxation of fixing bound for RELAX_BOUNDS. */
    00252     Number bound_relax_factor_;
    00253     /* Maximal slack for one-sidedly bounded variables.  If a
    00254      *  variable has only one bound, say a lower bound xL, then an
    00255      *  upper bound xL + max_onesided_bound_slack_.  If this value is
    00256      *  zero, no upper bound is added. */
    00257     /* Took this out:  Number max_onesided_bound_slack_; */
    00260     DerivativeTestEnum derivative_test_;
    00262     Number derivative_test_perturbation_;
    00265     Number derivative_test_tol_;
    00268     bool derivative_test_print_all_;
    00271     bool warm_start_same_structure_;
    00273     HessianApproximationType hessian_approximation_;
    00275     Index num_linear_variables_;
    00277     JacobianApproxEnum jacobian_approximation_;
    00279     Number findiff_perturbation_;
    00281     Number point_perturbation_radius_;
    00284     bool dependency_detection_with_rhs_;
    00285
    00287     Number tol_;
    00289
    00293     Index n_full_x_;
    00295     Index n_full_g_;
    00297     Index nz_jac_c_;
    00300     Index nz_jac_c_no_extra_;
    00302     Index nz_jac_d_;
    00304     Index nz_full_jac_g_;
    00306     Index nz_full_h_;
    00308     Index nz_h_;
    00310     Index n_x_fixed_;
    00312
    00314     TNLP::IndexStyleEnum index_style_;
    00315
    00318     SmartPtr<const VectorSpace> x_space_;
    00319     SmartPtr<const VectorSpace> c_space_;
    00320     SmartPtr<const VectorSpace> d_space_;
    00321     SmartPtr<const VectorSpace> x_l_space_;
    00322     SmartPtr<const MatrixSpace> px_l_space_;
    00323     SmartPtr<const VectorSpace> x_u_space_;
    00324     SmartPtr<const MatrixSpace> px_u_space_;
    00325     SmartPtr<const VectorSpace> d_l_space_;
    00326     SmartPtr<const MatrixSpace> pd_l_space_;
    00327     SmartPtr<const VectorSpace> d_u_space_;
    00328     SmartPtr<const MatrixSpace> pd_u_space_;
    00329     SmartPtr<const MatrixSpace> Jac_c_space_;
    00330     SmartPtr<const MatrixSpace> Jac_d_space_;
    00331     SmartPtr<const SymMatrixSpace> Hess_lagrangian_space_;
    00333
    00336     Number* full_x_;
    00337     Number* full_lambda_;
    00338     Number* full_g_;
    00339     Number* jac_g_;
    00340     Number* c_rhs_;
    00342
    00345     TaggedObject::Tag x_tag_for_iterates_;
    00346     TaggedObject::Tag y_c_tag_for_iterates_;
    00347     TaggedObject::Tag y_d_tag_for_iterates_;
    00348     TaggedObject::Tag x_tag_for_g_;
    00349     TaggedObject::Tag x_tag_for_jac_g_;
    00351
    00354     bool update_local_x(const Vector& x);
    00355     bool update_local_lambda(const Vector& y_c, const Vector& y_d);
    00357
    00361     bool internal_eval_g(bool new_x);
    00362     bool internal_eval_jac_g(bool new_x);
    00364
    00369     void initialize_findiff_jac(const Index* iRow, const Index* jCol);
    00371
    00376     SmartPtr<ExpansionMatrix> P_x_full_x_;
    00377     SmartPtr<ExpansionMatrixSpace> P_x_full_x_space_;
    00378
    00380     SmartPtr<ExpansionMatrix> P_x_x_L_;
    00381     SmartPtr<ExpansionMatrixSpace> P_x_x_L_space_;
    00382
    00384     SmartPtr<ExpansionMatrix> P_x_x_U_;
    00385     SmartPtr<ExpansionMatrixSpace> P_x_x_U_space_;
    00386
    00388     SmartPtr<ExpansionMatrixSpace> P_c_g_space_;
    00389     SmartPtr<ExpansionMatrix> P_c_g_;
    00390
    00392     SmartPtr<ExpansionMatrixSpace> P_d_g_space_;
    00393     SmartPtr<ExpansionMatrix> P_d_g_;
    00394
    00395     Index* jac_idx_map_;
    00396     Index* h_idx_map_;
    00397
    00399     Index* x_fixed_map_;
    00401
    00405     Index findiff_jac_nnz_;
    00408     Index* findiff_jac_ia_;
    00411     Index* findiff_jac_ja_;
    00413     Index* findiff_jac_postriplet_;
    00415     Number* findiff_x_l_;
    00417     Number* findiff_x_u_;
    00419   };
    00420
    00421 } // namespace Ipopt
    00422
    00423 #endif