How I can specify more parameters to GA in order to speed up my code execution. with the help of (optimoptions function of ga).. opts = optimoptions(@ga,

조회 수: 2 (최근 30일)
Matthew Worker 2021년 6월 3일
편집: Rena Berman 2021년 12월 16일
%% Genetic Algorithm
FT=@(x)-Genetic_A(x);
A = []; % No other constraints
b = [];
Aeq = [];
beq = [];
lb = zeros(1,n);
ub = ones(1,n);
[x,fval] = ga(FT,n,A,b,Aeq,beq,lb,ub);
C_ga = -fval;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function C_ga = Genetic_A(x)
global G Pn Pt F H %G,F,H Matrices and Pn,Pt scalar
theta = (2*pi)*(x); %Reflecting Angle IRS, where x is a vector of size 1xn
Phi = diag(exp(1i*theta)); %phase shift Matrix for IRS, % Set Amp = 1
HT = H+F*Phi*G; %Channel Matrix
W = pinv(HT); %Precoding Matrix
W_bar = W./vecnorm(W,2,1); %Normalized
D_Matrix = HT*W_bar; %Diagonal Matrix
D_Square = (abs(diag(D_Matrix))').^2; % Channel gains
%% Water_filling
P = waterfill(Pt,Pn./D_Square);
R = P.*D_Square/Pn;
C_ga = sum(log2(1+R)); %Capacity
댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Rena Berman 2021년 12월 16일
(Answers Dev) Restored edit

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

답변 (1개)

Abdolkarim Mohammadi 2021년 6월 3일
Indeed vectorization helps a lot for non-simulation objective functions. You should use the UseVectorized option.

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

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by