1 // This is core/vnl/algo/vnl_powell.h 2 #ifndef vnl_powell_h_ 3 #define vnl_powell_h_ 4 //: 5 // \file 6 // \brief Powell minimizer. 7 // \author awf@robots.ox.ac.uk 8 // \date 05 Dec 00 9 // 10 // \verbatim 11 // Modifications 12 // 31 Oct 2008 - Hans Johnson - fixed errors caused by uninitialized var bx; 13 // (U. Iowa) use vnl_brent_minimizer instead of vnl_brent 14 // \endverbatim 15 16 #include <vnl/vnl_cost_function.h> 17 #include <vnl/vnl_nonlinear_minimizer.h> 18 #include <vnl/algo/vnl_algo_export.h> 19 20 //: The ever-popular Powell minimizer. 21 // Derivative-free method which may be faster if your 22 // function is expensive to compute and many-dimensional. 23 // Implemented from scratch from NR. 24 class VNL_ALGO_EXPORT vnl_powell : public vnl_nonlinear_minimizer 25 { 26 public: 27 28 //: Initialize a powell with the given cost function vnl_powell(vnl_cost_function * functor)29 vnl_powell(vnl_cost_function* functor) 30 : functor_(functor), linmin_xtol_(1e-4), initial_step_(1.0) {} 31 32 //: Run minimization, place result in x. 33 ReturnCodes minimize(vnl_vector<double>& x); 34 35 //: Set tolerance on line search parameter step 36 // Default value is 0.0001 set_linmin_xtol(double tol)37 void set_linmin_xtol(double tol) { linmin_xtol_ = tol; } 38 39 //: Set initial step when bracketing minima along a line 40 // Default value is 1.0 set_initial_step(double step)41 void set_initial_step(double step) { initial_step_ = step; } 42 43 protected: 44 vnl_cost_function* functor_; 45 46 friend class vnl_powell_1dfun; pub_report_eval(double e)47 void pub_report_eval(double e) { report_eval(e); } 48 49 //: Tolerance on line search parameter step 50 double linmin_xtol_; 51 52 //: Initial step when bracketing minima along a line 53 double initial_step_; 54 }; 55 56 #endif // vnl_powell_h_ 57