npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

highs

v1.8.0

Published

Mixed integer linear programming library, built by compiling a high-performance C++ solver developed by the University of Edinburgh (HiGHS) to WebAssembly.

Downloads

11,979

Readme

highs-js

npm version CI status package size

This is a javascript mixed integer linear programming library. It is built by compiling a high-performance C++ solver developed by the University of Edinburgh, (HiGHS), to WebAssembly using emscripten.

Demo

See the online demo at: https://lovasoa.github.io/highs-js/

Usage

const highs_settings = {
  // In node, locateFile is not needed
  // In the browser, point locateFile to the URL of the wasm file (see below)
  locateFile: (file) => "https://lovasoa.github.io/highs-js/" + file
};
const highs_promise = require("highs")(highs_settings);

const PROBLEM = `Maximize
 obj:
    x1 + 2 x2 + 4 x3 + x4
Subject To
 c1: - x1 + x2 + x3 + 10 x4 <= 20
 c2: x1 - 4 x2 + x3 <= 30
 c3: x2 - 0.5 x4 = 0
Bounds
 0 <= x1 <= 40
 2 <= x4 <= 3
End`;

const EXPECTED_SOLUTION = {
  Status: 'Optimal',
  ObjectiveValue: 87.5,
  Columns: {
    x1: {
      Index: 0,
      Status: 'BS',
      Lower: 0,
      Upper: 40,
      Type: 'Continuous',
      Primal: 17.5,
      Dual: -0,
      Name: 'x1'
    },
    x2: {
      Index: 1,
      Status: 'BS',
      Lower: 0,
      Upper: Infinity,
      Type: 'Continuous',
      Primal: 1,
      Dual: -0,
      Name: 'x2'
    },
    x3: {
      Index: 2,
      Status: 'BS',
      Lower: 0,
      Upper: Infinity,
      Type: 'Continuous',
      Primal: 16.5,
      Dual: -0,
      Name: 'x3'
    },
    x4: {
      Index: 3,
      Status: 'LB',
      Lower: 2,
      Upper: 3,
      Type: 'Continuous',
      Primal: 2,
      Dual: -8.75,
      Name: 'x4'
    }
  },
  Rows: [
    {
      Index: 0,
      Name: 'c1',
      Status: 'UB',
      Lower: -Infinity,
      Upper: 20,
      Primal: 20,
      Dual: 1.5
    },
    {
      Index: 1,
      Name: 'c2',
      Status: 'UB',
      Lower: -Infinity,
      Upper: 30,
      Primal: 30,
      Dual: 2.5
    },
    {
      Index: 2,
      Name: 'c3',
      Status: 'UB',
      Lower: 0,
      Upper: 0,
      Primal: 0,
      Dual: 10.5
    }
  ]
};

async function test() {
  const highs = await highs_promise;
  const sol = highs.solve(PROBLEM);
  require("assert").deepEqual(sol, EXPECTED_SOLUTION);
}

The problem has to be passed in the CPLEX .lp file format.

For a more complete example, see the demo folder.

Loading the wasm file

This package requires a wasm file. You can find it in node_modules/highs/build/highs.wasm inside the NPM package, or download it from the release page. By default, it will be loaded from the same path as the javascript file, which means you have to add the wasm file to your assets.

Alternatively, if you don't want to bother with that, if you are running highs-js in a web browser (and not in node), you can load the file directly from github:

const highs_loader = require("highs");

const highs = await highs_loader({
  // In a browser, one can load the wasm file from github
  locateFile: (file) => "https://lovasoa.github.io/highs-js/" + file
});

Passing custom options

HiGHS is configurable through a large number of options.

You can pass options as the second parameter to solve :

const highs_promise = require("highs")(highs_settings);
const highs = await highs_promise;
const sol = highs.solve(PROBLEM, {
  "allowed_cost_scale_factor": 2,
  "run_crossover": true,
  "presolve": "on",
});