GLPK/Node.js

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Node.js [1] is an application platform based on server side JavaScript.

Node-glpk[edit | edit source]

Node-glpk [2] is a handcrafted language binding to access the GLPK library from NodeJS. It is subject to the Mozilla public license 2.0 [3].

Installation[edit | edit source]

The package is installed using the npm [4] package manager.

npm install glpk

Example[edit | edit source]

var glp = require("glpk");
var prob = new glp.Problem();
prob.readLpSync("todd.lpt");
prob.scaleSync(glp.SF_AUTO);
prob.simplexSync({presolve: glp.ON});
if (prob.getNumInt() > 0){
  function callback(tree){
    if (tree.reason() == glp.IBINGO){
      // ...
    }
  }
  prob.intoptSync({cbFunc: callback});
}
prob.delete();