bertrandbev / nlopt-js Goto Github PK
View Code? Open in Web Editor NEW⚡ NLopt-js is a port of the NLopt C++ optimization library
Home Page: https://bertrandbev.github.io/nlopt-js/#/
⚡ NLopt-js is a port of the NLopt C++ optimization library
Home Page: https://bertrandbev.github.io/nlopt-js/#/
Hi! Super exciting package here! It could be really enabling for some of our efforts to do scientific computing in the browser. I've installed the version on npm and I have it working in the browser, but I'm having trouble using the same distribution from npm in node
.
when i run the following in node v14.7.0
const nlopt = require('nlopt-js')
(async () => {
await nlopt.ready
const opt = new nlopt.Optimize(nlopt.Algorithm.LD_SLSQP, 2);
opt.setMinObjective((x, grad) => {
if (grad) {
grad[0] = 0;
grad[1] = 0.5 / Math.sqrt(x[1]);
}
return Math.sqrt(x[1]);
}, 1e-4);
const res = opt.optimize([1, 6]);
nlopt.GC.flush();
})()
I get the error
TypeError: require(...) is not a function
The import itself works, i.e. if I just try to run
const nlopt = require('nlopt-js')
console.log(nlopt)
I get
{
GC: [class D] { objects: Set(0) {}, whitelist: A { _data: {}, size: 0 } },
ready: Promise { <pending> }
}
So something is working! But if I run the actual example, I get the error above.
Maybe something went wrong with the dist
version published to npm? Again, it does work in the browser!
Thanks for any ideas or help. I might also try rebuilding myself.
Hey there,
This looks like a cool project!
I'm trying to use it in a web-based react app. I'm having some trouble importing it, so I've been trying to build your demo to see if I can get it working.
However, yarn fails saying dependencies not found.
I notice in your vue.config.js
there is the line
config.resolve.alias.set('@nlopt', path.resolve(__dirname, '../dist/index.js'))
Do you happen to have any tips for how to go about creating this dist/index.js
?
Thanks!
In the nlopt documentation there's a function set_xtol_rel
which sets the overall solver tolerance to error, which is an important config parameter. But looking at the code here that function seems to be missing. Could it be added?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.