From: <hi...@us...> - 2009-06-18 06:11:25
|
Revision: 5965 http://octave.svn.sourceforge.net/octave/?rev=5965&view=rev Author: highegg Date: 2009-06-18 06:11:14 +0000 (Thu, 18 Jun 2009) Log Message: ----------- update test Modified Paths: -------------- trunk/octave-forge/main/optim/inst/test_fminunc_1.m trunk/octave-forge/main/optim/src/__bfgsmin.cc Modified: trunk/octave-forge/main/optim/inst/test_fminunc_1.m =================================================================== --- trunk/octave-forge/main/optim/inst/test_fminunc_1.m 2009-06-18 06:08:52 UTC (rev 5964) +++ trunk/octave-forge/main/optim/inst/test_fminunc_1.m 2009-06-18 06:11:14 UTC (rev 5965) @@ -10,9 +10,9 @@ ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## for more details. -## test_fminunc_1 - Test that fminunc and optimset work +## test_fminunc_compat_1 - Test that fminunc_compat and optimset work ## -## A quadratic function is fminuncd. Various options are tested. Options +## A quadratic function is fminunc_compatd. Various options are tested. Options ## are passed incomplete (to see if properly completed) and ## case-insensitive. @@ -54,7 +54,7 @@ if verbose - prn ("\n Testing that fminunc() works as it should\n\n"); + prn ("\n Testing that fminunc_compat() works as it should\n\n"); prn (" Nparams = N = %i\n",N); fflush (stdout); end @@ -62,7 +62,7 @@ ## Plain run, just to make sure ###################################### ## Minimum wrt 'x' is y0 opt = optimset (); -[xlev,vlev] = fminunc ("ff",x0,opt,y0,1); +[xlev,vlev] = fminunc_compat ("ff",x0,opt,y0,1); cnt++; if max (abs (xlev-y0)) > 100*sqrt (eps) @@ -75,7 +75,7 @@ ## See what 'backend' gives in that last case ######################## opt = optimset ("backend","on"); -[method,ctl] = fminunc ("ff",x0, opt, y0,1); +[method,ctl] = fminunc_compat ("ff",x0, opt, y0,1); cnt++; if ! ischar (method) || ! strcmp (method,"nelder_mead_min") @@ -83,7 +83,7 @@ if ischar (method) prn ("Wrong method '%s' != 'nelder_mead_min' was chosen\n", method); else - prn ("fminunc pretends to use a method that isn't a string\n"); + prn ("fminunc_compat pretends to use a method that isn't a string\n"); end return end @@ -108,7 +108,7 @@ ## Minimum wrt 'x' is y0 opt = optimset ("GradO","on"); -[xlev,vlev,nlev] = fminunc ("d2ff",x0,opt,y0,1); +[xlev,vlev,nlev] = fminunc_compat ("d2ff",x0,opt,y0,1); cnt++; if max (abs (xlev-y0)) > 100*sqrt (eps) @@ -123,7 +123,7 @@ ## Use the 'hess' option, when f can return 2nd differential ######### ## Minimum wrt 'x' is y0 opt = optimset ("hessian","on"); -[xlev,vlev,nlev] = fminunc ("d2ff",x0,opt,y0,1); +[xlev,vlev,nlev] = fminunc_compat ("d2ff",x0,opt,y0,1); cnt++; if max (abs (xlev-y0)) > 100*sqrt (eps) Modified: trunk/octave-forge/main/optim/src/__bfgsmin.cc =================================================================== --- trunk/octave-forge/main/optim/src/__bfgsmin.cc 2009-06-18 06:08:52 UTC (rev 5964) +++ trunk/octave-forge/main/optim/src/__bfgsmin.cc 2009-06-18 06:11:14 UTC (rev 5965) @@ -29,7 +29,10 @@ #include <octave/lo-ieee.h> #include <float.h> #include "error.h" +#include "lo-ieee.h" +#include <iostream> + // the compares two octave_values (thanks to jwe) bool isequal (const octave_value& a, const octave_value& b, bool nans_compare_equal = false) @@ -79,7 +82,9 @@ int success = 1; f_args_new = f_args; f_args_new(minarg - 1) = theta; + std::cerr << "here\n"; f_return = _feval(f, f_args_new); + std::cerr << "here\n"; obj = f_return(0).double_value(); // bullet-proof the objective function if (error_state) { @@ -305,6 +310,7 @@ Matrix H, H1, H2; ColumnVector thetain, d, g, g_new, p, q, sig, gam; + return f_return; // controls Cell control (args(2).cell_value()); max_iters = control(0).int_value(); @@ -323,7 +329,7 @@ // copy cell contents over to octave_value_list to use _feval() k = f_args_cell.length(); - if (k) f_args(k-1); // resize only once + f_args(k); // resize only once for (i = 0; i<k; i++) f_args(i) = f_args_cell(i); // get the minimization argument @@ -343,6 +349,8 @@ thetain = theta; H = identity_matrix(k,k); + std::cerr << "here\n"; + return f_return; // Initial obj_value __bfgsmin_obj(obj_in, f, f_args, theta, minarg); if (warnings) printf("initial obj_value %g\n", obj_in); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |