- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2006 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpTNLPAdapter.hpp 759 2006-07-07 03:07:08Z 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
    00016 namespace Ipopt
    00017 {
    00018
    00019   // forward declarations
    00020   class ExpansionMatrix;
    00021   class ExpansionMatrixSpace;
    00022   class IteratesVector;
    00023
    00028   class TNLPAdapter : public NLP
    00029   {
    00030   public:
    00034     TNLPAdapter(const SmartPtr<TNLP> tnlp,
    00035                 const SmartPtr<const Journalist> jnlst = NULL);
    00036
    00038     virtual ~TNLPAdapter();
    00040
    00043     DECLARE_STD_EXCEPTION(INVALID_TNLP);
    00044     DECLARE_STD_EXCEPTION(ERROR_IN_TNLP_DERIVATIVE_TEST);
    00046
    00049     virtual bool ProcessOptions(const OptionsList& options,
    00050                                 const std::string& prefix);
    00051
    00054     virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space,
    00055                            SmartPtr<const VectorSpace>& c_space,
    00056                            SmartPtr<const VectorSpace>& d_space,
    00057                            SmartPtr<const VectorSpace>& x_l_space,
    00058                            SmartPtr<const MatrixSpace>& px_l_space,
    00059                            SmartPtr<const VectorSpace>& x_u_space,
    00060                            SmartPtr<const MatrixSpace>& px_u_space,
    00061                            SmartPtr<const VectorSpace>& d_l_space,
    00062                            SmartPtr<const MatrixSpace>& pd_l_space,
    00063                            SmartPtr<const VectorSpace>& d_u_space,
    00064                            SmartPtr<const MatrixSpace>& pd_u_space,
    00065                            SmartPtr<const MatrixSpace>& Jac_c_space,
    00066                            SmartPtr<const MatrixSpace>& Jac_d_space,
    00067                            SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space);
    00068
    00070     virtual bool GetBoundsInformation(const Matrix& Px_L,
    00071                                       Vector& x_L,
    00072                                       const Matrix& Px_U,
    00073                                       Vector& x_U,
    00074                                       const Matrix& Pd_L,
    00075                                       Vector& d_L,
    00076                                       const Matrix& Pd_U,
    00077                                       Vector& d_U);
    00078
    00081     virtual bool GetStartingPoint(
    00082       SmartPtr<Vector> x,
    00083       bool need_x,
    00084       SmartPtr<Vector> y_c,
    00085       bool need_y_c,
    00086       SmartPtr<Vector> y_d,
    00087       bool need_y_d,
    00088       SmartPtr<Vector> z_L,
    00089       bool need_z_L,
    00090       SmartPtr<Vector> z_U,
    00091       bool need_z_U
    00092     );
    00093
    00096     virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate);
    00098
    00101     virtual bool Eval_f(const Vector& x, Number& f);
    00102
    00103     virtual bool Eval_grad_f(const Vector& x, Vector& g_f);
    00104
    00105     virtual bool Eval_c(const Vector& x, Vector& c);
    00106
    00107     virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c);
    00108
    00109     virtual bool Eval_d(const Vector& x, Vector& d);
    00110
    00111     virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d);
    00112
    00113     virtual bool Eval_h(const Vector& x,
    00114                         Number obj_factor,
    00115                         const Vector& yc,
    00116                         const Vector& yd,
    00117                         SymMatrix& h);
    00118
    00119     virtual void GetScalingParameters(
    00120       const SmartPtr<const VectorSpace> x_space,
    00121       const SmartPtr<const VectorSpace> c_space,
    00122       const SmartPtr<const VectorSpace> d_space,
    00123       Number& obj_scaling,
    00124       SmartPtr<Vector>& x_scaling,
    00125       SmartPtr<Vector>& c_scaling,
    00126       SmartPtr<Vector>& d_scaling) const;
    00128
    00131     virtual void FinalizeSolution(SolverReturn status,
    00132                                   const Vector& x, const Vector& z_L, const Vector& z_U,
    00133                                   const Vector& c, const Vector& d,
    00134                                   const Vector& y_c, const Vector& y_d,
    00135                                   Number obj_value);
    00136     virtual bool IntermediateCallBack(AlgorithmMode mode,
    00137                                       Index iter, Number obj_value,
    00138                                       Number inf_pr, Number inf_du,
    00139                                       Number mu, Number d_norm,
    00140                                       Number regularization_size,
    00141                                       Number alpha_du, Number alpha_pr,
    00142                                       Index ls_trials,
    00143                                       const IpoptData* ip_data,
    00144                                       IpoptCalculatedQuantities* ip_cq);
    00146
    00148     virtual void
    00149     GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space,
    00150                                       SmartPtr<Matrix>& P_approx);
    00151
    00153     enum FixedVariableTreatmentEnum {
    00154       MAKE_PARAMETER=0,
    00155       MAKE_CONSTRAINT
    00156     };
    00157
    00159     enum DerivativeTestEnum {
    00160       NO_TEST=0,
    00161       FIRST_ORDER_TEST,
    00162       SECOND_ORDER_TEST
    00163     };
    00164
    00166     bool CheckDerivatives(DerivativeTestEnum deriv_test);
    00167
    00170     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
    00172
    00174     SmartPtr<TNLP> tnlp() const
    00175     {
    00176       return tnlp_;
    00177     }
    00178
    00179   private:
    00189     TNLPAdapter(const TNLPAdapter&);
    00190
    00192     void operator=(const TNLPAdapter&);
    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
    00209     SmartPtr<TNLP> tnlp_;
    00210
    00212     SmartPtr<const Journalist> jnlst_;
    00213
    00217     Number nlp_lower_bound_inf_;
    00219     Number nlp_upper_bound_inf_;
    00221     FixedVariableTreatmentEnum fixed_variable_treatment_;
    00222     /* Maximal slack for one-sidedly bounded variables.  If a
    00223      *  variable has only one bound, say a lower bound xL, then an
    00224      *  upper bound xL + max_onesided_bound_slack_.  If this value is
    00225      *  zero, no upper bound is added. */
    00226     /* Took this out:  Number max_onesided_bound_slack_; */
    00229     DerivativeTestEnum derivative_test_;
    00231     Number derivative_test_perturbation_;
    00234     Number derivative_test_tol_;
    00237     bool derivative_test_print_all_;
    00240     bool warm_start_same_structure_;
    00242     HessianApproximationType hessian_approximation_;
    00244
    00248     Index n_full_x_;
    00250     Index n_full_g_;
    00252     Index nz_jac_c_;
    00255     Index nz_jac_c_no_fixed_;
    00257     Index nz_jac_d_;
    00259     Index nz_full_jac_g_;
    00261     Index nz_full_h_;
    00263     Index nz_h_;
    00265     Index n_x_fixed_;
    00267
    00269     TNLP::IndexStyleEnum index_style_;
    00270
    00273     SmartPtr<const VectorSpace> x_space_;
    00274     SmartPtr<const VectorSpace> c_space_;
    00275     SmartPtr<const VectorSpace> d_space_;
    00276     SmartPtr<const VectorSpace> x_l_space_;
    00277     SmartPtr<const MatrixSpace> px_l_space_;
    00278     SmartPtr<const VectorSpace> x_u_space_;
    00279     SmartPtr<const MatrixSpace> px_u_space_;
    00280     SmartPtr<const VectorSpace> d_l_space_;
    00281     SmartPtr<const MatrixSpace> pd_l_space_;
    00282     SmartPtr<const VectorSpace> d_u_space_;
    00283     SmartPtr<const MatrixSpace> pd_u_space_;
    00284     SmartPtr<const MatrixSpace> Jac_c_space_;
    00285     SmartPtr<const MatrixSpace> Jac_d_space_;
    00286     SmartPtr<const SymMatrixSpace> Hess_lagrangian_space_;
    00288
    00291     Number* full_x_;
    00292     Number* full_lambda_;
    00293     Number* full_g_;
    00294     Number* jac_g_;
    00295     Number* c_rhs_;
    00297
    00300     TaggedObject::Tag x_tag_for_iterates_;
    00301     TaggedObject::Tag y_c_tag_for_iterates_;
    00302     TaggedObject::Tag y_d_tag_for_iterates_;
    00303     TaggedObject::Tag x_tag_for_g_;
    00304     TaggedObject::Tag x_tag_for_jac_g_;
    00306
    00309     bool update_local_x(const Vector& x);
    00310     bool update_local_lambda(const Vector& y_c, const Vector& y_d);
    00312
    00316     bool internal_eval_g(bool new_x);
    00317     bool internal_eval_jac_g(bool new_x);
    00319
    00324     SmartPtr<ExpansionMatrix> P_x_full_x_;
    00325     SmartPtr<ExpansionMatrixSpace> P_x_full_x_space_;
    00326
    00328     SmartPtr<ExpansionMatrix> P_x_x_L_;
    00329     SmartPtr<ExpansionMatrixSpace> P_x_x_L_space_;
    00330
    00332     SmartPtr<ExpansionMatrix> P_x_x_U_;
    00333     SmartPtr<ExpansionMatrixSpace> P_x_x_U_space_;
    00334
    00336     SmartPtr<ExpansionMatrixSpace> P_c_g_space_;
    00337     SmartPtr<ExpansionMatrix> P_c_g_;
    00338
    00340     SmartPtr<ExpansionMatrixSpace> P_d_g_space_;
    00341     SmartPtr<ExpansionMatrix> P_d_g_;
    00342
    00343     Index* jac_idx_map_;
    00344     Index* h_idx_map_;
    00345
    00347     Index* x_fixed_map_;
    00349   };
    00350
    00351 } // namespace Ipopt
    00352
    00353 #endif