Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using f_data #7

Closed
porterjamesj opened this issue Nov 23, 2013 · 5 comments
Closed

using f_data #7

porterjamesj opened this issue Nov 23, 2013 · 5 comments

Comments

@porterjamesj
Copy link

Does the interface here provide a way to use the void *f_data argument to an objective function? I have an objective function that needs some other data besides the parameters.

@mlubin
Copy link
Member

mlubin commented Nov 24, 2013

I believe the idiomatic way is to wrap the objective function in a closure, e.g. x->f(x,data) and pass that to NLopt.

@porterjamesj
Copy link
Author

Yeah that's what I figured, Unfortunately anonymous Julia functions are currently very slow (I believe due to poor type specialization). Hopefully this will get better in the future.

@porterjamesj
Copy link
Author

Performance issues aside though, currying does make for an elegant interface.

@stevengj
Copy link
Collaborator

Yes, the void* stuff is just a hack for languages lacking lexical scoping and nested functions.

@stevengj
Copy link
Collaborator

stevengj commented Feb 2, 2018

anonymous Julia functions are currently very slow

(For people coming late to this issue, note that this is no longer true as of Julia 0.5.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants