# HG changeset patch # User address@hidden # Date 1224787423 25200 # Node ID a92ae64d58829b4ba59a98825a7df573050a306d # Parent 095b3e4d64e99065bba14a14fcf849cc68a14fff Add optional arguement to qp() specifying the maximum number of iterations. diff -r 095b3e4d64e9 -r a92ae64d5882 scripts/optimization/qp.m --- a/scripts/optimization/qp.m Thu Oct 23 13:00:46 2008 -0400 +++ b/scripts/optimization/qp.m Thu Oct 23 11:43:43 2008 -0700 @@ -17,7 +17,7 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} address@hidden, @var{obj}, @var{info}, @var{lambda}] =} qp (@var{x0}, @var{H}, @var{q}, @var{A}, @var{b}, @var{lb}, @var{ub}, @var{A_lb}, @var{A_in}, @var{A_ub}) +## @deftypefn {Function File} address@hidden, @var{obj}, @var{info}, @var{lambda}] =} qp (@var{x0}, @var{H}, @var{q}, @var{A}, @var{b}, @var{lb}, @var{ub}, @var{A_lb}, @var{A_in}, @var{A_ub}, @var{max_iter}) ## Solve the quadratic program ## @iftex ## @tex @@ -57,6 +57,7 @@ ## Any bound (@var{A}, @var{b}, @var{lb}, @var{ub}, @var{A_lb}, ## @var{A_ub}) may be set to the empty matrix (@code{[]}) if not ## present. If the initial guess is feasible the algorithm is faster. +## If max_iter is present, it specifies the maximum number of iterations (default 200). ## ## The value @var{info} is a structure with the following fields: ## @table @code @@ -79,9 +80,12 @@ ## @end table ## @end deftypefn -function [x, obj, INFO, lambda] = qp (x0, H, q, A, b, lb, ub, A_lb, A_in, A_ub) +function [x, obj, INFO, lambda] = qp (x0, H, q, A, b, lb, ub, A_lb, A_in, A_ub, max_iter) - if (nargin == 5 || nargin == 7 || nargin == 10) + if (nargin == 5 || nargin == 7 || nargin == 10 || nargin == 11) + if (nargin < 11) + max_iter = 200; + endif ## Checking the quadratic penalty n = issquare (H); @@ -271,11 +275,9 @@ function [x, obj, INFO, lambda] = qp (x0 endif if (info == 0) - ## FIXME -- make maxit a user option. ## The initial (or computed) guess is feasible. ## We call the solver. - maxit = 200; - [x, lambda, info, iter] = __qp__ (x0, H, q, A, b, Ain, bin, maxit); + [x, lambda, info, iter] = __qp__ (x0, H, q, A, b, Ain, bin, max_iter); else iter = 0; x = x0;