4 loadpath = arg_list{i};
5 printf ("-- adding path: %s\n", loadpath);
9 function [val, gradient] = myfunc(x)
12 gradient = [0, 0.5 / val];
16 function [val, gradient] = myconstraint(x,a,b)
17 val = (a*x(1) + b)^3 - x(2);
19 gradient = [3*a*(a*x(1) + b)^2, -1];
24 opt.algorithm = NLOPT_LD_MMA
25 % opt.algorithm = NLOPT_LN_COBYLA
26 opt.lower_bounds = [-inf, 0]
27 opt.min_objective = @myfunc
28 opt.fc = { (@(x) myconstraint(x,2,0)), (@(x) myconstraint(x,-1,1)) }
29 opt.fc_tol = [1e-8, 1e-8];
31 [xopt, fmin, retcode] = nlopt_optimize(opt, [1.234 5.678])