1 // Copyright (C) 2005, 2009 International Business Machines and others. 2 // All Rights Reserved. 3 // This code is published under the Eclipse Public License. 4 // 5 // $Id$ 6 // 7 // Authors: Carl Laird, Andreas Waechter IBM 2005-07-13 8 9 #ifndef __IPGRADIENTSCALING_HPP__ 10 #define __IPGRADIENTSCALING_HPP__ 11 12 #include "IpNLPScaling.hpp" 13 #include "IpNLP.hpp" 14 15 namespace Ipopt 16 { 17 /** This class does problem scaling by setting the 18 * scaling parameters based on the maximum of the 19 * gradient at the user provided initial point. 20 */ 21 class GradientScaling : public StandardScalingBase 22 { 23 public: 24 /**@name Constructors/Destructors */ 25 //@{ GradientScaling(const SmartPtr<NLP> & nlp)26 GradientScaling(const SmartPtr<NLP>& nlp) 27 : 28 StandardScalingBase(), 29 nlp_(nlp) 30 {} 31 32 /** Default destructor */ ~GradientScaling()33 virtual ~GradientScaling() 34 {} 35 //@} 36 37 /** Methods for IpoptType */ 38 //@{ 39 /** Register the options for this class */ 40 static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions); 41 //@} 42 43 protected: 44 /** Initialize the object from the options */ 45 bool InitializeImpl(const OptionsList& options, 46 const std::string& prefix); 47 48 virtual void DetermineScalingParametersImpl( 49 const SmartPtr<const VectorSpace> x_space, 50 const SmartPtr<const VectorSpace> c_space, 51 const SmartPtr<const VectorSpace> d_space, 52 const SmartPtr<const MatrixSpace> jac_c_space, 53 const SmartPtr<const MatrixSpace> jac_d_space, 54 const SmartPtr<const SymMatrixSpace> h_space, 55 const Matrix& Px_L, const Vector& x_L, 56 const Matrix& Px_U, const Vector& x_U, 57 Number& df, 58 SmartPtr<Vector>& dx, 59 SmartPtr<Vector>& dc, 60 SmartPtr<Vector>& dd); 61 62 private: 63 64 /**@name Default Compiler Generated Methods 65 * (Hidden to avoid implicit creation/calling). 66 * These methods are not implemented and 67 * we do not want the compiler to implement 68 * them for us, so we declare them private 69 * and do not define them. This ensures that 70 * they will not be implicitly created/called. */ 71 //@{ 72 73 /** Copy Constructor */ 74 GradientScaling(const GradientScaling&); 75 76 /** Overloaded Equals Operator */ 77 void operator=(const GradientScaling&); 78 //@} 79 80 /** pointer to the NLP to get scaling parameters */ 81 SmartPtr<NLP> nlp_; 82 83 /** maximum allowed gradient before scaling is performed */ 84 Number scaling_max_gradient_; 85 86 /** target size of norm for objective gradient */ 87 Number scaling_obj_target_gradient_; 88 89 /** target size of norm for constraint gradients */ 90 Number scaling_constr_target_gradient_; 91 92 /** minimum value of a scaling parameter */ 93 Number scaling_min_value_; 94 }; 95 } // namespace Ipopt 96 #endif 97