00001 // This is core/vnl/algo/vnl_powell.h 00002 #ifndef vnl_powell_h_ 00003 #define vnl_powell_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief Powell minimizer. 00010 // \author awf@robots.ox.ac.uk 00011 // \date 05 Dec 00 00012 // 00013 // \verbatim 00014 // Modifications 00015 // 31 Oct 2008 - Hans Johnson - fixed errors caused by uninitialized var bx; 00016 // (U. Iowa) use vnl_brent_minimizer instead of vnl_brent 00017 // \endverbatim 00018 00019 #include <vnl/vnl_cost_function.h> 00020 #include <vnl/vnl_nonlinear_minimizer.h> 00021 00022 //: The ever-popular Powell minimizer. 00023 // Derivative-free method which may be faster if your 00024 // function is expensive to compute and many-dimensional. 00025 // Implemented from scratch from NR. 00026 class vnl_powell : public vnl_nonlinear_minimizer 00027 { 00028 public: 00029 00030 //: Initialize a powell with the given cost function 00031 vnl_powell(vnl_cost_function* functor) 00032 : functor_(functor), linmin_xtol_(1e-4), initial_step_(1.0) {} 00033 00034 //: Run minimization, place result in x. 00035 ReturnCodes minimize(vnl_vector<double>& x); 00036 00037 //: Set tolerance on line search parameter step 00038 // Default value is 0.0001 00039 void set_linmin_xtol(double tol) { linmin_xtol_ = tol; } 00040 00041 //: Set initial step when bracketing minima along a line 00042 // Default value is 1.0 00043 void set_initial_step(double step) { initial_step_ = step; } 00044 00045 protected: 00046 vnl_cost_function* functor_; 00047 00048 friend class vnl_powell_1dfun; 00049 void pub_report_eval(double e) { report_eval(e); } 00050 00051 //: Tolerance on line search parameter step 00052 double linmin_xtol_; 00053 00054 //: Initial step when bracketing minima along a line 00055 double initial_step_; 00056 }; 00057 00058 #endif // vnl_powell_h_