ktahar / ocaml-lp

LP and MIP modeling in OCaml
MIT License
27 stars 1 forks source link

Feature request: JS API #2

Closed Drup closed 2 years ago

Drup commented 2 years ago

It would be fantastic to have a backend compatible with Javascript. For instance https://github.com/JWally/jsLPSolver , or one of the webassemblified GLPK. It would dramatically simplify portability for LP-based software.

ktahar commented 2 years ago

Thanks for the request. Sounds interesting. Could you clarify the following?

  1. By backend, do you mean some high-level binding to solver like Lp_js_LP_solver.solve (similar to Lp_glpk.solve), that internally uses some ffi to call the JS API?
  2. If so, are there any ffi library (OCaml-JS) you'd assume?

(If portability is concerned, it would be the best to have LP solver written in OCaml. I'm actually planning to write such a thing, but it will take more time.)

Drup commented 2 years ago

Yes, I would suggest a high level API similar to the one you already provide for glpk. For the FFI, given the json-based API provided by the jsLPsolver, the basic FFI provided by js_of_ocaml should be more than sufficient.

Regarding an LP solver written in ocaml: that is a different and mildly ambitious endeveor (that I really support, but it's a bit different). Note that there is at least a verified Coq implementation of a simplex in the VPL, with code extracted to OCaml paper, sources, which would make for a pretty good verified backend too.

ktahar commented 2 years ago

Okay. It doesn't look that hard way. I'll try it out.

LP solver in OCaml was off-topic here and I'm going to do it as a very long-term, weekend hobby. Thank you for the pointer to verified simplex method. I'd consider to use it as a backend too.

ktahar commented 2 years ago

I tried jsLPsolver but glpk.js (wasm-ed glpk with clean json api) looked like a better option.

I've done small tests using node.js. But let me know if something is wrong in other use cases.