JWally / jsLPSolver

Simple OOP javaScript library to solve linear programs, and mixed integer linear programs
The Unlicense
420 stars 69 forks source link

Running in Browser #80

Closed kel89 closed 5 years ago

kel89 commented 6 years ago

Hello,

This is probably a rather basic issue, but I am new to javascript. I am wondering if there is a way to make this library work with javascript running solely in a browser? I am running into issues with the many "require()" statements. I have tried bundling everything into a single file using Browserify, but still no luck.

Any help would be greatly appreciated!

redblobgames commented 5 years ago

If you don't want to use Browserify, Webpack, etc., you can use Unpkg to turn it into a simple script that you can load:

<script src="https://unpkg.com/javascript-lp-solver/src/solver.js"></script>

This will create a global variable solver. You'll be able to call solver.Solve(…) with your model. (I've only tested this with the first example on the readme)

JWally commented 5 years ago

So for what its worth, there's a browser ready version under /prod/solver.js. Its not minified or gziped or anything, but, its out there if you want to host the file yourself.