I have a dataset consisting of matrices and I want to use them in the particle swarm optimization (PSO) algorithm, where each particle in the swarm, is represented by a matrix of size MxM.
Can I represent a particles as a matrix of size MxM or I have to reshape them to vector of size 1xM*M? Where the best solution should be a matrix not a vector.
In case of matrix your rows(number of samples) becomes particles and features(number of columns in your matrix) become dimensions.one individual swarm contains 1 row and M dimensions. Swarm has attributes position (1*M) , Velocity(1*M) and Pbest(1*M)
for i in range(rows):
for j in range(dimensions):
# write your code here for swarm