/home/coin/SVN-release/Ipopt-3.3.2/Ipopt/src/Interfaces/IpTNLPAdapter.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2004, 2007 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpTNLPAdapter.hpp 1020 2007-06-24 04:06:59Z 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     bool CheckDerivatives(DerivativeTestEnum deriv_test);
00176 
00179     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
00181 
00183     SmartPtr<TNLP> tnlp() const
00184     {
00185       return tnlp_;
00186     }
00187 
00188   private:
00198     TNLPAdapter(const TNLPAdapter&);
00199 
00201     void operator=(const TNLPAdapter&);
00203 
00210     void ResortX(const Vector& x, Number* x_orig);
00211     void ResortG(const Vector& c, const Vector& d, Number *g_orig);
00212     void ResortBnds(const Vector& x_L, Number* x_L_orig,
00213                     const Vector& x_U, Number* x_U_orig);
00215 
00218     bool DetermineDependentConstraints(Index n_x_var,
00219                                        const Index* x_not_fixed_map,
00220                                        const Number* x_l, const Number* x_u,
00221                                        const Number* g_l, const Number* g_u,
00222                                        Index n_c, const Index* c_map,
00223                                        std::list<Index>& c_deps);
00224 
00227     SmartPtr<TNLP> tnlp_;
00228 
00230     SmartPtr<const Journalist> jnlst_;
00231 
00234     SmartPtr<TDependencyDetector> dependency_detector_;
00235 
00239     Number nlp_lower_bound_inf_;
00241     Number nlp_upper_bound_inf_;
00243     FixedVariableTreatmentEnum fixed_variable_treatment_;
00244     /* Determines relaxation of fixing bound for RELAX_BOUNDS. */
00245     Number bound_relax_factor_;
00246     /* Maximal slack for one-sidedly bounded variables.  If a
00247      *  variable has only one bound, say a lower bound xL, then an
00248      *  upper bound xL + max_onesided_bound_slack_.  If this value is
00249      *  zero, no upper bound is added. */
00250     /* Took this out:  Number max_onesided_bound_slack_; */
00253     DerivativeTestEnum derivative_test_;
00255     Number derivative_test_perturbation_;
00258     Number derivative_test_tol_;
00261     bool derivative_test_print_all_;
00264     bool warm_start_same_structure_;
00266     HessianApproximationType hessian_approximation_;
00268     Number point_perturbation_radius_;
00271     bool dependency_detection_with_rhs_;
00272 
00274     Number tol_;
00276 
00280     Index n_full_x_;
00282     Index n_full_g_;
00284     Index nz_jac_c_;
00287     Index nz_jac_c_no_extra_;
00289     Index nz_jac_d_;
00291     Index nz_full_jac_g_;
00293     Index nz_full_h_;
00295     Index nz_h_;
00297     Index n_x_fixed_;
00299 
00301     TNLP::IndexStyleEnum index_style_;
00302 
00305     SmartPtr<const VectorSpace> x_space_;
00306     SmartPtr<const VectorSpace> c_space_;
00307     SmartPtr<const VectorSpace> d_space_;
00308     SmartPtr<const VectorSpace> x_l_space_;
00309     SmartPtr<const MatrixSpace> px_l_space_;
00310     SmartPtr<const VectorSpace> x_u_space_;
00311     SmartPtr<const MatrixSpace> px_u_space_;
00312     SmartPtr<const VectorSpace> d_l_space_;
00313     SmartPtr<const MatrixSpace> pd_l_space_;
00314     SmartPtr<const VectorSpace> d_u_space_;
00315     SmartPtr<const MatrixSpace> pd_u_space_;
00316     SmartPtr<const MatrixSpace> Jac_c_space_;
00317     SmartPtr<const MatrixSpace> Jac_d_space_;
00318     SmartPtr<const SymMatrixSpace> Hess_lagrangian_space_;
00320 
00323     Number* full_x_; 
00324     Number* full_lambda_; 
00325     Number* full_g_; 
00326     Number* jac_g_; 
00327     Number* c_rhs_; 
00329 
00332     TaggedObject::Tag x_tag_for_iterates_;
00333     TaggedObject::Tag y_c_tag_for_iterates_;
00334     TaggedObject::Tag y_d_tag_for_iterates_;
00335     TaggedObject::Tag x_tag_for_g_;
00336     TaggedObject::Tag x_tag_for_jac_g_;
00338 
00341     bool update_local_x(const Vector& x);
00342     bool update_local_lambda(const Vector& y_c, const Vector& y_d);
00344 
00348     bool internal_eval_g(bool new_x);
00349     bool internal_eval_jac_g(bool new_x);
00351 
00356     SmartPtr<ExpansionMatrix> P_x_full_x_;
00357     SmartPtr<ExpansionMatrixSpace> P_x_full_x_space_;
00358 
00360     SmartPtr<ExpansionMatrix> P_x_x_L_;
00361     SmartPtr<ExpansionMatrixSpace> P_x_x_L_space_;
00362 
00364     SmartPtr<ExpansionMatrix> P_x_x_U_;
00365     SmartPtr<ExpansionMatrixSpace> P_x_x_U_space_;
00366 
00368     SmartPtr<ExpansionMatrixSpace> P_c_g_space_;
00369     SmartPtr<ExpansionMatrix> P_c_g_;
00370 
00372     SmartPtr<ExpansionMatrixSpace> P_d_g_space_;
00373     SmartPtr<ExpansionMatrix> P_d_g_;
00374 
00375     Index* jac_idx_map_;
00376     Index* h_idx_map_;
00377 
00379     Index* x_fixed_map_;
00381   };
00382 
00383 } // namespace Ipopt
00384 
00385 #endif

Generated on Thu May 15 22:27:52 2008 by  doxygen 1.4.7