annotate libinterp/dldfcn/__glpk__.cc @ 17181:4e9ff411d0fa

Remove minor stylistic C'ism * __glpk__.cc: Declare control_params with C++ syntax instead of C's typedef convention.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 05 Aug 2013 14:36:05 -0400
parents 54e251e699bb
children 2899d110c178
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
1 /*
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12805
diff changeset
3 Copyright (C) 2005-2012 Nicolo' Giorgetti
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
4 Copyright (C) 2013 Sébastien Villemot <sebastien@debian.org>
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
5
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
6 This file is part of Octave.
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
7
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
11 option) any later version.
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
12
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
16 for more details.
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
17
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
20 <http://www.gnu.org/licenses/>.
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
21
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
22 */
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
23
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
24 #ifdef HAVE_CONFIG_H
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
25 #include <config.h>
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
26 #endif
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
27
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
28 #include <cfloat>
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
29 #include <csetjmp>
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
30 #include <ctime>
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
31
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
32 #include "lo-ieee.h"
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
33
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
34 #include "defun-dld.h"
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
35 #include "error.h"
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
36 #include "gripes.h"
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
37 #include "oct-map.h"
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
38 #include "oct-obj.h"
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
39 #include "pager.h"
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
40
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
41 #if defined (HAVE_GLPK)
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
42
6333
4e81fe3bceff [project @ 2007-02-20 21:05:10 by jwe]
jwe
parents: 6287
diff changeset
43 extern "C"
4e81fe3bceff [project @ 2007-02-20 21:05:10 by jwe]
jwe
parents: 6287
diff changeset
44 {
6804
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
45 #if defined (HAVE_GLPK_GLPK_H)
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
46 #include <glpk/glpk.h>
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
47 #else
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
48 #include <glpk.h>
6804
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
49 #endif
6472
fb53fc94f526 [project @ 2007-03-29 12:49:51 by jwe]
jwe
parents: 6381
diff changeset
50 }
6333
4e81fe3bceff [project @ 2007-02-20 21:05:10 by jwe]
jwe
parents: 6287
diff changeset
51
17181
4e9ff411d0fa Remove minor stylistic C'ism
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 17180
diff changeset
52 struct control_params
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
53 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
54 int msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
55 int dual;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
56 int price;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
57 int itlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
58 int outfrq;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
59 int branch;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
60 int btrack;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
61 int presol;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
62 int rtest;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
63 int tmlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
64 int outdly;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
65 double tolbnd;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
66 double toldj;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
67 double tolpiv;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
68 double objll;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
69 double objul;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
70 double tolint;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
71 double tolobj;
17181
4e9ff411d0fa Remove minor stylistic C'ism
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 17180
diff changeset
72 };
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
73
5241
ab89f95de831 [project @ 2005-03-24 02:45:30 by jwe]
jwe
parents: 5240
diff changeset
74 static jmp_buf mark; //-- Address for long jump to jump to
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
75
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
76 int
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
77 glpk (int sense, int n, int m, double *c, int nz, int *rn, int *cn,
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
78 double *a, double *b, char *ctype, int *freeLB, double *lb,
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
79 int *freeUB, double *ub, int *vartype, int isMIP, int lpsolver,
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
80 int save_pb, int scale, const control_params *par,
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
81 double *xmin, double *fmin, int *status,
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
82 double *lambda, double *redcosts, double *time)
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
83 {
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
84 int typx = 0;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
85 int errnum = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
86
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
87 clock_t t_start = clock ();
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
88
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
89 glp_prob *lp = glp_create_prob ();
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
90
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
91 //-- Set the sense of optimization
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
92 if (sense == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
93 glp_set_obj_dir (lp, GLP_MIN);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
94 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
95 glp_set_obj_dir (lp, GLP_MAX);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
96
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
97 glp_add_cols (lp, n);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
98 for (int i = 0; i < n; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
99 {
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
100 //-- Define type of the structural variables
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
101 if (! freeLB[i] && ! freeUB[i])
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
102 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
103 if (lb[i] != ub[i])
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
104 glp_set_col_bnds (lp, i+1, GLP_DB, lb[i], ub[i]);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
105 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
106 glp_set_col_bnds (lp, i+1, GLP_FX, lb[i], ub[i]);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
107 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
108 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
109 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
110 if (! freeLB[i] && freeUB[i])
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
111 glp_set_col_bnds (lp, i+1, GLP_LO, lb[i], ub[i]);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
112 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
113 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
114 if (freeLB[i] && ! freeUB[i])
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
115 glp_set_col_bnds (lp, i+1, GLP_UP, lb[i], ub[i]);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
116 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
117 glp_set_col_bnds (lp, i+1, GLP_FR, lb[i], ub[i]);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
118 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
119 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
120
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
121 // -- Set the objective coefficient of the corresponding
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
122 // -- structural variable. No constant term is assumed.
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
123 glp_set_obj_coef(lp,i+1,c[i]);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
124
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
125 if (isMIP)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
126 glp_set_col_kind (lp, i+1, vartype[i]);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
127 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
128
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
129 glp_add_rows (lp, m);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
130
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
131 for (int i = 0; i < m; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
132 {
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
133 /* If the i-th row has no lower bound (types F,U), the
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
134 corrispondent parameter will be ignored.
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
135 If the i-th row has no upper bound (types F,L), the corrispondent
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
136 parameter will be ignored.
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
137 If the i-th row is of S type, the i-th LB is used, but
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
138 the i-th UB is ignored.
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
139 */
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
140
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
141 switch (ctype[i])
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
142 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
143 case 'F':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
144 typx = GLP_FR;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
145 break;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
146
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
147 case 'U':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
148 typx = GLP_UP;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
149 break;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
150
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
151 case 'L':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
152 typx = GLP_LO;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
153 break;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
154
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
155 case 'S':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
156 typx = GLP_FX;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
157 break;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
158
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
159 case 'D':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
160 typx = GLP_DB;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
161 break;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
162 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
163
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
164 glp_set_row_bnds (lp, i+1, typx, b[i], b[i]);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
165
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
166 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
167
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
168 glp_load_matrix (lp, nz, rn, cn, a);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
169
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
170 if (save_pb)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
171 {
6484
1ece41c144a6 [project @ 2007-04-04 03:22:16 by jwe]
jwe
parents: 6472
diff changeset
172 static char tmp[] = "outpb.lp";
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
173 if (glp_write_lp (lp, NULL, tmp) != 0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
174 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
175 error ("__glpk__: unable to write problem");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
176 longjmp (mark, -1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
177 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
178 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
179
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
180 //-- scale the problem data
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
181 if (!par->presol || lpsolver != 1)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
182 glp_scale_prob (lp, scale);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
183
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
184 //-- build advanced initial basis (if required)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
185 if (lpsolver == 1 && !par->presol)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
186 glp_adv_basis (lp, 0);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
187
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
188 /* For MIP problems without a presolver, a first pass with glp_simplex
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
189 is required */
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
190 if ((!isMIP && lpsolver == 1)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
191 || (isMIP && !par->presol))
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
192 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
193 glp_smcp smcp;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
194 glp_init_smcp (&smcp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
195 smcp.msg_lev = par->msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
196 smcp.meth = par->dual;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
197 smcp.pricing = par->price;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
198 smcp.r_test = par->rtest;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
199 smcp.tol_bnd = par->tolbnd;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
200 smcp.tol_dj = par->toldj;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
201 smcp.tol_piv = par->tolpiv;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
202 smcp.obj_ll = par->objll;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
203 smcp.obj_ul = par->objul;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
204 smcp.it_lim = par->itlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
205 smcp.tm_lim = par->tmlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
206 smcp.out_frq = par->outfrq;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
207 smcp.out_dly = par->outdly;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
208 smcp.presolve = par->presol;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
209 errnum = glp_simplex (lp, &smcp);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
210 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
211
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
212 if (isMIP)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
213 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
214 glp_iocp iocp;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
215 glp_init_iocp (&iocp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
216 iocp.msg_lev = par->msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
217 iocp.br_tech = par->branch;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
218 iocp.bt_tech = par->btrack;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
219 iocp.tol_int = par->tolint;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
220 iocp.tol_obj = par->tolobj;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
221 iocp.tm_lim = par->tmlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
222 iocp.out_frq = par->outfrq;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
223 iocp.out_dly = par->outdly;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
224 iocp.presolve = par->presol;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
225 errnum = glp_intopt (lp, &iocp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
226 }
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
227
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
228 if (!isMIP && lpsolver == 2)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
229 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
230 glp_iptcp iptcp;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
231 glp_init_iptcp (&iptcp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
232 iptcp.msg_lev = par->msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
233 errnum = glp_interior (lp, &iptcp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
234 }
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
235
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
236 if (errnum == 0)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
237 {
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
238 if (isMIP)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
239 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
240 *status = glp_mip_status (lp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
241 *fmin = glp_mip_obj_val (lp);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
242 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
243 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
244 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
245 if (lpsolver == 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
246 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
247 *status = glp_get_status (lp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
248 *fmin = glp_get_obj_val (lp);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
249 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
250 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
251 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
252 *status = glp_ipt_status (lp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
253 *fmin = glp_ipt_obj_val (lp);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
254 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
255 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
256
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
257 if (isMIP)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
258 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
259 for (int i = 0; i < n; i++)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
260 xmin[i] = glp_mip_col_val (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
261 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
262 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
263 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
264 /* Primal values */
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
265 for (int i = 0; i < n; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
266 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
267 if (lpsolver == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
268 xmin[i] = glp_get_col_prim (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
269 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
270 xmin[i] = glp_ipt_col_prim (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
271 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
272
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
273 /* Dual values */
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
274 for (int i = 0; i < m; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
275 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
276 if (lpsolver == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
277 lambda[i] = glp_get_row_dual (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
278 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
279 lambda[i] = glp_ipt_row_dual (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
280 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
281
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
282 /* Reduced costs */
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
283 for (int i = 0; i < glp_get_num_cols (lp); i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
284 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
285 if (lpsolver == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
286 redcosts[i] = glp_get_col_dual (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
287 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
288 redcosts[i] = glp_ipt_col_dual (lp, i+1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
289 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
290 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
291
5241
ab89f95de831 [project @ 2005-03-24 02:45:30 by jwe]
jwe
parents: 5240
diff changeset
292 *time = (clock () - t_start) / CLOCKS_PER_SEC;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
293 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
294
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
295 glp_delete_prob (lp);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
296
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
297 return errnum;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
298 }
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
299
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
300 #endif
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
301
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
302 #define OCTAVE_GLPK_GET_REAL_PARAM(NAME, VAL) \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
303 do \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
304 { \
11053
c33b7054f1f9 in recent Octave_map -> octave_scalar_map changes, use GETFIELD to access map elements, not CONTENTS
John W. Eaton <jwe@octave.org>
parents: 11048
diff changeset
305 octave_value tmp = PARAM.getfield (NAME); \
11047
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
306 \
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
307 if (tmp.is_defined ()) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
308 { \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
309 if (! tmp.is_empty ()) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
310 { \
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
311 VAL = tmp.scalar_value (); \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
312 \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
313 if (error_state) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
314 { \
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
315 error ("glpk: invalid value in PARAM." NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
316 return retval; \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
317 } \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
318 } \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
319 else \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
320 { \
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
321 error ("glpk: invalid value in PARAM." NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
322 return retval; \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
323 } \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
324 } \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
325 } \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
326 while (0)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
327
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
328 #define OCTAVE_GLPK_GET_INT_PARAM(NAME, VAL) \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
329 do \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
330 { \
11053
c33b7054f1f9 in recent Octave_map -> octave_scalar_map changes, use GETFIELD to access map elements, not CONTENTS
John W. Eaton <jwe@octave.org>
parents: 11048
diff changeset
331 octave_value tmp = PARAM.getfield (NAME); \
11047
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
332 \
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
333 if (tmp.is_defined ()) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
334 { \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
335 if (! tmp.is_empty ()) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
336 { \
11047
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
337 VAL = tmp.int_value (); \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
338 \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
339 if (error_state) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
340 { \
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
341 error ("glpk: invalid value in PARAM." NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
342 return retval; \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
343 } \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
344 } \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
345 else \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
346 { \
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
347 error ("glpk: invalid value in PARAM." NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
348 return retval; \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
349 } \
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
350 } \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
351 } \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
352 while (0)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
353
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
354 DEFUN_DLD (__glpk__, args, ,
5245
3589aff4a35d [project @ 2005-03-25 03:36:13 by jwe]
jwe
parents: 5241
diff changeset
355 "-*- texinfo -*-\n\
3589aff4a35d [project @ 2005-03-25 03:36:13 by jwe]
jwe
parents: 5241
diff changeset
356 @deftypefn {Loadable Function} {[@var{values}] =} __glpk__ (@var{args})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6898
diff changeset
357 Undocumented internal function.\n\
5245
3589aff4a35d [project @ 2005-03-25 03:36:13 by jwe]
jwe
parents: 5241
diff changeset
358 @end deftypefn")
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
359 {
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
360 // The list of values to return. See the declaration in oct-obj.h
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
361 octave_value_list retval;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
362
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
363 #if defined (HAVE_GLPK)
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
364
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
365 int nrhs = args.length ();
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
366
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
367 if (nrhs != 9)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
368 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5631
diff changeset
369 print_usage ();
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
370 return retval;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
371 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
372
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
373 //-- 1nd Input. A column array containing the objective function
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
374 //-- coefficients.
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
375 volatile int mrowsc = args(0).rows ();
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
376
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
377 Matrix C (args(0).matrix_value ());
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
378
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
379 if (error_state)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
380 {
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
381 error ("__glpk__: invalid value of C");
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
382 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
383 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
384
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
385 double *c = C.fortran_vec ();
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
386 Array<int> rn;
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
387 Array<int> cn;
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
388 ColumnVector a;
5515
ae35b3381c7a [project @ 2005-10-27 16:46:07 by jwe]
jwe
parents: 5455
diff changeset
389 volatile int mrowsA;
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
390 volatile int nz = 0;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
391
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
392 //-- 2nd Input. A matrix containing the constraints coefficients.
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
393 // If matrix A is NOT a sparse matrix
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
394 if (args(1).is_sparse_type ())
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
395 {
5603
2c66c36d2698 [project @ 2006-01-31 11:57:47 by dbateman]
dbateman
parents: 5515
diff changeset
396 SparseMatrix A = args(1).sparse_matrix_value (); // get the sparse matrix
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
397
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
398 if (error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
399 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
400 error ("__glpk__: invalid value of A");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
401 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
402 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
403
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
404 mrowsA = A.rows ();
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
405 octave_idx_type Anc = A.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10350
diff changeset
406 octave_idx_type Anz = A.nnz ();
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
407 rn.resize (dim_vector (Anz+1, 1));
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
408 cn.resize (dim_vector (Anz+1, 1));
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
409 a.resize (Anz+1, 0.0);
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
410
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
411 if (Anc != mrowsc)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
412 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
413 error ("__glpk__: invalid value of A");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
414 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
415 }
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
416
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
417 for (octave_idx_type j = 0; j < Anc; j++)
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
418 for (octave_idx_type i = A.cidx (j); i < A.cidx (j+1); i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
419 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
420 nz++;
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
421 rn(nz) = A.ridx (i) + 1;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
422 cn(nz) = j + 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
423 a(nz) = A.data(i);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
424 }
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
425 }
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
426 else
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
427 {
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
428 Matrix A (args(1).matrix_value ()); // get the matrix
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
429
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
430 if (error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
431 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
432 error ("__glpk__: invalid value of A");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
433 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
434 }
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
435
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
436 mrowsA = A.rows ();
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
437 rn.resize (dim_vector (mrowsA*mrowsc+1, 1));
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
438 cn.resize (dim_vector (mrowsA*mrowsc+1, 1));
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
439 a.resize (mrowsA*mrowsc+1, 0.0);
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
440
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
441 for (int i = 0; i < mrowsA; i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
442 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
443 for (int j = 0; j < mrowsc; j++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
444 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
445 if (A(i,j) != 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
446 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
447 nz++;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
448 rn(nz) = i + 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
449 cn(nz) = j + 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
450 a(nz) = A(i,j);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
451 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
452 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
453 }
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
454
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
455 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
456
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
457 //-- 3rd Input. A column array containing the right-hand side value
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
458 // for each constraint in the constraint matrix.
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
459 Matrix B (args(2).matrix_value ());
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
460
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
461 if (error_state)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
462 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
463 error ("__glpk__: invalid value of B");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
464 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
465 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
466
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
467 double *b = B.fortran_vec ();
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
468
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
469 //-- 4th Input. An array of length mrowsc containing the lower
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
470 //-- bound on each of the variables.
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
471 Matrix LB (args(3).matrix_value ());
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
472
8036
854683691d7a fix invalid memory read in glpk
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
473 if (error_state || LB.length () < mrowsc)
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
474 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
475 error ("__glpk__: invalid value of LB");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
476 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
477 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
478
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
479 double *lb = LB.fortran_vec ();
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
480
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
481 //-- LB argument, default: Free
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
482 Array<int> freeLB (dim_vector (mrowsc, 1));
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
483 for (int i = 0; i < mrowsc; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
484 {
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
485 if (xisinf (lb[i]))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
486 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
487 freeLB(i) = 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
488 lb[i] = -octave_Inf;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
489 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
490 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
491 freeLB(i) = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
492 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
493
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
494 //-- 5th Input. An array of at least length numcols containing the upper
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
495 //-- bound on each of the variables.
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
496 Matrix UB (args(4).matrix_value ());
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
497
8036
854683691d7a fix invalid memory read in glpk
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
498 if (error_state || UB.length () < mrowsc)
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
499 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
500 error ("__glpk__: invalid value of UB");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
501 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
502 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
503
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
504 double *ub = UB.fortran_vec ();
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
505
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
506 Array<int> freeUB (dim_vector (mrowsc, 1));
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
507 for (int i = 0; i < mrowsc; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
508 {
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
509 if (xisinf (ub[i]))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
510 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
511 freeUB(i) = 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
512 ub[i] = octave_Inf;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
513 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
514 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
515 freeUB(i) = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
516 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
517
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
518 //-- 6th Input. A column array containing the sense of each constraint
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
519 //-- in the constraint matrix.
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
520 charMatrix CTYPE (args(5).char_matrix_value ());
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
521
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
522 if (error_state)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
523 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
524 error ("__glpk__: invalid value of CTYPE");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
525 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
526 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
527
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
528 char *ctype = CTYPE.fortran_vec ();
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
529
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
530 //-- 7th Input. A column array containing the types of the variables.
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
531 charMatrix VTYPE (args(6).char_matrix_value ());
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
532
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
533 if (error_state)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
534 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
535 error ("__glpk__: invalid value of VARTYPE");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
536 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
537 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
538
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
539 Array<int> vartype (dim_vector (mrowsc, 1));
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
540 volatile int isMIP = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
541 for (int i = 0; i < mrowsc ; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
542 {
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
543 if (VTYPE(i,0) == 'I')
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
544 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
545 isMIP = 1;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
546 vartype(i) = GLP_IV;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
547 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
548 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
549 vartype(i) = GLP_CV;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
550 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
551
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
552 //-- 8th Input. Sense of optimization.
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
553 volatile int sense;
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
554 double SENSE = args(7).scalar_value ();
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
555
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
556 if (error_state)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
557 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
558 error ("__glpk__: invalid value of SENSE");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
559 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
560 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
561
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
562 if (SENSE >= 0)
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
563 sense = 1;
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
564 else
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
565 sense = -1;
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
566
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
567 //-- 9th Input. A structure containing the control parameters.
11047
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
568 octave_scalar_map PARAM = args(8).scalar_map_value ();
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
569
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
570 if (error_state)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
571 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
572 error ("__glpk__: invalid value of PARAM");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
573 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
574 }
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
575
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
576 control_params par;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
577
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
578 //-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
579 //-- Integer parameters
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
580 //-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
581
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
582 //-- Level of messages output by the solver
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
583 par.msglev = 1;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
584 OCTAVE_GLPK_GET_INT_PARAM ("msglev", par.msglev);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
585 if (par.msglev < 0 || par.msglev > 3)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
586 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
587 error ("__glpk__: PARAM.msglev must be 0 (no output) or 1 (error and warning messages only [default]) or 2 (normal output) or 3 (full output)");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
588 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
589 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
590
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
591 //-- scaling option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
592 volatile int scale = 16;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
593 OCTAVE_GLPK_GET_INT_PARAM ("scale", scale);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
594 if (scale < 0 || scale > 128)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
595 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
596 error ("__glpk__: PARAM.scale must either be 128 (automatic selection of scaling options), or a bitwise or of: 1 (geometric mean scaling), 16 (equilibration scaling), 32 (round scale factors to power of two), 64 (skip if problem is well scaled");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
597 return retval;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
598 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
599
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
600 //-- Dual simplex option
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
601 par.dual = 1;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
602 OCTAVE_GLPK_GET_INT_PARAM ("dual", par.dual);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
603 if (par.dual < 1 || par.dual > 3)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
604 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
605 error ("__glpk__: PARAM.dual must be 1 (use two-phase primal simplex [default]) or 2 (use two-phase dual simplex) or 3 (use two-phase dual simplex, and if it fails, switch to the primal simplex)");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
606 return retval;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
607 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
608
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
609 //-- Pricing option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
610 par.price = 34;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
611 OCTAVE_GLPK_GET_INT_PARAM ("price", par.price);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
612 if (par.price != 17 && par.price != 34)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
613 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
614 error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
615 return retval;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
616 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
617
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
618 //-- Simplex iterations limit
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
619 par.itlim = INT_MAX;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
620 OCTAVE_GLPK_GET_INT_PARAM ("itlim", par.itlim);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
621
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
622 //-- Output frequency, in iterations
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
623 par.outfrq = 200;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
624 OCTAVE_GLPK_GET_INT_PARAM ("outfrq", par.outfrq);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
625
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
626 //-- Branching heuristic option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
627 par.branch = 4;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
628 OCTAVE_GLPK_GET_INT_PARAM ("branch", par.branch);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
629 if (par.branch < 1 || par.branch > 5)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
630 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
631 error ("__glpk__: PARAM.branch must be 1 (first fractional variable) or 2 (last fractional variable) or 3 (most fractional variable) or 4 (heuristic by Driebeck and Tomlin [default]) or 5 (hybrid pseudocost heuristic)");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
632 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
633 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
634
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
635 //-- Backtracking heuristic option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
636 par.btrack = 4;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
637 OCTAVE_GLPK_GET_INT_PARAM ("btrack", par.btrack);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
638 if (par.btrack < 1 || par.btrack > 4)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
639 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
640 error ("__glpk__: PARAM.btrack must be 1 (depth first search) or 2 (breadth first search) or 3 (best local bound) or 4 (best projection heuristic [default]");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
641 return retval;
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
642 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
643
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
644 //-- Presolver option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
645 par.presol = 1;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
646 OCTAVE_GLPK_GET_INT_PARAM ("presol", par.presol);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
647 if (par.presol < 0 || par.presol > 1)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
648 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
649 error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
650 return retval;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
651 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
652
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
653 //-- LPsolver option
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
654 volatile int lpsolver = 1;
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
655 OCTAVE_GLPK_GET_INT_PARAM ("lpsolver", lpsolver);
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
656 if (lpsolver < 1 || lpsolver > 2)
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
657 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
658 error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
659 return retval;
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
660 }
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
661
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
662 //-- Ratio test option
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
663 par.rtest = 34;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
664 OCTAVE_GLPK_GET_INT_PARAM ("rtest", par.rtest);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
665 if (par.rtest != 17 && par.rtest != 34)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
666 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
667 error ("__glpk__: PARAM.rtest must be 17 (standard ratio test) or 34 (Harris' two-pass ratio test [default])");
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
668 return retval;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
669 }
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
670
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
671 par.tmlim = INT_MAX;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
672 OCTAVE_GLPK_GET_INT_PARAM ("tmlim", par.tmlim);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
673
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
674 par.outdly = 0;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
675 OCTAVE_GLPK_GET_INT_PARAM ("outdly", par.outdly);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
676
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
677 //-- Save option
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
678 volatile int save_pb = 0;
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
679 OCTAVE_GLPK_GET_INT_PARAM ("save", save_pb);
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
680 save_pb = save_pb != 0;
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
681
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
682 //-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
683 //-- Real parameters
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
684 //-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
685
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
686 //-- Relative tolerance used to check if the current basic solution
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
687 //-- is primal feasible
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
688 par.tolbnd = 1e-7;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
689 OCTAVE_GLPK_GET_REAL_PARAM ("tolbnd", par.tolbnd);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
690
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
691 //-- Absolute tolerance used to check if the current basic solution
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
692 //-- is dual feasible
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
693 par.toldj = 1e-7;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
694 OCTAVE_GLPK_GET_REAL_PARAM ("toldj", par.toldj);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
695
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
696 //-- Relative tolerance used to choose eligible pivotal elements of
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
697 //-- the simplex table in the ratio test
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
698 par.tolpiv = 1e-10;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
699 OCTAVE_GLPK_GET_REAL_PARAM ("tolpiv", par.tolpiv);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
700
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
701 par.objll = -std::numeric_limits<double>::max ();
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
702 OCTAVE_GLPK_GET_REAL_PARAM ("objll", par.objll);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
703
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
704 par.objul = std::numeric_limits<double>::max ();
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
705 OCTAVE_GLPK_GET_REAL_PARAM ("objul", par.objul);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
706
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
707 par.tolint = 1e-5;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
708 OCTAVE_GLPK_GET_REAL_PARAM ("tolint", par.tolint);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
709
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
710 par.tolobj = 1e-7;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
711 OCTAVE_GLPK_GET_REAL_PARAM ("tolobj", par.tolobj);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
712
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
713 //-- Assign pointers to the output parameters
8068
e3e3d12364b0 make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents: 8036
diff changeset
714 ColumnVector xmin (mrowsc, octave_NA);
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
715 double fmin = octave_NA;
8068
e3e3d12364b0 make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents: 8036
diff changeset
716 ColumnVector lambda (mrowsA, octave_NA);
e3e3d12364b0 make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents: 8036
diff changeset
717 ColumnVector redcosts (mrowsc, octave_NA);
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
718 double time;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
719 int status, errnum = 0;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
720
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
721 int jmpret = setjmp (mark);
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
722
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
723 if (jmpret == 0)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
724 errnum = glpk (sense, mrowsc, mrowsA, c, nz, rn.fortran_vec (),
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
725 cn.fortran_vec (), a.fortran_vec (), b, ctype,
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
726 freeLB.fortran_vec (), lb, freeUB.fortran_vec (), ub,
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
727 vartype.fortran_vec (), isMIP, lpsolver, save_pb, scale, &par,
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
728 xmin.fortran_vec (), &fmin, &status, lambda.fortran_vec (),
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
729 redcosts.fortran_vec (), &time);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
730
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
731 octave_scalar_map extra;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
732
5238
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
733 if (! isMIP)
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
734 {
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
735 extra.assign ("lambda", lambda);
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
736 extra.assign ("redcosts", redcosts);
5238
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
737 }
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
738
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
739 extra.assign ("time", time);
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
740 extra.assign ("status", status);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
741
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
742 retval(3) = extra;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
743 retval(2) = errnum;
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
744 retval(1) = fmin;
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
745 retval(0) = xmin;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
746
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
747 #else
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
748
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
749 gripe_not_supported ("glpk");
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
750
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
751 #endif
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
752
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
753 return retval;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
754 }
12805
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
755
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
756 /*
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
757 ## No test needed for internal helper function.
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
758 %!assert (1)
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
759 */