0.0.11 • Published 5 months ago

glpk-ts v0.0.11

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
5 months ago

GLPK interface for TypeScript powered by WebAssembly

We aim to provide an easy-to-use interface to GLPK which works out of the box. Of course, Javascript is not the best choice for a modeling language. Nevertheless it might be a suitable alternative for some applications because it runs on almost any machine (in the browser) without additional dependencies and setup.

Installation

Using the usual command

npm install glpk-ts

you should get the library together with its wasm-dependency.

Example

const { loadModule, Model } = require('glpk-ts')

loadModule().then(() => {
  const m = new Model()
  // create 2 non-negative variables
  const [x, y] = m.addVars(2, { lb: 0.0, obj: -1.0 })
  // add the constraint x + y <= 1
  m.addConstr({
    ub: 1.0,
    coeffs: [
      [x, 1.0],
      [y, 1.0],
    ],
  })
  // let the simplex method solve the problem
  m.simplex()
  console.log(`x = ${x.value}, y = ${y.value}`)
})

Documentation

You can find the documentation here.

Performance

Below you can find a table with some runtime stats which I obtained on my local machine (i7-4790K running Ubuntu 20.04.2). The benchmark instances are taken from the Netlib Repository. Please have a look at this repository if you want to try it on your own machine.

If you have any idea why NodeJS is performing so great, please give me a hint.

NodeJSv14.17.0Chrome90.0.4430.212Firefox 88.0.1C++ (ref)GLPK 4.65PyGLPK (ref)GLPK 4.65
25fv4723.0433.6463.0186.8185.7
80bau3b78.01589.41048.0582.4574.8
adlittle0.12.81.00.70.8
afiro0.00.20.00.10.1
agg0.15.34.02.02.7
agg20.16.24.02.12.5
agg30.07.06.02.12.3
bandm2.149.936.019.720.6
beaconfd0.14.33.01.41.6
blend0.11.91.00.50.6
bnl15.1115.178.044.144.9
bnl258.01027.9745.0427.9428.4
boeing11.123.317.09.19.0
boeing20.04.24.01.61.7
bore3d0.07.06.02.42.5
brandy1.022.817.08.08.2
capri0.012.08.04.15.4
cycle24.0453.6323.0169.5181.0
czprob10.0215.6151.077.778.3
d2q06c209.13833.02836.01701.71728.5
d6cube71.11400.81056.0557.5557.9
degen23.169.248.026.028.2
degen342.0799.7594.0340.1337.0
dfl0013408.155618.943681.028133.926272.0
e2260.016.013.09.46.6
etamacro1.026.422.09.09.2
fffff8002.143.443.015.016.1
finnis1.023.318.07.88.1
fit1d2.156.143.021.721.0
fit1p7.0168.2114.056.156.8
fit2d301.16178.84822.02482.12427.5
fit2p475.19876.56659.03510.53516.4
forplan0.112.210.04.55.2
ganges6.0141.499.045.344.7
gfrd-pnc1.147.929.014.114.1
greenbea129.02390.11900.0993.9990.8
greenbeb102.11932.21368.0780.9780.7
grow152.152.238.020.418.7
grow226.0125.092.044.746.1
grow70.014.811.05.35.3
israel0.07.25.02.52.6
kb20.01.61.00.40.5
lotfi0.13.83.01.31.4
maros-r7206.13609.42988.01400.21407.4
maros16.1276.7241.0113.0111.9
modszk16.1118.283.042.643.9
nesm26.1485.0353.0198.4198.3
perold24.1384.0279.0157.5158.1
pilot.ja76.11191.9903.0510.5512.5
pilot258.14654.13617.01905.21901.8
pilot.we28.0502.9362.0205.2210.1
pilot48.1151.6111.064.563.7
pilot87636.012021.39820.05359.64743.4
pilotnov25.0487.1362.0215.1201.6
recipe0.00.60.00.20.3
sc1050.12.21.00.50.6
sc2050.013.26.04.42.8
sc50a0.00.40.00.20.2
sc50b0.00.50.00.30.2
scagr251.136.225.017.212.6
scagr70.13.42.01.51.3
scfxm11.023.214.08.07.5
scfxm23.069.645.027.124.8
scfxm37.1142.3100.049.050.2
scorpion0.012.59.05.54.2
scrs82.055.438.019.120.5
scsd10.04.32.01.61.6
scsd60.017.912.06.66.8
scsd85.0104.873.037.738.7
sctap10.121.010.05.96.2
sctap29.1192.0129.069.370.2
sctap315.1291.8206.0110.2112.8
seba1.035.424.011.412.1
share1b0.17.46.02.83.2
share2b0.11.51.00.60.6
shell1.039.524.011.812.7
ship04l1.024.216.09.67.5
ship04s0.120.212.010.25.9
ship08l4.194.854.026.830.0
ship08s3.156.831.015.016.5
ship12l7.0170.6100.045.847.4
ship12s4.1108.566.029.630.0
sierra3.072.644.020.922.0
stair2.154.240.018.218.7
standata0.03.13.01.11.1
standmps0.016.410.04.75.5
stocfor10.13.11.00.60.7
stocfor216.1335.9231.0113.9113.7
tuff1.032.921.010.611.3
vtp.base0.17.25.02.92.6
wood1p5.1134.0106.043.741.7
woodw22.0440.5293.0162.6157.6

Applications

  • Factoriolab (Angular-based calculator for factory games like Factorio and Dyson Sphere Program)

Let me know if you are planning to use glpk-ts for your application.

Coverage report

You can find the report here.

0.0.11

5 months ago

0.0.10

1 year ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago