Skip to content

opt.get_initial_step error in python #319

@jerry-ban

Description

@jerry-ban

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions