# HG changeset patch # User Julien Bect # Date 1384114241 -3600 # Node ID 185038fe7a164f04d134ef1afa928a18a33410e1 # Parent f05f571ff1fa89df226923328a84adf1bce60ecd 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. diff -r f05f571ff1fa -r 185038fe7a16 scripts/optimization/qp.m --- a/scripts/optimization/qp.m Sun Nov 10 12:26:14 2013 +0530 +++ b/scripts/optimization/qp.m Sun Nov 10 21:10:41 2013 +0100 @@ -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); +