Mercurial > octave-nkf
annotate scripts/optimization/glpk.m @ 14138:72c96de7a403 stable
maint: update copyright notices for 2012
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2012 14:25:41 -0500 |
parents | f96b9b9f141b |
children | b76f0740940e |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1 ## Copyright (C) 2005-2012 Nicolo' Giorgetti |
5233 | 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. | |
5233 | 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/>. | |
5233 | 18 |
5244 | 19 ## -*- texinfo -*- |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{xopt}, @var{fmin}, @var{status}, @var{extra}] =} glpk (@var{c}, @var{A}, @var{b}, @var{lb}, @var{ub}, @var{ctype}, @var{vartype}, @var{sense}, @var{param}) |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
21 ## Solve a linear program using the GNU @sc{glpk} library. Given three |
5244 | 22 ## arguments, @code{glpk} solves the following standard LP: |
6741 | 23 ## @tex |
24 ## $$ | |
25 ## \min_x C^T x | |
26 ## $$ | |
27 ## @end tex | |
28 ## @ifnottex | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
29 ## |
5244 | 30 ## @example |
31 ## min C'*x | |
32 ## @end example | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
33 ## |
6741 | 34 ## @end ifnottex |
5237 | 35 ## subject to |
6741 | 36 ## @tex |
37 ## $$ | |
38 ## Ax = b \qquad x \geq 0 | |
39 ## $$ | |
40 ## @end tex | |
41 ## @ifnottex | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
42 ## |
5244 | 43 ## @example |
44 ## @group | |
45 ## A*x = b | |
46 ## x >= 0 | |
47 ## @end group | |
48 ## @end example | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
49 ## |
6741 | 50 ## @end ifnottex |
5237 | 51 ## but may also solve problems of the form |
6741 | 52 ## @tex |
53 ## $$ | |
54 ## [ \min_x | \max_x ] C^T x | |
55 ## $$ | |
56 ## @end tex | |
57 ## @ifnottex | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
58 ## |
5244 | 59 ## @example |
60 ## [ min | max ] C'*x | |
61 ## @end example | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
62 ## |
6741 | 63 ## @end ifnottex |
5237 | 64 ## subject to |
6741 | 65 ## @tex |
66 ## $$ | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
67 ## Ax [ = | \leq | \geq ] b \qquad LB \leq x \leq UB |
6741 | 68 ## $$ |
69 ## @end tex | |
70 ## @ifnottex | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
71 ## |
5244 | 72 ## @example |
73 ## @group | |
74 ## A*x [ "=" | "<=" | ">=" ] b | |
75 ## x >= LB | |
76 ## x <= UB | |
77 ## @end group | |
78 ## @end example | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
79 ## |
6741 | 80 ## @end ifnottex |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
81 ## |
5244 | 82 ## Input arguments: |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
83 ## |
5244 | 84 ## @table @var |
85 ## @item c | |
86 ## A column array containing the objective function coefficients. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
87 ## |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
88 ## @item A |
5244 | 89 ## A matrix containing the constraints coefficients. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 ## |
5244 | 91 ## @item b |
92 ## A column array containing the right-hand side value for each constraint | |
93 ## in the constraint matrix. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
94 ## |
5244 | 95 ## @item lb |
96 ## An array containing the lower bound on each of the variables. If | |
97 ## @var{lb} is not supplied, the default lower bound for the variables is | |
98 ## zero. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
99 ## |
5244 | 100 ## @item ub |
101 ## An array containing the upper bound on each of the variables. If | |
102 ## @var{ub} is not supplied, the default upper bound is assumed to be | |
103 ## infinite. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
104 ## |
5244 | 105 ## @item ctype |
106 ## An array of characters containing the sense of each constraint in the | |
107 ## constraint matrix. Each element of the array may be one of the | |
108 ## following values | |
11595
5ec6aa05638d
Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
109 ## @table @asis |
5244 | 110 ## @item "F" |
7096 | 111 ## A free (unbounded) constraint (the constraint is ignored). |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
112 ## |
5244 | 113 ## @item "U" |
7096 | 114 ## An inequality constraint with an upper bound (@code{A(i,:)*x <= b(i)}). |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
115 ## |
5244 | 116 ## @item "S" |
7096 | 117 ## An equality constraint (@code{A(i,:)*x = b(i)}). |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
118 ## |
5244 | 119 ## @item "L" |
7096 | 120 ## An inequality with a lower bound (@code{A(i,:)*x >= b(i)}). |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
121 ## |
5244 | 122 ## @item "D" |
7096 | 123 ## An inequality constraint with both upper and lower bounds |
124 ## (@code{A(i,:)*x >= -b(i)} @emph{and} (@code{A(i,:)*x <= b(i)}). | |
5244 | 125 ## @end table |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
126 ## |
5244 | 127 ## @item vartype |
128 ## A column array containing the types of the variables. | |
11595
5ec6aa05638d
Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
129 ## @table @asis |
7096 | 130 ## @item "C" |
131 ## A continuous variable. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
132 ## |
7096 | 133 ## @item "I" |
134 ## An integer variable. | |
5244 | 135 ## @end table |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
136 ## |
5244 | 137 ## @item sense |
138 ## If @var{sense} is 1, the problem is a minimization. If @var{sense} is | |
139 ## -1, the problem is a maximization. The default value is 1. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
140 ## |
5244 | 141 ## @item param |
142 ## A structure containing the following parameters used to define the | |
143 ## behavior of solver. Missing elements in the structure take on default | |
144 ## values, so you only need to set the elements that you wish to change | |
145 ## from the default. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
146 ## |
5244 | 147 ## Integer parameters: |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
148 ## |
5244 | 149 ## @table @code |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
150 ## @item msglev (@w{@code{LPX_K_MSGLEV}}, default: 1) |
5244 | 151 ## Level of messages output by solver routines: |
152 ## @table @asis | |
153 ## @item 0 | |
154 ## No output. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
155 ## |
5244 | 156 ## @item 1 |
157 ## Error messages only. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
158 ## |
5244 | 159 ## @item 2 |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
160 ## Normal output. |
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
161 ## |
5244 | 162 ## @item 3 |
163 ## Full output (includes informational messages). | |
164 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
165 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
166 ## @item scale (@w{@code{LPX_K_SCALE}}, default: 1) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
167 ## Scaling option: |
5244 | 168 ## @table @asis |
169 ## @item 0 | |
7001 | 170 ## No scaling. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
171 ## |
5244 | 172 ## @item 1 |
7001 | 173 ## Equilibration scaling. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
174 ## |
5244 | 175 ## @item 2 |
176 ## Geometric mean scaling, then equilibration scaling. | |
177 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
178 ## |
10549 | 179 ## @item dual (@w{@code{LPX_K_DUAL}}, default: 0) |
5244 | 180 ## Dual simplex option: |
181 ## @table @asis | |
182 ## @item 0 | |
183 ## Do not use the dual simplex. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
184 ## |
5244 | 185 ## @item 1 |
186 ## If initial basic solution is dual feasible, use the dual simplex. | |
187 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
188 ## |
10549 | 189 ## @item price (@w{@code{LPX_K_PRICE}}, default: 1) |
5244 | 190 ## Pricing option (for both primal and dual simplex): |
191 ## @table @asis | |
192 ## @item 0 | |
193 ## Textbook pricing. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
194 ## |
5244 | 195 ## @item 1 |
196 ## Steepest edge pricing. | |
197 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
198 ## |
10549 | 199 ## @item round (@w{@code{LPX_K_ROUND}}, default: 0) |
5244 | 200 ## Solution rounding option: |
201 ## @table @asis | |
202 ## @item 0 | |
203 ## Report all primal and dual values "as is". | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
204 ## |
5244 | 205 ## @item 1 |
206 ## Replace tiny primal and dual values by exact zero. | |
207 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
208 ## |
10549 | 209 ## @item itlim (@w{@code{LPX_K_ITLIM}}, default: -1) |
5244 | 210 ## Simplex iterations limit. If this value is positive, it is decreased by |
211 ## one each time when one simplex iteration has been performed, and | |
212 ## reaching zero value signals the solver to stop the search. Negative | |
213 ## value means no iterations limit. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
214 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
215 ## @item itcnt (@w{@code{LPX_K_OUTFRQ}}, default: 200) |
5244 | 216 ## Output frequency, in iterations. This parameter specifies how |
217 ## frequently the solver sends information about the solution to the | |
218 ## standard output. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
219 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
220 ## @item branch (@w{@code{LPX_K_BRANCH}}, default: 2) |
5244 | 221 ## Branching heuristic option (for MIP only): |
222 ## @table @asis | |
223 ## @item 0 | |
224 ## Branch on the first variable. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
225 ## |
5244 | 226 ## @item 1 |
227 ## Branch on the last variable. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
228 ## |
5244 | 229 ## @item 2 |
230 ## Branch using a heuristic by Driebeck and Tomlin. | |
231 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
232 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
233 ## @item btrack (@w{@code{LPX_K_BTRACK}}, default: 2) |
5244 | 234 ## Backtracking heuristic option (for MIP only): |
235 ## @table @asis | |
236 ## @item 0 | |
237 ## Depth first search. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
238 ## |
5244 | 239 ## @item 1 |
240 ## Breadth first search. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
241 ## |
5244 | 242 ## @item 2 |
243 ## Backtrack using the best projection heuristic. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
244 ## @end table |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
245 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
246 ## @item presol (@w{@code{LPX_K_PRESOL}}, default: 1) |
5244 | 247 ## If this flag is set, the routine lpx_simplex solves the problem using |
248 ## the built-in LP presolver. Otherwise the LP presolver is not used. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
249 ## |
5244 | 250 ## @item lpsolver (default: 1) |
251 ## Select which solver to use. If the problem is a MIP problem this flag | |
252 ## will be ignored. | |
253 ## @table @asis | |
254 ## @item 1 | |
255 ## Revised simplex method. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
256 ## |
5244 | 257 ## @item 2 |
258 ## Interior point method. | |
259 ## @end table | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
260 ## |
5244 | 261 ## @item save (default: 0) |
7001 | 262 ## If this parameter is nonzero, save a copy of the problem in |
5244 | 263 ## CPLEX LP format to the file @file{"outpb.lp"}. There is currently no |
264 ## way to change the name of the output file. | |
265 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
266 ## |
5244 | 267 ## Real parameters: |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
268 ## |
5244 | 269 ## @table @code |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
270 ## @item relax (@w{@code{LPX_K_RELAX}}, default: 0.07) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
271 ## Relaxation parameter used in the ratio test. If it is zero, the textbook |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
272 ## ratio test is used. If it is non-zero (should be positive), Harris' |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
273 ## two-pass ratio test is used. In the latter case on the first pass of the |
5244 | 274 ## ratio test basic variables (in the case of primal simplex) or reduced |
275 ## costs of non-basic variables (in the case of dual simplex) are allowed | |
276 ## to slightly violate their bounds, but not more than | |
277 ## @code{relax*tolbnd} or @code{relax*toldj (thus, @code{relax} is a | |
6248 | 278 ## percentage of @code{tolbnd} or @code{toldj}}. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
279 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
280 ## @item tolbnd (@w{@code{LPX_K_TOLBND}}, default: 10e-7) |
5289 | 281 ## Relative tolerance used to check if the current basic solution is primal |
5244 | 282 ## feasible. It is not recommended that you change this parameter unless you |
283 ## have a detailed understanding of its purpose. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
284 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
285 ## @item toldj (@w{@code{LPX_K_TOLDJ}}, default: 10e-7) |
5244 | 286 ## Absolute tolerance used to check if the current basic solution is dual |
287 ## feasible. It is not recommended that you change this parameter unless you | |
288 ## have a detailed understanding of its purpose. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
289 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
290 ## @item tolpiv (@w{@code{LPX_K_TOLPIV}}, default: 10e-9) |
5244 | 291 ## Relative tolerance used to choose eligible pivotal elements of the |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
292 ## simplex table. It is not recommended that you change this parameter unless |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
293 ## you have a detailed understanding of its purpose. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
294 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
295 ## @item objll (@w{@code{LPX_K_OBJLL}}, default: -DBL_MAX) |
5244 | 296 ## Lower limit of the objective function. If on the phase II the objective |
297 ## function reaches this limit and continues decreasing, the solver stops | |
298 ## the search. This parameter is used in the dual simplex method only. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
299 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
300 ## @item objul (@w{@code{LPX_K_OBJUL}}, default: +DBL_MAX) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
301 ## Upper limit of the objective function. If on the phase II the objective |
5244 | 302 ## function reaches this limit and continues increasing, the solver stops |
303 ## the search. This parameter is used in the dual simplex only. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
304 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
305 ## @item tmlim (@w{@code{LPX_K_TMLIM}}, default: -1.0) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
306 ## Searching time limit, in seconds. If this value is positive, it is |
5244 | 307 ## decreased each time when one simplex iteration has been performed by the |
308 ## amount of time spent for the iteration, and reaching zero value signals | |
309 ## the solver to stop the search. Negative value means no time limit. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
310 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
311 ## @item outdly (@w{@code{LPX_K_OUTDLY}}, default: 0.0) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
312 ## Output delay, in seconds. This parameter specifies how long the solver |
5244 | 313 ## should delay sending information about the solution to the standard |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
314 ## output. Non-positive value means no delay. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
315 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
316 ## @item tolint (@w{@code{LPX_K_TOLINT}}, default: 10e-5) |
5289 | 317 ## Relative tolerance used to check if the current basic solution is integer |
5244 | 318 ## feasible. It is not recommended that you change this parameter unless |
319 ## you have a detailed understanding of its purpose. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
320 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
321 ## @item tolobj (@w{@code{LPX_K_TOLOBJ}}, default: 10e-7) |
5244 | 322 ## Relative tolerance used to check if the value of the objective function |
323 ## is not better than in the best known integer feasible solution. It is | |
324 ## not recommended that you change this parameter unless you have a | |
325 ## detailed understanding of its purpose. | |
326 ## @end table | |
327 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
328 ## |
5244 | 329 ## Output values: |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
330 ## |
5244 | 331 ## @table @var |
332 ## @item xopt | |
333 ## The optimizer (the value of the decision variables at the optimum). | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
334 ## |
5244 | 335 ## @item fopt |
336 ## The optimum value of the objective function. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
337 ## |
5244 | 338 ## @item status |
339 ## Status of the optimization. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
340 ## |
5244 | 341 ## Simplex Method: |
342 ## @table @asis | |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
343 ## @item 180 (@w{@code{LPX_OPT}}) |
5244 | 344 ## Solution is optimal. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
345 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
346 ## @item 181 (@w{@code{LPX_FEAS}}) |
5244 | 347 ## Solution is feasible. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
348 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
349 ## @item 182 (@w{@code{LPX_INFEAS}}) |
5244 | 350 ## Solution is infeasible. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
351 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
352 ## @item 183 (@w{@code{LPX_NOFEAS}}) |
5244 | 353 ## Problem has no feasible solution. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
354 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
355 ## @item 184 (@w{@code{LPX_UNBND}}) |
5244 | 356 ## Problem has no unbounded solution. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
357 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
358 ## @item 185 (@w{@code{LPX_UNDEF}}) |
5244 | 359 ## Solution status is undefined. |
360 ## @end table | |
361 ## Interior Point Method: | |
362 ## @table @asis | |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
363 ## @item 150 (@w{@code{LPX_T_UNDEF}}) |
5244 | 364 ## The interior point method is undefined. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
365 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
366 ## @item 151 (@w{@code{LPX_T_OPT}}) |
5244 | 367 ## The interior point method is optimal. |
368 ## @end table | |
369 ## Mixed Integer Method: | |
370 ## @table @asis | |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
371 ## @item 170 (@w{@code{LPX_I_UNDEF}}) |
5244 | 372 ## The status is undefined. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
373 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
374 ## @item 171 (@w{@code{LPX_I_OPT}}) |
5244 | 375 ## The solution is integer optimal. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
376 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
377 ## @item 172 (@w{@code{LPX_I_FEAS}}) |
5244 | 378 ## Solution integer feasible but its optimality has not been proven |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
379 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
380 ## @item 173 (@w{@code{LPX_I_NOFEAS}}) |
5244 | 381 ## No integer feasible solution. |
382 ## @end table | |
383 ## @noindent | |
384 ## If an error occurs, @var{status} will contain one of the following | |
385 ## codes: | |
5232 | 386 ## |
5244 | 387 ## @table @asis |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
388 ## @item 204 (@w{@code{LPX_E_FAULT}}) |
5244 | 389 ## Unable to start the search. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
390 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
391 ## @item 205 (@w{@code{LPX_E_OBJLL}}) |
5244 | 392 ## Objective function lower limit reached. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
393 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
394 ## @item 206 (@w{@code{LPX_E_OBJUL}}) |
5244 | 395 ## Objective function upper limit reached. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
396 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
397 ## @item 207 (@w{@code{LPX_E_ITLIM}}) |
5244 | 398 ## Iterations limit exhausted. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
399 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
400 ## @item 208 (@w{@code{LPX_E_TMLIM}}) |
5244 | 401 ## Time limit exhausted. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
402 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
403 ## @item 209 (@w{@code{LPX_E_NOFEAS}}) |
5244 | 404 ## No feasible solution. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
405 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
406 ## @item 210 (@w{@code{LPX_E_INSTAB}}) |
5244 | 407 ## Numerical instability. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
408 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
409 ## @item 211 (@w{@code{LPX_E_SING}}) |
5244 | 410 ## Problems with basis matrix. |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
411 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
412 ## @item 212 (@w{@code{LPX_E_NOCONV}}) |
5244 | 413 ## No convergence (interior). |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
414 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
415 ## @item 213 (@w{@code{LPX_E_NOPFS}}) |
5244 | 416 ## No primal feasible solution (LP presolver). |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
417 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
418 ## @item 214 (@w{@code{LPX_E_NODFS}}) |
5244 | 419 ## No dual feasible solution (LP presolver). |
420 ## @end table | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
421 ## |
5244 | 422 ## @item extra |
423 ## A data structure containing the following fields: | |
424 ## @table @code | |
425 ## @item lambda | |
426 ## Dual variables. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
427 ## |
5244 | 428 ## @item redcosts |
429 ## Reduced Costs. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
430 ## |
5244 | 431 ## @item time |
432 ## Time (in seconds) used for solving LP/MIP problem. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
433 ## |
5244 | 434 ## @item mem |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
435 ## Memory (in bytes) used for solving LP/MIP problem (this is not |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
436 ## available if the version of @sc{glpk} is 4.15 or later). |
5244 | 437 ## @end table |
438 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
439 ## |
5244 | 440 ## Example: |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
441 ## |
5244 | 442 ## @example |
443 ## @group | |
444 ## c = [10, 6, 4]'; | |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
445 ## A = [ 1, 1, 1; |
5244 | 446 ## 10, 4, 5; |
447 ## 2, 2, 6]; | |
448 ## b = [100, 600, 300]'; | |
449 ## lb = [0, 0, 0]'; | |
450 ## ub = []; | |
451 ## ctype = "UUU"; | |
452 ## vartype = "CCC"; | |
453 ## s = -1; | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
454 ## |
5244 | 455 ## param.msglev = 1; |
456 ## param.itlim = 100; | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
457 ## |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
458 ## [xmin, fmin, status, extra] = ... |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
459 ## glpk (c, A, b, lb, ub, ctype, vartype, s, param); |
5244 | 460 ## @end group |
461 ## @end example | |
462 ## @end deftypefn | |
5232 | 463 |
5233 | 464 ## Author: Nicolo' Giorgetti <giorgetti@dii.unisi.it> |
465 ## Adapted-by: jwe | |
5232 | 466 |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
467 function [xopt, fmin, status, extra] = glpk (c, A, b, lb, ub, ctype, vartype, sense, param) |
5232 | 468 |
5233 | 469 ## If there is no input output the version and syntax |
5237 | 470 if (nargin < 3 || nargin > 9) |
6046 | 471 print_usage (); |
5233 | 472 return; |
473 endif | |
5232 | 474 |
5233 | 475 if (all (size (c) > 1) || iscomplex (c) || ischar (c)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
476 error ("glpk:C must be a real vector"); |
5233 | 477 return; |
478 endif | |
479 nx = length (c); | |
480 ## Force column vector. | |
481 c = c(:); | |
5232 | 482 |
5237 | 483 ## 2) Matrix constraint |
5232 | 484 |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
485 if (isempty (A)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
486 error ("glpk: A cannot be an empty matrix"); |
5233 | 487 return; |
488 endif | |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
489 [nc, nxa] = size(A); |
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
490 if (! isreal (A) || nxa != nx) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
491 error ("glpk: A must be a real valued %d by %d matrix", nc, nx); |
5233 | 492 return; |
493 endif | |
494 | |
5237 | 495 ## 3) RHS |
5232 | 496 |
5233 | 497 if (isempty (b)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
498 error ("glpk: B cannot be an empty vector"); |
5233 | 499 return; |
500 endif | |
501 if (! isreal (b) || length (b) != nc) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
502 error ("glpk: B must be a real valued %d by 1 vector", nc); |
5233 | 503 return; |
504 endif | |
505 | |
5237 | 506 ## 4) Vector with the lower bound of each variable |
5232 | 507 |
5237 | 508 if (nargin > 3) |
5233 | 509 if (isempty (lb)) |
8036
854683691d7a
fix invalid memory read in glpk
Jaroslav Hajek <highegg@gmail.com>
parents:
7151
diff
changeset
|
510 lb = zeros (nx, 1); |
5233 | 511 elseif (! isreal (lb) || all (size (lb) > 1) || length (lb) != nx) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
512 error ("glpk: LB must be a real valued %d by 1 column vector", nx); |
5233 | 513 return; |
514 endif | |
515 else | |
5237 | 516 lb = zeros (nx, 1); |
7151 | 517 endif |
5233 | 518 |
5237 | 519 ## 5) Vector with the upper bound of each variable |
5232 | 520 |
5237 | 521 if (nargin > 4) |
5233 | 522 if (isempty (ub)) |
10541
e9d1a974a517
Eliminate repmat (Inf, x , y) and simply use Inf (x,y)
Rik <code@nomad.inbox5.com>
parents:
9758
diff
changeset
|
523 ub = Inf (nx, 1); |
5233 | 524 elseif (! isreal (ub) || all (size (ub) > 1) || length (ub) != nx) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
525 error ("glpk: UB must be a real valued %d by 1 column vector", nx); |
5233 | 526 return; |
527 endif | |
528 else | |
10541
e9d1a974a517
Eliminate repmat (Inf, x , y) and simply use Inf (x,y)
Rik <code@nomad.inbox5.com>
parents:
9758
diff
changeset
|
529 ub = Inf (nx, 1); |
7151 | 530 endif |
5232 | 531 |
5237 | 532 ## 6) Sense of each constraint |
5232 | 533 |
5237 | 534 if (nargin > 5) |
535 if (isempty (ctype)) | |
536 ctype = repmat ("S", nc, 1); | |
537 elseif (! ischar (ctype) || all (size (ctype) > 1) || length (ctype) != nc) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
538 error ("glpk: CTYPE must be a char valued vector of length %d", nc); |
5237 | 539 return; |
540 elseif (! all (ctype == "F" | ctype == "U" | ctype == "S" | |
10549 | 541 | ctype == "L" | ctype == "D")) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
542 error ("glpk: CTYPE must contain only F, U, S, L, or D"); |
5237 | 543 return; |
544 endif | |
545 else | |
546 ctype = repmat ("S", nc, 1); | |
7151 | 547 endif |
5237 | 548 |
549 ## 7) Vector with the type of variables | |
550 | |
551 if (nargin > 6) | |
5289 | 552 if (isempty (vartype)) |
5233 | 553 vartype = repmat ("C", nx, 1); |
554 elseif (! ischar (vartype) || all (size (vartype) > 1) | |
10549 | 555 || length (vartype) != nx) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
556 error ("glpk: VARTYPE must be a char valued vector of length %d", nx); |
5233 | 557 return; |
558 elseif (! all (vartype == "C" | vartype == "I")) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
559 error ("glpk: VARTYPE must contain only C or I"); |
5233 | 560 return; |
561 endif | |
562 else | |
563 ## As default we consider continuous vars | |
564 vartype = repmat ("C", nx, 1); | |
565 endif | |
5232 | 566 |
5289 | 567 ## 8) Sense of optimization |
568 | |
569 if (nargin > 7) | |
570 if (isempty (sense)) | |
571 sense = 1; | |
572 elseif (ischar (sense) || all (size (sense) > 1) || ! isreal (sense)) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
573 error ("glpk: SENSE must be an integer value"); |
5289 | 574 elseif (sense >= 0) |
575 sense = 1; | |
576 else | |
577 sense = -1; | |
578 endif | |
579 else | |
580 sense = 1; | |
581 endif | |
582 | |
583 ## 9) Parameters vector | |
5233 | 584 |
585 if (nargin > 8) | |
586 if (! isstruct (param)) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
587 error ("glpk: PARAM must be a structure"); |
5233 | 588 return; |
589 endif | |
590 else | |
591 param = struct (); | |
592 endif | |
5232 | 593 |
5233 | 594 [xopt, fmin, status, extra] = ... |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
595 __glpk__ (c, A, b, lb, ub, ctype, vartype, sense, param); |
5232 | 596 |
597 endfunction |