]> Creatis software - CreaPhase.git/blob - octave_packages/m/deprecated/glpkmex.m
update packages
[CreaPhase.git] / octave_packages / m / deprecated / glpkmex.m
1 ## Copyright (C) 2005-2012 Nicolo' Giorgetti
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {[@var{xopt}, @var{fmin}, @var{status}, @var{extra}] =} glpkmex (@var{sense}, @var{c}, @var{A}, @var{b}, @var{ctype}, @var{lb}, @var{ub}, @var{vartype}, @var{param}, @var{lpsolver}, @var{save_pb})
21 ## This function is provided for compatibility with the old @sc{matlab}
22 ## interface to the GNU @sc{glpk} library.  For Octave code, you should use
23 ## the @code{glpk} function instead.
24 ## @seealso{glpk}
25 ## @end deftypefn
26
27 function [xopt, fopt, status, extra] = glpkmex (varargin)
28
29   persistent warned = false;
30   if (! warned)
31     warned = true;
32     warning ("Octave:deprecated-function",
33              "glpkmex is obsolete and will be removed from a future version of Octave; please use glpk instead");
34   endif
35
36   ## If there is no input output the version and syntax
37   if (nargin < 4 || nargin > 11)
38     print_usage ();
39     return;
40   endif
41
42   ## reorder args:
43   ##
44   ##     glpkmex    glpk
45   ##
46   ##  1   sense      c
47   ##  2   c          a
48   ##  3   a          b
49   ##  4   b          lb
50   ##  5   ctype      ub
51   ##  6   lb         ctype
52   ##  7   ub         vartype
53   ##  8   vartype    sense
54   ##  9   param      param
55   ## 10   lpsolver
56   ## 11   savepb
57
58   sense = varargin{1};
59   c = varargin{2};
60   a = varargin{3};
61   b = varargin{4};
62
63   nx = length  (c);
64
65   if (nargin > 4)
66     ctype = varargin{5};
67   else
68     ctype = repmat ("U", nx, 1);
69   endif
70
71   if (nargin > 5)
72     lb = varargin{6};
73   else
74     lb = repmat (-Inf, nx, 1);
75   endif
76
77   if (nargin > 6)
78     ub = varargin{7};
79   else
80     ub = repmat (Inf, nx, 1);
81   endif
82
83   if (nargin > 7)
84     vartype = varargin{8};
85   else
86     vartype = repmat ("C", nx, 1);
87   endif
88
89   if (nargin > 8)
90     param = varargin{9};
91   else
92     param = struct ();
93   endif
94
95   if (nargin > 9 && ! isfield (param, "lpsolver"))
96     param.lpsolver = varargin{10};
97   endif
98
99   if (nargin > 10 && ! isfield (param, "save"))
100     param.save = varargin{11};
101   endif
102
103   if (nargout == 0)
104     glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
105   elseif (nargout == 1)
106     xopt = glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
107   elseif (nargout == 2)
108     [xopt, fopt] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
109   elseif (nargout == 3)
110     [xopt, fopt, status] = ...
111       glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
112   else
113     [xopt, fopt, status, extra] = ...
114       glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
115   endif
116
117 endfunction