how to write this constraint in fmincon
1 view (last 30 days)
Show older comments
Lingjuan Ma
on 28 Feb 2020
Commented: Lingjuan Ma
on 4 Mar 2020
Hi, does any one know how to write this constraint in fmincon?
sum(abs(x- w0) ) <= 0.3
w0 is known and it is a Nx1 vevctor. x is the unkown.
Thanks in advance.
0 Comments
Accepted Answer
Walter Roberson
on 28 Feb 2020
abs() can only be handled as a nonlinear constraint
function [c, ceq] = nonl(x, w0)n
c = sum(abs(x-w0)) - 0.3;
ceq = [];
And the corresponding location in the fmincon parameter list would be
@(x) nonl(x, w0)
0 Comments
More Answers (1)
Matt J
on 28 Feb 2020
Edited: Matt J
on 28 Feb 2020
Because the constraint is non-smooth, you cannot use fmincon's nonlinear constraint support to implement this. Instead you have to use a more indirect method, which reformulates the problem in terms of two unknown vectors x and y. If your original problem is,
then the reformulated problem is as below (which requires only linear constraints).
3 Comments
See Also
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!