5237
|
1 ## Copyright (C) 2005 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 2, or (at your option) |
|
8 ## 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, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
5237
|
19 |
5244
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {[@var{xopt}, @var{fmin}, @var{status}, @var{extra}] =} glpk (@var{sense}, @var{c}, @var{a}, @var{b}, @var{ctype}, @var{lb}, @var{ub}, @var{vartype}, @var{param}, @var{lpsolver}, @var{save_pb}) |
|
22 ## This function is provided for compatibility with the old @sc{Matlab} |
|
23 ## interface to the GNU GLPK library. For Octave code, you should use |
|
24 ## the @code{glpk} function instead. |
5375
|
25 ## @end deftypefn |
5237
|
26 |
|
27 function [xopt, fopt, status, extra] = glpkmex (varargin) |
|
28 |
|
29 ## If there is no input output the version and syntax |
|
30 if (nargin < 4 || nargin > 11) |
6046
|
31 print_usage (); |
5237
|
32 return; |
|
33 endif |
|
34 |
|
35 ## reorder args: |
|
36 ## |
|
37 ## glpkmex glpk |
|
38 ## |
|
39 ## 1 sense c |
|
40 ## 2 c a |
|
41 ## 3 a b |
|
42 ## 4 b lb |
|
43 ## 5 ctype ub |
|
44 ## 6 lb ctype |
|
45 ## 7 ub vartype |
|
46 ## 8 vartype sense |
|
47 ## 9 param param |
|
48 ## 10 lpsolver |
|
49 ## 11 savepb |
|
50 |
|
51 sense = varargin{1}; |
|
52 c = varargin{2}; |
|
53 a = varargin{3}; |
|
54 b = varargin{4}; |
|
55 |
|
56 nx = length (c); |
|
57 |
|
58 if (nargin > 4) |
|
59 ctype = varargin{5}; |
|
60 else |
|
61 ctype = repmat ("U", nx, 1); |
|
62 endif |
|
63 |
|
64 if (nargin > 5) |
|
65 lb = varargin{6}; |
|
66 else |
|
67 lb = repmat (-Inf, nx, 1); |
|
68 endif |
|
69 |
|
70 if (nargin > 6) |
|
71 ub = varargin{7}; |
|
72 else |
|
73 ub = repmat (Inf, nx, 1); |
|
74 endif |
|
75 |
|
76 if (nargin > 7) |
|
77 vartype = varargin{8}; |
|
78 else |
|
79 vartype = repmat ("C", nx, 1); |
|
80 endif |
|
81 |
|
82 if (nargin > 8) |
|
83 param = varargin{9}; |
|
84 else |
|
85 param = struct (); |
|
86 endif |
|
87 |
|
88 if (nargin > 9 && ! isfield (param, "lpsolver")) |
|
89 param.lpsolver = varargin{10}; |
|
90 endif |
|
91 |
|
92 if (nargin > 10 && ! isfield (param, "save")) |
5241
|
93 param.save = varargin{11}; |
5237
|
94 endif |
|
95 |
|
96 if (nargout == 0) |
|
97 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); |
|
98 elseif (nargout == 1) |
|
99 xopt = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); |
|
100 elseif (nargout == 2) |
|
101 [xopt, fopt] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); |
|
102 elseif (nargout == 3) |
|
103 [xopt, fopt, status] = ... |
|
104 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); |
|
105 else |
|
106 [xopt, fopt, status, extra] = ... |
|
107 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); |
|
108 endif |
|
109 |
|
110 endfunction |