{"id":17930549,"url":"https://github.com/lovasoa/highs-js","last_synced_at":"2025-04-04T15:12:04.555Z","repository":{"id":39901346,"uuid":"348485163","full_name":"lovasoa/highs-js","owner":"lovasoa","description":"Javascript linear programming library","archived":false,"fork":false,"pushed_at":"2024-12-20T19:54:02.000Z","size":9626,"stargazers_count":60,"open_issues_count":5,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T14:08:03.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://lovasoa.github.io/highs-js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovasoa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-16T20:38:25.000Z","updated_at":"2025-03-27T11:56:50.000Z","dependencies_parsed_at":"2024-06-21T14:29:43.501Z","dependency_job_id":null,"html_url":"https://github.com/lovasoa/highs-js","commit_stats":{"total_commits":97,"total_committers":9,"mean_commits":"10.777777777777779","dds":"0.25773195876288657","last_synced_commit":"89292f2a0a2e2d5635e0e0f1bb4501ecf63bc709"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasoa%2Fhighs-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasoa%2Fhighs-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasoa%2Fhighs-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasoa%2Fhighs-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovasoa","download_url":"https://codeload.github.com/lovasoa/highs-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198469,"owners_count":20900081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T21:14:06.588Z","updated_at":"2025-04-04T15:12:04.534Z","avatar_url":"https://github.com/lovasoa.png","language":"JavaScript","funding_links":[],"categories":["Linear Programming"],"sub_categories":[],"readme":"# highs-js\n\n[![npm version](https://badge.fury.io/js/highs.svg)](https://www.npmjs.com/package/highs)\n[![CI status](https://github.com/lovasoa/highs-js/actions/workflows/CI.yml/badge.svg)](https://github.com/lovasoa/highs-js/actions/workflows/CI.yml)\n[![package size](https://badgen.net/bundlephobia/minzip/highs)](https://bundlephobia.com/result?p=highs)\n\nThis is a javascript mixed integer linear programming library.\nIt is built by compiling a high-performance C++ solver developed by the University of Edinburgh, ([HiGHS](https://highs.dev)), to WebAssembly using emscripten.\n\n## Demo\n\nSee the online demo at: https://lovasoa.github.io/highs-js/\n\n## Usage\n\n```js\nconst highs_settings = {\n  // In node, locateFile is not needed\n  // In the browser, point locateFile to the URL of the wasm file (see below)\n  locateFile: (file) =\u003e \"https://lovasoa.github.io/highs-js/\" + file\n};\nconst highs_promise = require(\"highs\")(highs_settings);\n\nconst PROBLEM = `Maximize\n obj:\n    x1 + 2 x2 + 4 x3 + x4\nSubject To\n c1: - x1 + x2 + x3 + 10 x4 \u003c= 20\n c2: x1 - 4 x2 + x3 \u003c= 30\n c3: x2 - 0.5 x4 = 0\nBounds\n 0 \u003c= x1 \u003c= 40\n 2 \u003c= x4 \u003c= 3\nEnd`;\n\nconst EXPECTED_SOLUTION = {\n  Status: 'Optimal',\n  ObjectiveValue: 87.5,\n  Columns: {\n    x1: {\n      Index: 0,\n      Status: 'BS',\n      Lower: 0,\n      Upper: 40,\n      Type: 'Continuous',\n      Primal: 17.5,\n      Dual: -0,\n      Name: 'x1'\n    },\n    x2: {\n      Index: 1,\n      Status: 'BS',\n      Lower: 0,\n      Upper: Infinity,\n      Type: 'Continuous',\n      Primal: 1,\n      Dual: -0,\n      Name: 'x2'\n    },\n    x3: {\n      Index: 2,\n      Status: 'BS',\n      Lower: 0,\n      Upper: Infinity,\n      Type: 'Continuous',\n      Primal: 16.5,\n      Dual: -0,\n      Name: 'x3'\n    },\n    x4: {\n      Index: 3,\n      Status: 'LB',\n      Lower: 2,\n      Upper: 3,\n      Type: 'Continuous',\n      Primal: 2,\n      Dual: -8.75,\n      Name: 'x4'\n    }\n  },\n  Rows: [\n    {\n      Index: 0,\n      Name: 'c1',\n      Status: 'UB',\n      Lower: -Infinity,\n      Upper: 20,\n      Primal: 20,\n      Dual: 1.5\n    },\n    {\n      Index: 1,\n      Name: 'c2',\n      Status: 'UB',\n      Lower: -Infinity,\n      Upper: 30,\n      Primal: 30,\n      Dual: 2.5\n    },\n    {\n      Index: 2,\n      Name: 'c3',\n      Status: 'UB',\n      Lower: 0,\n      Upper: 0,\n      Primal: 0,\n      Dual: 10.5\n    }\n  ]\n};\n\nasync function test() {\n  const highs = await highs_promise;\n  const sol = highs.solve(PROBLEM);\n  require(\"assert\").deepEqual(sol, EXPECTED_SOLUTION);\n}\n```\n\nThe problem has to be passed in the [CPLEX .lp file format](http://web.mit.edu/lpsolve/doc/CPLEX-format.htm).\n\nFor a more complete example, see the [`demo`](./demo/) folder.\n\n### Loading the wasm file\n\nThis package requires a wasm file.\nYou can find it in `node_modules/highs/build/highs.wasm` inside the NPM package,\nor download it from the [release page](https://github.com/lovasoa/highs-js/releases).\nBy default, it will be loaded from the same path as the javascript file,\nwhich means you have to add the wasm file to your assets.\n\nAlternatively, if you don't want to bother with that, \nif you are running highs-js in a web browser (and not in node),\nyou can load the file directly from github:\n\n```js\nconst highs_loader = require(\"highs\");\n\nconst highs = await highs_loader({\n  // In a browser, one can load the wasm file from github\n  locateFile: (file) =\u003e \"https://lovasoa.github.io/highs-js/\" + file\n});\n```\n## Passing custom options\n\nHiGHS is configurable through [a large number of options](https://ergo-code.github.io/HiGHS/dev/options/definitions/).\n\nYou can pass options as the second parameter to `solve` : \n\n```js\nconst highs_promise = require(\"highs\")(highs_settings);\nconst highs = await highs_promise;\nconst sol = highs.solve(PROBLEM, {\n  \"allowed_cost_scale_factor\": 2,\n  \"run_crossover\": true,\n  \"presolve\": \"on\",\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasoa%2Fhighs-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovasoa%2Fhighs-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasoa%2Fhighs-js/lists"}