Mercurial > hg > octave-lyh
annotate scripts/optimization/glpk.m @ 11233:1dfbcc9eee92
eliminate special cases for __DECCXX
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Nov 2010 21:11:43 -0500 |
parents | 693e22af08ae |
children | 994e2a93a8e2 |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 2005, 2006, 2007, 2008, 2009 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 -*- |
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 |
5244 | 81 ## |
82 ## Input arguments: | |
83 ## | |
84 ## @table @var | |
85 ## @item c | |
86 ## A column array containing the objective function coefficients. | |
87 ## | |
88 ## @item a | |
89 ## A matrix containing the constraints coefficients. | |
90 ## | |
91 ## @item b | |
92 ## A column array containing the right-hand side value for each constraint | |
93 ## in the constraint matrix. | |
94 ## | |
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. | |
99 ## | |
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. | |
104 ## | |
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 | |
109 ## @table @code | |
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 |
126 ## | |
127 ## @item vartype | |
128 ## A column array containing the types of the variables. | |
129 ## @table @code | |
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 |
136 ## | |
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. | |
140 ## | |
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. | |
146 ## | |
147 ## Integer parameters: | |
148 ## | |
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 | |
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) |
5244 | 167 ## Scaling option: |
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 | |
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 | |
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 | |
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 | |
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. | |
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. | |
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 | |
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. | |
244 ## @end table | |
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. | |
249 ## | |
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 | |
266 ## | |
267 ## Real parameters: | |
268 ## | |
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}}. |
5244 | 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. | |
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. | |
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. |
5244 | 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. | |
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. | |
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. | |
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. |
5244 | 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. | |
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 | |
328 ## | |
329 ## Output values: | |
330 ## | |
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. | |
340 ## | |
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. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
345 ## @item 181 (@w{@code{LPX_FEAS}}) |
5244 | 346 ## Solution is feasible. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
347 ## @item 182 (@w{@code{LPX_INFEAS}}) |
5244 | 348 ## Solution is infeasible. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
349 ## @item 183 (@w{@code{LPX_NOFEAS}}) |
5244 | 350 ## Problem has no feasible solution. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
351 ## @item 184 (@w{@code{LPX_UNBND}}) |
5244 | 352 ## Problem has no unbounded solution. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
353 ## @item 185 (@w{@code{LPX_UNDEF}}) |
5244 | 354 ## Solution status is undefined. |
355 ## @end table | |
356 ## Interior Point Method: | |
357 ## @table @asis | |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
358 ## @item 150 (@w{@code{LPX_T_UNDEF}}) |
5244 | 359 ## The interior point method is undefined. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
360 ## @item 151 (@w{@code{LPX_T_OPT}}) |
5244 | 361 ## The interior point method is optimal. |
362 ## @end table | |
363 ## Mixed Integer Method: | |
364 ## @table @asis | |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
365 ## @item 170 (@w{@code{LPX_I_UNDEF}}) |
5244 | 366 ## The status is undefined. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
367 ## @item 171 (@w{@code{LPX_I_OPT}}) |
5244 | 368 ## The solution is integer optimal. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
369 ## @item 172 (@w{@code{LPX_I_FEAS}}) |
5244 | 370 ## Solution integer feasible but its optimality has not been proven |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
371 ## @item 173 (@w{@code{LPX_I_NOFEAS}}) |
5244 | 372 ## No integer feasible solution. |
373 ## @end table | |
374 ## @noindent | |
375 ## If an error occurs, @var{status} will contain one of the following | |
376 ## codes: | |
5232 | 377 ## |
5244 | 378 ## @table @asis |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
379 ## @item 204 (@w{@code{LPX_E_FAULT}}) |
5244 | 380 ## Unable to start the search. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
381 ## @item 205 (@w{@code{LPX_E_OBJLL}}) |
5244 | 382 ## Objective function lower limit reached. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
383 ## @item 206 (@w{@code{LPX_E_OBJUL}}) |
5244 | 384 ## Objective function upper limit reached. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
385 ## @item 207 (@w{@code{LPX_E_ITLIM}}) |
5244 | 386 ## Iterations limit exhausted. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
387 ## @item 208 (@w{@code{LPX_E_TMLIM}}) |
5244 | 388 ## Time limit exhausted. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
389 ## @item 209 (@w{@code{LPX_E_NOFEAS}}) |
5244 | 390 ## No feasible solution. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
391 ## @item 210 (@w{@code{LPX_E_INSTAB}}) |
5244 | 392 ## Numerical instability. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
393 ## @item 211 (@w{@code{LPX_E_SING}}) |
5244 | 394 ## Problems with basis matrix. |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
395 ## @item 212 (@w{@code{LPX_E_NOCONV}}) |
5244 | 396 ## No convergence (interior). |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
397 ## @item 213 (@w{@code{LPX_E_NOPFS}}) |
5244 | 398 ## No primal feasible solution (LP presolver). |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
399 ## @item 214 (@w{@code{LPX_E_NODFS}}) |
5244 | 400 ## No dual feasible solution (LP presolver). |
401 ## @end table | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
402 ## |
5244 | 403 ## @item extra |
404 ## A data structure containing the following fields: | |
405 ## @table @code | |
406 ## @item lambda | |
407 ## Dual variables. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
408 ## |
5244 | 409 ## @item redcosts |
410 ## Reduced Costs. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
411 ## |
5244 | 412 ## @item time |
413 ## 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
|
414 ## |
5244 | 415 ## @item mem |
6333 | 416 ## 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
|
417 ## available if the version of @sc{glpk} is 4.15 or later). |
5244 | 418 ## @end table |
419 ## @end table | |
420 ## | |
421 ## Example: | |
422 ## | |
423 ## @example | |
424 ## @group | |
425 ## c = [10, 6, 4]'; | |
426 ## a = [ 1, 1, 1; | |
427 ## 10, 4, 5; | |
428 ## 2, 2, 6]; | |
429 ## b = [100, 600, 300]'; | |
430 ## lb = [0, 0, 0]'; | |
431 ## ub = []; | |
432 ## ctype = "UUU"; | |
433 ## vartype = "CCC"; | |
434 ## s = -1; | |
435 ## | |
436 ## param.msglev = 1; | |
437 ## param.itlim = 100; | |
438 ## | |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
439 ## [xmin, fmin, status, extra] = ... |
5244 | 440 ## glpk (c, a, b, lb, ub, ctype, vartype, s, param); |
441 ## @end group | |
442 ## @end example | |
443 ## @end deftypefn | |
5232 | 444 |
5233 | 445 ## Author: Nicolo' Giorgetti <giorgetti@dii.unisi.it> |
446 ## Adapted-by: jwe | |
5232 | 447 |
5237 | 448 function [xopt, fmin, status, extra] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param) |
5232 | 449 |
5233 | 450 ## If there is no input output the version and syntax |
5237 | 451 if (nargin < 3 || nargin > 9) |
6046 | 452 print_usage (); |
5233 | 453 return; |
454 endif | |
5232 | 455 |
5233 | 456 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
|
457 error ("glpk:C must be a real vector"); |
5233 | 458 return; |
459 endif | |
460 nx = length (c); | |
461 ## Force column vector. | |
462 c = c(:); | |
5232 | 463 |
5237 | 464 ## 2) Matrix constraint |
5232 | 465 |
5233 | 466 if (isempty (a)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
467 error ("glpk: A cannot be an empty matrix"); |
5233 | 468 return; |
469 endif | |
470 [nc, nxa] = size(a); | |
471 if (! isreal (a) || nxa != nx) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
472 error ("glpk: A must be a real valued %d by %d matrix", nc, nx); |
5233 | 473 return; |
474 endif | |
475 | |
5237 | 476 ## 3) RHS |
5232 | 477 |
5233 | 478 if (isempty (b)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
479 error ("glpk: B cannot be an empty vector"); |
5233 | 480 return; |
481 endif | |
482 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
|
483 error ("glpk: B must be a real valued %d by 1 vector", nc); |
5233 | 484 return; |
485 endif | |
486 | |
5237 | 487 ## 4) Vector with the lower bound of each variable |
5232 | 488 |
5237 | 489 if (nargin > 3) |
5233 | 490 if (isempty (lb)) |
8036
854683691d7a
fix invalid memory read in glpk
Jaroslav Hajek <highegg@gmail.com>
parents:
7151
diff
changeset
|
491 lb = zeros (nx, 1); |
5233 | 492 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
|
493 error ("glpk: LB must be a real valued %d by 1 column vector", nx); |
5233 | 494 return; |
495 endif | |
496 else | |
5237 | 497 lb = zeros (nx, 1); |
7151 | 498 endif |
5233 | 499 |
5237 | 500 ## 5) Vector with the upper bound of each variable |
5232 | 501 |
5237 | 502 if (nargin > 4) |
5233 | 503 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
|
504 ub = Inf (nx, 1); |
5233 | 505 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
|
506 error ("glpk: UB must be a real valued %d by 1 column vector", nx); |
5233 | 507 return; |
508 endif | |
509 else | |
10541
e9d1a974a517
Eliminate repmat (Inf, x , y) and simply use Inf (x,y)
Rik <code@nomad.inbox5.com>
parents:
9758
diff
changeset
|
510 ub = Inf (nx, 1); |
7151 | 511 endif |
5232 | 512 |
5237 | 513 ## 6) Sense of each constraint |
5232 | 514 |
5237 | 515 if (nargin > 5) |
516 if (isempty (ctype)) | |
517 ctype = repmat ("S", nc, 1); | |
518 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
|
519 error ("glpk: CTYPE must be a char valued vector of length %d", nc); |
5237 | 520 return; |
521 elseif (! all (ctype == "F" | ctype == "U" | ctype == "S" | |
10549 | 522 | ctype == "L" | ctype == "D")) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
523 error ("glpk: CTYPE must contain only F, U, S, L, or D"); |
5237 | 524 return; |
525 endif | |
526 else | |
527 ctype = repmat ("S", nc, 1); | |
7151 | 528 endif |
5237 | 529 |
530 ## 7) Vector with the type of variables | |
531 | |
532 if (nargin > 6) | |
5289 | 533 if (isempty (vartype)) |
5233 | 534 vartype = repmat ("C", nx, 1); |
535 elseif (! ischar (vartype) || all (size (vartype) > 1) | |
10549 | 536 || length (vartype) != nx) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
537 error ("glpk: VARTYPE must be a char valued vector of length %d", nx); |
5233 | 538 return; |
539 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
|
540 error ("glpk: VARTYPE must contain only C or I"); |
5233 | 541 return; |
542 endif | |
543 else | |
544 ## As default we consider continuous vars | |
545 vartype = repmat ("C", nx, 1); | |
546 endif | |
5232 | 547 |
5289 | 548 ## 8) Sense of optimization |
549 | |
550 if (nargin > 7) | |
551 if (isempty (sense)) | |
552 sense = 1; | |
553 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
|
554 error ("glpk: SENSE must be an integer value"); |
5289 | 555 elseif (sense >= 0) |
556 sense = 1; | |
557 else | |
558 sense = -1; | |
559 endif | |
560 else | |
561 sense = 1; | |
562 endif | |
563 | |
564 ## 9) Parameters vector | |
5233 | 565 |
566 if (nargin > 8) | |
567 if (! isstruct (param)) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
568 error ("glpk: PARAM must be a structure"); |
5233 | 569 return; |
570 endif | |
571 else | |
572 param = struct (); | |
573 endif | |
5232 | 574 |
5233 | 575 [xopt, fmin, status, extra] = ... |
5237 | 576 __glpk__ (c, a, b, lb, ub, ctype, vartype, sense, param); |
5232 | 577 |
578 endfunction |