changeset 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 f05f571ff1fa
children 8c33abdd2f9a
files scripts/optimization/qp.m
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);
+