Skip to main content
. 2023 Jan 31;25(2):259. doi: 10.3390/e25020259
Algorithm 2 calFitness Algorithm.

Input: localDatac,particleSwarmBC

Output: particleSwarmFitness

  •     1:

    // Run in worker Node c

  •     2:

    functioncalFitness(localDatac,particleSwarmBC)

  •     3:

        particleSwarmBCValue = particleSwarmBC.value

  •     4:

        for 1 ≤ i ≤ particleSwarmBCValue do

  •     5:

            dataWithClusterK ← K-means clustering with particlei.position as the cluster center using localDatac

  •     6:

            Calculate the objective function value as the local fitness value based on (2) and the dataWithClusterK

  •     7:

            Calculate the objective function value as the local fitness value based on (3) and the dataWithClusterK

  •     8:

        end for

  •     9:

        return particleSwarmFitness

  •   10:

    end function