Feature request: A browser-friendly version of or-tools (emscripten) #2997
Replies: 14 comments 9 replies
-
As expected, you, or somebody else can try. :-)
But I will not spend some time on it. I prefer the client server approach.
…--Laurent
Le ven. 25 oct. 2019 à 22:33, Nils Franzen <[email protected]> a
écrit :
With web development frameworks such as Vue, React and Angular, a
web-based version (WASM) of or-tools would make a big difference for us
developers. The ability to solve many optimization problems directly in the
browser would provide a better user experience and the opportunity to do
work in the browser when offline.
Unfortunately, I'm not a star on tools like https://emscripten.org/,
otherwise I would have made the first attempt myself. But can it be a
simple task for someone else in this community?
Thank you for your hard work on this project!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1670?email_source=notifications&email_token=ACUPL3M3BNH2CW3WA4RVH7DQQNJYHA5CNFSM4JFI2YQKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HUPJYYQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3NRZ4K4X67RI4PG3OLQQNJYHANCNFSM4JFI2YQA>
.
|
Beta Was this translation helpful? Give feedback.
-
There's a reason solvers and local search algorithms aren't implemented in high level languages. They're not suited for solving NP-hard problems. If you really need to do this client side, you could look into packages like https://www.npmjs.com/package/simulated-annealing or https://github.com/njoubert/csp.js. If you just need a simpler interface for modelling optimization problems client-side, check out the MiniZinc project. |
Beta Was this translation helpful? Give feedback.
-
An experimental/poc wasm-version of or-tools is available at https://github.com/kjartanm/wasm-or-tools (and wasm is not exactly high level :) ) |
Beta Was this translation helpful? Give feedback.
-
Copy of the mailing list topic: Proof of concept WASM-build of OR-Tools Few comments for myself (and sorry, I should have done this feedback 20 days ago when you reply in the issue):
ref: https://emscripten.org/docs/compiling/Building-Projects.html#detecting-emscripten-in-preprocessor
- cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN_CMAKE_PATH} ..
+ cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN_CMAKE_PATH} -DBUILD_DEPS=ON -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF .. ref: kjartanm@ed4d870
|
Beta Was this translation helpful? Give feedback.
-
On archlinux: pacman -S emscripten
cat /usr/lib/emscripten/cmake/Modules/Platform/Emscripten.cmake |
Beta Was this translation helpful? Give feedback.
-
This would be very useful. Is there an easy way to compile or-tools with emscripten? |
Beta Was this translation helpful? Give feedback.
-
@luiscastro193 now or-tools, on master branch, support CMAKE_TOOLCHAIN_FILES for C++, see https://github.com/google/or-tools/blob/master/tools/cross_compile.sh |
Beta Was this translation helpful? Give feedback.
-
Ok so I followed these steps:
However, the building process fails at some point: output.txt Am I doing something wrong? |
Beta Was this translation helpful? Give feedback.
-
I added
to have wasm as a target, and
to set the toolchain and turn off some parts of the process. It runs for a good while, but kicks the bucket around 85%, after |
Beta Was this translation helpful? Give feedback.
-
The blockers for compiling seems to be the same 2 minor points that I addressed in my PoC-build (https://github.com/kjartanm/wasm-or-tools -- I cleaned it up a bit, so it is less hacky than to begin with :) ) It can be handled using EMSCRIPTEN preprocessor variable. Would something like this be an option? glop/lp_solver.cc, 160:
base/raw_logging.cc, 28:
|
Beta Was this translation helpful? Give feedback.
-
Yes send us a PR.
Le mer. 17 févr. 2021 à 08:41, Kjartan Müller <[email protected]> a
écrit :
… The blockers for compiling seems to be the same 2 minor points that I
addressed in my PoC-build (https://github.com/kjartanm/wasm-or-tools -- I
cleaned it up a bit, so it is less hacky than to begin with :) )
It can be handled using *EMSCRIPTEN* preprocessor variable. Would
something like this be an option?
glop/lp_solver.cc, 160:
// Note that we only activate the floating-point exceptions after we are sure
// that the program is valid. This way, if we have input NaNs, we will not
// crash.
#ifndef __EMSCRIPTEN__
ScopedFloatingPointEnv scoped_fenv;
if (absl::GetFlag(FLAGS_lp_solver_enable_fp_exceptions)) {
#ifdef _MSC_VER
scoped_fenv.EnableExceptions(_EM_INVALID | EM_ZERODIVIDE);
#else
scoped_fenv.EnableExceptions(FE_DIVBYZERO | FE_INVALID);
#endif
}
#endif
base/raw_logging.cc, 28:
#if !defined(_MSC_VER) && !defined(__EMSCRIPTEN__)
#include <sys/syscall.h> // for syscall()
#define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
#else
#if !defined(__EMSCRIPTEN__)
#include <io.h> // _write()
// Not so safe, but what can you do?
#define safe_write(fd, s, len) _write(fd, s, len)
#else
#define safe_write(fd, s, len) write(fd, s, len)
#endif
#endif
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1670 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3NBSXU2JKWZCVCQR5TS7NXI7ANCNFSM4JFI2YQA>
.
|
Beta Was this translation helpful? Give feedback.
-
I have sent a PR for |
Beta Was this translation helpful? Give feedback.
-
No, on master
Le sam. 20 févr. 2021 à 10:47, Kjartan Müller <[email protected]> a
écrit :
… I have sent a PR for glop/lp_solver.cc and base/raw_logging.cc, but I
also have a suggestion for cross_compile.sh that is currently in master.
I have understood it so that you only want PRs on stable?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1670 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3PSVASPUOUZXDWP633S76AMFANCNFSM4JFI2YQA>
.
|
Beta Was this translation helpful? Give feedback.
-
Has anyone successfully cross built or tools for emscripten(web assembly) without hacks. |
Beta Was this translation helpful? Give feedback.
-
With web development frameworks such as Vue, React and Angular, a web-based version (WASM) of or-tools would make a big difference for us developers. The ability to solve many optimization problems directly in the browser would provide a better user experience and the opportunity to do work in the browser when offline.
Unfortunately, I'm not a star on tools like https://emscripten.org/, otherwise I would have made the first attempt myself. But can it be a simple task for someone else in this community?
Thank you for your hard work on this project!
Beta Was this translation helpful? Give feedback.
All reactions