vtf-logo

Penalty.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__numerical_Penalty_h__)
00009 #define __numerical_Penalty_h__
00010 
00011 // If we are debugging the whole numerical package.
00012 #if defined(DEBUG_numerical) && !defined(DEBUG_Penalty)
00013 #define DEBUG_Penalty
00014 #endif
00015 
00016 #include "CoordinateDescent.h"
00017 #include "FunctionWithQuadraticPenalty.h"
00018 
00019 BEGIN_NAMESPACE_NUMERICAL
00020 
00022 
00029 template <int N, class Function, class Constraint, 
00030           typename T = typename Function::result_type,
00031           typename Point = typename Function::argument_type>
00032 class Penalty
00033 {
00034 public:
00035 
00036   //
00037   // Public types.
00038   //
00039   
00041   typedef Function function_type;
00042 
00044   typedef Constraint constraint_type;
00045 
00047   typedef T number_type;
00048 
00050   typedef Point point_type;
00051 
00052 private:
00053 
00054   // The objective function with a quadratic penalty.
00055   typedef FunctionWithQuadraticPenalty<N, function_type, constraint_type,
00056                                        number_type, point_type>
00057   function_with_penalty_type;
00058 
00059   // The unconstrained optimization method.
00060   typedef CoordinateDescent<N, function_with_penalty_type, number_type, 
00061                             point_type> 
00062   optimization_type;
00063 
00064 private:
00065 
00066   //
00067   // Member data.
00068   //
00069 
00070   // The objective function with a quadratic penalty.
00071   function_with_penalty_type _function_with_penalty;
00072 
00073   // The unconstrained optimization method.
00074   optimization_type _optimization;
00075 
00076   // The initial step size;
00077   number_type _initial_step_size;
00078 
00079   // The final step size;
00080   number_type _final_step_size;
00081 
00082   // The maximum allowed error in the constraint.
00083   number_type _max_constraint_error;
00084 
00085   // The initial value of the penalty parameter.
00086   number_type _initial_penalty_parameter;
00087 
00088   //
00089   // Not implemented.
00090   //
00091   
00092   // Default constructor not implemented.
00093   Penalty();
00094 
00095   // Copy constructor not implemented.
00096   Penalty( const Penalty& );
00097 
00098   // Assignment operator not implemented.
00099   Penalty&
00100   operator=( const Penalty& );
00101 
00102 public:
00103 
00104   //--------------------------------------------------------------------------
00108   // @{
00109 
00111   Penalty( const function_type& function,
00112            const constraint_type& constraint,
00113            const number_type initial_step_size = 
00114            std::pow( std::numeric_limits<number_type>::epsilon(), 0.25 ),
00115            const number_type final_step_size = 
00116            std::sqrt( std::numeric_limits<number_type>::epsilon() ),
00117            const number_type max_constraint_error = 
00118            std::pow( std::numeric_limits<number_type>::epsilon(), 0.25 ),
00119            const int max_function_calls = 10000 );
00120 
00122   virtual
00123   ~Penalty()
00124   {}
00125 
00126   // @}
00127   //--------------------------------------------------------------------------
00129   // @{
00130 
00132   void
00133   find_minimum( point_type& x );
00134 
00135   // @}
00136   //--------------------------------------------------------------------------
00138   // @{
00139 
00141   number_type
00142   penalty_parameter() const
00143   {
00144     return _function_with_penalty.penalty_parameter();
00145   }
00146 
00148   number_type
00149   max_constraint_error() const
00150   {
00151     return _max_constraint_error;
00152   }
00153 
00154   // @}
00155   //--------------------------------------------------------------------------
00157   // @{
00158 
00160   void
00161   set_initial_step_size( const number_type initial_step_size )
00162   {
00163     _initial_step_size = initial_step_size;
00164   }
00165 
00167   void
00168   set_final_step_size( const number_type final_step_size )
00169   {
00170     _final_step_size = final_step_size;
00171   }
00172 
00174   void
00175   set_step_size_reduction_factor( const number_type 
00176                                   step_size_reduction_factor )
00177   {
00178     _optimization.set_step_size_reduction_factor( step_size_reduction_factor );
00179   }
00180 
00182   void
00183   set_max_constraint_error( const number_type max_constraint_error )
00184   {
00185     _max_constraint_error = max_constraint_error;
00186   }
00187 
00189   void
00190   set_penalty_parameter( const number_type penalty_parameter )
00191   {
00192     _optimization.function().set_penalty_parameter( penalty_parameter );
00193   }
00194 
00195   // @}
00196 
00197 };
00198 
00199 END_NAMESPACE_NUMERICAL
00200 
00201 #define __Penalty_ipp__
00202 #include "Penalty.ipp"
00203 #undef __Penalty_ipp__
00204 
00205 #endif

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