• 沒有找到結果。

A General PSO Algorithm for the K-of-N Lifetime Problem

5.1 Algorithm

In this section, a heuristic algorithm based on PSO to solve the K-of-N lifetime problem under general constraints is proposed. An initial set of particles is first randomly generated, with each particle representing a possible BS location. Each particle is also allocated an initial velocity for changing its state. Let ej(0) be the initial energy, rj be the data transmission rate, αj1 be the distance-independent parameter, and αj2 be the distance-dependent parameter of the j-th AN. The lifetime lij

of an application node ANj for the i-th particle is calculated by the following formula:

, where is the n-order Euclidian distance from the j-th AN to the i-th particle. In

the K-of-N lifetime problem, given N ANs, the system survives as long as at least K ANs are alive. Restated, the system fails when at least N-K+1 ANs run out of energy.

The fitness function used for evaluating each particle is thus shown below:

n

That is, the fitness of the i-th particle is its (N-K+1)-th minimal lifetime among all the ANs. A larger fitness value thus denotes a better solution quality for the K-of-N lifetime problem, meaning the corresponding BS location is better. The fitness value of each particle is then compared with that of its corresponding pBest. If the fitness value of the i-th particle is larger than that of pBesti, pBesti is replaced with the i-th particle. The best pBesti among all the particles is chosen as the gBest. Besides, each particle has a velocity, which is used to change the current position. All particles thus continuously move in the search space. When the termination conditions are achieved, the final gBest will be output as the location of the base station. The proposed algorithm is stated below.

The proposed PSO algorithm for the K-of-N lifetime problem:

Input: A set of N ANs, each ANj with its location (xj, yj), data transmission rate rj, initial energy ej(0), parameter αj1,parameterαj2, and the allowed number K of alive ANs.

Output: A BS location that will cause a nearly maximal lifetime for the K-of-N lifetime problem.

Step 1: Initialize the fitness values of all pBests and the gBest to zero.

Step 2: Randomly generate a group of n particles, each representing a possible BS

location. Locations may be two-dimensional or three-dimensional, depending on the problems to be solved.

Step 3: Randomly generate an initial velocity for each particle.

Step 4: Calculate the lifetime lij of the j-th AN for the i-th particle by the following formula:

distance-independent parameter, αj2 is a distance-dependent parameter of the j-th AN, and is the n-order Euclidean distance from the i-th particle (BS)

to the j-th AN.

n

dij

Step 5: Calculate the (N-K+1)-th minimal lifetime among all the ANs for the i-th particle as its fitness value (fitness(i)) by the following formula:

}

Step 6: Set pBesti as the current i-th particle if the value of fitness(i) is larger than the current fitness value of pBesti.

Step 7: Set gBest as the best pBest among all the particles. That is, let:

fitness of pBestk =maxin=1fitness of pBesti,

1 2 d

and set gBest=pBestk.

Step 8: Update the velocity of the i-th particle as:

( )

where is the new velocity of the i-th particle at the d-th dimension, is the current velocity of the i-th particle at the d-th dimension, w is the

inertial weight, c

new

Vid

old

Vid

1 is the acceleration constant for particles moving to pBest, c2

is the acceleration constant for particles moving to gBest, Rand1() and Rand2() are two random numbers among 0 to 1, xid is the current position of the i-th particle at the d-th dimension, pBestid is the value of pBesti at the d-th dimension, and gBestd is the value of gBest at the d-th dimension.

Step 9: Update the position of the i-th particle as:

new

where xidnew and are respectively the new position and the current position of the i-th particle at the d-th dimension.

old

xid

Step 10: Repeat Steps 4 to 9 until the termination conditions are satisfied.

In Step 10, the termination conditions may be predefined execution time, a fixed number of generations or when the particles have converged to a certain threshold.

5.2 An Example

In this section, a simple example in a two-dimensional space is given to explain how the PSO approach can be used to find the best BS location for the K-of-N lifetime problem. Assume there are totally four ANs in the example and their initial parameters are shown in Table 9, where “Location” represents the two-dimensional coordinate position of an AN, “Rate” represents the data transmission rate, and

“Power” represents the initially allocated energy. All αj1’sare set at 0 and all αj2’sat 1 for simplicity. Also assume the allowed number K of alive ANs is 3.

Table 9: The initial parameters of ANs in the example AN Location Rate Power

1 (1, 10) 3 10000 2 (11, 0) 5 10000 3 (8, 7) 4 6400 4 (4, 3) 4 6400

For the example, the proposed PSO algorithm proceeds as follows.

Step 1: The initial fitness values of all pBests and the gBest are set to zero.

Step 2: A group of n particles are generated at random. Assume n is set at 3 in this example for simplicity. Also assume the three initial particles randomly

generated are located at (4, 7), (9, 5) and (6, 4). Figure 6 shows the positions of the given ANs and the initial particles, where the triangles represent the particles and the circles represent the ANs.

1

Figure 6: The positions of the given ANs and the initial particles

Step 3: An initial velocity is randomly generated for each particle. In this example assume the initial velocity is set at zero for simplicity.

Step 4: The lifetime of each AN for a particle is calculated. Take the first AN for the first particle as an example. Its lifetime is calculated as follows:

18

The lifetimes of all ANs for all particles are shown in Table 10.

Table 10: The lifetimes of all ANs for all particles 1(1, 10) 2(11, 0) 3(8, 7) 4(4, 3) 1(4, 7) 185.18 20.40 100 100 2(9, 5) 37.45 68.96 320 55.17 3(6, 4) 54.64 48.78 123.07 320

Particle AN

Step 5: The (N-K+1)-th minimal lifetime among all the ANs for each particle is calculated as its fitness value. Take the first particle as an example. Its fitness is calculated as follows:

Fitness(1)= Min(4-3+1){l11, l12, l13, l14}

= Min(4-3+1){185.18, 20.41, 100, 100}

= 100.

In the same way, the fitness values of all the particles are calculated and shown in Table 11.

Table 11: The fitness values of all the particles Particle Location Fitness

1 (4, 7) 100 2 (9, 5) 55.17 3 (6, 4) 54.64

Step 6: The fitness value of each particle is compared with that of its corresponding

pBest. If the fitness value of the i-th particle is larger than that of pBesti,

pBesti is replaced with the i-th particle. In the first generation, the fitness

values of all the pBests are zero, smaller than those of the particles. The particles are then stored as the new pBests. The resulting pBests are shown in Table 12, where the field “appearance generation” represents the generation number in which a particle is set as the current pBest.

Table 12: The pBests after the first generation Particle Location Fitness Appearance

Generation

1 (4, 7) 100 1

2 (9, 5) 55.17 1

3 (6, 4) 54.64 1

Step 7: The best pBesti among all the particles is chosen as the gBest. In this example, pBest1 has the largest fitness value and is set as the gBest.

Step 8: The new velocity of each particle is updated. Assume the inertial weight w is set at 1, the acceleration constant c1 for particles moving to pBest is set at 2, and the acceleration constant c2 for particles moving to gBest is set at 2. Take the second particle as an example to illustrate the step. Its new velocity is calculated as follows:

( ) old ()

new w V c Rand pBest x

V2x = × 2x + 1× 1 × 2x 2x +c2×Rand2()×(gBestdx2x)

=1*0+2*0.5(9-9)+2*0.25(4-9)

where the four random numbers generated are 0.5, 0.25, 1 and 0.125, respectively. In the same way, the new velocities of the other two particles can be calculated. The results are shown in Table 13.

Table 13: The new velocities of all the three particles Particle Old Location Velocity

1 (4, 7) (0, 0)

2 (9, 5) (-2.5, 0.5) 3 (6, 4) (-1.2, 2.4)

Step 9: The position of each particle is updated. Take the second particle as an

example. Its new position is calculated as follows:

newx

= 5.5.

In the same way, the new positions of all the other two particles can be found. The results are shown in Table 14.

Table 14: The new positions of all the three particles Particle Old Location Velocity New Location

1 (4, 7) (0, 0) (4, 7)

2 (9, 5) (-2.5, 0.5) (6.5, 5.5) 3 (6, 4) (-1.2, 2.4) (4.8, 6.4)

Step 10: Steps 4 to 9 are then repeated until the termination conditions are satisfied.

The lifetime evolution along with different generations for this example is shown in Figure 7.

0 50 100 150

0 20 40 60 80 100

Generations

Lifetime

Figure 7: The evolution of the system lifetime for the example.

In this example, the solutions converge after about 70 generations. The solution

was located at (4.5515, 6.419) and its lifetime was 130.8344 time units.

CHAPTER 6

A General PSO Algorithm for the m-in-K-of-N

相關文件