All Projects → jvail → glpk.js

jvail / glpk.js

Licence: GPL-3.0 license
GLPK for browser & node

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
c
50402 projects - #5 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to glpk.js

rust-lp-modeler
Lp modeler written in Rust
Stars: ✭ 75 (+4.17%)
Mutual labels:  solver, glpk
blt
Lattice-based integer linear programming solver
Stars: ✭ 60 (-16.67%)
Mutual labels:  solver, glpk
Visma
VISual MAth - an equation solver and visualizer
Stars: ✭ 71 (-1.39%)
Mutual labels:  solver
WarpPI
WarpPI Calculator, Step-by-step algebra calculator for Raspberry Pi. (abandoned project)
Stars: ✭ 93 (+29.17%)
Mutual labels:  solver
Pyro2
A framework for hydrodynamics explorations and prototyping
Stars: ✭ 181 (+151.39%)
Mutual labels:  solver
Hiop
HPC solver for nonlinear optimization problems
Stars: ✭ 75 (+4.17%)
Mutual labels:  solver
Optaplanner
AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.
Stars: ✭ 2,454 (+3308.33%)
Mutual labels:  solver
Prioritizr
Systematic conservation prioritization in R
Stars: ✭ 62 (-13.89%)
Mutual labels:  solver
SkytilsMod
A Hypixel Skyblock Utilities mod
Stars: ✭ 236 (+227.78%)
Mutual labels:  solver
Qpsolvers
Quadratic Programming solvers in Python with a unified API
Stars: ✭ 157 (+118.06%)
Mutual labels:  solver
SiEPIC Photonics Package
A Python (v3.6.5) package that provides a set of basic functions commonly used in integrated photonics.
Stars: ✭ 22 (-69.44%)
Mutual labels:  solver
Cosmo.jl
COSMO: Accelerated ADMM-based solver for convex conic optimisation problems (LP, QP, SOCP, SDP, ExpCP, PowCP). Automatic chordal decomposition of sparse semidefinite programs.
Stars: ✭ 149 (+106.94%)
Mutual labels:  solver
Java Smt
JavaSMT - Unified Java API for SMT solvers.
Stars: ✭ 88 (+22.22%)
Mutual labels:  solver
Sundials
SUNDIALS is a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. This is a mirror of current releases, and development will move here eventually. Pull requests are welcome for bug fixes and minor changes.
Stars: ✭ 194 (+169.44%)
Mutual labels:  solver
Angler
Frequency-domain photonic simulation and inverse design optimization for linear and nonlinear devices
Stars: ✭ 75 (+4.17%)
Mutual labels:  solver
mSAT
A modular sat/smt solver with proof output.
Stars: ✭ 91 (+26.39%)
Mutual labels:  solver
Py Lapsolver
Fast linear assignment problem (LAP) solvers for Python based on c-extensions
Stars: ✭ 70 (-2.78%)
Mutual labels:  solver
Hodlr
A fast, accurate direct solver and determinant computation for dense linear systems
Stars: ✭ 140 (+94.44%)
Mutual labels:  solver
Logician
Logic programming in Swift
Stars: ✭ 182 (+152.78%)
Mutual labels:  solver
sudokufx
AR Sudoku grabber and solver using JavaCV, JavaFX and Scala
Stars: ✭ 64 (-11.11%)
Mutual labels:  solver

glpk.js

JavaScript/WebAssembly port of GLPK (GNU Linear Programming Kit) for browser & node. 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.

Install

npm install glpk.js

Code Example

const GLPK = require('glpk.js');
const glpk = GLPK();
const options = {
    msglev: glpk.GLP_MSG_ALL,
    presol: true,
    cb: {
        call: progress => console.log(progress),
        each: 1
    }
};
const res = glpk.solve({
    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 }
        }
    ]
}, options);

Live Examples

glpk.js and Mixed-Integer Programming with a lot of background information:

Simple LP in the browser:

Some (slighty outdated) examples using glpk.js:

API

interface LP {
    name: string,
    objective: {
        direction: number,
        name: string,
        vars: { name: string, coef: number }[]
    },
    subjectTo: {
        name: string,
        vars: { name: string, coef: number }[],
        bnds: { type: number, ub: number, lb: number }
    }[],
    bounds?: {
        name: string,
        type: number,
        ub: number,
        lb: number
    }[],
    binaries?: string[],
    generals?: string[],
    options?: Options
}

Optionally the "kind of structural variable"

  • continuous variable (default)
  • integer variable
  • binary variable

may be specified with an array of variable names:

  /* integer */
  lp.generals = ['x1', 'x2'];

  /* binary */
  lp.binaries = ['x3', 'x4'];
interface Options {
    mipgap?: number,    /* set relative mip gap tolerance to mipgap, default 0.0 */
    tmlim?: number,     /* limit solution time to tmlim seconds, default INT_MAX */
    msglev?: number,    /* message level for terminal output, default GLP_MSG_ERR */
    presol?: boolean,   /* use presolver, default true */
    cb?: {              /* a callback called at each 'each' iteration (only simplex) */
        call(result: Result),
        each: number
    }
}

interface Result {
    name: string;
    time: number;
    result: {
        status: number;
        z: number;
        vars: {[key:string]: number};
        dual?: { [key: string]: number }; /* simplex only */
    };
}

interface GLPK {

    /* direction */
    readonly GLP_MIN: number;  /* minimization */
    readonly GLP_MAX: number;  /* maximization */

    /* type of auxiliary/structural variable: */
    readonly GLP_FR: number;  /* free (unbounded) variable */
    readonly GLP_LO: number;  /* variable with lower bound */
    readonly GLP_UP: number;  /* variable with upper bound */
    readonly GLP_DB: number;  /* double-bounded variable */
    readonly GLP_FX: number;  /* fixed variable */

    /* message level: */
    readonly GLP_MSG_OFF: number;  /* no output */
    readonly GLP_MSG_ERR: number;  /* warning and error messages only */
    readonly GLP_MSG_ON: number;   /* normal output */
    readonly GLP_MSG_ALL: number;  /* full output */
    readonly GLP_MSG_DBG: number;  /* debug output */

    /* solution status: */
    readonly GLP_UNDEF: number;   /* solution is undefined */
    readonly GLP_FEAS: number;    /* solution is feasible */
    readonly GLP_INFEAS: number;  /* solution is infeasible */
    readonly GLP_NOFEAS: number;  /* no feasible solution exists */
    readonly GLP_OPT: number;     /* solution is optimal */
    readonly GLP_UNBND: number;   /* solution is unbounded */

    version: string;  /* GLPK version */
    write(lp: LP): string; /* writes problem data in CPLEX LP */
    solve(lp: LP, options?: number | Options): Result /* options is either a glp message level or an options obj */
}

Building

emsdk

git clone https://github.com/jvail/glpk.js.git
cd glpk.js
git submodule update --init --recursive
npm install
source ~/emsdk/emsdk_env.sh
npm run build && npm run test

docker

Uses official docker images for emscripten/emsdk.

docker build . -t glpk.js
docker run -v $PWD:/app glpk.js
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].