Mercurial > hg > octave-lyh
annotate scripts/optimization/glpkmex.m @ 11188:4cb1522e4d0f
Use function handle as input to cellfun,
rather than quoted function name or anonymous function wrapper.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 03 Nov 2010 17:20:56 -0700 |
parents | be55736a0783 |
children | 994e2a93a8e2 |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 2005, 2006, 2007, 2009 Nicolo' Giorgetti |
5237 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5237 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5237 | 18 |
5244 | 19 ## -*- texinfo -*- |
6555 | 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}) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
7017
diff
changeset
|
21 ## This function is provided for compatibility with the old @sc{matlab} |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
22 ## interface to the GNU @sc{glpk} library. For Octave code, you should use |
5244 | 23 ## the @code{glpk} function instead. |
5375 | 24 ## @end deftypefn |
5237 | 25 |
26 function [xopt, fopt, status, extra] = glpkmex (varargin) | |
27 | |
28 ## If there is no input output the version and syntax | |
29 if (nargin < 4 || nargin > 11) | |
6046 | 30 print_usage (); |
5237 | 31 return; |
32 endif | |
33 | |
34 ## reorder args: | |
35 ## | |
36 ## glpkmex glpk | |
37 ## | |
38 ## 1 sense c | |
39 ## 2 c a | |
40 ## 3 a b | |
41 ## 4 b lb | |
42 ## 5 ctype ub | |
43 ## 6 lb ctype | |
44 ## 7 ub vartype | |
45 ## 8 vartype sense | |
46 ## 9 param param | |
47 ## 10 lpsolver | |
48 ## 11 savepb | |
49 | |
50 sense = varargin{1}; | |
51 c = varargin{2}; | |
52 a = varargin{3}; | |
53 b = varargin{4}; | |
54 | |
55 nx = length (c); | |
56 | |
57 if (nargin > 4) | |
58 ctype = varargin{5}; | |
59 else | |
60 ctype = repmat ("U", nx, 1); | |
61 endif | |
62 | |
63 if (nargin > 5) | |
64 lb = varargin{6}; | |
65 else | |
66 lb = repmat (-Inf, nx, 1); | |
67 endif | |
68 | |
69 if (nargin > 6) | |
70 ub = varargin{7}; | |
71 else | |
72 ub = repmat (Inf, nx, 1); | |
73 endif | |
74 | |
75 if (nargin > 7) | |
76 vartype = varargin{8}; | |
77 else | |
78 vartype = repmat ("C", nx, 1); | |
79 endif | |
80 | |
81 if (nargin > 8) | |
82 param = varargin{9}; | |
83 else | |
84 param = struct (); | |
85 endif | |
86 | |
87 if (nargin > 9 && ! isfield (param, "lpsolver")) | |
88 param.lpsolver = varargin{10}; | |
89 endif | |
90 | |
91 if (nargin > 10 && ! isfield (param, "save")) | |
5241 | 92 param.save = varargin{11}; |
5237 | 93 endif |
94 | |
95 if (nargout == 0) | |
96 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
97 elseif (nargout == 1) | |
98 xopt = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
99 elseif (nargout == 2) | |
100 [xopt, fopt] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
101 elseif (nargout == 3) | |
102 [xopt, fopt, status] = ... | |
103 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
104 else | |
105 [xopt, fopt, status, extra] = ... | |
106 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
107 endif | |
108 | |
109 endfunction |