nlopt
nlopt copied to clipboard
Additional data to non-linear constraints in Matlab
I would like to pass additional data to my constraint functions similar to f_data in the general reference. This is because I want constraints for multiple locations and this can be up to several hundred constraints. I would like to use Matlab if possible.
My approach was as follows, I defined a general function [x,g]=minimaxnloptconstraint_point(x,p) which takes in both x and the additional data, p.
Then I used a for loop to create a number of anonymous constraints:
point_func = {}
for p=1:size(coildata,1)
point_func{p} = @(x) minimaxconstnlopt_point(x, p)
end
This issue is anonymous functions only allow for one output meaning I cannot supply a gradient to the optimizer. Functions cannot be defined in a loop unless they are anonymous. This leaves me at an impasse and I was wondering if anyone knew a way around this?
Thank you!