Matrix array in ga

조회 수: 3 (최근 30일)
Leonid Medvedev
Leonid Medvedev 2021년 3월 30일
답변: Alan Weiss 2021년 3월 31일
Tell me please, I used GA to optimize the antenna array matrix,but I ran into a problem. I can't figure out how to limit the number of units in the optimized matrix.When I tried to impose restrictions, matlab said that I should switch the data type to doubleVector, however, using doubleVector, the algorithm simply does not run.In general, the algorithm works as I need, but I need the number of ones
in the matrix to not exceed 80 (matrix 16x16). I hope you can tell me something.
  댓글 수: 1
Alan Weiss
Alan Weiss 2021년 3월 30일
Sorry, we will need more detail. Are you trying to run a custom data type? A bitstring data type? Can we please see your ga options and your ga call?
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Weiss
Alan Weiss 2021년 3월 31일
I think that you are making a mistake by choosing the bitstring data type. Doing so loses the possibility of having constraints enforced automatically; you have to ensure that your mutation and crossover functions cause the constraints to be satisfied at each iteration.
If you will not use the recommended data type, you have to have custom creation, crossover, and mutation functions that enforce all linear constraints at each iteration. It is easy to create a random population that satisfies the linear equality constraint. Each individual can be created by the command
p = randperm(N); % p is an individual, N is the number of dimensions
p = double(p <= beq); % Gives sum(p) = beq
Making good crossover and mutation functions is a bit harder. For mutation, ensure that any new individual has the same number of 1 entries as the previous. For crossover, the same. I don't know what other constraints you are trying to enforce, but you can do it in your custom functions.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

추가 답변 (1개)

Leonid Medvedev
Leonid Medvedev 2021년 3월 31일
Aeq = ones(1,256)
beq = 64
b=256
% Pass fixed parameters to objfun
objfun = @(Mask)FitFun(ImIdeal,AsIdeal,TimeDelay,PulseRise,ta,Mask,xa,xi,zi,PARcv);
% Set nondefault solver options
options = optimoptions('ga',...%'CrossoverFcn','crossovertwopoint',...
'PopulationSize',40,'InitialPopulationMatrix',Mask,'PopulationType','bitstring','MaxGenerations',200,'CrossoverFraction',1,'PlotFcn','gaplotbestf');
% Solve
[Mask,objectiveValue] = ga(objfun,b,Aeq,beq,[],[],zeros(b,1),ones(b,1),...
[],options);
I know that all constraints are ignored for 'bitString' population. So do i have the opportunity to somehow limit the number of '1' in my matrix array?

카테고리

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