Mercurial > hg > octave-thorsten
comparison scripts/optimization/glpkmex.m @ 5237:652e8aa49fa7
[project @ 2005-03-23 21:28:45 by jwe]
author | jwe |
---|---|
date | Wed, 23 Mar 2005 21:28:46 +0000 |
parents | |
children | ab89f95de831 |
comparison
equal
deleted
inserted
replaced
5236:6879f10db3a4 | 5237:652e8aa49fa7 |
---|---|
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 | |
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
18 ## 02111-1307, USA. | |
19 | |
20 ## GLPKMEX - An Octave Interface for the GNU GLPK library | |
21 ## | |
22 ## This function is provided for compatibility with the old Matlab | |
23 ## interface to GLPK. | |
24 | |
25 function [xopt, fopt, status, extra] = glpkmex (varargin) | |
26 | |
27 ## If there is no input output the version and syntax | |
28 if (nargin < 4 || nargin > 11) | |
29 usage ("[xopt, fopt, status, extra] = glpkmex (sense, c, a, b, ctype, lb, ub, vartype, param, lpsolver, savepb"); | |
30 return; | |
31 endif | |
32 | |
33 ## reorder args: | |
34 ## | |
35 ## glpkmex glpk | |
36 ## | |
37 ## 1 sense c | |
38 ## 2 c a | |
39 ## 3 a b | |
40 ## 4 b lb | |
41 ## 5 ctype ub | |
42 ## 6 lb ctype | |
43 ## 7 ub vartype | |
44 ## 8 vartype sense | |
45 ## 9 param param | |
46 ## 10 lpsolver | |
47 ## 11 savepb | |
48 | |
49 sense = varargin{1}; | |
50 c = varargin{2}; | |
51 a = varargin{3}; | |
52 b = varargin{4}; | |
53 | |
54 nx = length (c); | |
55 | |
56 if (nargin > 4) | |
57 ctype = varargin{5}; | |
58 else | |
59 ctype = repmat ("U", nx, 1); | |
60 endif | |
61 | |
62 if (nargin > 5) | |
63 lb = varargin{6}; | |
64 else | |
65 lb = repmat (-Inf, nx, 1); | |
66 endif | |
67 | |
68 if (nargin > 6) | |
69 ub = varargin{7}; | |
70 else | |
71 ub = repmat (Inf, nx, 1); | |
72 endif | |
73 | |
74 if (nargin > 7) | |
75 vartype = varargin{8}; | |
76 else | |
77 vartype = repmat ("C", nx, 1); | |
78 endif | |
79 | |
80 if (nargin > 8) | |
81 param = varargin{9}; | |
82 else | |
83 param = struct (); | |
84 endif | |
85 | |
86 if (nargin > 9 && ! isfield (param, "lpsolver")) | |
87 param.lpsolver = varargin{10}; | |
88 endif | |
89 | |
90 if (nargin > 10 && ! isfield (param, "save")) | |
91 param.lpsolver = varargin{11}; | |
92 endif | |
93 | |
94 if (nargout == 0) | |
95 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
96 elseif (nargout == 1) | |
97 xopt = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
98 elseif (nargout == 2) | |
99 [xopt, fopt] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
100 elseif (nargout == 3) | |
101 [xopt, fopt, status] = ... | |
102 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
103 else | |
104 [xopt, fopt, status, extra] = ... | |
105 glpk (c, a, b, lb, ub, ctype, vartype, sense, param); | |
106 endif | |
107 | |
108 endfunction |