Mercurial > octave
annotate libinterp/dldfcn/__glpk__.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, 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-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.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-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-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.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,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3 // Copyright (C) 2005-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
5234 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
5234 | 28 #endif |
5232 | 29 |
30 #include <ctime> | |
31 | |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
32 #include <limits> |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
33 |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
34 #include "Array.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
35 #include "chMatrix.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
36 #include "dColVector.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
37 #include "dMatrix.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
38 #include "dSparse.h" |
9003
0631d397fbe0
replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
39 #include "lo-ieee.h" |
0631d397fbe0
replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
40 |
5234 | 41 #include "defun-dld.h" |
42 #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
|
43 #include "errwarn.h" |
5235 | 44 #include "oct-map.h" |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
45 #include "ov.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
46 #include "ovl.h" |
5235 | 47 |
48 #if defined (HAVE_GLPK) | |
5232 | 49 |
6333 | 50 extern "C" |
51 { | |
6804 | 52 #if defined (HAVE_GLPK_GLPK_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
53 # include <glpk/glpk.h> |
6804 | 54 #else |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
55 # include <glpk.h> |
6804 | 56 #endif |
6472 | 57 } |
6333 | 58 |
17181
4e9ff411d0fa
Remove minor stylistic C'ism
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17180
diff
changeset
|
59 struct control_params |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
60 { |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
61 int msglev; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
62 int dual; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
63 int price; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
64 int itlim; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
65 int outfrq; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
66 int branch; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
67 int btrack; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
68 int presol; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
69 int rtest; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
70 int tmlim; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
71 int outdly; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
72 double tolbnd; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
73 double toldj; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
74 double tolpiv; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
75 double objll; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
76 double objul; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
77 double tolint; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
78 double tolobj; |
17181
4e9ff411d0fa
Remove minor stylistic C'ism
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17180
diff
changeset
|
79 }; |
5232 | 80 |
29966
7d9be634ac91
declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
81 static int |
5234 | 82 glpk (int sense, int n, int m, double *c, int nz, int *rn, int *cn, |
83 double *a, double *b, char *ctype, int *freeLB, double *lb, | |
84 int *freeUB, double *ub, int *vartype, int isMIP, int lpsolver, | |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
85 int save_pb, int scale, const control_params& par, |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
86 double *xmin, double& fmin, int& status, |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
87 double *lambda, double *redcosts, double& time) |
5232 | 88 { |
5234 | 89 int typx = 0; |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
90 int errnum = 0; |
30018
09d97b7bc904
avoid possible uninitialized variable warnings
John W. Eaton <jwe@octave.org>
parents:
30010
diff
changeset
|
91 |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
92 time = 0.0; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
93 status = -1; // Initialize status to "bad" value |
5234 | 94 |
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
|
95 clock_t t_start = clock (); |
5234 | 96 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
97 glp_prob *lp = glp_create_prob (); |
5232 | 98 |
20946 | 99 // Set the sense of optimization |
5234 | 100 if (sense == 1) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
101 glp_set_obj_dir (lp, GLP_MIN); |
5234 | 102 else |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
103 glp_set_obj_dir (lp, GLP_MAX); |
5234 | 104 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
105 glp_add_cols (lp, n); |
5234 | 106 for (int i = 0; i < n; i++) |
107 { | |
20946 | 108 // Define type of the structural variables |
5234 | 109 if (! freeLB[i] && ! freeUB[i]) |
10154
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 (lb[i] != ub[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_DB, 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_FX, lb[i], ub[i]); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
115 } |
5234 | 116 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
117 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
118 if (! freeLB[i] && freeUB[i]) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
119 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
|
120 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
121 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
122 if (freeLB[i] && ! freeUB[i]) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
123 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
|
124 else |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
125 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
|
126 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
127 } |
5234 | 128 |
129 // -- Set the objective coefficient of the corresponding | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
130 // -- structural variable. No constant term is assumed. |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30019
diff
changeset
|
131 glp_set_obj_coef(lp, i+1, c[i]); |
5232 | 132 |
5234 | 133 if (isMIP) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
134 glp_set_col_kind (lp, i+1, vartype[i]); |
5234 | 135 } |
136 | |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
137 glp_add_rows (lp, m); |
5234 | 138 |
139 for (int i = 0; i < m; i++) | |
140 { | |
20946 | 141 // If the i-th row has no lower bound (types F,U), the |
142 // corrispondent parameter will be ignored. If the i-th row has | |
143 // no upper bound (types F,L), the corrispondent parameter will be | |
144 // ignored. If the i-th row is of S type, the i-th LB is used, | |
145 // but the i-th UB is ignored. | |
5234 | 146 |
147 switch (ctype[i]) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
148 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
149 case 'F': |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
150 typx = GLP_FR; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
151 break; |
5234 | 152 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
153 case 'U': |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
154 typx = GLP_UP; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
155 break; |
5234 | 156 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
157 case 'L': |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
158 typx = GLP_LO; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
159 break; |
5232 | 160 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
161 case 'S': |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
162 typx = GLP_FX; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
163 break; |
5232 | 164 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
165 case 'D': |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
166 typx = GLP_DB; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
167 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
168 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
169 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
170 glp_set_row_bnds (lp, i+1, typx, b[i], b[i]); |
5234 | 171 |
172 } | |
173 | |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
174 glp_load_matrix (lp, nz, rn, cn, a); |
5232 | 175 |
5234 | 176 if (save_pb) |
177 { | |
6484 | 178 static char tmp[] = "outpb.lp"; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23583
diff
changeset
|
179 if (glp_write_lp (lp, nullptr, tmp) != 0) |
21090
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
180 error ("__glpk__: unable to write problem"); |
5234 | 181 } |
182 | |
20946 | 183 // scale the problem data |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
184 if (! par.presol || lpsolver != 1) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
185 glp_scale_prob (lp, scale); |
5234 | 186 |
20946 | 187 // build advanced initial basis (if required) |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
188 if (lpsolver == 1 && ! par.presol) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
189 glp_adv_basis (lp, 0); |
5232 | 190 |
20946 | 191 // For MIP problems without a presolver, a first pass with glp_simplex |
192 // is required | |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
193 if ((! isMIP && lpsolver == 1) |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
194 || (isMIP && ! par.presol)) |
5234 | 195 { |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
196 glp_smcp smcp; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
197 glp_init_smcp (&smcp); |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
198 smcp.msg_lev = par.msglev; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
199 smcp.meth = par.dual; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
200 smcp.pricing = par.price; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
201 smcp.r_test = par.rtest; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
202 smcp.tol_bnd = par.tolbnd; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
203 smcp.tol_dj = par.toldj; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
204 smcp.tol_piv = par.tolpiv; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
205 smcp.obj_ll = par.objll; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
206 smcp.obj_ul = par.objul; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
207 smcp.it_lim = par.itlim; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
208 smcp.tm_lim = par.tmlim; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
209 smcp.out_frq = par.outfrq; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
210 smcp.out_dly = par.outdly; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
211 smcp.presolve = par.presol; |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
212 errnum = glp_simplex (lp, &smcp); |
5234 | 213 } |
214 | |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
215 if (isMIP) |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
216 { |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
217 glp_iocp iocp; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
218 glp_init_iocp (&iocp); |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
219 iocp.msg_lev = par.msglev; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
220 iocp.br_tech = par.branch; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
221 iocp.bt_tech = par.btrack; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
222 iocp.tol_int = par.tolint; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
223 iocp.tol_obj = par.tolobj; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
224 iocp.tm_lim = par.tmlim; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
225 iocp.out_frq = par.outfrq; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
226 iocp.out_dly = par.outdly; |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
227 iocp.presolve = par.presol; |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
228 errnum = glp_intopt (lp, &iocp); |
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 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
231 if (! isMIP && lpsolver == 2) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
232 { |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
233 glp_iptcp iptcp; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
234 glp_init_iptcp (&iptcp); |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
235 iptcp.msg_lev = par.msglev; |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
236 errnum = glp_interior (lp, &iptcp); |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
237 } |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
238 |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
239 if (errnum == 0) |
5234 | 240 { |
241 if (isMIP) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
242 { |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
243 status = glp_mip_status (lp); |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
244 fmin = glp_mip_obj_val (lp); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
245 } |
5234 | 246 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
247 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
248 if (lpsolver == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
249 { |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
250 status = glp_get_status (lp); |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
251 fmin = glp_get_obj_val (lp); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
252 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
253 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
254 { |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
255 status = glp_ipt_status (lp); |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
256 fmin = glp_ipt_obj_val (lp); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
257 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
258 } |
5232 | 259 |
5234 | 260 if (isMIP) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
261 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
262 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
|
263 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
|
264 } |
5234 | 265 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
266 { |
20946 | 267 // Primal values |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
268 for (int i = 0; i < n; i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
269 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
270 if (lpsolver == 1) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
271 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
|
272 else |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
273 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
|
274 } |
5232 | 275 |
20946 | 276 // Dual values |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
277 for (int i = 0; i < m; i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
278 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
279 if (lpsolver == 1) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
280 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
|
281 else |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
282 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
|
283 } |
5234 | 284 |
20946 | 285 // Reduced costs |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
286 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
|
287 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
288 if (lpsolver == 1) |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
289 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
|
290 else |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
291 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
|
292 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
293 } |
26558
434c0163d7be
Fix uninitialized argument value found by clang static analysis (bug #55440).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
294 } |
5234 | 295 |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
296 time = (clock () - t_start) / CLOCKS_PER_SEC; |
5234 | 297 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
298 glp_delete_prob (lp); |
21445
de155ca994d4
Ask glpk to free all resources used after solving problem.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
299 // Request that GLPK free all memory resources. |
de155ca994d4
Ask glpk to free all resources used after solving problem.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
300 // This prevents reported memory leaks, but isn't strictly necessary. |
26558
434c0163d7be
Fix uninitialized argument value found by clang static analysis (bug #55440).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
301 // The memory blocks used are allocated once and don't grow with further |
21604
d7a268e68e69
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21445
diff
changeset
|
302 // calls to glpk so they would be reclaimed anyways when Octave exits. |
21445
de155ca994d4
Ask glpk to free all resources used after solving problem.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
303 glp_free_env (); |
5234 | 304 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
305 return errnum; |
5232 | 306 } |
307 | |
5235 | 308 #endif |
309 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
310 OCTAVE_BEGIN_NAMESPACE(octave) |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
311 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
312 #define OCTAVE_GLPK_GET_REAL_PARAM(NAME, VAL) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
313 do \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
314 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
315 octave_value tmp = PARAM.getfield (NAME); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
316 \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
317 if (tmp.is_defined ()) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
318 { \ |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
319 if (! tmp.isempty ()) \ |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
320 VAL = tmp.xscalar_value ("glpk: invalid value in PARAM" NAME); \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
321 else \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
322 error ("glpk: invalid value in PARAM" NAME); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
323 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
324 } \ |
5240 | 325 while (0) |
326 | |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
327 #define OCTAVE_GLPK_GET_INT_PARAM(NAME, VAL) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
328 do \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
329 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
330 octave_value tmp = PARAM.getfield (NAME); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
331 \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
332 if (tmp.is_defined ()) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
333 { \ |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
334 if (! tmp.isempty ()) \ |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
335 VAL = tmp.xint_value ("glpk: invalid value in PARAM" NAME); \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
336 else \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
337 error ("glpk: invalid value in PARAM" NAME); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
338 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
339 } \ |
5240 | 340 while (0) |
341 | |
5235 | 342 DEFUN_DLD (__glpk__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
343 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
344 @deftypefn {} {[@var{values}] =} __glpk__ (@var{args}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
345 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
346 @end deftypefn */) |
5232 | 347 { |
5235 | 348 #if defined (HAVE_GLPK) |
349 | |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20790
diff
changeset
|
350 // 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
|
351 if (args.length () != 9) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
352 print_usage (); |
5234 | 353 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26558
diff
changeset
|
354 // 1st 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
|
355 int mrowsc = args(0).rows (); |
5234 | 356 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
357 Matrix C = args(0).xmatrix_value ("__glpk__: invalid value of C"); |
5240 | 358 |
5234 | 359 double *c = C.fortran_vec (); |
5455 | 360 Array<int> rn; |
361 Array<int> cn; | |
362 ColumnVector a; | |
21090
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
363 int mrowsA; |
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
364 int nz = 0; |
5232 | 365 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20867
diff
changeset
|
366 // 2nd Input. A matrix containing the constraints coefficients. |
5234 | 367 // If matrix A is NOT a sparse matrix |
23583
b7747a2c88b2
maint: Deprecate is_sparse_type and replace with issparse.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
368 if (args(1).issparse ()) |
5455 | 369 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
370 SparseMatrix A = args(1).xsparse_matrix_value ("__glpk__: invalid value of A"); |
5234 | 371 |
5455 | 372 mrowsA = A.rows (); |
373 octave_idx_type Anc = A.cols (); | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10350
diff
changeset
|
374 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
|
375 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
|
376 cn.resize (dim_vector (Anz+1, 1)); |
5455 | 377 a.resize (Anz+1, 0.0); |
378 | |
379 if (Anc != mrowsc) | |
20825
66cd994d1b79
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20818
diff
changeset
|
380 error ("__glpk__: invalid value of A"); |
5455 | 381 |
382 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
|
383 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
|
384 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
385 nz++; |
14854
5ae9f0f77635
maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
386 rn(nz) = A.ridx (i) + 1; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
387 cn(nz) = j + 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
388 a(nz) = A.data(i); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
389 } |
5455 | 390 } |
5631 | 391 else |
392 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
393 Matrix A = args(1).xmatrix_value ("__glpk__: invalid value of A"); |
5631 | 394 |
395 mrowsA = A.rows (); | |
11574
a83bad07f7e3
attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
396 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
|
397 cn.resize (dim_vector (mrowsA*mrowsc+1, 1)); |
5631 | 398 a.resize (mrowsA*mrowsc+1, 0.0); |
399 | |
400 for (int i = 0; i < mrowsA; i++) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
401 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
402 for (int j = 0; j < mrowsc; j++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
403 { |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30019
diff
changeset
|
404 if (A(i, j) != 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
405 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
406 nz++; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
407 rn(nz) = i + 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
408 cn(nz) = j + 1; |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30019
diff
changeset
|
409 a(nz) = A(i, j); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
410 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
411 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
412 } |
5631 | 413 |
414 } | |
5232 | 415 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
416 // 3rd Input. A column array containing the right-hand side value |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
417 // 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
|
418 Matrix B = args(2).xmatrix_value ("__glpk__: invalid value of B"); |
5240 | 419 |
5234 | 420 double *b = B.fortran_vec (); |
421 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
422 // 4th Input. An array of length mrowsc containing the lower |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
423 // bound on each of the variables. |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
424 Matrix LB = args(3).xmatrix_value ("__glpk__: invalid value of LB"); |
5240 | 425 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
426 if (LB.numel () < mrowsc) |
20825
66cd994d1b79
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20818
diff
changeset
|
427 error ("__glpk__: invalid dimensions for LB"); |
5240 | 428 |
5234 | 429 double *lb = LB.fortran_vec (); |
430 | |
20946 | 431 // LB argument, default: Free |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
432 Array<int> freeLB (dim_vector (mrowsc, 1)); |
5234 | 433 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
|
434 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
435 if (math::isinf (lb[i])) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
436 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
437 freeLB(i) = 1; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
438 lb[i] = -numeric_limits<double>::Inf (); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
439 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
440 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
441 freeLB(i) = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
442 } |
5234 | 443 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
444 // 5th Input. An array of at least length numcols containing the upper |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
445 // bound on each of the variables. |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
446 Matrix UB = args(4).xmatrix_value ("__glpk__: invalid value of UB"); |
5234 | 447 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
448 if (UB.numel () < mrowsc) |
20825
66cd994d1b79
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20818
diff
changeset
|
449 error ("__glpk__: invalid dimensions for UB"); |
5240 | 450 |
5234 | 451 double *ub = UB.fortran_vec (); |
5232 | 452 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
453 Array<int> freeUB (dim_vector (mrowsc, 1)); |
5234 | 454 for (int i = 0; i < mrowsc; i++) |
455 { | |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
456 if (math::isinf (ub[i])) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
457 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
458 freeUB(i) = 1; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
459 ub[i] = numeric_limits<double>::Inf (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
460 } |
5234 | 461 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
462 freeUB(i) = 0; |
5234 | 463 } |
464 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
465 // 6th Input. A column array containing the sense of each constraint |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
466 // in the constraint matrix. |
21091
72eefc36c6b7
use correct value extractor functions in glpk
John W. Eaton <jwe@octave.org>
parents:
21090
diff
changeset
|
467 charMatrix CTYPE = args(5).xchar_matrix_value ("__glpk__: invalid value of CTYPE"); |
5240 | 468 |
5237 | 469 char *ctype = CTYPE.fortran_vec (); |
470 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
471 // 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
|
472 charMatrix VTYPE = args(6).xchar_matrix_value ("__glpk__: invalid value of VARTYPE"); |
5240 | 473 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
474 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
|
475 int isMIP = 0; |
5234 | 476 for (int i = 0; i < mrowsc ; i++) |
477 { | |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30019
diff
changeset
|
478 if (VTYPE(i, 0) == 'I') |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
479 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
480 isMIP = 1; |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
481 vartype(i) = GLP_IV; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
482 } |
5234 | 483 else |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
484 vartype(i) = GLP_CV; |
5234 | 485 } |
486 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
487 // 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
|
488 int sense; |
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
489 double SENSE = args(7).xscalar_value ("__glpk__: invalid value of SENSE"); |
5240 | 490 |
5237 | 491 if (SENSE >= 0) |
492 sense = 1; | |
493 else | |
494 sense = -1; | |
495 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
496 // 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
|
497 octave_scalar_map PARAM = args(8).xscalar_map_value ("__glpk__: invalid value of PARAM"); |
5240 | 498 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
499 control_params par; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
500 |
20946 | 501 // Integer parameters |
5234 | 502 |
20946 | 503 // 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
|
504 par.msglev = 1; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
505 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
|
506 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
|
507 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 | 508 |
20946 | 509 // scaling option |
21090
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
510 int scale = 16; |
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 ("scale", scale); |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
512 if (scale < 0 || scale > 128) |
20825
66cd994d1b79
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20818
diff
changeset
|
513 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 | 514 |
20946 | 515 // Dual simplex option |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
516 par.dual = 1; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
517 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
|
518 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
|
519 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 | 520 |
20946 | 521 // Pricing option |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
522 par.price = 34; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
523 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
|
524 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
|
525 error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])"); |
5234 | 526 |
20946 | 527 // 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
|
528 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
|
529 OCTAVE_GLPK_GET_INT_PARAM ("itlim", par.itlim); |
5234 | 530 |
20946 | 531 // Output frequency, in iterations |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
532 par.outfrq = 200; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
533 OCTAVE_GLPK_GET_INT_PARAM ("outfrq", par.outfrq); |
5234 | 534 |
20946 | 535 // Branching heuristic option |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
536 par.branch = 4; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
537 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
|
538 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
|
539 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 | 540 |
20946 | 541 // Backtracking heuristic option |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
542 par.btrack = 4; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
543 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
|
544 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
|
545 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 | 546 |
20946 | 547 // Presolver option |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
548 par.presol = 1; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
549 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
|
550 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
|
551 error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])"); |
5234 | 552 |
20946 | 553 // LPsolver 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 lpsolver = 1; |
5240 | 555 OCTAVE_GLPK_GET_INT_PARAM ("lpsolver", lpsolver); |
556 if (lpsolver < 1 || lpsolver > 2) | |
20825
66cd994d1b79
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20818
diff
changeset
|
557 error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)"); |
5237 | 558 |
20946 | 559 // Ratio test option |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
560 par.rtest = 34; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
561 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
|
562 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
|
563 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
|
564 |
17195
2899d110c178
Use std::numeric_limits instead of INT_MAX in __glpk__ (bug #39715).
Rik <rik@octave.org>
parents:
17181
diff
changeset
|
565 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
|
566 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
|
567 |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
568 par.outdly = 0; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
569 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
|
570 |
20946 | 571 // Save option |
21090
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
572 int save_pb = 0; |
5240 | 573 OCTAVE_GLPK_GET_INT_PARAM ("save", save_pb); |
574 save_pb = save_pb != 0; | |
5237 | 575 |
20946 | 576 // Real parameters |
5234 | 577 |
20946 | 578 // Relative tolerance used to check if the current basic solution |
579 // is primal feasible | |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
580 par.tolbnd = 1e-7; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
581 OCTAVE_GLPK_GET_REAL_PARAM ("tolbnd", par.tolbnd); |
5234 | 582 |
20946 | 583 // Absolute tolerance used to check if the current basic solution |
584 // is dual feasible | |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
585 par.toldj = 1e-7; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
586 OCTAVE_GLPK_GET_REAL_PARAM ("toldj", par.toldj); |
5232 | 587 |
20946 | 588 // Relative tolerance used to choose eligible pivotal elements of |
589 // 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
|
590 par.tolpiv = 1e-10; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
591 OCTAVE_GLPK_GET_REAL_PARAM ("tolpiv", par.tolpiv); |
5234 | 592 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
593 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
|
594 OCTAVE_GLPK_GET_REAL_PARAM ("objll", par.objll); |
5232 | 595 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
596 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
|
597 OCTAVE_GLPK_GET_REAL_PARAM ("objul", par.objul); |
5234 | 598 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
599 par.tolint = 1e-5; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
600 OCTAVE_GLPK_GET_REAL_PARAM ("tolint", par.tolint); |
5234 | 601 |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
602 par.tolobj = 1e-7; |
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
603 OCTAVE_GLPK_GET_REAL_PARAM ("tolobj", par.tolobj); |
5234 | 604 |
20946 | 605 // 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
|
606 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
|
607 double fmin = octave_NA; |
8068
e3e3d12364b0
make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents:
8036
diff
changeset
|
608 ColumnVector lambda (mrowsA, octave_NA); |
e3e3d12364b0
make glpk return NA values for unfeasible problems
Jaroslav Hajek <highegg@gmail.com>
parents:
8036
diff
changeset
|
609 ColumnVector redcosts (mrowsc, octave_NA); |
30018
09d97b7bc904
avoid possible uninitialized variable warnings
John W. Eaton <jwe@octave.org>
parents:
30010
diff
changeset
|
610 |
09d97b7bc904
avoid possible uninitialized variable warnings
John W. Eaton <jwe@octave.org>
parents:
30010
diff
changeset
|
611 double time = 0.0; |
09d97b7bc904
avoid possible uninitialized variable warnings
John W. Eaton <jwe@octave.org>
parents:
30010
diff
changeset
|
612 int status = -1; |
5232 | 613 |
21090
93d294511277
don't use setjmp/longjmp to handle error in glpk
John W. Eaton <jwe@octave.org>
parents:
21082
diff
changeset
|
614 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
|
615 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
|
616 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
|
617 ub, vartype.fortran_vec (), isMIP, lpsolver, |
30019
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
618 save_pb, scale, par, xmin.fortran_vec (), fmin, |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
619 status, lambda.fortran_vec (), |
593796903cf4
glpk: prefer passing variables by reference where possible
John W. Eaton <jwe@octave.org>
parents:
30018
diff
changeset
|
620 redcosts.fortran_vec (), time); |
5232 | 621 |
11048
10c65e01f042
__glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11047
diff
changeset
|
622 octave_scalar_map extra; |
5234 | 623 |
5238 | 624 if (! isMIP) |
625 { | |
11048
10c65e01f042
__glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11047
diff
changeset
|
626 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
|
627 extra.assign ("redcosts", redcosts); |
5238 | 628 } |
629 | |
11048
10c65e01f042
__glpk__.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11047
diff
changeset
|
630 extra.assign ("time", time); |
17180
54e251e699bb
Use the new GLPK API (bug #39038).
Sébastien Villemot <sebastien@debian.org>
parents:
15213
diff
changeset
|
631 extra.assign ("status", status); |
5232 | 632 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20867
diff
changeset
|
633 return ovl (xmin, fmin, errnum, extra); |
5234 | 634 |
5235 | 635 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
636 |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
637 octave_unused_parameter (args); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
638 |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21091
diff
changeset
|
639 err_disabled_feature ("glpk", "GNU Linear Programming Kit"); |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21604
diff
changeset
|
640 |
5235 | 641 #endif |
5232 | 642 } |
12805
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
643 |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
644 /* |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
645 ## 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
|
646 %!assert (1) |
3641167e5b75
codesprint: *.cc helper functions do not need tests
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
647 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
648 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
649 OCTAVE_END_NAMESPACE(octave) |