Skip to main content

swiglpk - Simple swig bindings for the GNU Linear Programming Kit

Project description

PyPI License Build Status AppVeyor Status

Why?

swiglpk is not a high-level wrapper for GLPK (take a look at optlang if you are interested in a python-based mathematical programming language). It just provides plain vanilla swig bindings to the underlying C library. In constrast to other GLPK wrappers for python (e.g. PyGLPK, Python-GLPK, ctypes-glpk, ecyglpki etc.) it is fairly version agnostic: it will try to guess the location of the glpk.h header file (using which glpsol) and then compile the extension for your particular GLPK installation.

Dependencies

  • GLPK (swiglpk has been tested with versions 4.45 and 4.52 on OS X)

  • swig (swiglpk has been tested tested with version 3.0.2 on OS X)

If you’re on OS X, swig and GLPK can easily be installed with homebrew.

brew install swig glpk

If you’re using ubuntu linux, you can install swig and GLPK using apt-get.

apt-get install glpk-utils libglpk-dev swig

Installation

python setup.py install

Example

Running the following (slightly adapted) example from the GLPK manual

from swiglpk import *

ia = intArray(1+1000); ja = intArray(1+1000);
ar = doubleArray(1+1000);
lp = glp_create_prob();
glp_set_prob_name(lp, "sample");
glp_set_obj_dir(lp, GLP_MAX);
glp_add_rows(lp, 3);
glp_set_row_name(lp, 1, "p");
glp_set_row_bnds(lp, 1, GLP_UP, 0.0, 100.0);
glp_set_row_name(lp, 2, "q");
glp_set_row_bnds(lp, 2, GLP_UP, 0.0, 600.0);
glp_set_row_name(lp, 3, "r");
glp_set_row_bnds(lp, 3, GLP_UP, 0.0, 300.0);
glp_add_cols(lp, 3);
glp_set_col_name(lp, 1, "x1");
glp_set_col_bnds(lp, 1, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, 1, 10.0);
glp_set_col_name(lp, 2, "x2");
glp_set_col_bnds(lp, 2, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, 2, 6.0);
glp_set_col_name(lp, 3, "x3");
glp_set_col_bnds(lp, 3, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, 3, 4.0);
ia[1] = 1; ja[1] = 1; ar[1] = 1.0; # a[1,1] = 1
ia[2] = 1; ja[2] = 2; ar[2] = 1.0; # a[1,2] = 1
ia[3] = 1; ja[3] = 3; ar[3] = 1.0; # a[1,3] = 1
ia[4] = 2; ja[4] = 1; ar[4] = 10.0; # a[2,1] = 10
ia[5] = 3; ja[5] = 1; ar[5] = 2.0; # a[3,1] = 2
ia[6] = 2; ja[6] = 2; ar[6] = 4.0; # a[2,2] = 4
ia[7] = 3; ja[7] = 2; ar[7] = 2.0; # a[3,2] = 2
ia[8] = 2; ja[8] = 3; ar[8] = 5.0; # a[2,3] = 5
ia[9] = 3; ja[9] = 3; ar[9] = 6.0; # a[3,3] = 6
glp_load_matrix(lp, 9, ia, ja, ar);
glp_simplex(lp, None);
Z = glp_get_obj_val(lp);
x1 = glp_get_col_prim(lp, 1);
x2 = glp_get_col_prim(lp, 2);
x3 = glp_get_col_prim(lp, 3);
print("\nZ = %g; x1 = %g; x2 = %g; x3 = %g\n" % (Z, x1, x2, x3))
glp_delete_prob(lp);

… will produce the following output (the example can also be found at examples/example.py):

GLPK Simplex Optimizer, v4.52
3 rows, 3 columns, 9 non-zeros
*     0: obj =   0.000000000e+00  infeas =  0.000e+00 (0)
*     2: obj =   7.333333333e+02  infeas =  0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND

Z = 733.333; x1 = 33.3333; x2 = 66.6667; x3 = 0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

swiglpk-1.3.3.win-amd64-py3.5.exe (1.1 MB view details)

Uploaded Source

swiglpk-1.3.3.win-amd64-py3.4.exe (735.5 kB view details)

Uploaded Source

swiglpk-1.3.3.win-amd64-py3.3.exe (735.5 kB view details)

Uploaded Source

swiglpk-1.3.3.win-amd64-py2.7.exe (737.6 kB view details)

Uploaded Source

swiglpk-1.3.3.win32-py3.5.exe (907.1 kB view details)

Uploaded Source

swiglpk-1.3.3.win32-py3.4.exe (631.7 kB view details)

Uploaded Source

swiglpk-1.3.3.win32-py3.3.exe (631.8 kB view details)

Uploaded Source

swiglpk-1.3.3.win32-py2.7.exe (630.9 kB view details)

Uploaded Source

swiglpk-1.3.3-cp35-cp35m-win_amd64.whl (529.2 kB view details)

Uploaded CPython 3.5m Windows x86-64

swiglpk-1.3.3-cp35-cp35m-win32.whl (445.2 kB view details)

Uploaded CPython 3.5m Windows x86

swiglpk-1.3.3-cp35-cp35m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.5m

swiglpk-1.3.3-cp35-cp35m-manylinux1_i686.whl (1.7 MB view details)

Uploaded CPython 3.5m

swiglpk-1.3.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (830.2 kB view details)

Uploaded CPython 3.5m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

swiglpk-1.3.3-cp34-cp34m-win_amd64.whl (511.6 kB view details)

Uploaded CPython 3.4m Windows x86-64

swiglpk-1.3.3-cp34-cp34m-win32.whl (439.1 kB view details)

Uploaded CPython 3.4m Windows x86

swiglpk-1.3.3-cp34-cp34m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.4m

swiglpk-1.3.3-cp34-cp34m-manylinux1_i686.whl (1.7 MB view details)

Uploaded CPython 3.4m

swiglpk-1.3.3-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (830.1 kB view details)

Uploaded CPython 3.4m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

swiglpk-1.3.3-cp33-cp33m-win_amd64.whl (511.6 kB view details)

Uploaded CPython 3.3m Windows x86-64

swiglpk-1.3.3-cp33-cp33m-win32.whl (439.1 kB view details)

Uploaded CPython 3.3m Windows x86

swiglpk-1.3.3-cp27-cp27mu-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 2.7mu

swiglpk-1.3.3-cp27-cp27mu-manylinux1_i686.whl (1.7 MB view details)

Uploaded CPython 2.7mu

swiglpk-1.3.3-cp27-cp27m-win_amd64.whl (512.2 kB view details)

Uploaded CPython 2.7m Windows x86-64

swiglpk-1.3.3-cp27-cp27m-win32.whl (433.1 kB view details)

Uploaded CPython 2.7m Windows x86

swiglpk-1.3.3-cp27-cp27m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 2.7m

swiglpk-1.3.3-cp27-cp27m-manylinux1_i686.whl (1.7 MB view details)

Uploaded CPython 2.7m

swiglpk-1.3.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (833.4 kB view details)

Uploaded CPython 2.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

File details

Details for the file swiglpk-1.3.3.win-amd64-py3.5.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win-amd64-py3.5.exe
Algorithm Hash digest
SHA256 5a5e863cbd9a447d55aedf2cf2a7ac0d13a0856490ec0f338fcd082083b48efc
MD5 1477e71a9aa32db6018568782a203c48
BLAKE2b-256 ae22ed9c70d3f42fb67d66fa01c66914925a1d36fc208fe702bda3987de5101b

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win-amd64-py3.4.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win-amd64-py3.4.exe
Algorithm Hash digest
SHA256 ad88c5f939c756581e85ad8922769b042cef097ed4cdc69a0b86f41ebb015894
MD5 055a8e3c3616020954282c9260d4b66d
BLAKE2b-256 3d671119f716b2b37ced52092868686a0b5e2b5a4b5523094ef1f85cabc7833c

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win-amd64-py3.3.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win-amd64-py3.3.exe
Algorithm Hash digest
SHA256 435c63fcd8e8b6e3734751fe663d20a1750adced8d3245662e1116f78c800a5c
MD5 47528766d118ffbb13975aa808ac16b5
BLAKE2b-256 30372d1427c09bd535a007c01688c59db410efb0dbaade77f806a944ed6bd393

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 032d2bbd1dc5183e5489b2ee16528db211f22cbbbdc55ae9131e1d31486298c4
MD5 11ace2db8260f71c665787086f26e1b9
BLAKE2b-256 c82e62bddc5070bced494344d38db101e67d823ba01f8b3997ebb7d18e454749

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win32-py3.5.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win32-py3.5.exe
Algorithm Hash digest
SHA256 0459328db4447cc063338af27250e0ca072e39add2ad4e9d413cb84dd03446e5
MD5 1be7348df20e56bb44622fde31a0a35b
BLAKE2b-256 7c440698982549f2317bada56fefe0c056c14fbb2e66a48af943d80d3f06569c

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win32-py3.4.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win32-py3.4.exe
Algorithm Hash digest
SHA256 4f28ca75034f542492523d610ac768e62cf4d75772b7f7cea075c6c168e7ea67
MD5 0f9d0e1c5dba148ec5d590fe1170e4a4
BLAKE2b-256 cfc95ceacdcf2762cf12ca994eca6ebbbf1cc8ed9b77cf9c3f12fc7e71f4fe38

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win32-py3.3.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win32-py3.3.exe
Algorithm Hash digest
SHA256 b06d91076381b0c9778394123776ab654622794291b6423a4bb0c9a11d5c2813
MD5 110fcd5bde57dc9039f62ffe1edab99f
BLAKE2b-256 ec348e56c56bf489575b0a6580875c1185c561d1b1acc740d46f823991f023de

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3.win32-py2.7.exe.

File metadata

File hashes

Hashes for swiglpk-1.3.3.win32-py2.7.exe
Algorithm Hash digest
SHA256 0995bc34c828971b13799da5a621ec2b72d879367037a5122a3513b1110d97a0
MD5 9d57de019584968e9a3021907bc5bac0
BLAKE2b-256 3d9ed4fcfd96283e3b4ed2bbd97152e483f7131a09539f8ea4d3398fcf4f5eeb

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 f8f8af6f34622d3bb3dc6e90affe5015def510da55dd8bbf589841a0b5cb564f
MD5 48d0695d231ee3c549ff09b6c49b383c
BLAKE2b-256 81ecd69abc29e0133fe80f4c0addf1149fca081ea66cba4fcdadc55cd6029ae7

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 af3e9f6d9eda9fcb94222df974c017a350370de3d057f90ef1de5644d0d12a94
MD5 f4f7d1eee76ddc03fc41a923e95e21d1
BLAKE2b-256 24d4fe99531127ca65320c33ac1b274aa57ca4613e1eea12cf4a716bba731e43

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3b062a3b805b638cc18137cf51ee6cc85497f1535fe3a4f17ffe3054c7a9ca4d
MD5 203eb4bff3123e61098a89f49b790b93
BLAKE2b-256 2263908831b6f6917c6bd489085541c98cc7c27745fa44fae7af85b50e395f8d

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 aa2a2c508780044cc9fab84058da5a79c46cf0f52dfd51e4c3d6c97d6eb0ed74
MD5 d633755083b9267944e91bc0422c2018
BLAKE2b-256 07ff9302e9ec8f73eb58595fe623e8d791821f033967d93f612e924115511f25

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 bdcc370d38598fd315c400db9cf04811400f90c20966b4b19639182ea64d78a1
MD5 d81247fe745c37ca24b943d616903270
BLAKE2b-256 7b22641acc8d4deda6a18cc5eff4151d9c600890383b289a98706ed678c399af

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp34-cp34m-win_amd64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 ec4d2a786df512262cce53e3b73352c0ea98b0318cd301610067e7adcabce5b3
MD5 8a7b14f9db48ac5be485bb5063b5bdd2
BLAKE2b-256 c012d64686a6fc630e19d1bc93cbfc9d315d7ab352a68c1c924c1a89a3f3abf4

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp34-cp34m-win32.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 49c1cb4e1d0829dcb73d77cb9c3cad8d0038a163933972f677ef366a9d9ea371
MD5 fe88cf4e0f9cebbc209377230ad9bbd9
BLAKE2b-256 3153696e0540b246d8debcae48641f22e09fd2782ba196e62c6d0cd79eaed1b8

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 46215727b583f3b87f55ec44b61c07dacb33078d89c6e115bf4ee06ee5743cf6
MD5 843151f7ed383fc55e66b07a6fd59e78
BLAKE2b-256 8e52d5bdad45a01f30331473e72c47ccd222790d04fa1c8e6e018edf958bf9e8

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5fcdf7902836cf9ab76a84afb12ec4b9b8ec08c3de1ac0a8184adb7a9a12fd6a
MD5 0d58ec2bb8eef95b123edbbba6a785bc
BLAKE2b-256 66efc587c089297eb1022896774eb4c30817253c3cd1dda9bd30bbefe37a2832

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 26b6b223661497b5fd04279f487eb9b78aba1e8fea068cb90155d57ec780f080
MD5 fd6bb2bebee5902986f9856d224334c1
BLAKE2b-256 4f092122933077ef645078001ee5cd979082d363e0cb06bc06ba86ca5d9c5c06

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp33-cp33m-win_amd64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp33-cp33m-win_amd64.whl
Algorithm Hash digest
SHA256 5301613d7d9487e1cedf408c024fa9ab3280efd01661143dc28a4899e55a3bdd
MD5 12d359b332f81600d62c10a9ceca2ccf
BLAKE2b-256 fdda8bbc4c010a4d7d9983364d1c0644a67525a23770b476770b29d6a51a388c

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp33-cp33m-win32.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp33-cp33m-win32.whl
Algorithm Hash digest
SHA256 778222759b5546bc4596569625d0144646bd2df1133b888852e361545c5989e9
MD5 5acc798cb2d997625a45e29229181d8d
BLAKE2b-256 60d5af998170563ede155d1f5791a9a49eff86afc6740030ce8fe0c6a15dbece

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2fc2ef301a52d74172c240edea14bad2b3869b7ef7c3c1800a59fbb249b476be
MD5 9dce7bc384475b34b77d1c31be517972
BLAKE2b-256 e27db62c332c9385b3041c5678bbfc0edb4b083260671cd4877c2aa0a687675a

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 a902fb33c88f5380ba5fc05e168563fca3aadb28f652c86ea3c228597d0683fe
MD5 b9cb2388a8fad080376b3010a66411bb
BLAKE2b-256 bc85564e64d8ae3e34b832c864690b188a8156777a46588d3b58c8d66b13343f

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 d5d648b391eccea8e0aa5835b56c83b5894d5bc1c96e6b5278ee09e200f3bd95
MD5 4fd35cc678b2bae6cee56d1b5f79e5d9
BLAKE2b-256 660aac5b863f2df42281be5aa3fcab7f6051d535eca4f2848ff9bfc867462198

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 87c3e3de987b6bc2721aa2b911e645329e297562fc1872c2f8214907e9449d72
MD5 cf1dd98e27b20cfc35d0ef90ff0c4833
BLAKE2b-256 5d3aee3c94512514d8e85dd62dc8715378f587f4fe00d2472c2a9963c2652108

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ff7530624e34b1ff3a0123c7917839da474522988d125acbd498970413c7711e
MD5 159fa3248dc4c8225664bc8f31339b1b
BLAKE2b-256 9969017f50ec23d4896cc586a4b04036ea769221c9559d93dfa645bc5a6258d1

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1bb73aa46479e7f9a3ecf89eb219931a0837b0b614e3b37895a41265ecf4ab39
MD5 3b2cdbb5d3a6d00e38cfbb0a5c9ed659
BLAKE2b-256 d91ea703deca70836bcaf3c431a63a0ef3225ee7a95a7bf56e930c84305db363

See more details on using hashes here.

File details

Details for the file swiglpk-1.3.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for swiglpk-1.3.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 53f51d5d4959b72787c19132bf1ee281caaee2821efff7cd996b025094c0191c
MD5 9cdfc4a834db25b9a01e3ba68abf4dfb
BLAKE2b-256 7276db16c6521c1e85b81061c9f6f671e8840543289ca1fed23e19561ef0317a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page