WSN Nodes Location Optimization

$0.00

Total downloads: 96

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.
Download Test
 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))

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

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.

69 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

  8. rama.v (verified owner)

    Good

  9. yousef.qudeisat (verified owner)

    thank you

  10. yousef.qudeisat (verified owner)

    thanks alot

  11. abhishek.gupta-1310 (verified owner)

    Its a great platform to start

  12. nishant.tripathi (verified owner)

    thank you

  13. nishant.tripathi (verified owner)

    thank you

  14. ming.li (verified owner)

    ok\

  15. ming.li (verified owner)

    ok

  16. zhang.xin (verified owner)

    nice code for free

  17. biswajit.sahoo (verified owner)

    great

  18. biswajit.sahoo (verified owner)

    super

  19. thiyagarajan.n (verified owner)

    good

  20. thiyagarajan.n (verified owner)

    good

  21. thiyagarajan.n (verified owner)

    good

  22. thiyagarajan.n (verified owner)

    good

  23. thiyagarajan.n (verified owner)

    best

  24. chou_aib (verified owner)

    Great

  25. nikhil.kumar (verified owner)

    good

  26. Md. Mohin Islam (verified owner)

    Thank you.

  27. mos.bas (verified owner)

    good

  28. ftafta

    THANK

  29. ftafta

    THANKS

  30. ftafta

    THANKS

  31. akash.raghuvanshi (verified owner)

    good

  32. akash.raghuvanshi (verified owner)

    good

  33. akbaralipaper (verified owner)

    excellent

  34. saranya.gunasekar (verified owner)

    useful,excellent

  35. thiyagarajan.n-1218 (verified owner)

    thankyou

  36. bipin.sahu (verified owner)

    thank u sarita

  37. bipin.sahu (verified owner)

    sry sarita

  38. bipin.sahu (verified owner)

    thanks

  39. hamdi.karim (verified owner)

    thnx

  40. saeideh (verified owner)

    good

  41. saeideh (verified owner)

    graet

  42. saeideh (verified owner)

    nice

  43. saranya.gunasekar (verified owner)

    GOOD

  44. j.k (verified owner)

    Registering just for this?

  45. prashant.kulkarni-0716 (verified owner)

    excellent

  46. prashant.kulkarni-0716 (verified owner)

    excellent

  47. prashant.kulkarni-0716 (verified owner)

    good

  48. prashant.kulkarni (verified owner)

    excellent work

  49. sagar.verma-6850 (verified owner)

    Thanks

  50. sagar.verma-6850 (verified owner)

    Thanks

  51. thanhca (verified owner)

    ok

  52. Shilean (verified owner)

    Good

  53. aditi.bodkhe (verified owner)

  54. manishshukla8840 (verified owner)

    na

  55. manishshukla8840 (verified owner)

    na n

  56. manishshukla8840 (verified owner)

    na n

  57. manishshukla8840 (verified owner)

    ZGoog theme but all topics was not covered in this portal

  58. akg16n (verified owner)

    thanks

  59. kumar neeraj (verified owner)

    nice

  60. seham (verified owner)

    good

  61. seham (verified owner)

    good

  62. seham (verified owner)

    good

  63. seham (verified owner)

    good

  64. abdul.fofanah (verified owner)

    great

  65. abdul.fofanah (verified owner)

    amazing

  66. ijaganjac (verified owner)

    excellent.

  67. jayati.vaish (verified owner)

    good

  68. jayati.vaish (verified owner)

    good

  69. jayati.vaish (verified owner)

    good

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