Hi Steven, I've listed below a dummy python script. Which does nothing but to demonstrate the continuation of the optimizer after an error. Sure the error in myfunction can be captured in a wrapper with try:....except:.... statement but that is not the issue here.
import nlopt from numpy import * #counter to indicate no. of optimizations performed counter = 0 def myfunction(x, grad): "this function doesn nothing but return an division by zero error" global counter counter += 1 print "start function no " + str(counter) #raise error 1/0 #set optimization opt = nlopt.opt(nlopt.GN_CRS2_LM, 3) opt.set_max_objective(myfunction) opt.set_lower_bounds([-4, -4, -4]) opt.set_upper_bounds([4, 4, 4]) #start oprimization print "start optimization" xopt = opt.optimize([0, 0, 0]) print "finish" Thanks, Ben
_______________________________________________ NLopt-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
