WSN Nodes Location Optimization

$0.00

Total downloads: 24

This MATLAB code is written to optimally set the wireless sensor nodes’ locations to mitigate the coverage hole generated due to any energy depleted node. Particle Swarm Optimization (PSO) is used for this purpose. The objective is the maximum coverage area with available nodes. No constraint is used in this optimization.

This repository contains:

  • MATLAB code for WSN nodes optimal positioning to cover the coverage hole.
 Discuss Code
Categories: , ,

Description

Contents

close all
clear
clc
addpath(genpath(cd))
warning('off')
N=10;                       % number of nodes
area=[10,10];              % nodes deployment area in meter
Trange=2;                   % transmission range of sensor node in meter
nodes.pos=area(1).*rand(N,2);% nodes geographical locations
% redundantNo=9;               % number of healing nodes
redundantNo=round(10*N/100);

plot the nodes deployment

cnt=1;
for ii=1:N
    for jj=1:N
        if ii~=jj
            nodes.distance(ii,jj)=pdist([nodes.pos(ii,:);nodes.pos(jj,:)]);
            if nodes.distance(ii,jj)<Trange || nodes.distance(ii,jj)==Trange
                nodes.inrange(ii,jj)=1;
            else
                nodes.inrange(ii,jj)=0;
            end
        end
    end
end

figure
F5=plot(nodes.pos(:,1),nodes.pos(:,2),'.','color','r');
hold on
for ii=1:N                   % plot the circular transmission range
    [nodes.circle.x(ii,:),nodes.circle.y(ii,:)]=circle(nodes.pos(ii,1),nodes.pos(ii,2),Trange);
    F6=fill(nodes.circle.x(ii,:),nodes.circle.y(ii,:),[0.25,0.25,0.25]);
    alpha 0.3
    hold on
end
axis on
xlabel('x(m)')
ylabel('y(m)')
title('Initial Placement of Nodes with circular transmission range')

plot Delaunay triangle

TRI = delaunay(nodes.pos(:,1),nodes.pos(:,2));
figure(2)
F5 = plot(nodes.pos(:,1),nodes.pos(:,2),'.','color','r');
hold on
for ii=1:N                   % plot the circular transmission range
    [nodes.circle.x(ii,:),nodes.circle.y(ii,:)]=circle(nodes.pos(ii,1),nodes.pos(ii,2),Trange);
    F6=fill(nodes.circle.x(ii,:),nodes.circle.y(ii,:),[0.25,0.25,0.25]);
    alpha 0.3
    hold on
end
axis on
xlabel('x(m)')
ylabel('y(m)')
title('Coverage hole in initila position of Nodes')
hold on
triplot(TRI,nodes.pos(:,1),nodes.pos(:,2))

WSN Nodes Location Optimization

Hole detection

[holeDetected.circle,Circmcenter.circle,circumradius.circle]=holeDetection(TRI,nodes,F5,F6,Trange,area,2,1);
display(['--> No of detected Holes for Circular = ',num2str(numel(find(holeDetected.circle)))])
--> No of detected Holes for Circular = 2

WSN Nodes Location Optimization

PSO optimize the position of the rest wsn nodes to cover the hole

nvars = 2*(N);
fun=@(x)objf(x,Trange,area);
lb=zeros(nvars,1);
ub=area(1).*ones(nvars,1);
options = optimoptions(@particleswarm,'Display','iter','MaxIterations',100,'PlotFcn','pswplotbestf');
[x,fval] = particleswarm(fun,nvars,lb,ub,options);
finalPos = reshape(x,[numel(x)/2,2]);
% plot the final tuned Node' pos
figure
plot(finalPos(:,1),finalPos(:,2),'o','color','r');
hold on
for ii=1:N                 % plot the circular transmission range
    [finalcircle.x(ii,:),finalcircle.y(ii,:)]=circle(finalPos(ii,1),finalPos(ii,2),Trange);
    fill(finalcircle.x(ii,:),finalcircle.y(ii,:),[0.25,0.25,0.25]);
    alpha 0.3
    hold on
end
axis on
xlabel('x(m)')
ylabel('y(m)')
title('Optimized location of Nodes with circular transmission range')
                                 Best            Mean     Stall
Iteration     f-count            f(x)            f(x)    Iterations
    0             100           1.205           1.554        0
    1             200           1.205            2.49        0
    2             300           1.205           1.658        1
    3             400           1.205           1.812        2
    4             500           1.205           1.651        3
    5             600           1.205           1.696        4
    6             700           1.205           1.644        5
    7             800           1.205            1.54        6
    8             900           1.205           1.454        0
    9            1000           1.205           1.434        1
   10            1100           1.174           1.406        0
   11            1200           1.157           1.367        0
   12            1300           1.136           1.347        0
   13            1400            1.13            1.33        0
   14            1500           1.121           1.303        0
   15            1600           1.117           1.279        0
   16            1700           1.101           1.266        0
   17            1800           1.097           1.243        0
   18            1900           1.093            1.25        0
   19            2000           1.093           1.288        1
   20            2100           1.093           1.277        2
   21            2200           1.093           1.322        3
   22            2300           1.093           1.338        4
   23            2400           1.093           1.341        5
   24            2500           1.093           1.369        6
   25            2600           1.093           1.312        7
   26            2700           1.093           1.251        8
   27            2800           1.085           1.217        0
   28            2900           1.084            1.19        0
   29            3000           1.068           1.173        0
   30            3100           1.064           1.146        0

                                 Best            Mean     Stall
Iteration     f-count            f(x)            f(x)    Iterations
   31            3200           1.056           1.125        0
   32            3300           1.051           1.117        0
   33            3400           1.046           1.099        0
   34            3500           1.043           1.087        0
   35            3600            1.04           1.083        0
   36            3700            1.04           1.084        0
   37            3800           1.034           1.085        0
   38            3900           1.034           1.089        1
   39            4000           1.031           1.093        0
   40            4100           1.031           1.108        0
   41            4200           1.031           1.122        1
   42            4300           1.031           1.128        2
   43            4400           1.031           1.149        3
   44            4500           1.031           1.167        4
   45            4600           1.031           1.185        5
   46            4700           1.031           1.207        6
   47            4800           1.031           1.144        7
   48            4900           1.031           1.107        8
   49            5000           1.031           1.084        0
   50            5100           1.029           1.066        0
   51            5200           1.028           1.057        0
   52            5300           1.027           1.054        0
   53            5400           1.024           1.048        0
   54            5500           1.021           1.044        0
   55            5600           1.021           1.038        0
   56            5700           1.019           1.037        0
   57            5800           1.019           1.037        1
   58            5900           1.019           1.037        2
   59            6000           1.019           1.036        0
   60            6100           1.019           1.039        1

                                 Best            Mean     Stall
Iteration     f-count            f(x)            f(x)    Iterations
   61            6200           1.019           1.042        2
   62            6300           1.019           1.044        3
   63            6400           1.019           1.059        4
   64            6500           1.019           1.055        5
   65            6600           1.019           1.047        0
   66            6700           1.019           1.045        1
   67            6800           1.019           1.038        2
   68            6900           1.018           1.034        0
   69            7000           1.018           1.028        1
   70            7100           1.018           1.027        2
   71            7200           1.017           1.029        0
   72            7300           1.017           1.028        1
   73            7400           1.017           1.027        2
   74            7500           1.017           1.026        3
   75            7600           1.017           1.026        0
   76            7700           1.017           1.028        1
   77            7800           1.017           1.027        2
   78            7900           1.017           1.029        3
   79            8000           1.017           1.026        4
   80            8100           1.017           1.025        5
   81            8200           1.017           1.026        6
   82            8300           1.017           1.027        7
   83            8400           1.017           1.026        0
   84            8500           1.017           1.024        1
   85            8600           1.017           1.024        2
   86            8700           1.017           1.026        3
   87            8800           1.017           1.027        4
   88            8900           1.017           1.024        5
   89            9000           1.017           1.026        6
   90            9100           1.017           1.026        7

                                 Best            Mean     Stall
Iteration     f-count            f(x)            f(x)    Iterations
   91            9200           1.017           1.026        8
   92            9300           1.017           1.026        9
   93            9400           1.017           1.026       10
   94            9500           1.017           1.025        0
   95            9600           1.017           1.026        1
   96            9700           1.017           1.026        2
   97            9800           1.017           1.024        3
   98            9900           1.017           1.024        4
   99           10000           1.017           1.025        5
  100           10100           1.017           1.025        6
Optimization ended: number of iterations exceeded OPTIONS.MaxIterations.

WSN Nodes Location Optimization WSN Nodes Location Optimization WSN Nodes Location Optimization

7 reviews for WSN Nodes Location Optimization

  1. alok.kumar (verified owner)

    Thanks for your support.

  2. alok.kumar (verified owner)

    Thanks.

  3. alok.kumar (verified owner)

    Thanks

  4. vankani.arjun (verified owner)

    Nice project !!

  5. sameer.kumthekar (verified owner)

    Thank you !

  6. sumit.gupta (verified owner)

    I will be highly obliged to you.

  7. sameer.kumthekar (verified owner)

    best one

Only logged in customers who have purchased this product may leave a review.