nlopt icon indicating copy to clipboard operation
nlopt copied to clipboard

nlopt ags

Open samuellhong opened this issue 6 years ago • 1 comments

I am having trouble getting to work the nlopt global algorithm ags. I have ran other functions but this does not work with error: nlopt invalid argument.

import nlopt
import numpy as np

def eggholder(x, grad):
    return (-(x[1] + 47) * np.sin(np.sqrt(abs(x[0]/2 + (x[1]  + 47)))) -x[0] * np.sin(np.sqrt(abs(x[0] - (x[1]  + 47)))))


x0 = np.array([0, 0])
opt = nlopt.opt(nlopt.GN_AGS, 2)
opt.set_min_objective(eggholder)
opt.set_lower_bounds(-512)
opt.set_upper_bounds(512)
opt.set_xtol_rel(1e-3)
opt.set_ftol_rel(1e-5)
opt.set_maxeval(20000)
%time opt_x = opt.optimize(x0)
opt_value = opt.last_optimum_value()
opt_result = opt.last_optimize_result()

this is the code, if I replace GN_AGS with other algorithms, the others will work. Any ideas?

samuellhong avatar Jul 19 '19 18:07 samuellhong

I run this fine, maybe it wasnt compiled because of c++11 support ?

jschueller avatar Jul 19 '19 18:07 jschueller