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
0 个评论
回答(1 个)
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 个评论
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
For uniqueness, you would need,
A=ones(numel(x))-eye(numel(x));
nlcon=@(x)Nonlcon(x,A);
nlcon(x) %violated
nlcon(randperm(6)) %satisfied
function [c,ceq]=Nonlcon(x,A)
ceq=[];
c=A-abs(x-x');
end
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!