How to turn this function into function with handle that is suitable for particle swarm ?

2 vues (au cours des 30 derniers jours)
I have a function like this :
function y = Sum_throughput_U1_phase2(beta,a1_t2,a2_t2, SNRdB,M, Rate1, Rate2,eta_BS,xai,L1,L3)
gama1 = 2^(2*Rate1/(1-beta)) - 1;
gama2 = 2^(2*Rate2/(1-beta)) - 1;
phi1 = 0;
constraint1 = a1_t2 - phi1*gama1*a2_t2 > 0;
constraint2 = a2_t2 - gama2*a1_t2 > 0;
if constraint1 && constraint2
SNR = 10^(SNRdB/10);
Psi1 = 2*eta_BS*beta/(1-beta);
cuc1 = gama1/(a1_t2*xai*Psi1*SNR);
cuc2 = gama2/( (a2_t2-gama2*a1_t2)*(xai*Psi1*SNR) );
delta_one = max(cuc1,cuc2);
term1 = 2/factorial(M-1);
term2 = delta_one/(L3*L1);
Outage_Near_User = 1 - term1*power(term2,M/2)*besselk(M,2*sqrt(term2));
elseif ~constraint1 && ~constraint2
Outage_Near_User=1;
end
y = (1-Outage_Near_User)*Rate1;
end
Bassically it compute this thing here which is called the throughput
I want to optimize this throughput with respect to 3 variables by using particle swarm optimization particleswarm(fun,nvars):
beta,a1_t2,a2_t2
Require to add something call function handle @(x).
Please help me to turn the function Sum_throughput_U1_phase2(beta,a1_t2,a2_t2, SNRdB,M, Rate1, Rate2,eta_BS,xai,L1,L3) into the function with handle that is suitable for using particle swarm optimization with three decision variable beta,a1_t2,a2_t2
Note that .
I just have one thinking that it might be possible throught the use of the funcion matlabFunction to Convert symbolic expression to function handle or file but still strugle with the actual implementation !
P/S Any help that mirror the situation is okay, I dont want you to waste too much time
Thank you very much !
  1 commentaire
Stephen23
Stephen23 le 17 Juin 2021
As you are not using symbolic variables the symbolic toolbox function matlabFunction is unlikely to help you.
For the inputs that you want to optimize, define them as one input to your function, following the instructions here:
For the rest of those inputs you can parameterize the function:

Connectez-vous pour commenter.

Réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by