Improved Particle Coding
PSO is a computational method used for optimization problems, by imitating the way birds or fish move together in groups. The method is based on the idea that individual elements (particles) can work together and interact with their surroundings to produce sophisticated overall outcomes. Each element in the swarm represents a potential solution to the problem being optimized. The PSO algorithm models each bird in a flock as a lightweight particle with two characteristics: velocity (V) and position (P). The rate of movement of particle is denoted as velocity and the direction of particle movement is denoted as position.
Every individual particle in the system examines the available options and selects the most suitable solution for itself, which it stores as its personal best (pbest). This individual best value is shared with other particles in the swarm. The algorithm then identifies the optimum solution among all particles, called the global best (gbest).
All particles adjust their V and P based on their personal best and the global best. This collaborative and iterative process aims to converge on the global optimal solution.
For our experiment let’s have the below assumptions,
T as task count,
N as edge server count,
CFreqs = {CFreqs,1, CFreqs,2, CFreqs,3 … CFreqs,N} represents the edge server CPU frequency, and
channel gain matrix Cg as
The channel gain Cgi,i for local execution is 0 and channel gain Cgi,j needed for edge device i to transfer the data to edge server j is denoted as (1 ≤ i ≤ T, 1 ≤ j ≤ N, i = j), Edge device CPU frequency is represented as CFrequ = CFrequ,1, CFrequ,2, CFrequ,3 … CFrequ,T and transmit power of edge device is represented as P = {P1, P2, P3 … PT}.
As part of particle coding, each element of particle is represented within the range 0 to N. Here particle dimension should be same as task sets dimension. The particle position vector (PPV) = {pp1, pp2, …, ppT} is randomly initialized and represent where the tasks are delegated. For example, if a task set has 4 tasks, like CT = {c1, c2, c3, c4} and having the particle code as [0, 2, 4, 5], means that the task c1 is processed in edge device itself, and c2 is delegated to the edge server with id as 2, and so on.
The particle velocity vector (PVV) represents the range of offloading tasks to other edge servers, denoted as PVV = {pv1, pv2, …, pvT}. Initially, each particle is assigned a random velocity keeping the dimension of the PVV matching task count to be offloaded. For example, if particle position vector PPV is [4, 2, 1, 7], and the PVV is [1, 2, 3, 1] then the first item in PPV, 4, indicates that task c1 is computed at the edge server with id as 4. The last item in PVV, 1, means that the task c1 is moved to the next appropriate edge server with id as 7.
The overall cost calculation subject to energy usage limitations, is already expressed in Equation (11) as fitness function.
The detailed steps involved in the proposed IPSOGA algorithm is given as below:
Start by creating the population, assigning initial velocities and positions to the particles.
From the particle’s position vector calculate the particle’s new fitness value using the fitness function and store it.
If the particle’s new fitness value is lower than the current best fitness value, update the best fitness value and store the corresponding position vector.
Update the position and velocity of the particles using the below equations:
where:
Wp is the inertia weight, a positive constant to balance the global search (Higher the value improves the exploration) and local search (lower the value improves the exploitation).
Pbest is the particle’s personal best position.
Gbest is the swam’s global best position.
is the ith particle velocity.
is the ith particle position.
l1 and l2 are cognitive and social learning factors.
U1 and U2 are random numbers
To enhance the PSO algorithm’s exploration capability, the acceleration learning factors
l1 and
l2 are dynamically adjusted from higher value to lower value as follows:
where:
Selection: Select a collection of particles based on their fitness (e.g., tournament selection or roulette wheel selection).
Crossover: Do crossover on selected collection of particles to produce new offsprings.
Mutation: Do mutation to the crossover offsprings to maintain diversity.
Merge Population: Combine the original particle population with the new mutated offsprings, by replacing least performing particles.
Evaluation: Evaluate the fitness of the new population.
Update Best Positions: Update the particle’s personal and global best position values if better solutions are found.
Algorithm is terminated if global best solution is found or until the maximum iteration is reached.
Algorithm: IPSOGA |
initialize population of particles by randomly setting the code for each particle;
convergence = 0.001
Evaluate initial fitness and set personal bests(pBest) for each particle
# Main Optimization Loop
Continue loop until termination criterion not met:
# PSO Operations
for every particle in population:
partical velocity is updated using Eq. 13
partical position is updated using Eq. 14
evaluate the new fitness of the particle
particle’s personal best (Pbest) is updated
particle’s global best (Gbest) is updated
end for
# GA Operations
selected_particles = subset_selection(particles)
offspring = crossover(selected_particles)
mutated_offspring = mutation(offspring)
- 18.
# Merge populations
- 19.
new_population = least performant particles are replaced in population with mutated_offspring
- 20.
# Evaluate new population
- 21.
for every particle in new_population:
- 22.
do fitness evalution for particle
- 23.
personal best (Pbest) is updated
- 24.
global best (Gbest) is updated
- 25.
end for
- 26.
#Check for convergence
- 27.
If swam’s global best (Gbest) <= convergence
- 28.
Global best soln is found, do task offloading after decoding particle codes
- 29.
Exit Continue Loop
- 30.
End if
- 31.
end Continue loop
|