MATLAB Answers

Matrix array in ga

15 views (last 30 days)
Leonid Medvedev
Leonid Medvedev on 30 Mar 2021
Answered: Alan Weiss on 31 Mar 2021
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 Comment
Alan Weiss
Alan Weiss on 30 Mar 2021
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

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 31 Mar 2021
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

More Answers (1)

Leonid Medvedev
Leonid Medvedev on 31 Mar 2021
Aeq = ones(1,256)
beq = 64
% 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',...
% Solve
[Mask,objectiveValue] = ga(objfun,b,Aeq,beq,[],[],zeros(b,1),ones(b,1),...
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?


Community Treasure Hunt

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

Start Hunting!