nlopt icon indicating copy to clipboard operation
nlopt copied to clipboard

nlopt stogo

Open samuellhong opened this issue 6 years ago • 1 comments

I am trying to find the global minimization of the eggholder function:

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.zeros(2)
opt = nlopt.opt(nlopt.GD_STOGO, x0.size)
opt.set_min_objective(eggholder)
opt.set_lower_bounds(-512)
opt.set_upper_bounds(512)
opt.set_xtol_rel(1e-8)
%time opt_x = opt.optimize(x0)
opt_value = opt.last_optimum_value()
opt_result = opt.last_optimize_result()

However, the optimization function keeps running and never finds the global minimum. Does anyone know why the optimize function keeps running?

samuellhong avatar Jul 17 '19 20:07 samuellhong

maybe it does not converge, try "opt.set_maxeval(1000)" or set_maxtime

jschueller avatar Jul 18 '19 06:07 jschueller