diff options
author | Sebastien Fabbro <bicatali@gentoo.org> | 2014-01-16 18:44:41 +0000 |
---|---|---|
committer | Sebastien Fabbro <bicatali@gentoo.org> | 2014-01-16 18:44:41 +0000 |
commit | cd23e172fc7917d10fdbc01e599a1650de7ce2f0 (patch) | |
tree | 27b97bc791a5479d1216c4afe1a889ab3aa1d6ea /dev-python/cvxopt | |
parent | Mark m68k/s390/sh stable. (diff) | |
download | historical-cd23e172fc7917d10fdbc01e599a1650de7ce2f0.tar.gz historical-cd23e172fc7917d10fdbc01e599a1650de7ce2f0.tar.bz2 historical-cd23e172fc7917d10fdbc01e599a1650de7ce2f0.zip |
Fixed for glpk versions > 4.49 (bug #473454), fixed for blas/lapck under /opt (bug #498144, thanks kiwifb), removed old (bug #404427, #450992)
Package-Manager: portage-2.2.8-prefix/cvs/Linux x86_64
Manifest-Sign-Key: 0x13CB1360
Diffstat (limited to 'dev-python/cvxopt')
-rw-r--r-- | dev-python/cvxopt/ChangeLog | 10 | ||||
-rw-r--r-- | dev-python/cvxopt/Manifest | 18 | ||||
-rw-r--r-- | dev-python/cvxopt/cvxopt-1.1.5-r2.ebuild | 82 | ||||
-rw-r--r-- | dev-python/cvxopt/cvxopt-1.1.6.ebuild | 20 | ||||
-rw-r--r-- | dev-python/cvxopt/files/cvxopt-1.1.5-setup.patch | 171 | ||||
-rw-r--r-- | dev-python/cvxopt/files/cvxopt-1.1.6-glpk.patch | 889 | ||||
-rw-r--r-- | dev-python/cvxopt/metadata.xml | 14 |
7 files changed, 927 insertions, 277 deletions
diff --git a/dev-python/cvxopt/ChangeLog b/dev-python/cvxopt/ChangeLog index b0e8bd0260bb..212777dccf6e 100644 --- a/dev-python/cvxopt/ChangeLog +++ b/dev-python/cvxopt/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for dev-python/cvxopt -# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/cvxopt/ChangeLog,v 1.15 2013/06/21 20:08:52 bicatali Exp $ +# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/cvxopt/ChangeLog,v 1.16 2014/01/16 18:44:31 bicatali Exp $ + + 16 Jan 2014; Sébastien Fabbro <bicatali@gentoo.org> + +files/cvxopt-1.1.6-glpk.patch, -cvxopt-1.1.5-r2.ebuild, + -files/cvxopt-1.1.5-setup.patch, cvxopt-1.1.6.ebuild, metadata.xml: + Fixed for glpk versions > 4.49 (bug #473454), fixed for blas/lapck under /opt + (bug #498144, thanks kiwifb), removed old (bug #404427, #450992) 21 Jun 2013; Sébastien Fabbro <bicatali@gentoo.org> cvxopt-1.1.6.ebuild: Add temporary directory for tex generated fonts (bug #473896) diff --git a/dev-python/cvxopt/Manifest b/dev-python/cvxopt/Manifest index ca0a36aeffd4..6e1a988e5778 100644 --- a/dev-python/cvxopt/Manifest +++ b/dev-python/cvxopt/Manifest @@ -1,18 +1,16 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 -AUX cvxopt-1.1.5-setup.patch 5810 SHA256 ef461a563c7ff9122b24410f446bedc1188b5755c935a90e457ebac089e0f440 SHA512 ac2c12d2208b5d24e780c44068922e0f84f6a0b7f3f92e725f58cec54c0ec2667de78202049d2a4970b54ff0d27ebad732f82aa881f1716da8761a1e14e30d44 WHIRLPOOL a42b7467dbc29eca970d48f78c47042fc03acaea199af16b8198344388388ce8c810c2f4fa839edbd4b70f8a2702b25fb6de602819f7bb64c25deeb184c15073 +AUX cvxopt-1.1.6-glpk.patch 32201 SHA256 cb2e4004112aca900c1a64fbd735b8b7c7235e5a0051986d89603dc2024d5836 SHA512 29e441c9b8f9e2b1ccfebe80755880a6feeaac8f17faaeae1353c672d543acffa53d31f1188127cd8d4256f4e2bec6b9c996361419f94fcc983d4385069a92bc WHIRLPOOL fa28e93d68d06c88a23ef0182cf49c33ad0bcf1fc66ac5b0000187274a1bb359e935e3bcd4cb59f1e7ffa761a4cb55be83cd3340b75b1e5d54d63ff298acfc4d AUX cvxopt-1.1.6-setup.patch 6277 SHA256 ac4d190c11325737a9c9b83acda24a48f5646d9b8538887c1e14db61e6147dce SHA512 a5ddca5f55c359044806e918ee37847f6864b0a8bf8281be3f9e52f54ecd2618faffb4c54d8e5d380d992f0195d9eaa121c442b3b65646f8cd8b66dfb6f098e1 WHIRLPOOL b0657ea0785b0abf3d894d7b4d234c4a0ac15c18ba591460dc802cd7405b088b707616357fbd79f80d1d2b2d74833c1df92fc0fe8daff728fc895f52d6e9ac8b -DIST cvxopt-1.1.5.tar.gz 3436288 SHA256 f1c0bd46321db941a46bb3544f4a23c6b15a90cbe5a485d735659abf110993d8 SHA512 8318e51589c7001f253e190082d550becbabcffa761cdb867c74593a7be9b764770fefc879057a389edccd64dcc34434b665f7df8bca460a036275dbcaa259a8 WHIRLPOOL 6dd81538813e033f028fae528d6d97d4477f57087479686017b249a054d46cc34d32e7dc61414bcf2628791cb43821545c576872b9332da953f9417e58ffa40c DIST cvxopt-1.1.6.tar.gz 3352996 SHA256 7b4ccf3ed896dde6624623431c0b1f5e32d874384329ed716f51babcbf416227 SHA512 b9f5fd7870412423b60068d205efb99d3630012509cb659fb67a10d6175906768846d7c906cf2fcac4be29afd558619b71e2dca730041329195a2365dd1d722c WHIRLPOOL d43cf090ee0396a77851fb71e6e34c980152bccdd5fdb3ecc53d0a464a505ac87a1e7198d313ec669443970bcf8a2d616f03c2f861b7df2f620bd583a97ea140 -EBUILD cvxopt-1.1.5-r2.ebuild 1842 SHA256 7172370462be765dcf4c75d330edd191f67c9e3e3a4cdce32de3505565d6d4ad SHA512 c2bc2811584a9935322669386fd179c36ad0a2eb480e69a79afbb066d3a9a5ae5c0c6650eb50b1b21bfa1ab9746ffd84c945afa641ee81307700473816924351 WHIRLPOOL d445936f4f78b55e38ef561f705952908506bed43edbc1a73b4f97dcf215cd5115824b0e194c2feb21664ea211ea758ec328b923f1fd6339d8535627dfaa0dd6 -EBUILD cvxopt-1.1.6.ebuild 1786 SHA256 cf67407f3734e53d0c63e581d849649cdbabf2ffcd8f5699a0719f5b64e73508 SHA512 1934efa647dca6b35794882d625bd1b9136dabb7622f909d84d1502bbf7c79664584202bbdefca92372f099ceeccc44c4e4148be6b53286c8e95860a9b924afa WHIRLPOOL ffb0ae918545ecc0ebd1fd3a6d75dc086be12267939ead302dcf25e79648a7cca9e055753b44acd0fe968661851e5126e01ec9d39042e661016afcf5cbdf6b9e -MISC ChangeLog 4570 SHA256 bf6672a67d9e5aa9446b6ed0c47d6fb2b68a8d546c32bb56388fbc7493b270b8 SHA512 50102eacc0cd6113797266d4ef32039a1d26e5cf199ecfd1ab440809b51d0a5a3e6181bc17ebaee5ac0d7827b638ac703ff1b6c79241b7cc899116db23a9a530 WHIRLPOOL 4ba9aeb635e5634ef3541dae87ddcc7237c81487151aefa33b75b34fd49fd5d45ee902d3ac80fa38db0db2da724915c7ecbd00623deecadb38e0d68e809e6354 -MISC metadata.xml 618 SHA256 9355ed07efa3008d28e4a463166636c2fb82d1ac03fbc930a69c10a28f7f259f SHA512 1d33e7e871bcb6250ed2c40626cdf491975f04f62fc913591a3f273d55f3dba2ba2f3ec1f00b714b4d4f56e74f53f8f4338522619adf1c266b9f90c8dc2c7440 WHIRLPOOL a6408401eeceb2cfdb37d7ea0682f57a468bc7e2845f5858e08939c4e205020c695ff1d355a1a0fc2ce3547908532b6fbf9e013a0adbc7016478c8b80b0116fa +EBUILD cvxopt-1.1.6.ebuild 2172 SHA256 f0bb302528ced6f2c8801ad2e8bc71fc1d5e43e6390f1d44c0658eaa2f8bd5e8 SHA512 6601fa76bab8f9622fdfe68aab093e1452e13ec198990965d415a8f3204685ff7ae5c7562e3b52df75da6b73bb35e9e250ad8426bcb25a2d3e80fdd93278a62e WHIRLPOOL 0bc514d5621d71b82ee534aff918bbbec9123a4e5318e9bcbaf5025abc44d47b0b0bb8575198d5869c032d4e10007d307ce6b0dbdc43e42003ca64ac5af29fbb +MISC ChangeLog 4902 SHA256 e05c00abf884853afd0ee57a79085e95c0bb96acfddd5292e62a368365ec15e4 SHA512 4bb90879eaecbbbef9fda99a8b2ba1bf1588cba388d8b76094ddb882a39f807657d02f8f36cf01238263531b4713f00e7b6fda5476679529c9041ce90053bc70 WHIRLPOOL f67523d4f828298fb95fbb882085725438a7a8c5471d69f83a32f2b2f0db6d9dd54638781d0f3840f14b27c1a6b7dab11507aeefbfda43b7b76c2c1b07b41009 +MISC metadata.xml 606 SHA256 2931fe1108dcc21dfd17c27b46030f845b643992754c4f56efe1351a8d5b798a SHA512 0cdec9e0c5422ef3f08073d7abdbbc324080478fe77f9d5597cd0e1f6825d63ec6c6eff06d0d555061b9ee26b29aca8fbf200d8d865036467baa68cf35996524 WHIRLPOOL 1ca5295112eef3cf93c4dace2e00c4f7d4471dabdd96952cb742b6fa8a5ab636dcadc9d506e7756ea5a1acd759f7b9fc10a4241894b70501aac6fb208fe42ebe -----BEGIN PGP SIGNATURE----- -Version: GnuPG v2.0.20 (GNU/Linux) +Version: GnuPG v2.0.22 (GNU/Linux) -iEYEAREIAAYFAlHEstUACgkQ1ycZbhPLE2D93ACgi8obnTzbNXhSxh8Ha5tJgarw -HjMAoKJ9WmsTIlYOvUgFW69NexNYb+5C -=Lg3C +iEYEAREIAAYFAlLYKJQACgkQ1ycZbhPLE2CX8ACghtZMSf0vOIFmsYC0xpZdRtZa +fz4An18wE9C7/I8JcS82XvzrB+UgIibi +=Whx8 -----END PGP SIGNATURE----- diff --git a/dev-python/cvxopt/cvxopt-1.1.5-r2.ebuild b/dev-python/cvxopt/cvxopt-1.1.5-r2.ebuild deleted file mode 100644 index 560365a6717a..000000000000 --- a/dev-python/cvxopt/cvxopt-1.1.5-r2.ebuild +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 1999-2013 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/cvxopt/cvxopt-1.1.5-r2.ebuild,v 1.1 2013/02/26 20:33:17 jlec Exp $ - -EAPI=5 - -PYTHON_COMPAT=( python{2_6,2_7} ) - -inherit distutils-r1 toolchain-funcs - -DESCRIPTION="Python package for convex optimization" -HOMEPAGE="http://abel.ee.ucla.edu/cvxopt" -SRC_URI="http://abel.ee.ucla.edu/${PN}/${P}.tar.gz" - -LICENSE="GPL-3" -SLOT="0" -KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" -IUSE="doc +dsdp examples fftw +glpk gsl" - -RDEPEND=" - virtual/blas - virtual/cblas - virtual/lapack - sci-libs/cholmod - sci-libs/umfpack - dsdp? ( sci-libs/dsdp ) - fftw? ( sci-libs/fftw:3.0 ) - glpk? ( sci-mathematics/glpk ) - gsl? ( sci-libs/gsl )" -DEPEND="${RDEPEND} - virtual/pkgconfig - doc? ( dev-python/sphinx )" - -S="${WORKDIR}/${P}/src" - -python_prepare_all(){ - local PATCHES=( "${FILESDIR}"/${P}-setup.patch ) - rm -rf src/C/SuiteSparse*/ - rm -rf ../doc/build # 413905 - - distutils-r1_python_prepare_all - - pkg_lib() { - local pylib=\'$($(tc-getPKG_CONFIG) --libs-only-l ${1} | sed \ - -e 's/^-l//' \ - -e "s/ -l/\',\'/g" \ - -e 's/.,.pthread//g' \ - -e "s:[[:space:]]::g")\' - sed -i -e "/_LIB = /s:\(.*\)'${1}'\(.*\):\1${pylib}\2:" setup.py || die - } - - use_cvx() { - if use ${1}; then - sed -i \ - -e "s/\(BUILD_${1^^} =\) 0/\1 1/" \ - setup.py || die - fi - } - - pkg_lib blas - pkg_lib lapack - use_cvx gsl - use_cvx fftw - use_cvx glpk - use_cvx dsdp -} - -python_compile_all() { - use doc && emake -C "${WORKDIR}"/${P}/doc -B html -} - -python_test() { - cd "${WORKDIR}"/${P}/examples/doc/chap8 - "${PYTHON}" lp.py || die -} - -python_install_all() { - use doc && HTML_DOCS=( "${WORKDIR}"/${P}/doc/build/html/. ) - insinto /usr/share/doc/${PF} - use examples && doins -r "${WORKDIR}"/${P}/examples - distutils-r1_python_install_all -} diff --git a/dev-python/cvxopt/cvxopt-1.1.6.ebuild b/dev-python/cvxopt/cvxopt-1.1.6.ebuild index 503a88aff266..50d4dc6d37f9 100644 --- a/dev-python/cvxopt/cvxopt-1.1.6.ebuild +++ b/dev-python/cvxopt/cvxopt-1.1.6.ebuild @@ -1,12 +1,12 @@ -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/cvxopt/cvxopt-1.1.6.ebuild,v 1.2 2013/06/21 20:08:52 bicatali Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/cvxopt/cvxopt-1.1.6.ebuild,v 1.3 2014/01/16 18:44:31 bicatali Exp $ EAPI=5 PYTHON_COMPAT=( python{2_6,2_7,3_2,3_3} ) -inherit distutils-r1 toolchain-funcs +inherit distutils-r1 toolchain-funcs eutils DESCRIPTION="Python package for convex optimization" HOMEPAGE="http://cvxopt.org/" @@ -25,14 +25,16 @@ RDEPEND=" sci-libs/umfpack dsdp? ( sci-libs/dsdp ) fftw? ( sci-libs/fftw:3.0 ) - glpk? ( sci-mathematics/glpk ) + glpk? ( sci-mathematics/glpk:= ) gsl? ( sci-libs/gsl )" DEPEND="${RDEPEND} virtual/pkgconfig doc? ( dev-python/sphinx )" python_prepare_all(){ - local PATCHES=( "${FILESDIR}"/${PN}-1.1.6-setup.patch ) + local PATCHES=( "${FILESDIR}"/${PN}-1.1.6-setup.patch ) + has_version ">=sci-mathematics/glpk-4.49" && \ + epatch "${FILESDIR}"/${PN}-1.1.6-glpk.patch rm -r src/C/SuiteSparse*/ || die distutils-r1_python_prepare_all @@ -56,6 +58,14 @@ python_prepare_all(){ pkg_lib blas pkg_lib lapack + + # Deal with blas/lapck libraries that are not in /usr/lib{64} + local lapackdir=\'$($(tc-getPKG_CONFIG) --libs-only-L lapack | sed \ + -e 's/^-L//' \ + -e "s/ -L/\',\'/g" \ + -e "s:[[:space:]]::g")\' + sed -i -e "s:BLAS_LIB_DIR = '':BLAS_LIB_DIR = ${lapackdir}:" setup.py || die + use_cvx gsl use_cvx fftw use_cvx glpk diff --git a/dev-python/cvxopt/files/cvxopt-1.1.5-setup.patch b/dev-python/cvxopt/files/cvxopt-1.1.5-setup.patch deleted file mode 100644 index f91ae9f62ff4..000000000000 --- a/dev-python/cvxopt/files/cvxopt-1.1.5-setup.patch +++ /dev/null @@ -1,171 +0,0 @@ ---- setup.py.orig 2012-04-04 17:18:51.000000000 +0100 -+++ setup.py 2012-04-19 00:02:14.000000000 +0100 -@@ -2,7 +2,7 @@ - from glob import glob - - # Modifiy this if BLAS and LAPACK libraries are not in /usr/lib. --BLAS_LIB_DIR = '/usr/lib' -+BLAS_LIB_DIR = '' - - # Default names of BLAS and LAPACK libraries - BLAS_LIB = ['blas'] -@@ -18,37 +18,37 @@ - BUILD_GSL = 0 - - # Directory containing libgsl (used only when BUILD_GSL = 1). --GSL_LIB_DIR = '/usr/lib' -+GSL_LIB_DIR = '' - - # Directory containing the GSL header files (used only when BUILD_GSL = 1). --GSL_INC_DIR = '/usr/include/gsl' -+GSL_INC_DIR = '' - - # Set to 1 if you are installing the fftw module. - BUILD_FFTW = 0 - - # Directory containing libfftw3 (used only when BUILD_FFTW = 1). --FFTW_LIB_DIR = '/usr/lib' -+FFTW_LIB_DIR = '' - - # Directory containing fftw.h (used only when BUILD_FFTW = 1). --FFTW_INC_DIR = '/usr/include' -+FFTW_INC_DIR = '' - - # Set to 1 if you are installing the glpk module. - BUILD_GLPK = 0 - - # Directory containing libglpk (used only when BUILD_GLPK = 1). --GLPK_LIB_DIR = '/usr/lib' -+GLPK_LIB_DIR = '' - - # Directory containing glpk.h (used only when BUILD_GLPK = 1). --GLPK_INC_DIR = '/usr/include' -+GLPK_INC_DIR = '' - - # Set to 1 if you are installing the DSDP module. - BUILD_DSDP = 0 - - # Directory containing libdsdp (used only when BUILD_DSDP = 1). --DSDP_LIB_DIR = '/usr/lib' -+DSDP_LIB_DIR = '' - - # Directory containing dsdp5.h (used only when BUILD_DSDP = 1). --DSDP_INC_DIR = '/usr/include/dsdp' -+DSDP_INC_DIR = '' - - # No modifications should be needed below this line. - -@@ -61,39 +61,32 @@ - # optional modules - - if BUILD_GSL: -- gsl = Extension('gsl', libraries = ['m', 'gsl'] + BLAS_LIB, -- include_dirs = [ GSL_INC_DIR ], -- library_dirs = [ GSL_LIB_DIR, BLAS_LIB_DIR ], -- extra_link_args = BLAS_EXTRA_LINK_ARGS, -+ gsl = Extension('gsl', libraries = ['gsl'], -+ library_dirs = [ GSL_LIB_DIR ], - sources = ['C/gsl.c'] ) - extmods += [gsl]; - - if BUILD_FFTW: -- fftw = Extension('fftw', libraries = ['fftw3'] + BLAS_LIB, -- include_dirs = [ FFTW_INC_DIR ], -- library_dirs = [ FFTW_LIB_DIR, BLAS_LIB_DIR ], -- extra_link_args = BLAS_EXTRA_LINK_ARGS, -+ fftw = Extension('fftw', libraries = ['fftw3'], -+ library_dirs = [ FFTW_LIB_DIR ], - sources = ['C/fftw.c'] ) - extmods += [fftw]; - - if BUILD_GLPK: - glpk = Extension('glpk', libraries = ['glpk'], -- include_dirs = [ GLPK_INC_DIR ], - library_dirs = [ GLPK_LIB_DIR ], - sources = ['C/glpk.c'] ) - extmods += [glpk]; - - if BUILD_DSDP: -- dsdp = Extension('dsdp', libraries = ['dsdp'] + LAPACK_LIB + BLAS_LIB, -- include_dirs = [ DSDP_INC_DIR ], -- library_dirs = [ DSDP_LIB_DIR, BLAS_LIB_DIR ], -- extra_link_args = BLAS_EXTRA_LINK_ARGS, -+ dsdp = Extension('dsdp', libraries = ['dsdp'], -+ library_dirs = [ DSDP_LIB_DIR ], - sources = ['C/dsdp.c'] ) - extmods += [dsdp]; - - # Required modules - --base = Extension('base', libraries = ['m'] + LAPACK_LIB + BLAS_LIB, -+base = Extension('base', libraries = LAPACK_LIB, - library_dirs = [ BLAS_LIB_DIR ], - define_macros = MACROS, - extra_link_args = BLAS_EXTRA_LINK_ARGS, -@@ -105,55 +98,36 @@ - extra_link_args = BLAS_EXTRA_LINK_ARGS, - sources = ['C/blas.c'] ) - --lapack = Extension('lapack', libraries = LAPACK_LIB + BLAS_LIB, -+lapack = Extension('lapack', libraries = LAPACK_LIB , - library_dirs = [ BLAS_LIB_DIR ], - define_macros = MACROS, - extra_link_args = BLAS_EXTRA_LINK_ARGS, - sources = ['C/lapack.c'] ) - - umfpack = Extension('umfpack', -- include_dirs = [ 'C/SuiteSparse/UMFPACK/Include', -- 'C/SuiteSparse/AMD/Include', 'C/SuiteSparse/AMD/Source', -- 'C/SuiteSparse/UFconfig' ], - library_dirs = [ BLAS_LIB_DIR ], - define_macros = MACROS, -- libraries = LAPACK_LIB + BLAS_LIB, -- extra_link_args = BLAS_EXTRA_LINK_ARGS, -- sources = [ 'C/umfpack.c', -- 'C/SuiteSparse/UMFPACK/Source/umfpack_global.c', -- 'C/SuiteSparse/UMFPACK/Source/umfpack_tictoc.c' ] + -- glob('C/SuiteSparse_cvxopt_extra/umfpack/*')) -+ libraries = [ 'umfpack' ], -+ sources = [ 'C/umfpack.c' ]) -+ - - # Build for int or long? - import sys - if sys.maxsize > 2**31: MACROS += [('DLONG','')] - - cholmod = Extension('cholmod', -- library_dirs = [ BLAS_LIB_DIR ], -- libraries = LAPACK_LIB + BLAS_LIB, -- include_dirs = [ 'C/SuiteSparse/CHOLMOD/Include', -- 'C/SuiteSparse/COLAMD', 'C/SuiteSparse/AMD/Include', -- 'C/SuiteSparse/UFconfig', 'C/SuiteSparse/COLAMD/Include' ], -- define_macros = MACROS + [('NPARTITION', '1')], -- extra_link_args = BLAS_EXTRA_LINK_ARGS, -- sources = [ 'C/cholmod.c' ] + -- ['C/SuiteSparse/AMD/Source/' + s for s in ['amd_global.c', -- 'amd_postorder.c', 'amd_post_tree.c', 'amd_2.c']] + -- ['C/SuiteSparse/COLAMD/Source/' + s for s in ['colamd.c', -- 'colamd_global.c']] + -- glob('C/SuiteSparse/CHOLMOD/Core/c*.c') + -- glob('C/SuiteSparse/CHOLMOD/Cholesky/c*.c') + -- ['C/SuiteSparse/CHOLMOD/Check/cholmod_check.c'] + -- glob('C/SuiteSparse/CHOLMOD/Supernodal/c*.c') ) -+ libraries = ['cholmod'] + BLAS_LIB, -+ define_macros = MACROS + [('NPARTITION', '1')], -+ sources = [ 'C/cholmod.c' ]) -+ - - amd = Extension('amd', -- include_dirs = [ 'C/SuiteSparse/AMD/Include', -- 'C/SuiteSparse/UFconfig' ], - define_macros = MACROS, -- sources = [ 'C/amd.c' ] + glob('C/SuiteSparse/AMD/Source/*.c') ) -+ libraries = ['amd'], -+ sources = [ 'C/amd.c' ]) - - misc_solvers = Extension('misc_solvers', -- libraries = LAPACK_LIB + BLAS_LIB, -+ libraries = LAPACK_LIB, - library_dirs = [ BLAS_LIB_DIR ], - define_macros = MACROS, - extra_link_args = BLAS_EXTRA_LINK_ARGS, diff --git a/dev-python/cvxopt/files/cvxopt-1.1.6-glpk.patch b/dev-python/cvxopt/files/cvxopt-1.1.6-glpk.patch new file mode 100644 index 000000000000..2887ccd02206 --- /dev/null +++ b/dev-python/cvxopt/files/cvxopt-1.1.6-glpk.patch @@ -0,0 +1,889 @@ +--- src/C/glpk.c.orig 2013-07-31 12:05:27.089955661 -0600 ++++ src/C/glpk.c 2013-07-31 12:13:40.702115730 -0600 +@@ -22,6 +22,8 @@ + #include "cvxopt.h" + #include "misc.h" + #include "glpk.h" ++#include <float.h> ++#include <limits.h> + + PyDoc_STRVAR(glpk__doc__, + "Interface to the simplex and mixed integer LP algorithms in GLPK.\n\n" +@@ -36,62 +38,15 @@ PyDoc_STRVAR(glpk__doc__, + + static PyObject *glpk_module; + +-typedef struct { +- char name[20]; +- int idx; +- char type; +-} param_tuple; +- +-static const param_tuple GLPK_PARAM_LIST[] = { +- {"LPX_K_MSGLEV", LPX_K_MSGLEV, 'i'}, +- {"LPX_K_SCALE", LPX_K_SCALE, 'i'}, +- {"LPX_K_DUAL", LPX_K_DUAL, 'i'}, +- {"LPX_K_PRICE", LPX_K_PRICE, 'i'}, +- {"LPX_K_RELAX", LPX_K_RELAX, 'f'}, +- {"LPX_K_TOLBND", LPX_K_TOLBND, 'f'}, +- {"LPX_K_TOLDJ", LPX_K_TOLDJ, 'f'}, +- {"LPX_K_TOLPIV", LPX_K_TOLPIV, 'f'}, +- {"LPX_K_ROUND", LPX_K_ROUND, 'i'}, +- {"LPX_K_OBJLL", LPX_K_OBJLL, 'f'}, +- {"LPX_K_OBJUL", LPX_K_OBJUL, 'f'}, +- {"LPX_K_ITLIM", LPX_K_ITLIM, 'i'}, +- {"LPX_K_ITCNT", LPX_K_ITCNT, 'i'}, +- {"LPX_K_TMLIM", LPX_K_TMLIM, 'f'}, +- {"LPX_K_OUTFRQ", LPX_K_OUTFRQ, 'i'}, +- {"LPX_K_OUTDLY", LPX_K_OUTDLY, 'f'}, +- {"LPX_K_BRANCH", LPX_K_BRANCH, 'i'}, +- {"LPX_K_BTRACK", LPX_K_BTRACK, 'i'}, +- {"LPX_K_TOLINT", LPX_K_TOLINT, 'f'}, +- {"LPX_K_TOLOBJ", LPX_K_TOLOBJ, 'f'}, +- {"LPX_K_MPSINFO", LPX_K_MPSINFO, 'i'}, +- {"LPX_K_MPSOBJ", LPX_K_MPSOBJ, 'i'}, +- {"LPX_K_MPSORIG", LPX_K_MPSORIG, 'i'}, +- {"LPX_K_MPSWIDE", LPX_K_MPSWIDE, 'i'}, +- {"LPX_K_MPSFREE", LPX_K_MPSFREE, 'i'}, +- {"LPX_K_MPSSKIP", LPX_K_MPSSKIP, 'i'}, +- {"LPX_K_LPTORIG", LPX_K_LPTORIG, 'i'}, +- {"LPX_K_PRESOL", LPX_K_PRESOL, 'i'}, +-}; /* 28 paramaters */ +- +- + #if PY_MAJOR_VERSION >= 3 +-static int get_param_idx(const char *str, int *idx, char *type) ++#define PYINT_CHECK(value) PyLong_Check(value) ++#define PYINT_AS_LONG(value) PyLong_AS_LONG(value) ++#define PYSTRING_FROMSTRING(str) PyUnicode_FromString(str) + #else +-static int get_param_idx(char *str, int *idx, char *type) ++#define PYINT_CHECK(value) PyInt_Check(value) ++#define PYINT_AS_LONG(value) PyInt_AS_LONG(value) ++#define PYSTRING_FROMSTRING(str) PyString_FromString(str) + #endif +-{ +- int i; +- +- for (i=0; i<28; i++) { +- if (!strcmp(GLPK_PARAM_LIST[i].name, str)) { +- *idx = GLPK_PARAM_LIST[i].idx; +- *type = GLPK_PARAM_LIST[i].type; +- return 1; +- } +- } +- return 0; +-} +- + + static char doc_simplex[] = + "Solves a linear program using GLPK.\n\n" +@@ -127,11 +82,12 @@ static PyObject *simplex(PyObject *self, + { + matrix *c, *h, *b=NULL, *x=NULL, *z=NULL, *y=NULL; + PyObject *G, *A=NULL, *t=NULL, *param, *key, *value; +- LPX *lp; +- int m, n, p, i, j, k, nnz, nnzmax, *rn=NULL, *cn=NULL, param_id; ++ glp_prob *lp; ++ glp_smcp smcp; ++ int m, n, p, i, j, k, nnz, nnzmax, *rn=NULL, *cn=NULL; + int_t pos=0; + double *a=NULL, val; +- char param_type, err_str[100]; ++ char err_str[100]; + #if PY_MAJOR_VERSION >= 3 + const char *keystr; + #else +@@ -183,18 +139,18 @@ static PyObject *simplex(PyObject *self, + return NULL; + } + +- lp = lpx_create_prob(); +- lpx_add_rows(lp, m+p); +- lpx_add_cols(lp, n); ++ lp = glp_create_prob(); ++ glp_add_rows(lp, m+p); ++ glp_add_cols(lp, n); + + for (i=0; i<n; i++){ +- lpx_set_obj_coef(lp, i+1, MAT_BUFD(c)[i]); +- lpx_set_col_bnds(lp, i+1, LPX_FR, 0.0, 0.0); ++ glp_set_obj_coef(lp, i+1, MAT_BUFD(c)[i]); ++ glp_set_col_bnds(lp, i+1, GLP_FR, 0.0, 0.0); + } + for (i=0; i<m; i++) +- lpx_set_row_bnds(lp, i+1, LPX_UP, 0.0, MAT_BUFD(h)[i]); ++ glp_set_row_bnds(lp, i+1, GLP_UP, 0.0, MAT_BUFD(h)[i]); + for (i=0; i<p; i++) +- lpx_set_row_bnds(lp, i+m+1, LPX_FX, MAT_BUFD(b)[i], ++ glp_set_row_bnds(lp, i+m+1, GLP_FX, MAT_BUFD(b)[i], + MAT_BUFD(b)[i]); + + nnzmax = (SpMatrix_Check(G) ? SP_NNZ(G) : m*n ) + +@@ -203,7 +159,7 @@ static PyObject *simplex(PyObject *self, + rn = (int *) calloc(nnzmax+1, sizeof(int)); + cn = (int *) calloc(nnzmax+1, sizeof(int)); + if (!a || !rn || !cn){ +- free(a); free(rn); free(cn); lpx_delete_prob(lp); ++ free(a); free(rn); free(cn); glp_delete_prob(lp); + return PyErr_NoMemory(); + } + +@@ -242,84 +198,155 @@ static PyObject *simplex(PyObject *self, + nnz++; + } + +- lpx_load_matrix(lp, nnz, rn, cn, a); ++ glp_load_matrix(lp, nnz, rn, cn, a); + free(rn); free(cn); free(a); + + if (!(t = PyTuple_New(A ? 4 : 3))){ +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return PyErr_NoMemory(); + } + + if (!(param = PyObject_GetAttrString(glpk_module, "options")) + || !PyDict_Check(param)){ +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + PyErr_SetString(PyExc_AttributeError, + "missing glpk.options dictionary"); + return NULL; + } + +- while (PyDict_Next(param, &pos, &key, &value)) ++ glp_init_smcp(&smcp); ++ while (PyDict_Next(param, &pos, &key, &value)){ + #if PY_MAJOR_VERSION >= 3 +- if ((PyUnicode_Check(key)) && +- get_param_idx(_PyUnicode_AsString(key), ¶m_id, +- ¶m_type)){ ++ if (PyUnicode_Check(key)){ + keystr = _PyUnicode_AsString(key); + #else +- if ((keystr = PyString_AsString(key)) && get_param_idx(keystr, +- ¶m_id, ¶m_type)){ +-#endif +- if (param_type == 'i'){ +-#if PY_MAJOR_VERSION >= 3 +- if (!PyLong_Check(value)){ +-#else +- if (!PyInt_Check(value)){ +-#endif +- sprintf(err_str, "invalid value for integer " +- "GLPK parameter: %-.20s", keystr); +- PyErr_SetString(PyExc_ValueError, err_str); +- lpx_delete_prob(lp); +- Py_DECREF(param); +- return NULL; +- } +- if (!strcmp("LPX_K_PRESOL", keystr) && +-#if PY_MAJOR_VERSION >= 3 +- PyLong_AS_LONG(value) != 1){ +-#else +- PyInt_AS_LONG(value) != 1){ ++ if ((keystr = PyString_AsString(key))){ + #endif ++ if (!strcmp("LPX_K_MSGLEV", keystr)){ ++ switch (PYINT_AS_LONG(value)){ ++ case 0: smcp.msg_lev = GLP_MSG_OFF; break; ++ case 1: smcp.msg_lev = GLP_MSG_ERR; break; ++ case 2: smcp.msg_lev = GLP_MSG_ON; break; ++ case 3: smcp.msg_lev = GLP_MSG_ALL; break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_SCALE", keystr)){ ++ switch(PYINT_AS_LONG(value)){ ++ case 0: glp_unscale_prob(lp); break; ++ case 1: glp_scale_prob(lp, GLP_SF_EQ); break; ++ case 2: glp_scale_prob(lp, GLP_SF_GM); break; ++ case 3: glp_scale_prob(lp, GLP_SF_GM | GLP_SF_EQ); break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_DUAL", keystr)){ ++ switch(PYINT_AS_LONG(value)){ ++ case 0: smcp.meth = GLP_PRIMAL; break; ++ case 1: smcp.meth = GLP_DUAL; break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_PRICE", keystr)){ ++ switch(PYINT_AS_LONG(value)){ ++ case 0: smcp.pricing = GLP_PT_STD; break; ++ case 1: smcp.pricing = GLP_PT_PSE; break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_RELAX", keystr)){ ++ double relax = PyFloat_AsDouble(value); ++ if (relax < 0.0 || relax > 1.0) ++ goto error; ++ smcp.r_test = (relax == 0.0) ? GLP_RT_STD : GLP_RT_HAR; ++ } else if (!strcmp("LPX_K_TOLBND", keystr)){ ++ smcp.tol_bnd = PyFloat_AsDouble(value); ++ if (smcp.tol_bnd < DBL_EPSILON || smcp.tol_bnd > 0.001) ++ goto error; ++ } else if (!strcmp("LPX_K_TOLDJ", keystr)){ ++ smcp.tol_dj = PyFloat_AsDouble(value); ++ if (smcp.tol_dj < DBL_EPSILON || smcp.tol_dj > 0.001) ++ goto error; ++ } else if (!strcmp("LPX_K_TOLPIV", keystr)){ ++ smcp.tol_piv = PyFloat_AsDouble(value); ++ if (smcp.tol_piv < DBL_EPSILON || smcp.tol_piv > 0.001) ++ goto error; ++ } else if (!strcmp("LPX_K_ROUND", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_OBJLL", keystr)){ ++ smcp.obj_ll = PyFloat_AsDouble(value); ++ } else if (!strcmp("LPX_K_OBJUL", keystr)){ ++ smcp.obj_ul = PyFloat_AsDouble(value); ++ } else if (!strcmp("LPX_K_ITLIM", keystr)){ ++ smcp.it_lim = PYINT_AS_LONG(value); ++ if (smcp.it_lim < 0) ++ smcp.it_lim = INT_MAX; ++ } else if (!strcmp("LPX_K_ITCNT", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TMLIM", keystr)){ ++ smcp.tm_lim = (int)(PyFloat_AsDouble(value) * 1000.0); ++ if (smcp.tm_lim < 0) ++ smcp.tm_lim = INT_MAX; ++ } else if (!strcmp("LPX_K_OUTFRQ", keystr)){ ++ smcp.out_frq = PYINT_AS_LONG(value); ++ if (smcp.out_frq <= 0) ++ goto error; ++ } else if (!strcmp("LPX_K_OUTDLY", keystr)){ ++ smcp.out_dly = (int)(PyFloat_AsDouble(value) * 1000.0); ++ } else if (!strcmp("LPX_K_BRANCH", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_BTRACK", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TOLINT", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TOLOBJ", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSINFO", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSOBJ", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSORIG", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSWIDE", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSFREE", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSSKIP", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_LPTORIG", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_PRESOL", keystr)){ ++ if (PYINT_AS_LONG(value) != 1) + PyErr_Warn(PyExc_UserWarning, "ignoring value of " + "GLPK parameter 'LPX_K_PRESOL'"); ++ } else if (!strcmp("LPX_K_BINARIZE", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_USECUTS", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_BFTYPE", keystr)){ ++ glp_bfcp bfcp; ++ ++ glp_get_bfcp(lp, &bfcp); ++ switch(PYINT_AS_LONG(value)){ ++ case 1: bfcp.type = GLP_BF_FT; break; ++ case 2: bfcp.type = GLP_BF_BG; break; ++ case 3: bfcp.type = GLP_BF_GR; break; ++ default: goto error; + } +- else lpx_set_int_parm(lp, param_id, +-#if PY_MAJOR_VERSION >= 3 +- PyLong_AS_LONG(value)); +-#else +- PyInt_AS_LONG(value)); +-#endif +- } +- else { +-#if PY_MAJOR_VERSION >= 3 +- if (!PyLong_Check(value) && !PyFloat_Check(value)){ +-#else +- if (!PyInt_Check(value) && !PyFloat_Check(value)){ +-#endif +- sprintf(err_str, "invalid value for floating point " +- "GLPK parameter: %-.20s", keystr); +- PyErr_SetString(PyExc_ValueError, err_str); +- lpx_delete_prob(lp); +- Py_DECREF(param); +- return NULL; +- } +- lpx_set_real_parm(lp, param_id, +- PyFloat_AsDouble(value)); ++ glp_set_bfcp(lp, &bfcp); ++ } else if (!strcmp("LPX_K_MIPGAP", keystr)){ ++ /* Ignored */ ++ } else { ++ sprintf(err_str, "unknown GLPK parameter: %-.20s", keystr); ++ PyErr_SetString(PyExc_ValueError, err_str); ++ glp_delete_prob(lp); ++ Py_DECREF(param); ++ return NULL; + } ++ } + } +- lpx_set_int_parm(lp, LPX_K_PRESOL, 1); ++ smcp.presolve = GLP_ON; + Py_DECREF(param); + +- switch (lpx_simplex(lp)){ ++ switch (glp_simplex(lp, &smcp)){ + +- case LPX_E_OK: ++ case 0: + + x = (matrix *) Matrix_New(n,1,DOUBLE); + z = (matrix *) Matrix_New(m,1,DOUBLE); +@@ -329,71 +356,61 @@ static PyObject *simplex(PyObject *self, + Py_XDECREF(z); + Py_XDECREF(y); + Py_XDECREF(t); +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return PyErr_NoMemory(); + } + +- PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("optimal")); +-#else +- PyString_FromString("optimal")); +-#endif ++ PyTuple_SET_ITEM(t, 0, (PyObject *)PYSTRING_FROMSTRING("optimal")); + + for (i=0; i<n; i++) +- MAT_BUFD(x)[i] = lpx_get_col_prim(lp, i+1); ++ MAT_BUFD(x)[i] = glp_get_col_prim(lp, i+1); + PyTuple_SET_ITEM(t, 1, (PyObject *) x); + + for (i=0; i<m; i++) +- MAT_BUFD(z)[i] = -lpx_get_row_dual(lp, i+1); ++ MAT_BUFD(z)[i] = -glp_get_row_dual(lp, i+1); + PyTuple_SET_ITEM(t, 2, (PyObject *) z); + + if (A){ + for (i=0; i<p; i++) +- MAT_BUFD(y)[i] = -lpx_get_row_dual(lp, m+i+1); ++ MAT_BUFD(y)[i] = -glp_get_row_dual(lp, m+i+1); + PyTuple_SET_ITEM(t, 3, (PyObject *) y); + } + +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return (PyObject *) t; + +- case LPX_E_NOPFS: ++ case GLP_ENOPFS: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("primal infeasible")); +-#else +- PyString_FromString("primal infeasible")); +-#endif ++ PYSTRING_FROMSTRING("primal infeasible")); + break; + +- case LPX_E_NODFS: ++ case GLP_ENODFS: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("dual infeasible")); +-#else +- PyString_FromString("dual infeasible")); +-#endif ++ PYSTRING_FROMSTRING("dual infeasible")); + break; + + default: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("unknown")); +-#else +- PyString_FromString("unknown")); +-#endif ++ PYSTRING_FROMSTRING("unknown")); + } + +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + + PyTuple_SET_ITEM(t, 1, Py_BuildValue("")); + PyTuple_SET_ITEM(t, 2, Py_BuildValue("")); + if (A) PyTuple_SET_ITEM(t, 3, Py_BuildValue("")); + + return (PyObject *) t; ++ ++error: ++ sprintf(err_str, "invalid value for GLPK parameter: %-.20s", keystr); ++ PyErr_SetString(PyExc_ValueError, err_str); ++ glp_delete_prob(lp); ++ Py_DECREF(param); ++ return NULL; + } + + +@@ -428,11 +445,12 @@ static PyObject *integer(PyObject *self, + matrix *c, *h, *b=NULL, *x=NULL; + PyObject *G, *A=NULL, *IntSet=NULL, *BinSet = NULL; + PyObject *t=NULL, *param, *key, *value; +- LPX *lp; +- int m, n, p, i, j, k, nnz, nnzmax, *rn=NULL, *cn=NULL, param_id; ++ glp_prob *lp; ++ glp_iocp iocp; ++ int m, n, p, i, j, k, nnz, nnzmax, *rn=NULL, *cn=NULL; + int_t pos=0; + double *a=NULL, val; +- char param_type, err_str[100]; ++ char err_str[100]; + #if PY_MAJOR_VERSION >= 3 + const char *keystr; + #else +@@ -490,18 +508,18 @@ static PyObject *integer(PyObject *self, + if ((BinSet) && (!PyAnySet_Check(BinSet))) + PY_ERR_TYPE("invalid binary index set"); + +- lp = lpx_create_prob(); +- lpx_add_rows(lp, m+p); +- lpx_add_cols(lp, n); ++ lp = glp_create_prob(); ++ glp_add_rows(lp, m+p); ++ glp_add_cols(lp, n); + + for (i=0; i<n; i++){ +- lpx_set_obj_coef(lp, i+1, MAT_BUFD(c)[i]); +- lpx_set_col_bnds(lp, i+1, LPX_FR, 0.0, 0.0); ++ glp_set_obj_coef(lp, i+1, MAT_BUFD(c)[i]); ++ glp_set_col_bnds(lp, i+1, GLP_FR, 0.0, 0.0); + } + for (i=0; i<m; i++) +- lpx_set_row_bnds(lp, i+1, LPX_UP, 0.0, MAT_BUFD(h)[i]); ++ glp_set_row_bnds(lp, i+1, GLP_UP, 0.0, MAT_BUFD(h)[i]); + for (i=0; i<p; i++) +- lpx_set_row_bnds(lp, i+m+1, LPX_FX, MAT_BUFD(b)[i], ++ glp_set_row_bnds(lp, i+m+1, GLP_FX, MAT_BUFD(b)[i], + MAT_BUFD(b)[i]); + + nnzmax = (SpMatrix_Check(G) ? SP_NNZ(G) : m*n ) + +@@ -510,7 +528,7 @@ static PyObject *integer(PyObject *self, + rn = (int *) calloc(nnzmax+1, sizeof(int)); + cn = (int *) calloc(nnzmax+1, sizeof(int)); + if (!a || !rn || !cn){ +- free(a); free(rn); free(cn); lpx_delete_prob(lp); ++ free(a); free(rn); free(cn); glp_delete_prob(lp); + return PyErr_NoMemory(); + } + +@@ -549,77 +567,152 @@ static PyObject *integer(PyObject *self, + nnz++; + } + +- lpx_load_matrix(lp, nnz, rn, cn, a); ++ glp_load_matrix(lp, nnz, rn, cn, a); + free(rn); free(cn); free(a); + + if (!(t = PyTuple_New(2))) { +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return PyErr_NoMemory(); + } + + if (!(param = PyObject_GetAttrString(glpk_module, "options")) + || !PyDict_Check(param)){ +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + PyErr_SetString(PyExc_AttributeError, + "missing glpk.options dictionary"); + return NULL; + } + +- while (PyDict_Next(param, &pos, &key, &value)) +-#if PY_MAJOR_VERSION >= 3 +- if ((PyUnicode_Check(key)) && (keystr = PyUnicode_AS_DATA(key)) +- && get_param_idx(keystr, ¶m_id, ¶m_type)){ +-#else +- if ((keystr = PyString_AsString(key)) && get_param_idx(keystr, +- ¶m_id, ¶m_type)){ +-#endif +- if (param_type == 'i'){ +-#if PY_MAJOR_VERSION >= 3 +- if (!PyLong_Check(value)){ +-#else +- if (!PyInt_Check(value)){ +-#endif +- sprintf(err_str, "invalid value for integer " +- "GLPK parameter: %-.20s", keystr); +- PyErr_SetString(PyExc_ValueError, err_str); +- lpx_delete_prob(lp); +- Py_DECREF(param); +- return NULL; +- } +- if (!strcmp("LPX_K_PRESOL", keystr) && ++ glp_init_iocp(&iocp); ++ while (PyDict_Next(param, &pos, &key, &value)) { + #if PY_MAJOR_VERSION >= 3 +- PyLong_AS_LONG(value) != 1){ ++ if ((PyUnicode_Check(key)) && (keystr = PyUnicode_AS_DATA(key))){ + #else +- PyInt_AS_LONG(value) != 1){ ++ if ((keystr = PyString_AsString(key))){ + #endif ++ if (!strcmp("LPX_K_MSGLEV", keystr)){ ++ switch (PYINT_AS_LONG(value)){ ++ case 0: iocp.msg_lev = GLP_MSG_OFF; break; ++ case 1: iocp.msg_lev = GLP_MSG_ERR; break; ++ case 2: iocp.msg_lev = GLP_MSG_ON; break; ++ case 3: iocp.msg_lev = GLP_MSG_ALL; break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_SCALE", keystr)){ ++ switch(PYINT_AS_LONG(value)){ ++ case 0: glp_unscale_prob(lp); break; ++ case 1: glp_scale_prob(lp, GLP_SF_EQ); break; ++ case 2: glp_scale_prob(lp, GLP_SF_GM); break; ++ case 3: glp_scale_prob(lp, GLP_SF_GM | GLP_SF_EQ); break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_DUAL", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_PRICE", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_RELAX", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TOLBND", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TOLDJ", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TOLPIV", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_ROUND", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_OBJLL", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_OBJUL", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_ITLIM", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_ITCNT", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_TMLIM", keystr)){ ++ iocp.tm_lim = (int)(PyFloat_AsDouble(value) * 1000.0); ++ if (iocp.tm_lim < 0) ++ iocp.tm_lim = INT_MAX; ++ } else if (!strcmp("LPX_K_OUTFRQ", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_OUTDLY", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_BRANCH", keystr)){ ++ switch(PYINT_AS_LONG(value)){ ++ case 0: iocp.br_tech = GLP_BR_FFV; break; ++ case 1: iocp.br_tech = GLP_BR_LFV; break; ++ case 2: iocp.br_tech = GLP_BR_DTH; break; ++ case 3: iocp.br_tech = GLP_BR_MFV; break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_BTRACK", keystr)){ ++ switch(PYINT_AS_LONG(value)){ ++ case 0: iocp.bt_tech = GLP_BT_DFS; break; ++ case 1: iocp.bt_tech = GLP_BT_BFS; break; ++ case 2: iocp.bt_tech = GLP_BT_BPH; break; ++ case 3: iocp.bt_tech = GLP_BT_BLB; break; ++ default: goto error; ++ } ++ } else if (!strcmp("LPX_K_TOLINT", keystr)){ ++ iocp.tol_int = PyFloat_AsDouble(value); ++ if (iocp.tol_int < DBL_EPSILON || iocp.tol_int > 0.001) ++ goto error; ++ } else if (!strcmp("LPX_K_TOLOBJ", keystr)){ ++ iocp.tol_obj = PyFloat_AsDouble(value); ++ if (iocp.tol_obj < DBL_EPSILON || iocp.tol_obj > 0.001) ++ goto error; ++ } else if (!strcmp("LPX_K_MPSINFO", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSOBJ", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSORIG", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSWIDE", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSFREE", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_MPSSKIP", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_LPTORIG", keystr)){ ++ /* Ignored */ ++ } else if (!strcmp("LPX_K_PRESOL", keystr)){ ++ if (PYINT_AS_LONG(value) != 1) + PyErr_Warn(PyExc_UserWarning, "ignoring value of " + "GLPK parameter 'LPX_K_PRESOL'"); ++ } else if (!strcmp("LPX_K_BINARIZE", keystr)){ ++ iocp.binarize = (PYINT_AS_LONG(value) == 0) ? GLP_OFF : GLP_ON; ++ } else if (!strcmp("LPX_K_USECUTS", keystr)){ ++ int cuts = PYINT_AS_LONG(value); ++ if (cuts & ~0xFF) ++ goto error; ++ iocp.cov_cuts = (cuts & 1) ? GLP_ON : GLP_OFF; ++ iocp.clq_cuts = (cuts & 2) ? GLP_ON : GLP_OFF; ++ iocp.gmi_cuts = (cuts & 4) ? GLP_ON : GLP_OFF; ++ iocp.mir_cuts = (cuts & 8) ? GLP_ON : GLP_OFF; ++ } else if (!strcmp("LPX_K_BFTYPE", keystr)){ ++ glp_bfcp bfcp; ++ ++ glp_get_bfcp(lp, &bfcp); ++ switch(PYINT_AS_LONG(value)){ ++ case 1: bfcp.type = GLP_BF_FT; break; ++ case 2: bfcp.type = GLP_BF_BG; break; ++ case 3: bfcp.type = GLP_BF_GR; break; ++ default: goto error; + } +- else +-#if PY_MAJOR_VERSION >= 3 +- lpx_set_int_parm(lp, param_id, PyLong_AS_LONG(value)); +-#else +- lpx_set_int_parm(lp, param_id, PyInt_AS_LONG(value)); +-#endif +- } +- else { +-#if PY_MAJOR_VERSION >= 3 +- if (!PyLong_Check(value) && !PyFloat_Check(value)){ +-#else +- if (!PyInt_Check(value) && !PyFloat_Check(value)){ +-#endif +- sprintf(err_str, "invalid value for floating point " +- "GLPK parameter: %-.20s", keystr); +- PyErr_SetString(PyExc_ValueError, err_str); +- lpx_delete_prob(lp); +- Py_DECREF(param); +- return NULL; +- } +- lpx_set_real_parm(lp, param_id, +- PyFloat_AsDouble(value)); ++ glp_set_bfcp(lp, &bfcp); ++ } else if (!strcmp("LPX_K_MIPGAP", keystr)){ ++ iocp.mip_gap = PyFloat_AsDouble(value); ++ if (iocp.mip_gap < 0.0) ++ goto error; ++ } else { ++ sprintf(err_str, "unknown GLPK parameter: %-.20s", keystr); ++ PyErr_SetString(PyExc_ValueError, err_str); ++ glp_delete_prob(lp); ++ Py_DECREF(param); ++ return NULL; + } ++ } + } +- lpx_set_int_parm(lp, LPX_K_PRESOL, 1); ++ iocp.presolve = GLP_ON; + Py_DECREF(param); + + if (IntSet) { +@@ -628,22 +721,14 @@ static PyObject *integer(PyObject *self, + for (i=0; i<PySet_GET_SIZE(IntSet); i++) { + + PyObject *tmp = PySequence_Fast_GET_ITEM(iter, i); +-#if PY_MAJOR_VERSION >= 3 +- if (!PyLong_Check(tmp)) { +-#else +- if (!PyInt_Check(tmp)) { +-#endif +- lpx_delete_prob(lp); ++ if (!PYINT_CHECK(tmp)) { ++ glp_delete_prob(lp); + Py_DECREF(iter); + PY_ERR_TYPE("non-integer element in I"); + } +-#if PY_MAJOR_VERSION >= 3 +- int k = PyLong_AS_LONG(tmp); +-#else +- int k = PyInt_AS_LONG(tmp); +-#endif ++ int k = PYINT_AS_LONG(tmp); + if ((k < 0) || (k >= n)) { +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + Py_DECREF(iter); + PY_ERR(PyExc_IndexError, "index element out of range in I"); + } +@@ -659,22 +744,14 @@ static PyObject *integer(PyObject *self, + for (i=0; i<PySet_GET_SIZE(BinSet); i++) { + + PyObject *tmp = PySequence_Fast_GET_ITEM(iter, i); +-#if PY_MAJOR_VERSION >= 3 +- if (!PyLong_Check(tmp)) { +-#else +- if (!PyInt_Check(tmp)) { +-#endif +- lpx_delete_prob(lp); ++ if (!PYINT_CHECK(tmp)) { ++ glp_delete_prob(lp); + Py_DECREF(iter); + PY_ERR_TYPE("non-binary element in I"); + } +-#if PY_MAJOR_VERSION >= 3 +- int k = PyLong_AS_LONG(tmp); +-#else +- int k = PyInt_AS_LONG(tmp); +-#endif ++ int k = PYINT_AS_LONG(tmp); + if ((k < 0) || (k >= n)) { +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + Py_DECREF(iter); + PY_ERR(PyExc_IndexError, "index element out of range in B"); + } +@@ -686,117 +763,92 @@ static PyObject *integer(PyObject *self, + } + + ++ switch (glp_intopt(lp, &iocp)){ + +- switch (lpx_intopt(lp)){ +- +- case LPX_E_OK: ++ case 0: + + x = (matrix *) Matrix_New(n,1,DOUBLE); + if (!x) { + Py_XDECREF(t); +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return PyErr_NoMemory(); + } +- PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("optimal")); +-#else +- PyString_FromString("optimal")); +-#endif ++ PyTuple_SET_ITEM(t, 0, (PyObject *)PYSTRING_FROMSTRING("optimal")); + + for (i=0; i<n; i++) +- MAT_BUFD(x)[i] = lpx_mip_col_val(lp, i+1); ++ MAT_BUFD(x)[i] = glp_mip_col_val(lp, i+1); + PyTuple_SET_ITEM(t, 1, (PyObject *) x); + +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return (PyObject *) t; + +- case LPX_E_TMLIM: ++ case GLP_ETMLIM: + + x = (matrix *) Matrix_New(n,1,DOUBLE); + if (!x) { + Py_XDECREF(t); +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return PyErr_NoMemory(); + } + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("time limit exceeded")); +-#else +- PyString_FromString("time limit exceeded")); +-#endif ++ PYSTRING_FROMSTRING("time limit exceeded")); + + for (i=0; i<n; i++) +- MAT_BUFD(x)[i] = lpx_mip_col_val(lp, i+1); ++ MAT_BUFD(x)[i] = glp_mip_col_val(lp, i+1); + PyTuple_SET_ITEM(t, 1, (PyObject *) x); + +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + return (PyObject *) t; + + +- case LPX_E_FAULT: ++ case GLP_EBADB: ++ case GLP_ECOND: ++ case GLP_EBOUND: + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("invalid MIP formulation")); +-#else +- PyString_FromString("invalid MIP formulation")); +-#endif ++ PYSTRING_FROMSTRING("invalid MIP formulation")); + break; + +- case LPX_E_NOPFS: ++ case GLP_ENOPFS: + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("primal infeasible")); +-#else +- PyString_FromString("primal infeasible")); +-#endif ++ PYSTRING_FROMSTRING("primal infeasible")); + break; + +- case LPX_E_NODFS: ++ case GLP_ENODFS: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("dual infeasible")); +-#else +- PyString_FromString("dual infeasible")); +-#endif ++ PYSTRING_FROMSTRING("dual infeasible")); + break; + +- case LPX_E_ITLIM: ++ case GLP_EITLIM: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("maxiters exceeded")); +-#else +- PyString_FromString("maxiters exceeded")); +-#endif ++ PYSTRING_FROMSTRING("maxiters exceeded")); + break; + +- case LPX_E_SING: ++ case GLP_ESING: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("singular or ill-conditioned basis")); +-#else +- PyString_FromString("singular or ill-conditioned basis")); +-#endif ++ PYSTRING_FROMSTRING("singular or ill-conditioned basis")); + break; + + + default: + + PyTuple_SET_ITEM(t, 0, (PyObject *) +-#if PY_MAJOR_VERSION >= 3 +- PyUnicode_FromString("unknown")); +-#else +- PyString_FromString("unknown")); +-#endif ++ PYSTRING_FROMSTRING("unknown")); + } + +- lpx_delete_prob(lp); ++ glp_delete_prob(lp); + + PyTuple_SET_ITEM(t, 1, Py_BuildValue("")); + return (PyObject *) t; ++ ++error: ++ sprintf(err_str, "invalid value for GLPK parameter: %-.20s", keystr); ++ PyErr_SetString(PyExc_ValueError, err_str); ++ glp_delete_prob(lp); ++ Py_DECREF(param); ++ return NULL; + } + + diff --git a/dev-python/cvxopt/metadata.xml b/dev-python/cvxopt/metadata.xml index 2e5db1fcde1d..3255645ec596 100644 --- a/dev-python/cvxopt/metadata.xml +++ b/dev-python/cvxopt/metadata.xml @@ -1,17 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> <pkgmetadata> - <herd>sci-mathematics</herd> - <longdescription lang="en"> +<herd>sci-mathematics</herd> +<longdescription lang="en"> CVXOPT is a software for convex optimization based on the Python programming language. Its main purpose is to make the development of software for convex optimization applications straightforward. </longdescription> - <use> - <flag name="glpk">Use GNU Linear Programming Kit - <pkg>sci-mathematics/glpk</pkg></flag> - <flag name="dsdp">Use interior point library +<use> + <flag name="dsdp">Use interior point library <pkg>sci-libs/dsdp</pkg></flag> - </use> + <flag name="glpk">Use GNU Linear Programming Kit + <pkg>sci-mathematics/glpk</pkg></flag> +</use> </pkgmetadata> |