Mercurial > hg > octave-nkf
diff scripts/optimization/qp.m @ 17897:185038fe7a16
qp.m: Fix test on GLPK's return status (bug #40536)
* qp.m: Update test on GLPK's return status to comply with the new interface
introduced by changeset 54e251e699bb. Add a regression test.
author | Julien Bect <julien.bect@supelec.fr> |
---|---|
date | Sun, 10 Nov 2013 21:10:41 +0100 |
parents | d63878346099 |
children | a404853d2073 |
line wrap: on
line diff
--- a/scripts/optimization/qp.m +++ b/scripts/optimization/qp.m @@ -1,3 +1,4 @@ +## Copyright (C) 2013 Julien Bect ## Copyright (C) 2000-2013 Gabriele Pannocchia. ## ## This file is part of Octave. @@ -364,7 +365,7 @@ ub = []; ctype = repmat ("L", n_in, 1); [P, dummy, status] = glpk (ctmp, Atmp, btmp, lb, ub, ctype); - if ((status == 180 || status == 181 || status == 151) + if ((status == 0) && all (abs (P(n-n_eq+1:end)) < rtol * (1 + norm (btmp)))) ## We found a feasible starting point if (n_eq > 0) @@ -406,3 +407,15 @@ endfunction + +%!test # with infeasible initial guess +%! +%! H = 1; q = 0; # objective: x -> 0.5 x^2 +%! A = 1; lb = 1; ub = +inf; # constraint: x >= 1 +%! x0 = 0; # infeasible initial guess +%! +%! [x, obj_qp, INFO, lambda] = qp (x0, H, q, [], [], [], [], lb, A, ub); +%! +%! assert (isstruct (INFO) && isfield (INFO, "info") && (INFO.info == 0)); +%! assert ([x obj_qp], [1.0 0.5], eps); +