annotate libinterp/dldfcn/__glpk__.cc @ 21100:e39e05d90788

Switch gripe_XXX to either err_XXX or warn_XXX naming scheme. * libinterp/corefcn/errwarn.h, libinterp/corefcn/errwarn.cc: New header and .cc file with common errors and warnings for libinterp. * libinterp/corefcn/module.mk: Add errwarn.h, errwarn.cc to build system. * liboctave/util/lo-array-errwarn.h, liboctave/util/lo-array-errwarn.cc: New header and .cc file with common errors and warnings for liboctave. * liboctave/util/module.mk: Add lo-array-errwarn.h, lo-array-errwarn.cc to build system. * lo-array-gripes.h: #include "lo-array-errwarn.h" for access to class index_exception. Remove const char *error_id_XXX prototypes. * lo-array-gripes.cc: Remove const char *error_id_XXX initializations. Remove index_exception method definitions. * Cell.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, betainc.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc, dirfns.cc, eig.cc, fft.cc, fft2.cc, fftn.cc, find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, graphics.in.h, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jit-typeinfo.cc, load-save.cc, lookup.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, lsode.cc, lu.cc, luinc.cc, max.cc, mgorth.cc, oct-hist.cc, oct-procbuf.cc, oct-stream.cc, oct.h, pager.cc, pinv.cc, pr-output.cc, quad.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, syscalls.cc, typecast.cc, utils.cc, variables.cc, xdiv.cc, xnorm.cc, xpow.cc, __eigs__.cc, __glpk__.cc, __magick_read__.cc, __osmesa_print__.cc, audiodevinfo.cc, audioread.cc, chol.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-mex-fcn.cc, ov-perm.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-struct.cc, ov-type-conv.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc, op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int-conv.cc, op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, lex.ll, pt-assign.cc, pt-eval.cc, pt-idx.cc, pt-loop.cc, pt-mat.cc, pt-stmt.cc, Array-util.cc, Array-util.h, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MDiagArray2.cc, MSparse.cc, PermMatrix.cc, Range.cc, Sparse.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, CmplxGEPBAL.cc, dbleGEPBAL.cc, fCmplxGEPBAL.cc, floatGEPBAL.cc, Sparse-diag-op-defs.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, mx-inlines.cc, mx-op-defs.h, oct-binmap.h: Replace 'include "gripes.h"' with 'include "errwarn.h". Change all gripe_XXX to err_XXX or warn_XXX or errwarn_XXX.
author Rik <rik@octave.org>
date Mon, 18 Jan 2016 18:28:06 -0800
parents 72eefc36c6b7
children fcac5dbbf9ed
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
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
3 Copyright (C) 2005-2015 Nicolo' Giorgetti
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
4 Copyright (C) 2013-2015 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 <ctime>
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
30
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
31 #include "lo-ieee.h"
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
32
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
33 #include "defun-dld.h"
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
34 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21091
diff changeset
35 #include "errwarn.h"
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
36 #include "oct-map.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
37 #include "ovl.h"
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
38 #include "pager.h"
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
39
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
40 #if defined (HAVE_GLPK)
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
41
6333
4e81fe3bceff [project @ 2007-02-20 21:05:10 by jwe]
jwe
parents: 6287
diff changeset
42 extern "C"
4e81fe3bceff [project @ 2007-02-20 21:05:10 by jwe]
jwe
parents: 6287
diff changeset
43 {
6804
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
44 #if defined (HAVE_GLPK_GLPK_H)
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
45 #include <glpk/glpk.h>
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
46 #else
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
47 #include <glpk.h>
6804
4d3fa8841006 [project @ 2007-07-26 18:44:06 by jwe]
jwe
parents: 6484
diff changeset
48 #endif
6472
fb53fc94f526 [project @ 2007-03-29 12:49:51 by jwe]
jwe
parents: 6381
diff changeset
49 }
6333
4e81fe3bceff [project @ 2007-02-20 21:05:10 by jwe]
jwe
parents: 6287
diff changeset
50
17181
4e9ff411d0fa Remove minor stylistic C'ism
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 17180
diff changeset
51 struct control_params
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
52 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
53 int msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
54 int dual;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
55 int price;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
56 int itlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
57 int outfrq;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
58 int branch;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
59 int btrack;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
60 int presol;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
61 int rtest;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
62 int tmlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
63 int outdly;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
64 double tolbnd;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
65 double toldj;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
66 double tolpiv;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
67 double objll;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
68 double objul;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
69 double tolint;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
70 double tolobj;
17181
4e9ff411d0fa Remove minor stylistic C'ism
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 17180
diff changeset
71 };
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
72
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
73 int
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
74 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
75 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
76 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
77 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
78 double *xmin, double *fmin, int *status,
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
79 double *lambda, double *redcosts, double *time)
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
80 {
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
81 int typx = 0;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
82 int errnum = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
83
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
84 clock_t t_start = clock ();
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
85
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
86 glp_prob *lp = glp_create_prob ();
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
87
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
88 // Set the sense of optimization
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
89 if (sense == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
90 glp_set_obj_dir (lp, GLP_MIN);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
91 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
92 glp_set_obj_dir (lp, GLP_MAX);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
93
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
94 glp_add_cols (lp, n);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
95 for (int i = 0; i < n; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
96 {
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
97 // Define type of the structural variables
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
98 if (! freeLB[i] && ! freeUB[i])
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
99 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
100 if (lb[i] != ub[i])
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
101 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
102 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
103 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
104 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
105 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
106 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
107 if (! freeLB[i] && freeUB[i])
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
108 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
109 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
110 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
111 if (freeLB[i] && ! freeUB[i])
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
112 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
113 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
114 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
115 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
116 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
117
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
118 // -- Set the objective coefficient of the corresponding
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
119 // -- 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
120 glp_set_obj_coef(lp,i+1,c[i]);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
121
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
122 if (isMIP)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
123 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
124 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
125
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
126 glp_add_rows (lp, m);
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 for (int i = 0; i < m; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
129 {
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
130 // If the i-th row has no lower bound (types F,U), the
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
131 // corrispondent parameter will be ignored. If the i-th row has
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
132 // no upper bound (types F,L), the corrispondent parameter will be
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
133 // ignored. If the i-th row is of S type, the i-th LB is used,
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
134 // but the i-th UB is ignored.
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
135
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
136 switch (ctype[i])
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
137 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
138 case 'F':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
139 typx = GLP_FR;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
140 break;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
141
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
142 case 'U':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
143 typx = GLP_UP;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
144 break;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
145
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
146 case 'L':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
147 typx = GLP_LO;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
148 break;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
149
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
150 case 'S':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
151 typx = GLP_FX;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
152 break;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
153
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
154 case 'D':
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
155 typx = GLP_DB;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
156 break;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
157 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
158
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
159 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
160
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
161 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
162
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
163 glp_load_matrix (lp, nz, rn, cn, a);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
164
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
165 if (save_pb)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
166 {
6484
1ece41c144a6 [project @ 2007-04-04 03:22:16 by jwe]
jwe
parents: 6472
diff changeset
167 static char tmp[] = "outpb.lp";
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
168 if (glp_write_lp (lp, 0, tmp) != 0)
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
169 error ("__glpk__: unable to write problem");
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
170 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
171
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
172 // scale the problem data
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
173 if (! par->presol || lpsolver != 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
174 glp_scale_prob (lp, scale);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
175
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
176 // build advanced initial basis (if required)
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
177 if (lpsolver == 1 && ! par->presol)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
178 glp_adv_basis (lp, 0);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
179
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
180 // For MIP problems without a presolver, a first pass with glp_simplex
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
181 // is required
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
182 if ((! isMIP && lpsolver == 1)
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
183 || (isMIP && ! par->presol))
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
184 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
185 glp_smcp smcp;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
186 glp_init_smcp (&smcp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
187 smcp.msg_lev = par->msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
188 smcp.meth = par->dual;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
189 smcp.pricing = par->price;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
190 smcp.r_test = par->rtest;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
191 smcp.tol_bnd = par->tolbnd;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
192 smcp.tol_dj = par->toldj;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
193 smcp.tol_piv = par->tolpiv;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
194 smcp.obj_ll = par->objll;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
195 smcp.obj_ul = par->objul;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
196 smcp.it_lim = par->itlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
197 smcp.tm_lim = par->tmlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
198 smcp.out_frq = par->outfrq;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
199 smcp.out_dly = par->outdly;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
200 smcp.presolve = par->presol;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
201 errnum = glp_simplex (lp, &smcp);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
202 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
203
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
204 if (isMIP)
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
205 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
206 glp_iocp iocp;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
207 glp_init_iocp (&iocp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
208 iocp.msg_lev = par->msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
209 iocp.br_tech = par->branch;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
210 iocp.bt_tech = par->btrack;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
211 iocp.tol_int = par->tolint;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
212 iocp.tol_obj = par->tolobj;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
213 iocp.tm_lim = par->tmlim;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
214 iocp.out_frq = par->outfrq;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
215 iocp.out_dly = par->outdly;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
216 iocp.presolve = par->presol;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
217 errnum = glp_intopt (lp, &iocp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
218 }
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
219
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
220 if (! isMIP && lpsolver == 2)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
221 {
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
222 glp_iptcp iptcp;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
223 glp_init_iptcp (&iptcp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
224 iptcp.msg_lev = par->msglev;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
225 errnum = glp_interior (lp, &iptcp);
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 (errnum == 0)
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
229 {
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
230 if (isMIP)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
231 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
232 *status = glp_mip_status (lp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
233 *fmin = glp_mip_obj_val (lp);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
234 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
235 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
236 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
237 if (lpsolver == 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
238 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
239 *status = glp_get_status (lp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
240 *fmin = glp_get_obj_val (lp);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
241 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
242 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
243 {
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
244 *status = glp_ipt_status (lp);
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
245 *fmin = glp_ipt_obj_val (lp);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
246 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
247 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
248
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
249 if (isMIP)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
250 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
251 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
252 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
253 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
254 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
255 {
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
256 // Primal values
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
257 for (int i = 0; i < n; i++)
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 if (lpsolver == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
260 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
261 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
262 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
263 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
264
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
265 // Dual values
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
266 for (int i = 0; i < m; i++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
267 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
268 if (lpsolver == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
269 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
270 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
271 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
272 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
273
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
274 // Reduced costs
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
275 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
276 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
277 if (lpsolver == 1)
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
278 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
279 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
280 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
281 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
282 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
283
5241
ab89f95de831 [project @ 2005-03-24 02:45:30 by jwe]
jwe
parents: 5240
diff changeset
284 *time = (clock () - t_start) / CLOCKS_PER_SEC;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
285 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
286
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
287 glp_delete_prob (lp);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
288
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
289 return errnum;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
290 }
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
291
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
292 #endif
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
293
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
294 #define OCTAVE_GLPK_GET_REAL_PARAM(NAME, VAL) \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
295 do \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
296 { \
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
297 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
298 \
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
299 if (tmp.is_defined ()) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
300 { \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
301 if (! tmp.is_empty ()) \
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
302 VAL = tmp.xscalar_value ("glpk: invalid value in PARAM" NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
303 else \
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
304 error ("glpk: invalid value in PARAM" NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
305 } \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
306 } \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
307 while (0)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
308
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
309 #define OCTAVE_GLPK_GET_INT_PARAM(NAME, VAL) \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
310 do \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
311 { \
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
312 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
313 \
52609f73c7d9 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10527
diff changeset
314 if (tmp.is_defined ()) \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
315 { \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
316 if (! tmp.is_empty ()) \
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
317 VAL = tmp.xint_value ("glpk: invalid value in PARAM" NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
318 else \
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
319 error ("glpk: invalid value in PARAM" NAME); \
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
320 } \
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
321 } \
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
322 while (0)
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
323
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
324 DEFUN_DLD (__glpk__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
325 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20825
diff changeset
326 @deftypefn {} {[@var{values}] =} __glpk__ (@var{args})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6898
diff changeset
327 Undocumented internal function.\n\
5245
3589aff4a35d [project @ 2005-03-25 03:36:13 by jwe]
jwe
parents: 5241
diff changeset
328 @end deftypefn")
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
329 {
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
330 #if defined (HAVE_GLPK)
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
331
20812
d9ca869ca124 maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents: 20790
diff changeset
332 // FIXME: Should we even need checking for an internal function?
20818
cef0448a6ed2 eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20812
diff changeset
333 if (args.length () != 9)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20704
diff changeset
334 print_usage ();
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
335
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20867
diff changeset
336 // 1nd Input. A column array containing the objective function coefficients.
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
337 int mrowsc = args(0).rows ();
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
338
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
339 Matrix C = args(0).xmatrix_value ("__glpk__: invalid value of C");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
340
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
341 double *c = C.fortran_vec ();
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
342 Array<int> rn;
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
343 Array<int> cn;
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
344 ColumnVector a;
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
345 int mrowsA;
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
346 int nz = 0;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
347
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20867
diff changeset
348 // 2nd Input. A matrix containing the constraints coefficients.
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
349 // If matrix A is NOT a sparse matrix
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
350 if (args(1).is_sparse_type ())
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
351 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
352 SparseMatrix A = args(1).xsparse_matrix_value ("__glpk__: invalid value of A");
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
353
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
354 mrowsA = A.rows ();
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
355 octave_idx_type Anc = A.cols ();
10527
b4d2080b6df7 Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents: 10350
diff changeset
356 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
357 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
358 cn.resize (dim_vector (Anz+1, 1));
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
359 a.resize (Anz+1, 0.0);
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
360
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
361 if (Anc != mrowsc)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
362 error ("__glpk__: invalid value of A");
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
363
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
364 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
365 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
366 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
367 nz++;
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
368 rn(nz) = A.ridx (i) + 1;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
369 cn(nz) = j + 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
370 a(nz) = A.data(i);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
371 }
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
372 }
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
373 else
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
374 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
375 Matrix A = args(1).xmatrix_value ("__glpk__: invalid value of A");
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
376
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
377 mrowsA = A.rows ();
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
378 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
379 cn.resize (dim_vector (mrowsA*mrowsc+1, 1));
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
380 a.resize (mrowsA*mrowsc+1, 0.0);
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
381
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
382 for (int i = 0; i < mrowsA; i++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
383 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
384 for (int j = 0; j < mrowsc; j++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
385 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
386 if (A(i,j) != 0)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
387 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
388 nz++;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
389 rn(nz) = i + 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
390 cn(nz) = j + 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
391 a(nz) = A(i,j);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
392 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
393 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
394 }
5631
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
395
7171d19706df [project @ 2006-02-22 20:15:06 by dbateman]
dbateman
parents: 5604
diff changeset
396 }
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
397
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
398 // 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
399 // for each constraint in the constraint matrix.
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
400 Matrix B = args(2).xmatrix_value ("__glpk__: invalid value of B");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
401
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
402 double *b = B.fortran_vec ();
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
403
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
404 // 4th Input. An array of length mrowsc containing the lower
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
405 // bound on each of the variables.
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
406 Matrix LB = args(3).xmatrix_value ("__glpk__: invalid value of LB");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
407
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
408 if (LB.numel () < mrowsc)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
409 error ("__glpk__: invalid dimensions for LB");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
410
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
411 double *lb = LB.fortran_vec ();
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
412
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
413 // LB argument, default: Free
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
414 Array<int> freeLB (dim_vector (mrowsc, 1));
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
415 for (int i = 0; i < mrowsc; i++)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
416 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
417 if (xisinf (lb[i]))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
418 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
419 freeLB(i) = 1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
420 lb[i] = -octave_Inf;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
421 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
422 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
423 freeLB(i) = 0;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
424 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
425
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
426 // 5th Input. An array of at least length numcols containing the upper
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
427 // bound on each of the variables.
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
428 Matrix UB = args(4).xmatrix_value ("__glpk__: invalid value of UB");
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
429
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
430 if (UB.numel () < mrowsc)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
431 error ("__glpk__: invalid dimensions for UB");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
432
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
433 double *ub = UB.fortran_vec ();
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
434
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
435 Array<int> freeUB (dim_vector (mrowsc, 1));
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
436 for (int i = 0; i < mrowsc; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
437 {
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5307
diff changeset
438 if (xisinf (ub[i]))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
439 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
440 freeUB(i) = 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
441 ub[i] = octave_Inf;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
442 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
443 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
444 freeUB(i) = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
445 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
446
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
447 // 6th Input. A column array containing the sense of each constraint
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
448 // in the constraint matrix.
21091
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
449 charMatrix CTYPE = args(5).xchar_matrix_value ("__glpk__: invalid value of CTYPE");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
450
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
451 char *ctype = CTYPE.fortran_vec ();
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
452
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
453 // 7th Input. A column array containing the types of the variables.
21091
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
454 charMatrix VTYPE = args(6).xchar_matrix_value ("__glpk__: invalid value of VARTYPE");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
455
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
456 Array<int> vartype (dim_vector (mrowsc, 1));
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
457 int isMIP = 0;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
458 for (int i = 0; i < mrowsc ; i++)
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
459 {
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
460 if (VTYPE(i,0) == 'I')
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
461 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
462 isMIP = 1;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
463 vartype(i) = GLP_IV;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
464 }
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
465 else
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
466 vartype(i) = GLP_CV;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
467 }
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
468
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
469 // 8th Input. Sense of optimization.
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
470 int sense;
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
471 double SENSE = args(7).xscalar_value ("__glpk__: invalid value of SENSE");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
472
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
473 if (SENSE >= 0)
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
474 sense = 1;
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
475 else
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
476 sense = -1;
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
477
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
478 // 9th Input. A structure containing the control parameters.
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
479 octave_scalar_map PARAM = args(8).xscalar_map_value ("__glpk__: invalid value of PARAM");
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
480
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
481 control_params par;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
482
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
483 // Integer parameters
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
484
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
485 // 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
486 par.msglev = 1;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
487 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
488 if (par.msglev < 0 || par.msglev > 3)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
489 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)");
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
490
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
491 // scaling option
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
492 int scale = 16;
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
493 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
494 if (scale < 0 || scale > 128)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
495 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");
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
496
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
497 // Dual simplex option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
498 par.dual = 1;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
499 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
500 if (par.dual < 1 || par.dual > 3)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
501 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)");
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
502
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
503 // Pricing option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
504 par.price = 34;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
505 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
506 if (par.price != 17 && par.price != 34)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
507 error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])");
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
508
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
509 // Simplex iterations limit
17195
2899d110c178 Use std::numeric_limits instead of INT_MAX in __glpk__ (bug #39715).
Rik <rik@octave.org>
parents: 17181
diff changeset
510 par.itlim = std::numeric_limits<int>::max ();
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
511 OCTAVE_GLPK_GET_INT_PARAM ("itlim", par.itlim);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
512
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
513 // Output frequency, in iterations
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
514 par.outfrq = 200;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
515 OCTAVE_GLPK_GET_INT_PARAM ("outfrq", par.outfrq);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
516
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
517 // Branching heuristic option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
518 par.branch = 4;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
519 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
520 if (par.branch < 1 || par.branch > 5)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
521 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)");
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
522
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
523 // Backtracking heuristic option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
524 par.btrack = 4;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
525 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
526 if (par.btrack < 1 || par.btrack > 4)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
527 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]");
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
528
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
529 // Presolver option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
530 par.presol = 1;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
531 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
532 if (par.presol < 0 || par.presol > 1)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
533 error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])");
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
534
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
535 // LPsolver option
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
536 int lpsolver = 1;
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
537 OCTAVE_GLPK_GET_INT_PARAM ("lpsolver", lpsolver);
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
538 if (lpsolver < 1 || lpsolver > 2)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
539 error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)");
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
540
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
541 // Ratio test option
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
542 par.rtest = 34;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
543 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
544 if (par.rtest != 17 && par.rtest != 34)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20818
diff changeset
545 error ("__glpk__: PARAM.rtest must be 17 (standard ratio test) or 34 (Harris' two-pass ratio test [default])");
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
546
17195
2899d110c178 Use std::numeric_limits instead of INT_MAX in __glpk__ (bug #39715).
Rik <rik@octave.org>
parents: 17181
diff changeset
547 par.tmlim = std::numeric_limits<int>::max ();
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
548 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
549
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
550 par.outdly = 0;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
551 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
552
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
553 // Save option
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
554 int save_pb = 0;
5240
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
555 OCTAVE_GLPK_GET_INT_PARAM ("save", save_pb);
2bb31f40c339 [project @ 2005-03-24 02:34:13 by jwe]
jwe
parents: 5238
diff changeset
556 save_pb = save_pb != 0;
5237
652e8aa49fa7 [project @ 2005-03-23 21:28:45 by jwe]
jwe
parents: 5235
diff changeset
557
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
558 // Real parameters
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
559
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
560 // Relative tolerance used to check if the current basic solution
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
561 // is primal feasible
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
562 par.tolbnd = 1e-7;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
563 OCTAVE_GLPK_GET_REAL_PARAM ("tolbnd", par.tolbnd);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
564
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
565 // Absolute tolerance used to check if the current basic solution
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
566 // is dual feasible
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
567 par.toldj = 1e-7;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
568 OCTAVE_GLPK_GET_REAL_PARAM ("toldj", par.toldj);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
569
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
570 // Relative tolerance used to choose eligible pivotal elements of
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
571 // 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
572 par.tolpiv = 1e-10;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
573 OCTAVE_GLPK_GET_REAL_PARAM ("tolpiv", par.tolpiv);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
574
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
575 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
576 OCTAVE_GLPK_GET_REAL_PARAM ("objll", par.objll);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
577
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
578 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
579 OCTAVE_GLPK_GET_REAL_PARAM ("objul", par.objul);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
580
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
581 par.tolint = 1e-5;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
582 OCTAVE_GLPK_GET_REAL_PARAM ("tolint", par.tolint);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
583
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
584 par.tolobj = 1e-7;
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
585 OCTAVE_GLPK_GET_REAL_PARAM ("tolobj", par.tolobj);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
586
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
587 // 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
588 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
589 double fmin = octave_NA;
8068
e3e3d12364b0 make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents: 8036
diff changeset
590 ColumnVector lambda (mrowsA, octave_NA);
e3e3d12364b0 make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents: 8036
diff changeset
591 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
592 double time;
19779
166051951878 avoid warning from GCC about variables possibly clobbered by longjmp
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
593 int status;
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
594
21090
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
595 int errnum = glpk (sense, mrowsc, mrowsA, c, nz, rn.fortran_vec (),
93d294511277 don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents: 21082
diff changeset
596 cn.fortran_vec (), a.fortran_vec (), b, ctype,
21091
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
597 freeLB.fortran_vec (), lb, freeUB.fortran_vec (),
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
598 ub, vartype.fortran_vec (), isMIP, lpsolver,
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
599 save_pb, scale, &par, xmin.fortran_vec (), &fmin,
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
600 &status, lambda.fortran_vec (),
72eefc36c6b7 use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents: 21090
diff changeset
601 redcosts.fortran_vec (), &time);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
602
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
603 octave_scalar_map extra;
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
604
5238
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
605 if (! isMIP)
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
606 {
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
607 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
608 extra.assign ("redcosts", redcosts);
5238
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
609 }
d432b7809fe5 [project @ 2005-03-23 21:40:29 by jwe]
jwe
parents: 5237
diff changeset
610
11048
10c65e01f042 __glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11047
diff changeset
611 extra.assign ("time", time);
17180
54e251e699bb Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents: 15213
diff changeset
612 extra.assign ("status", status);
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
613
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20867
diff changeset
614 return ovl (xmin, fmin, errnum, extra);
5234
a791b8b777e4 [project @ 2005-03-22 18:37:06 by jwe]
jwe
parents: 5232
diff changeset
615
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
616 #else
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21091
diff changeset
617 err_disabled_feature ("glpk", "GNU Linear Programming Kit");
5235
5f0ad69b5c8c [project @ 2005-03-22 19:48:16 by jwe]
jwe
parents: 5234
diff changeset
618 #endif
5232
9b776f5a33eb [project @ 2005-03-22 16:16:30 by jwe]
jwe
parents:
diff changeset
619 }
12805
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
620
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
621 /*
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
622 ## 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
623 %!assert (1)
3641167e5b75 codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
624 */