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

5 次查看(过去 30 天)
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;

回答(1 个)

John D'Errico
John D'Errico 2017-12-3
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.

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by