{"id":19301301,"url":"https://github.com/fuglede/highs-wasm","last_synced_at":"2025-08-02T03:10:18.576Z","repository":{"id":90007430,"uuid":"534768551","full_name":"fuglede/highs-wasm","owner":"fuglede","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-15T19:37:02.000Z","size":962,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T01:39:47.773Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/fuglede.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-09-09T18:52:21.000Z","updated_at":"2022-09-09T19:07:40.000Z","dependencies_parsed_at":"2023-05-30T22:00:34.381Z","dependency_job_id":null,"html_url":"https://github.com/fuglede/highs-wasm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fuglede/highs-wasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fhighs-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fhighs-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fhighs-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fhighs-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuglede","download_url":"https://codeload.github.com/fuglede/highs-wasm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fhighs-wasm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268330914,"owners_count":24233152,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-09T23:17:29.258Z","updated_at":"2025-08-02T03:10:18.539Z","avatar_url":"https://github.com/fuglede.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Run npm test](https://github.com/fuglede/highs-wasm/actions/workflows/test.yml/badge.svg)](https://github.com/fuglede/highs-wasm/actions/workflows/test.yml)\n\n# highs-wasm\n\nThis provides a [Emscripten](https://emscripten.org)-based [WebAssembly](https://webassembly.org/) binary of the [HiGHS](https://highs.dev) optimization software\nalong with JavaScript wrappers of the low-level solvers from its C API.\n\n## Use case\n\nThe intended use of this is for situations where you need access to a high-performance MILP/LP/QP solver, but you do not want to use commercial\nsolvers, and where you want to be able to access the solvers from a Wasm runtime such as a browser. In particular, this is useful when you want\nto ship a piece of software that embeds the solver in a way that is easy for users to work with (as a web page is), and where you do not want\nto manage a server backend hosting the optimization software, but would rather that everything runs entirely on the client.\n\nIf you can provide the program in LP format, then the [highs-js](https://github.com/lovasoa/highs-js) project (which we draw heavily on) solves\nthis problem. Here, instead, we expose the lower-level solver methods and assume that you are able to provide the constraint matrix of your\nprogram in [compressed sparse](https://en.wikipedia.org/wiki/Sparse_matrix) (CSC/CSR) format. This is often the case and going directly to\nthis level avoids a potentially expensive model creation step.\n\n## Example usage\n\nThe example below shows how to make use of the solver in vanilla JavaScript. After loading `highs.js`, the Emscripten module can be obtained\nfrom the `Highs()` promise, and the module then provides functions wrapping the solvers from the HiGHS C API.\n\nThe example below can be seen in action on https://fuglede.github.io/highs-wasm/.\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003c!-- Do not rely on the URL below never changing. For now, download highs.js and highs.wasm. --\u003e\n    \u003cscript src=\"https://fuglede.github.io/highs-wasm/highs.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      Highs().then(highs =\u003e {\n        // Let us solve the following maximization problem:\n        //\n        // Max    f  =  x_0 +  x_1 + 3\n        // s.t.                x_1 \u003c= 7\n        //        5 \u003c=  x_0 + 2x_1 \u003c= 15\n        //        6 \u003c= 3x_0 + 2x_1\n        // 0 \u003c= x_0 \u003c= 4; 1 \u003c= x_1\n        // x_0, x_1 integers\n        //\n        // The constraint matrix is the 3x2 matrix [[0, 1], [1, 2], [3, 2]] which\n        // we will be providing in compressed sparse column (CSC) format; that is,\n        // we read the non-zero entries column-by-column, and for each entry note\n        // its value and which row it is in, as well as how many values are in each\n        // column. See https://en.wikipedia.org/wiki/Sparse_matrix\n        const numColumns = 2;\n        const numRows = 3;\n        const constraintMatrixFormat = highs.ConstraintMatrixFormat.CompressedSparseColumn;\n        const constraintMatrixValues = [1, 3, 1, 2, 2];\n        const constraintMatrixIndices = [1, 2, 0, 1, 2];\n        const constraintMatrixStarts = [0, 2];\n        // The bounds in the constraints are given as separate arrays. We use large\n        // positive/negative values to indicate bounds that should not be included.\n        const rowLower = [-1e30, 5, 6];\n        const rowUpper = [7, 15, 1e30];\n        // Similarly, the bounds for each variable are given as separate arrays.\n        const columnLower = [0, 1];\n        const columnUpper = [4, 1e30];\n        // The objective is given in terms of the coefficients of each variable, as\n        // well as the constant term.\n        const offset = 3;\n        const columnCosts = [1, 1];\n        const optimizationSense = highs.OptimizationSense.Maximize;\n        // Finally, we specify that both variables have integer values.\n        const integrality = [highs.VariableType.Integer, highs.VariableType.Integer];\n  \n        // That's all. Now we can let HiGHS solve the problem and spit out the\n        // values of the two variables leading to the maximum objective value.\n        var res = highs.mipCall(\n          numColumns, numRows, constraintMatrixFormat, optimizationSense, offset,\n          columnCosts, columnLower, columnUpper, rowLower, rowUpper,\n          constraintMatrixStarts, constraintMatrixIndices, constraintMatrixValues, integrality);\n\n        console.log(res);\n        document.getElementById(\"x0\").innerText = res.columnValues[0];\n        document.getElementById(\"x1\").innerText = res.columnValues[1];\n      });\n    \u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cp\u003e\n      \u003ci\u003ex\u003c/i\u003e\u003csub\u003e0\u003c/sub\u003e: \u003cspan id=\"x0\"\u003e\u003c/span\u003e,\u003cbr /\u003e\n      \u003ci\u003ex\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e: \u003cspan id=\"x1\"\u003e\u003c/span\u003e\n    \u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuglede%2Fhighs-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuglede%2Fhighs-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuglede%2Fhighs-wasm/lists"}