I am working on the SEARCH algorithm and have started to implement it.
The trouble is I'm getting the graphs as attached .... linear/staircase like which I feel must not be the case .
I feel theres a mistake in the way I'm calculating the residual energy. Since I've initialized the initial energy as constant for all nodes I feel there might be a problem with that which results which is why I'm getting the graphs as follows.
Apart from that the graph has a further problem that there is a linear portion to the end bang in the middle of it all.
See the files to understand.
I have modified the code for the traditional LEACH protocol as follows: -
close all;
clear;
clc;
% PARAMETER initialization
%Number of Nodes in the field
n=input('Enter the number of nodes in the space : ');
%Energy Model (all values in Joules)
%Initial Energy
%Eo=0.1;
Eo=input('Enter the initial energy of sensor in nJ : ');
%Field Dimensions - x and y maximum (in meters)
% xm=input('Enter x value for area plot : ');
% ym=input('Enter y value for area plot : ');
xm=100;
ym=100;
%message size
l=2000;
%x and y Coordinates of the Sink
sink.x=0.5*xm;
sink.y=0.5*ym;
%Optimal Election Probability of a node
%to become cluster head
p=0.2;
ETX=50*0.000000001;
ERX=50*0.000000001;
Eelec=ETX;
%Transmit Amplifier types
Efs=10*0.000000000001;
Emp=0.0013*0.000000000001;
%Data Aggregation Energy
EDA=5*0.000000001;
%Values for Hetereogeneity
%Percentage of nodes than are advanced
m=0.5;
%\alpha
a=1;
%maximum number of rounds
rmax=input('enter the number of rounds : ');
%rmax=50;
%optimal number of cluster heads
k=input('enter optimal number of cluster heads');
%%%%%%%%%%%%%%%%%%%%%%%%% END OF PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%
%Computation of do
do=sqrt(Efs/Emp);
%Creation of the random Sensor Network
figure(1);
hold off;
for i=1:1:n
S(i).xd=rand(1,1)*xm;
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym;
YR(i)=S(i).yd;
S(i).G=0;
%initially there are no cluster heads only nodes
S(i).type='N';
temp_rnd0=i;
%Random Election of Normal Nodes
if (temp_rnd0>=m*n+1)
S(i).E=Eo;
S(i).ENERGY=0;
plot(S(i).xd,S(i).yd,'o-r');
hold on;
end
%Random Election of Advanced Nodes
if (temp_rnd00)
temp_rand=rand;
t=t+1;
if ( (S(i).G)do)
S(C(min_dis_cluster).id).E=S(C(min_dis_cluster).id).E- ( (ETX+EDA)*(4000) + Emp*4000*( d*d*d*d ));
end
if (d0)
sum=sum+S(i).E;
end
end
avg=sum/n;
STATISTICS(r+1).AVG=avg;
sum;
%Code for Voronoi Cells
%Unfortynately if there is a small
%number of cells, Matlab's voronoi
%procedure has some problems
warning('OFF');
[vx,vy]=voronoi(X(:),Y(:));
plot(X,Y,'g+',vx,vy,'m-');
hold on;
voronoi(X,Y);
axis([10 xm 0 ym]);
%add the count of cluster heads vs Number of rounds curve
end
r=1:1:rmax-1;
figure(2);
ylabel('Average Energy of Each Node');
xlabel('Round Number');
plot([r r+1],[STATISTICS(r).AVG STATISTICS(r+1).AVG],'red');
title('Average Energy of Each Node vs Round Number');
ylabel('Average Energy of Each Node');
xlabel('Round Number');
hold on;
figure(3);
ylabel('Number of Dead Nodes');
xlabel('Round Number');
plot([r r+1],[STATISTICS(r).DEAD STATISTICS(r+1).DEAD],'red');
ylabel('Number of Dead Nodes');
xlabel('Round Number');
hold on;
%legend
%*: cluster head
%+:advanced node
%x:sink
%o : normal nodes
%'N':normal nodes
%'A':advanced nodes
%'S':super advanced nodes
%Efs=Energy dissipated in free space routing
%Emp=Energy dissipated in multipath routing
Can anyone be kind enough to point out where exactly I'm going wrong or what section of the code I need to correct ?
I frankly don't know what to do next.
By the way I'm working according to my understanding of the attached research paper.
Kindly enlighten me as to where I'm going wrong.