$24
Write a Python program to use “Binary Particle Swarm Optimization” (BPSO) scheme to predict a linear model for an HIV inhibitor (Pill). You can either choose a linear model such as “Multiple Linear Regression”, “Support Vector Machine”, or “Partial Least Square Regression”, or a none-linear model such “Artificial Neural Network”. The architecture of the BPSO is:
How to find the initial velocity:
for (i=0; i<50; i++)
for (j=0; j<385; j++)
{
V[i, j] = random number between 0 and 1; // this is not binary. It is between 0 and 1
}
How to find the new population:
Find the value of alpha ()
During the 1000 iteration, the value of ranges from 0.5 downs to 0.33. So, the different between 0.5 and 0.33 is (0.5 – 0.33 = 0.17). Thus, to reduce the value of in each iteration (1000 iterations) we need to divide 0.17 by 1000 (0.00017) to know how much in each iteration we need to subtract from the value of
Finding the new population: (note: the value of p=(0.5) *(1+) )
If (velocity[i][j] <=) then new-population [i][j] = old-population[i][j]
Else if (velocity[i][j] and velocity[i][j] <=p ) then new-population [i][j] = local-best matrix[i][j]
Else if (velocity [i][j] p and velocity[i][j] <=1) new-population[i][j] = global-best[j]
Else new-population[i][j] = old-population[i][j]
Updating the new local best Matrix:
For each row “i” of the current population
If the fitness of the population[i] < fitness of local-best[i]
Local-best[i] = population[i]
Updating the Global best row:
Global-best row = the row of the local-matrix with the lowest fitness
Updating the velocity: