You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have a problem setup where it would be convenient (if not essential) if NLopts MATLAB interface could handle vector-valued constraint functions as described in the NLopt General Reference in the Vector-valued constraints section. If I understood correctly, the MATLAB interface should be able to achieve this but I do not see how. I think this was already mentioned here, but the solution said that you would have to pass m separate function handles into the cell array which is not what I need.
Essentially, I want to have one function that evaluates m constraints at once and returns the result as a vector. I only want to pass e.g.
opt.fc = {@(x)myconstraint(x)}
where
function [ fc_ ,gradfc_ ] = myconstraint(x)
fc_(1) = x(1)-x(2);
fc_(2) = x(2)^2+x(1);
.
.
.
fc_(m) = x(4)-x(3)*x(2);
if nargout > 1
% calc gradient
end
end
But this results in the error Error using nlopt_optimize user function must return real scalar
Thank you in advance.
The text was updated successfully, but these errors were encountered:
sh-cau
changed the title
Concerning MATLAB constraint functions
Concerning MATLAB vector-valued constraint functions
Jun 28, 2019
Hi,
I have a problem setup where it would be convenient (if not essential) if NLopts MATLAB interface could handle vector-valued constraint functions as described in the NLopt General Reference in the Vector-valued constraints section. If I understood correctly, the MATLAB interface should be able to achieve this but I do not see how. I think this was already mentioned here, but the solution said that you would have to pass
m
separate function handles into the cell array which is not what I need.Essentially, I want to have one function that evaluates
m
constraints at once and returns the result as a vector. I only want to pass e.g.opt.fc = {@(x)myconstraint(x)}
where
But this results in the error
Error using nlopt_optimize user function must return real scalar
Thank you in advance.
The text was updated successfully, but these errors were encountered: