Skip to content

ds604/glpk.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glpk.js

JavaScript (emscripten) port of GLPK (GNU Linear Programming Kit).

Rather than porting the complete GLPK library (including GLPSOL) this project aims at creating a simple JSON interface to setup and solve LP/MILP with JavaScript.

Usage

const glpk = require('../glpk.js');

let lp = {
  name: 'LP',
  objective: {
    direction: glpk.GLP_MAX,
    name: 'obj',
    vars: [
      { name: 'x1', coef: 0.6 },
      { name: 'x2', coef: 0.5 }
    ]
  },
  subjectTo: [
    {
      name: 'cons1',
      vars: [
        { name: 'x1', coef: 1.0 },
        { name: 'x2', coef: 2.0 }
      ],
      bnds: { type: glpk.GLP_UP, ub: 1.0, lb: 0.0 }
    },
    {
      name: 'cons2',
      vars: [
        { name: 'x1', coef: 3.0 },
        { name: 'x2', coef: 1.0 }
      ],
      bnds: { type: glpk.GLP_UP, ub: 2.0, lb: 0.0 }
    }
  ]
};

console.log(
  glpk.solve(lp, glpk.GLP_MSG_ALL)
);

Examples

Acknowledgements

The research leading to these results has received funding from the European Community’s Seventh Framework Programme (FP7/2007–2013) under grant agreement No. FP7-266367 (SOLID).

About

JavaScript port of GLPK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 75.8%
  • Makefile 21.2%
  • C 3.0%