Matlab code for a developed pseudo code

Hello,
I am trying to implement and develop the code for enhancing the energy efficiency using PSO algorithm as per the psedo code given in the research papers. it would help me if anybody could guide me on this. Can I do it by creating 2 functions each for pmin and Xi and then compare with the velocities and positions for optimisation? or could you help me with the leads.
Thanks!

4 Comments

Do you have any attempts?
Yes Darova, I have developed PSO in matlab which I would like to share here,
clc;
clear;
close all;
%% Problem Definition
Cell_coverage = @(Xi) function_Cell_coverage(); %coverage func
Power_minimum = @(P_min) function_min_power(); % computation of minimum power
nvar = 5; %numb of decision variables
Varsize = [1 nvar]; %matrix size
Varmin = -10;
Varmax = 10;
%% Parameters of PSO
maxit = 50; %maximum itterations
npop = 20; %population size
wmax= 0.9;
wmin = 0.4;
w=1;
c1=2;
c2=2;
%ptx_min = 10;
%ptx_max = 46;
%G_min=5;
%G_max=10;
%BW_min=1.4;
%BW_max=20;
%SINR_min=4;
%m = 5;
%sigma= 8;
%% Initialisation
empty_particle.position = [];
empty_particle.velocity = [];
empty_particle.Cell_cov =[];
empty_particle.Best.Position = [];
empty_particle.Best.Cell_cov = [];
particle = repmat(empty_particle, npop,1);
%%GlobalBest.Cell_cov = -inf;
for i=1:npop
particle(i).position = unifrnd(Varmin, Varmax, Varsize);
particle(i).velocity = zeros(Varsize);
particle(i).Cell_cov = Cell_coverage(particle(i).position);
particle(i).Best.Position = particle(i).position;
particle(i).Best.Cell_cov = particle(i).Cell_cov;
% if particle(i).Best.Cell_cov < GlobalBest.Cell_cov
% GlobalBest = particle(i).Best;
% end
end
BestCosts = zeros(maxit,1);
%% Main Loop
for it=1:maxit
for i= 1:npop
particle(i).Velocity = w * particle(i).Velocity ...
+ c1 * rand(Varsize)*(particle(i).Best.Position - particle(i).position);
+ c2 * rand(Varsize)*(GlobalBest.Position - particle(i).position);
particle(i).Position = particle(i).position + particle(i).Velocity;
particle(i).Cell_cov = function_Cell_coverage(i).Position;
if particle(i).Cost<particle(i).Best.Cell_cov
particle(i).Best.Position = particle(i).position;
particle(i).Best.Cell_cov = particle(i).Cell_cov;
end
end
end
%% Results
I am confused as to how to compare each constriants to this.
Where are IF conditions?
This tag is useless: "file:///c:/users/61468/downloads/symmetry-11-00408%20(3).pdf" We do not have access to your harddrive.

Sign in to comment.

Answers (0)

Tags

Asked:

on 23 May 2021

Commented:

Jan
on 25 May 2021

Community Treasure Hunt

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

Start Hunting!