Clear Filters
Clear Filters

How I create a non-equal restriction for GA problem?

5 views (last 30 days)
How to say for matlab that all elements in a vector must be different? I need to make a restriction for a GA problem, like V = [x1 x2 x3 x4], and x1~=x2,x3,x4, x2~=x3,x4, x3~=x4;

Answers (1)

John D'Errico
John D'Errico on 3 Dec 2017
Essentially, you cannot. Or constraints are not an option for any optimizer, including GA, thus x1>x2 OR x1<x2. And you cannot have strict inequalities anyway.
Are these integers?
Could you require that the x_i are sorted, thus something like:
x1 + tol <= x2
x2 + tol <= x3
x3 + tol <= x4?
Yes, somebody will probably tell you to use a constraint like
abs(x1 - x2) >= tol
etc.
It might even work, SOME of the time, IF you used good starting values. But it will certainly create a problem with multiple local minima, ABSOLUTELY necessitating good starting values.

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!