How to turn this function into function with handle that is suitable for particle swarm ?
1 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/656280/image.png)
I want to optimize this throughput with respect to 3 variables by using particle swarm optimization particleswarm(fun,nvars):
beta,a1_t2,a2_t2
However the tutorial from https://www.mathworks.com/help/gads/particleswarm.html
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
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/656285/image.png)
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 个评论
Stephen23
2021-6-17
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:
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!