# IpNLPScaling.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 Eclipse Public License.
    00004 //
    00005 // $Id: IpNLPScaling.hpp 2036 2011-07-02 17:21:08Z stefan $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    00008
    00009 #ifndef __IPNLPSCALING_HPP__
    00010 #define __IPNLPSCALING_HPP__
    00011
    00012 #include "IpOptionsList.hpp"
    00013 #include "IpRegOptions.hpp"
    00014
    00015 namespace Ipopt
    00016 {
    00017   // forward declarations
    00018   class Vector;
    00019   class VectorSpace;
    00020   class Matrix;
    00021   class MatrixSpace;
    00022   class SymMatrix;
    00023   class SymMatrixSpace;
    00024   class ScaledMatrixSpace;
    00025   class SymScaledMatrixSpace;
    00026
    00032   class NLPScalingObject : public ReferencedObject
    00033   {
    00034   public:
    00037     NLPScalingObject();
    00038
    00040     virtual ~NLPScalingObject();
    00042
    00044     bool Initialize(const Journalist& jnlst,
    00045                     const OptionsList& options,
    00046                     const std::string& prefix)
    00047     {
    00048       jnlst_ = &jnlst;
    00049       return InitializeImpl(options, prefix);
    00050     }
    00051
    00055     virtual Number apply_obj_scaling(const Number& f)=0;
    00057     virtual Number unapply_obj_scaling(const Number& f)=0;
    00059     virtual SmartPtr<Vector>
    00060     apply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v)=0;
    00062     virtual SmartPtr<const Vector>
    00063     apply_vector_scaling_x(const SmartPtr<const Vector>& v)=0;
    00065     virtual SmartPtr<Vector>
    00066     unapply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v)=0;
    00068     virtual SmartPtr<const Vector>
    00069     unapply_vector_scaling_x(const SmartPtr<const Vector>& v)=0;
    00071     virtual SmartPtr<const Vector>
    00072     apply_vector_scaling_c(const SmartPtr<const Vector>& v)=0;
    00074     virtual SmartPtr<const Vector>
    00075     unapply_vector_scaling_c(const SmartPtr<const Vector>& v)=0;
    00077     virtual SmartPtr<Vector>
    00078     apply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v)=0;
    00080     virtual SmartPtr<Vector>
    00081     unapply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v)=0;
    00083     virtual SmartPtr<const Vector>
    00084     apply_vector_scaling_d(const SmartPtr<const Vector>& v)=0;
    00086     virtual SmartPtr<const Vector>
    00087     unapply_vector_scaling_d(const SmartPtr<const Vector>& v)=0;
    00089     virtual SmartPtr<Vector>
    00090     apply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v)=0;
    00092     virtual SmartPtr<Vector>
    00093     unapply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v)=0;
    00098     virtual SmartPtr<const Matrix>
    00099     apply_jac_c_scaling(SmartPtr<const Matrix> matrix)=0;
    00104     virtual SmartPtr<const Matrix>
    00105     apply_jac_d_scaling(SmartPtr<const Matrix> matrix)=0;
    00110     virtual SmartPtr<const SymMatrix>
    00111     apply_hessian_scaling(SmartPtr<const SymMatrix> matrix)=0;
    00113
    00117     SmartPtr<Vector> apply_vector_scaling_x_LU_NonConst(
    00118       const Matrix& Px_LU,
    00119       const SmartPtr<const Vector>& lu,
    00120       const VectorSpace& x_space);
    00122     SmartPtr<const Vector> apply_vector_scaling_x_LU(
    00123       const Matrix& Px_LU,
    00124       const SmartPtr<const Vector>& lu,
    00125       const VectorSpace& x_space);
    00127     SmartPtr<Vector> apply_vector_scaling_d_LU_NonConst(
    00128       const Matrix& Pd_LU,
    00129       const SmartPtr<const Vector>& lu,
    00130       const VectorSpace& d_space);
    00132     SmartPtr<const Vector> apply_vector_scaling_d_LU(
    00133       const Matrix& Pd_LU,
    00134       const SmartPtr<const Vector>& lu,
    00135       const VectorSpace& d_space);
    00137     SmartPtr<Vector> unapply_vector_scaling_d_LU_NonConst(
    00138       const Matrix& Pd_LU,
    00139       const SmartPtr<const Vector>& lu,
    00140       const VectorSpace& d_space);
    00142     SmartPtr<const Vector> unapply_vector_scaling_d_LU(
    00143       const Matrix& Pd_LU,
    00144       const SmartPtr<const Vector>& lu,
    00145       const VectorSpace& d_space);
    00147
    00153     virtual SmartPtr<Vector>
    00154     apply_grad_obj_scaling_NonConst(const SmartPtr<const Vector>& v);
    00156     virtual SmartPtr<const Vector>
    00157     apply_grad_obj_scaling(const SmartPtr<const Vector>& v);
    00160     virtual SmartPtr<Vector>
    00161     unapply_grad_obj_scaling_NonConst(const SmartPtr<const Vector>& v);
    00164     virtual SmartPtr<const Vector>
    00165     unapply_grad_obj_scaling(const SmartPtr<const Vector>& v);
    00167
    00172     virtual bool have_x_scaling()=0;
    00174     virtual bool have_c_scaling()=0;
    00176     virtual bool have_d_scaling()=0;
    00178
    00182     virtual void DetermineScaling(const SmartPtr<const VectorSpace> x_space,
    00183                                   const SmartPtr<const VectorSpace> c_space,
    00184                                   const SmartPtr<const VectorSpace> d_space,
    00185                                   const SmartPtr<const MatrixSpace> jac_c_space,
    00186                                   const SmartPtr<const MatrixSpace> jac_d_space,
    00187                                   const SmartPtr<const SymMatrixSpace> h_space,
    00188                                   SmartPtr<const MatrixSpace>& new_jac_c_space,
    00189                                   SmartPtr<const MatrixSpace>& new_jac_d_space,
    00190                                   SmartPtr<const SymMatrixSpace>& new_h_space,
    00191                                   const Matrix& Px_L, const Vector& x_L,
    00192                                   const Matrix& Px_U, const Vector& x_U)=0;
    00193   protected:
    00196     virtual bool InitializeImpl(const OptionsList& options,
    00197                                 const std::string& prefix)=0;
    00198
    00200     const Journalist& Jnlst() const
    00201     {
    00202       return *jnlst_;
    00203     }
    00204   private:
    00205
    00214
    00216     NLPScalingObject(const NLPScalingObject&);
    00217
    00219     void operator=(const NLPScalingObject&);
    00221
    00222     SmartPtr<const Journalist> jnlst_;
    00223   };
    00224
    00229   class StandardScalingBase : public NLPScalingObject
    00230   {
    00231   public:
    00234     StandardScalingBase();
    00235
    00237     virtual ~StandardScalingBase();
    00239
    00243     virtual Number apply_obj_scaling(const Number& f);
    00245     virtual Number unapply_obj_scaling(const Number& f);
    00247     virtual SmartPtr<Vector>
    00248     apply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v);
    00250     virtual SmartPtr<const Vector>
    00251     apply_vector_scaling_x(const SmartPtr<const Vector>& v);
    00253     virtual SmartPtr<Vector>
    00254     unapply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v);
    00256     virtual SmartPtr<const Vector>
    00257     unapply_vector_scaling_x(const SmartPtr<const Vector>& v);
    00259     virtual SmartPtr<const Vector>
    00260     apply_vector_scaling_c(const SmartPtr<const Vector>& v);
    00262     virtual SmartPtr<const Vector>
    00263     unapply_vector_scaling_c(const SmartPtr<const Vector>& v);
    00265     virtual SmartPtr<Vector>
    00266     apply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v);
    00268     virtual SmartPtr<Vector>
    00269     unapply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v);
    00271     virtual SmartPtr<const Vector>
    00272     apply_vector_scaling_d(const SmartPtr<const Vector>& v);
    00274     virtual SmartPtr<const Vector>
    00275     unapply_vector_scaling_d(const SmartPtr<const Vector>& v);
    00277     virtual SmartPtr<Vector>
    00278     apply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v);
    00280     virtual SmartPtr<Vector>
    00281     unapply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v);
    00286     virtual SmartPtr<const Matrix>
    00287     apply_jac_c_scaling(SmartPtr<const Matrix> matrix);
    00292     virtual SmartPtr<const Matrix>
    00293     apply_jac_d_scaling(SmartPtr<const Matrix> matrix);
    00298     virtual SmartPtr<const SymMatrix>
    00299     apply_hessian_scaling(SmartPtr<const SymMatrix> matrix);
    00301
    00305     virtual bool have_x_scaling();
    00306     virtual bool have_c_scaling();
    00307     virtual bool have_d_scaling();
    00309
    00313     virtual void DetermineScaling(const SmartPtr<const VectorSpace> x_space,
    00314                                   const SmartPtr<const VectorSpace> c_space,
    00315                                   const SmartPtr<const VectorSpace> d_space,
    00316                                   const SmartPtr<const MatrixSpace> jac_c_space,
    00317                                   const SmartPtr<const MatrixSpace> jac_d_space,
    00318                                   const SmartPtr<const SymMatrixSpace> h_space,
    00319                                   SmartPtr<const MatrixSpace>& new_jac_c_space,
    00320                                   SmartPtr<const MatrixSpace>& new_jac_d_space,
    00321                                   SmartPtr<const SymMatrixSpace>& new_h_space,
    00322                                   const Matrix& Px_L, const Vector& x_L,
    00323                                   const Matrix& Px_U, const Vector& x_U);
    00324
    00327     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
    00329
    00330   protected:
    00332     virtual bool InitializeImpl(const OptionsList& options,
    00333                                 const std::string& prefix);
    00334
    00339     virtual void DetermineScalingParametersImpl(
    00340       const SmartPtr<const VectorSpace> x_space,
    00341       const SmartPtr<const VectorSpace> c_space,
    00342       const SmartPtr<const VectorSpace> d_space,
    00343       const SmartPtr<const MatrixSpace> jac_c_space,
    00344       const SmartPtr<const MatrixSpace> jac_d_space,
    00345       const SmartPtr<const SymMatrixSpace> h_space,
    00346       const Matrix& Px_L, const Vector& x_L,
    00347       const Matrix& Px_U, const Vector& x_U,
    00348       Number& df,
    00349       SmartPtr<Vector>& dx,
    00350       SmartPtr<Vector>& dc,
    00351       SmartPtr<Vector>& dd)=0;
    00352
    00353   private:
    00354
    00363
    00365     StandardScalingBase(const StandardScalingBase&);
    00366
    00368     void operator=(const StandardScalingBase&);
    00370
    00377     Number df_;
    00379     SmartPtr<Vector> dx_;
    00381
    00385     SmartPtr<ScaledMatrixSpace> scaled_jac_c_space_;
    00387     SmartPtr<ScaledMatrixSpace> scaled_jac_d_space_;
    00389     SmartPtr<SymScaledMatrixSpace> scaled_h_space_;
    00391
    00395     Number obj_scaling_factor_;
    00397   };
    00398
    00400   class NoNLPScalingObject : public StandardScalingBase
    00401   {
    00402   public:
    00405     NoNLPScalingObject()
    00406     {}
    00407
    00409     virtual ~NoNLPScalingObject()
    00410     {}
    00412
    00413
    00414   protected:
    00416     virtual void DetermineScalingParametersImpl(
    00417       const SmartPtr<const VectorSpace> x_space,
    00418       const SmartPtr<const VectorSpace> c_space,
    00419       const SmartPtr<const VectorSpace> d_space,
    00420       const SmartPtr<const MatrixSpace> jac_c_space,
    00421       const SmartPtr<const MatrixSpace> jac_d_space,
    00422       const SmartPtr<const SymMatrixSpace> h_space,
    00423       const Matrix& Px_L, const Vector& x_L,
    00424       const Matrix& Px_U, const Vector& x_U,
    00425       Number& df,
    00426       SmartPtr<Vector>& dx,
    00427       SmartPtr<Vector>& dc,
    00428       SmartPtr<Vector>& dd);
    00429
    00430   private:
    00431
    00440
    00442     NoNLPScalingObject(const NoNLPScalingObject&);
    00443
    00445     void operator=(const NoNLPScalingObject&);
    00447   };
    00448
    00449 } // namespace Ipopt
    00450
    00451 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines