Mercurial > forge
changeset 1696:6c9ff91d534e octave-forge
Fix newtonstep bug introduced in July, and add pointers to examples to algorithms
author | mcreel |
---|---|
date | Tue, 07 Sep 2004 10:30:02 +0000 |
parents | 05e9fb1491a8 |
children | 4ce5827eb699 |
files | main/optim/bfgsmin.cc main/optim/lbfgsmin.cc main/optim/newtonstep.cc main/optim/samin.cc |
diffstat | 4 files changed, 48 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/main/optim/bfgsmin.cc Mon Sep 06 14:45:14 2004 +0000 +++ b/main/optim/bfgsmin.cc Tue Sep 07 10:30:02 2004 +0000 @@ -64,7 +64,7 @@ DEFUN_DLD(bfgsmin, args, , - "bfgsmin: bfgs minimization of a function. See bfgsmin-example.m\n\ + "bfgsmin: bfgs minimization of a function. See bfgsmin_example.m\n\ \n\ [x, obj, convergence] = bfgsmin(\"f\", {args}, {control}, {tols})\n\ \n\ @@ -149,9 +149,9 @@ if (args.length() >= 3) { Cell control (args(2).cell_value()); - if (xisinf (control(0).double_value())) - max_iters = -1; - else + // if (xisinf (control(0).double_value())) + // max_iters = -1; + //else max_iters = control(0).int_value(); if (max_iters == -1) max_iters = INT_MAX; verbosity = control(1).int_value();
--- a/main/optim/lbfgsmin.cc Mon Sep 06 14:45:14 2004 +0000 +++ b/main/optim/lbfgsmin.cc Tue Sep 07 10:30:02 2004 +0000 @@ -96,7 +96,7 @@ DEFUN_DLD(lbfgsmin, args, , - "lbfgsmin: limited memory bfgs minimization of a function. See lbfgsmin-example.m\n\ + "lbfgsmin: limited memory bfgs minimization of a function. See lbfgsmin_example.m\n\ \n\ [x, obj, convergence] = lbfgsmin(\"f\", {args}, {control}, {tols}]\n\ \n\
--- a/main/optim/newtonstep.cc Mon Sep 06 14:45:14 2004 +0000 +++ b/main/optim/newtonstep.cc Tue Sep 07 10:30:02 2004 +0000 @@ -28,52 +28,52 @@ #include <octave/lo-ieee.h> #include <float.h> -static bool -any_bad_argument(const octave_value_list& args) -{ - if (!args(0).is_string()) - { - error("newtonstep: first argument must be string holding objective function name"); - return true; - } - if (!args(1).is_cell()) - { - error("newtonstep: second argument must cell array of function arguments"); - return true; - } - if (!args(2).is_real_type()) - { - error("newtonstep: third argument must be column vector of directions"); - return true; - } - - if (args.length() == 4) - { - if (!args(3).is_real_scalar()) - { - error("newtonstep: 4th argument, if supplied, must be a scalar specifying which is the minimand"); - return true; - } - } - - return false; -} +// static bool +// any_bad_argument(const octave_value_list& args) +// { +// if (!args(0).is_string()) +// { +// error("newtonstep: first argument must be string holding objective function name"); +// return true; +// } +// if (!args(1).is_cell()) +// { +// error("newtonstep: second argument must cell array of function arguments"); +// return true; +// } +// if (!args(2).is_real_type()) +// { +// error("newtonstep: third argument must be column vector of directions"); +// return true; +// } +// +// if (args.length() == 4) +// { +// if (!args(3).is_real_scalar()) +// { +// error("newtonstep: 4th argument, if supplied, must be a scalar specifying which is the minimand"); +// return true; +// } +// } +// +// return false; +// } -DEFUN_DLD(newtonstep, args, , "newtonstep.cc - for internal use by bfgsmin and related functions") +DEFUN_DLD(newtonstep, args, , "newtonstep.cc") { - int nargin = args.length (); - if ((nargin < 3) || (nargin > 4)) - { - error("newtonstep: you must supply 3 or 4 arguments"); - return octave_value_list(); - } - - // check the arguments - if (any_bad_argument(args)) return octave_value_list(); +// int nargin = args.length (); +// if ((nargin < 3) || (nargin > 4)) +// { +// error("newtonstep: you must supply 3 or 4 arguments"); +// return octave_value_list(); +// } +// +// // check the arguments +// if (any_bad_argument(args)) return octave_value_list(); @@ -138,7 +138,7 @@ if (a < 0) // since direction is descending, a must be positive { // if it is not, go to bisection step - f_return = feval("newtonstep", args); + f_return = feval("bisectionstep", args); a = f_return(0).double_value(); obj = f_return(1).double_value(); stepobj(0) = a; @@ -157,7 +157,7 @@ // if not, fall back to bisection if ((obj > obj_0) || lo_ieee_isnan(obj)) { - f_return = feval("newtonstep", args); + f_return = feval("bisectionstep", args); a = f_return(0).double_value(); obj = f_return(1).double_value(); }
--- a/main/optim/samin.cc Mon Sep 06 14:45:14 2004 +0000 +++ b/main/optim/samin.cc Tue Sep 07 10:30:02 2004 +0000 @@ -140,7 +140,7 @@ //-------------- The annealing algorithm -------------- DEFUN_DLD(samin, args, , - "samin: simulated annealing minimization of a function.\n\ + "samin: simulated annealing minimization of a function. See samin_example.m\n\ \n\ [x, obj, convergence] = samin(\"f\", {args}, {control})\n\ \n\