Git Product home page Git Product logo

nlopt-js's People

Contributors

bertrandbev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nlopt-js's Issues

node version not working

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.

Can't Build Demo

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.