Non linear constrain to multi objective integer genetic algorithm

4 次查看(过去 30 天)
Hello all,
I am trying to set up a multibjective optimization in ga that the possible candidates for the x array have different values (it is an optimal sensor placement problem thus I cannot have the same sensor in the same grid more than once).
When I use the single objcetive function "ga" and define nonlcon = @(x) deal(any(abs(diff(x(1:length(lb)/2))) ~= 1), []) the optimization works fine. (only the first half of the array regards the sensors the rest is the strain component so the values dont have to be unique)
However for the case of "gamultiobj" the non linear constrain does not seem to be taken into account.
Have you ever had such an issue?
Thanks

回答(1 个)

Matt J
Matt J 2024-4-26
编辑:Matt J 2024-4-26
Is the idea that x(1:end/2) contain unique integers? I don't see how the given constraint would ensure that. The diff() function would only detect whether two consecutive x(i) are the same or not. If the idea is to have no consecutive repetitions, then you should have,
nonlcon = @(x) deal( 1-abs(diff(x(1:end/2))) , [])
  2 个评论
Sotiris
Sotiris 2024-4-26
Yes thats the idea but that is ensured by the "intcon" argument that follows the non linear constarins in the matlab function. You are right about the consecutive x(i) and as I want every element in the array to be uninque I will adjust the code accordingly.
However not even that constrain is satisfied.
Matt J
Matt J 2024-4-26
Yes thats the idea but that is ensured by the "intcon" argument that follows the non linear constarins in the matlab function
If you're anticipating that "integer constraints" plus "no consecutive repetitions" = "uniqueness" then that's wrong. Here is a simple sequence of non-unique integers satisfying your constraints,
x=[1,2,1,2,1,2];
any( abs(diff(x)) ~= 1) %satisfied
ans = logical
0
For uniqueness, you would need,
A=ones(numel(x))-eye(numel(x));
nlcon=@(x)Nonlcon(x,A);
nlcon(x) %violated
ans = 6x6
0 0 1 0 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 0 1 0 1 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
nlcon(randperm(6)) %satisfied
ans = 6x6
0 -2 0 -1 -1 0 -2 0 -3 -4 0 -1 0 -3 0 0 -2 -1 -1 -4 0 0 -3 -2 -1 0 -2 -3 0 0 0 -1 -1 -2 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
function [c,ceq]=Nonlcon(x,A)
ceq=[];
c=A-abs(x-x');
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by