chiark / gitweb /
Use deterministic test seed
[nlopt.git] / test / t_python.py
index 8dee3db9848ebfcc87cce33f2a7f87fe4bad36ef..3ce7bdd456366e0b649a9a70d4a38fbaf76dc7da 100644 (file)
@@ -20,11 +20,12 @@ def myconstraint(x, grad, a, b):
 opt = nlopt.opt(nlopt.LD_MMA, 2)
 opt.set_lower_bounds([-float('inf'), 0])
 opt.set_min_objective(myfunc)
-opt.add_inequality_constraint(lambda x,grad: myconstraint(x,grad,2,0), 1e-8)
-opt.add_inequality_constraint(lambda x,grad: myconstraint(x,grad,-1,1), 1e-8)
+opt.add_inequality_constraint(lambda x, grad: myconstraint(x,grad, 2, 0), 1e-8)
+opt.add_inequality_constraint(lambda x, grad: myconstraint(x,grad, -1, 1), 1e-8)
 opt.set_xtol_rel(1e-4)
 x = opt.optimize([1.234, 5.678])
 minf = opt.last_optimum_value()
-print('optimum at ', x[0],x[1])
+print('optimum at ', x[0], x[1])
 print('minimum value = ', minf)
 print('result code = ', opt.last_optimize_result())
+print('nevals = ', opt.get_numevals())