vtf-logo

PenaltyQuasiNewton.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__numerical_PenaltyQuasiNewton_h__)
00009 #define __numerical_PenaltyQuasiNewton_h__
00010 
00011 // If we are debugging the whole numerical package.
00012 #if defined(DEBUG_numerical) && !defined(DEBUG_PenaltyQuasiNewton)
00013 #define DEBUG_PenaltyQuasiNewton
00014 #endif
00015 
00016 #include "QuasiNewton.h"
00017 #include "FunctionWithQuadraticPenalty.h"
00018 
00019 BEGIN_NAMESPACE_NUMERICAL
00020 
00022 
00029 template <int N, 
00030           class Function, 
00031           class Constraint, 
00032           typename T = typename Function::result_type,
00033           typename Point = typename Function::argument_type>
00034 class PenaltyQuasiNewton
00035 {
00036 public:
00037 
00038   //
00039   // Public types.
00040   //
00041   
00043   typedef Function function_type;
00044 
00046   typedef Constraint constraint_type;
00047 
00049   typedef T number_type;
00050 
00052   typedef Point point_type;
00053 
00054 private:
00055 
00056   // The objective function with a quadratic penalty.
00057   typedef FunctionWithQuadraticPenalty<N, function_type, constraint_type,
00058                                        number_type, point_type>
00059   function_with_penalty_type;
00060 
00061   // The unconstrained optimization method.
00062   typedef QuasiNewton<N, function_with_penalty_type, number_type, point_type> 
00063   optimization_type;
00064 
00065 private:
00066 
00067   //
00068   // Member data.
00069   //
00070 
00071   // The objective function with a quadratic penalty.
00072   function_with_penalty_type _function_with_penalty;
00073 
00074   // The unconstrained optimization method.
00075   optimization_type _optimization;
00076 
00077   // The maximum allowed error in the constraint.
00078   number_type _max_constraint_error;
00079 
00080   // The initial value of the penalty parameter.
00081   number_type _initial_penalty_parameter;
00082 
00083   //
00084   // Not implemented.
00085   //
00086   
00087   // Default constructor not implemented.
00088   PenaltyQuasiNewton();
00089 
00090   // Copy constructor not implemented.
00091   PenaltyQuasiNewton( const PenaltyQuasiNewton& );
00092 
00093   // Assignment operator not implemented.
00094   PenaltyQuasiNewton&
00095   operator=( const PenaltyQuasiNewton& );
00096 
00097 public:
00098 
00099   //--------------------------------------------------------------------------
00103   // @{
00104 
00106   PenaltyQuasiNewton( const function_type& function,
00107                       const constraint_type& constraint,
00108                       const number_type max_constraint_error = 
00109                       std::pow( std::numeric_limits<number_type>::epsilon(), 
00110                                 0.25 ),
00111                       const number_type x_tolerance 
00112                       = 4 * std::numeric_limits<number_type>::epsilon(),
00113                       const number_type gradient_tolerance 
00114                       = 4 * std::numeric_limits<number_type>::epsilon(),
00115                       const int max_function_calls = 10000 );
00116 
00118   virtual
00119   ~PenaltyQuasiNewton()
00120   {}
00121 
00122   // @}
00123   //--------------------------------------------------------------------------
00125   // @{
00126 
00128   void
00129   find_minimum( point_type& x, number_type& value, int& num_iterations,
00130                 number_type max_step = 0,
00131                 const number_type x_tolerance = 0,
00132                 const number_type gradient_tolerance = 0 );
00133 
00134   // @}
00135   //--------------------------------------------------------------------------
00137   // @{
00138 
00140   number_type
00141   penalty_parameter() const
00142   {
00143     return _function_with_penalty.penalty_parameter();
00144   }
00145 
00147   number_type
00148   initial_penalty_parameter() const
00149   {
00150     return _initial_penalty_parameter;
00151   }
00152 
00154   number_type
00155   max_constraint_error() const
00156   {
00157     return _max_constraint_error;
00158   }
00159 
00160   // @}
00161   //--------------------------------------------------------------------------
00163   // @{
00164 
00166   void
00167   set_max_constraint_error( const number_type max_constraint_error )
00168   {
00169     _max_constraint_error = max_constraint_error;
00170   }
00171 
00173   void
00174   set_initial_penalty_parameter( const number_type initial_penalty_parameter )
00175   {
00176     _initial_penalty_parameter = initial_penalty_parameter;
00177   }
00178 
00179   // @}
00180 
00181 };
00182 
00183 END_NAMESPACE_NUMERICAL
00184 
00185 #define __PenaltyQuasiNewton_ipp__
00186 #include "PenaltyQuasiNewton.ipp"
00187 #undef __PenaltyQuasiNewton_ipp__
00188 
00189 #endif

Generated on Fri Aug 24 12:56:05 2007 for Numerical Algorithms Package by  doxygen 1.4.7