[WSN coverage] Three-dimensional wireless sensor network coverage optimization based on sparrow search algorithm Three-dimensional WSN coverage optimization [Matlab code #26]

Article directory

    • [Other algorithms can be replaced, `Get resources`, please refer to Section 5 of the article: Resource acquisition]
    • 1. SSA algorithm
    • 2. 3D overlay model
    • 3. Partial code display
    • 4. Simulation result display
    • 5. Resource Acquisition

【Other algorithms can be replaced, Get resources, please refer to Section 5 of the article: Resource acquisition】

1. SSA algorithm


2. 3D overlay model

The 3D overlay model is shown in Figure 1 below.

Since the nodes are scattered randomly, the distribution of sensor nodes will affect the network coverage, so

R

c

o

v

R_{cov}

Rcov? is used as the coverage evaluation standard. In the three-dimensional coverage area, the coverage area of sensor nodes is a sphere with a certain radius. Randomly sprinkled in the 3D monitoring area

N

N

N sensor nodes, forming a node set

S

=

{

the s

1

,

the s

2

,

.

.

.

,

the s

N

}

(1)

S=\left \{ s_{1},s_{2},…,s_{N} \right \} \tag{1}

S={s1?,s2?,…,sN?}(1)
Among them, the first

i

i

The coordinates of i nodes are

the s

i

(

x

i

,

the y

i

,

z

i

)

s_{i}(x_{i},y_{i},z_{i})

si? (xi?, yi?, zi?). The set of three-dimensional monitoring nodes is

L

=

{

l

1

,

l

2

,

.

.

.

,

l

N

}

(2)

L=\left \{ l_{1},l_{2},…,l_{N} \right \} \tag{2}

L={l1?,l2?,…,lN?}(2) Among them, a target point in the three-dimensional monitoring area is

l

v

(

x

v

,

the y

v

,

z

v

)

l_{v}(x_{v},y_{v},z_{v})

lv?(xv?,yv?,zv?), the distance between the three-dimensional monitoring point and the target point is:

d

(

the s

i

,

l

v

)

=

(

x

i

?

x

v

)

2

+

(

the y

i

?

the y

v

)

2

+

(

z

i

?

z

v

)

2

(3)

d(s_{i},l_{v})=\sqrt{(x_{i}-x_{v})^{2} + (y_{i}-y_{v})^{2} + (z_ {i}-z_{v})^{2}} \tag{3}

d(si?,lv?)=(xixv?)2 + (yiyv?)2 + (zizv?)2
?(3)
like

d

(

the s

i

,

l

v

)

R

the s

d(s_{i},l_{v})\le R_{s}

d(si?,lv?)≤Rs?, the target point is within the three-dimensional coverage area, and the perception is marked as 1; otherwise, the perception is marked as 0 outside the three-dimensional coverage area. Using the Boolean perception model, the perception degree is:

p

(

the s

i

,

l

v

)

=

{

1

,

d

(

the s

i

,

l

v

)

R

S

0

,

d

(

the s

i

,

l

v

)

>

R

S

(4)

p(s_{i},l_{v})=\left\{\begin{matrix} 1,d(s_{i},l_{v})\le R_{S} \ 0,d(s_{ i},l_{v})> R_{S} \end{matrix}\right. \tag{4}

p(si?,lv?)={1,d(si?,lv?)≤RS?0,d(si?,lv?)>RS(4)
Among them, R_{s} is the communication radius of the node, assuming that there is

k

k

k nodes to be tested

the s

1

,

the s

2

,

.

.

.

,

the s

k

s_{1},s_{2},…,s_{k}

s1?,s2?,…,sk?, corresponding points

l

l

The coverage of l is

p

(

the s

i

,

l

v

)

p(s_{i},l_{v})

p(si?,lv?), where

k

a

l

l

k_{all}

kall? is all sensor nodes to be tested in the monitoring area,

R

p

(

k

a

l

l

,

l

v

)

R_{p}(k_{all},l_{v})

Rp?(kall?,lv?) is the joint perception probability, the expression is:

R

p

(

k

a

l

l

,

l

v

)

=

1

?

Π

i

=

1

k

(

1

?

p

(

the s

i

,

l

v

)

)

(5)

R_{p}(k_{all},l_{v})=1-\prod_{i=1}^{k}(1-p(s_{i},l_{v})) \tag{5}

Rp?(kall?,lv?)=1?i=1∏k?(1?p(si?,lv?))(5)
The overall coverage of the network is:

R

c

o

v

=

i

=

1

k

R

p

(

k

a

l

l

,

l

v

)

k

(6)

R_{cov}=\frac{\sum_{i=1}^{k}R_{p}(k_{all},l_{v}) }{k} \tag{6}

Rcov?=k∑i=1k?Rp?(kall?,lv?)?(6)
in,

R

c

o

v

R_{cov}

Rcov? is the overall coverage of the sensor network,

P

P

P is any monitoring point in the area. The coverage performance of the wireless sensor network can be tested by using the coverage rate as a fitness function.

3. Partial code display

FoodNumber=30; % population number
maxCycle=500; %Maximum number of iterations
dim=30; % number of parameters to be optimized
P_percent = 0.2; %finder ratio
pNum = round( FoodNumber * P_percent ); % number of discoverers
objfun = 'WSNcover';
c=0; % lower limit
d=50; % upper limit
r=10; % border width

lb= c.*ones( 1,dim ); % Lower limit bounds
ub= d.*ones( 1,dim ); % Upper limit bounds
for i = 1 : FoodNumber
    FoodsX( i, : ) = lb + (ub - lb) .* rand( 1, dim );
    FoodsY( i, : ) = lb + (ub - lb) .* rand( 1, dim );
    FoodsZ( i, : ) = lb + (ub - lb) .* rand( 1, dim );
    ObjVal(i)=feval(objfun,FoodsX( i, : ),FoodsY( i, : ),FoodsZ( i, : ),dim,r,d);
    Fitness(i)=calculateFitness(-ObjVal(i));% Get the fitness value, the higher the coverage, the higher the fitness value
end

pFit = Fitness;
pObj = ObjVal;
pX = FoodsX;
pY = FoodsY;
pZ = FoodsZ;
[ ObjMax, ObjbestI ] = max( ObjVal );
[ fMax, fbestI ] = max( Fitness );
bestX = FoodsX( fbestI, : );
bestY = FoodsY( fbestI, : );
bestZ = FoodsZ( fbestI, : );
HistoryObjMax = [1,maxCycle];

% draw
figure(1)
for i=1:dim
    x = bestX(1,i);
    y = bestY(1,i);
    z = bestZ(1,i);
    cc(x,y,z,r);
    hold on;
end
xlabel('X(m)');
ylabel('Y(m)');
zlabel('Z(m)');
title('Overlay effect before optimization');

4. Simulation result display



5. Resource acquisition

Full source code is available.