How to add user defined function as constraint for optimization?
Show older comments
How to add user defined function as constraint for optimization? Example is given below. The problem that I know is a problem is that I am parsing a constraint to a function that sees that constraint as a variable, which it is not.
x = optimvar("x",3,3);
y = const1;
z = const2;
in loop:
return_val = my_fun(x(i,j),y)
prob.Constraints.Con1 = return_val >= z;
end loop
4 Comments
Torsten
on 6 Jul 2022
This should help:
Faruk Šehić
on 6 Jul 2022
Torsten
on 6 Jul 2022
Yes. Use the solver-based instead of the problem-based approach.
Faruk Šehić
on 6 Jul 2022
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!