## [Vxl-users] Using Powell

 [Vxl-users] Using Powell From: Sonia Pujol - 2002-11-02 14:00:20 ```Hi ! I am trying to compute a Powell minimization on a cost function that I has defined but I have some difficulties to understand how to use the vnl_powel class. I have defined a class CMyCostFunction as : class CMyCostFunction :: vnl_cost_function(16){ ... double f(vnl_vector&x) { // here is the expression of my cost function } } and then in the main program I did : CMyCostFunction * m_S ; double f = 0.0 ; m_S->compute(p_vector, &f, 0) ; // p_vector is a vnl_vector that I have computed earlier vnl_powell l_powell(m_S) ; and then I call the minimization and this object by : l_powell.minimize(l_res); Could you tell where I do an error ? Where I can find an example using this class ? Thanks ! Sonia ```

 [Vxl-users] Using Powell From: Sonia Pujol - 2002-11-02 14:00:20 ```Hi ! I am trying to compute a Powell minimization on a cost function that I has defined but I have some difficulties to understand how to use the vnl_powel class. I have defined a class CMyCostFunction as : class CMyCostFunction :: vnl_cost_function(16){ ... double f(vnl_vector&x) { // here is the expression of my cost function } } and then in the main program I did : CMyCostFunction * m_S ; double f = 0.0 ; m_S->compute(p_vector, &f, 0) ; // p_vector is a vnl_vector that I have computed earlier vnl_powell l_powell(m_S) ; and then I call the minimization and this object by : l_powell.minimize(l_res); Could you tell where I do an error ? Where I can find an example using this class ? Thanks ! Sonia ```
 RE: [Vxl-users] Using Powell From: Andrew Fitzgibbon - 2002-11-02 14:25:59 ```> I have defined a class CMyCostFunction as : > > class CMyCostFunction :: vnl_cost_function(16){ > ... > double f(vnl_vector&x) { > // here is the expression of my cost function > } > } > and then in the main program I did : > > CMyCostFunction * m_S ; > double f = 0.0 ; > m_S->compute(p_vector, &f, 0) ; // p_vector is a > vnl_vector > that I have computed earlier > vnl_powell l_powell(m_S) ; > > and then I call the minimization and this object by : > l_powell.minimize(l_res); Try vnl/examples/vnl_rosenbrock.cxx http://www.isbe.man.ac.uk/public_vxl_doc/vxl/vnl/html/vnl_rosenbrock.cxx -source.html This shows how to use many minimizers to minimize the "Rosenbrock" standard test function (see http://www.esat.kuleuven.ac.be/~targetjr/www.robots.ox.ac.uk/vxl/book/bo ok_6.html#SEC50 ) A. ```