How to do "not equal to" constraints in fmincon/Global search?

20 views (last 30 days)
Is there (in the meantime) a better way than:
existing to "add" a not equal constraint to the optimization Problem?
I want to say for example "x not equal to [0,1,0,1]".
  6 Comments
Walter Roberson
Walter Roberson on 6 Jun 2022
Matt's suggestion of requiring a minimum distance from the distinguished point might be useful for this situation.
And possibly paretosearch() instead of global search.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 6 Jun 2022
I need to test somehow if the solution i get from Global Search is unique.
The run() command, with 5 output arguments, can return all candidate solutions located by the search
If you see that multiple solutions have the same objective value, it would indicate the solution is not unique.
  1 Comment
Walter Roberson
Walter Roberson on 6 Jun 2022
... after doing uniquetol by rows to filter points that are essentially the same.

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 5 Jun 2022
You could try a nonlinear equality constraint
ceq = double(isequal(x, [0 1 0 1]));
This would return 1 if the equality holds, but non-zero is disfavored. Favoured is 0 which corresponds to false which would be the case when the x is anything else.
I am not convinced that this will work well.
  2 Comments
Walter Roberson
Walter Roberson on 5 Jun 2022
I was thinking about the continuity / differentiability when I posted that. I was thinking that it would seem plausible that you could use the nonlinear constraints to exclude (for example) a circle from consideration, and a point is a circle shrunk down to no radius. The nonlinear constraints have never been documented as being required to establish a concave area of solution.

Sign in to comment.


Matt J
Matt J on 6 Jun 2022
You could impose a constraint like as a smooth approximation to .
function [c,ceq,gradc,gradceq]=nonlcon(x,r)
ceq=[]; gradceq=[];
gradc=[0;1;0;1]-x(:);
c=(r^2-norm(gradc)^2)/2;
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by