Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concerning MATLAB vector-valued constraint functions #280

Open
sh-cau opened this issue Jun 28, 2019 · 3 comments
Open

Concerning MATLAB vector-valued constraint functions #280

sh-cau opened this issue Jun 28, 2019 · 3 comments

Comments

@sh-cau
Copy link

sh-cau commented 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

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.

@sh-cau sh-cau changed the title Concerning MATLAB constraint functions Concerning MATLAB vector-valued constraint functions Jun 28, 2019
@jiyess
Copy link

jiyess commented Mar 11, 2020

Hi,
I have the same problem. Do you have solve the problem?

I don't find the solution!
Thanks for the help.

@sh-cau
Copy link
Author

sh-cau commented Mar 11, 2020

Hi,
I have the same problem. Do you have solve the problem?

I don't find the solution!
Thanks for the help.

Unfortunately, I have not looked too deep into this. Therefore, no solution yet. Sorry

@jiyess
Copy link

jiyess commented Mar 12, 2020

Hi,
I have the same problem. Do you have solve the problem?
I don't find the solution!
Thanks for the help.

Unfortunately, I have not looked too deep into this. Therefore, no solution yet. Sorry

Thank you all the same! : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants