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

opt.get_initial_step error in python #319

Closed
jerry-ban opened this issue Mar 24, 2020 · 1 comment · Fixed by #321
Closed

opt.get_initial_step error in python #319

jerry-ban opened this issue Mar 24, 2020 · 1 comment · Fixed by #321

Comments

@jerry-ban
Copy link

hi, I am getting an error while running optimization with the step size function in python environment, google search return nothing useful so looking for help here
.
I am trying to get the initial step size, based on an feasible starting solution x0. here by the example from NLOPT tutorial;

    _def run_offcial_example(self):
        opt = nlopt.opt(nlopt.LD_MMA, 2)
        opt.set_lower_bounds([-float('inf'), 0])
        opt.set_min_objective(self._official_myfunc)
        opt.add_inequality_constraint(lambda x, grad: self._official_myconstraint(x, grad, 2, 0), 1e-8)
        opt.add_inequality_constraint(lambda x, grad: self._official_myconstraint(x, grad, -1, 1), 1e-8)
        opt.set_xtol_rel(1e-4)
        print("\noptimization starts!")
        x0 = [1.234, 5.678]
        step_size = opt.get_initial_step(x0)
        x = opt.optimize(x0)

        print("\noptimization finished!\n")_

everyting works fine without the step size call: step_size = opt.get_initial_step(x0)
the step size call will shows error as follows:

return _nlopt.opt_get_initial_step(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'opt_get_initial_step'.
 Possible C/C++ prototypes are:
   nlopt::opt::get_initial_step(std::vector< double,std::allocator< double > > &) const
   nlopt::opt::get_initial_step() const
   nlopt::opt::get_initial_step(std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > &) const

anything wrong here? thank you

@jschueller
Copy link
Collaborator

jschueller commented Mar 24, 2020

actually the in-place version is called, maybe it could be swapped with the value return variant (and renamed get_initial_step_in_place), but that would break the api
note that only value return variant is useful for the swig bindings

jschueller added a commit to jschueller/nlopt that referenced this issue Apr 4, 2020
jschueller added a commit to jschueller/nlopt that referenced this issue Apr 4, 2020
jschueller added a commit that referenced this issue Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants