Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Mixed integer linear programming library, built by compiling a high-performance C++ solver developed by the University of Edinburgh (HiGHS) to WebAssembly.
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.
See the online demo at: https://lovasoa.github.io/highs-js/
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.
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
});
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",
});
FAQs
Mixed integer linear programming library, built by compiling a high-performance C++ solver developed by the University of Edinburgh (HiGHS) to WebAssembly.
The npm package highs receives a total of 1,535 weekly downloads. As such, highs popularity was classified as popular.
We found that highs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.