Skip to main content
. 2023 Jan 31;25(2):259. doi: 10.3390/e25020259
Algorithm 1 Spark-MOPSO-Avg.

Input: dataset, Repository, Archive, Itermax, n, Np

Output: a group of external archives
  •     1:
    // Run in Master Node
  •     2:
    dataRDD ← sc.textFile(hdfs).repartition(n).persist()
  •     3:
    particleSwarm ← Initialize particle swarm
  •     4:
    Archive ← Initialize Archive
  •     5:
    particleSwarmBC ← sc.broadcast(particleSwarm)
  •     6:
    // Calculate the fitness value of the particle using Algorithm 2 and localDatac is the data cached in the working node c
  •     7:
    localFitnessRDD ← dataRDD.mapPartition(calFitness(localDatac,particleSwarmBC))
  •     8:
    localFitness ← localFitnessRDD.collect()
  •     9:
    for each particle in particleSwarm do
  •   10:
        particle’s Fitnessi←∑c=1nlocalFitnessc,i∗NcN
  •   11:
    end for
  •   12:
    particleSwarm.map (Update pbest)
  •   13:
    Archive ← Update Archive
  •   14:
    for each iter = 1, 2, …, Itermax do
  •   15:
        gbest ← Select Global Best Fitness
  •   16:
        for each particle in particleSwarm do
  •   17:
            Update particle velocity by (4)
  •   18:
            Update particle position by (5)
  •   19:
        end for
  •   20:
        particleSwarmBC ← sc.broadcast(particleSwarm)
  •   21:
      // Calculate the fitness value of the particle using Algorithm 2 and localDatac is the data cached in the working node c
  •   22:
      localFitnessRDD ←
    dataRDD.mapPartition(calFitness(localDatac,particleSwarmBC))
  •   23:
        localFitness ← localFitnessRDD.collect()
  •   24:
        for each particle in particleSwarm do
  •   25:
            particle’s Fitnessi←∑c=1nlocalFitnessc,i∗NcN
  •   26:
        end for
  •   27:
        for each particle in particleSwarm do
  •   28:
            if particle’s Fitness Pareto dominates pbest then
  •   29:
               Update pbest
  •   30:
            end if
  •   31:
        end for
  •   32:
        particleSwarm.map(Update pbest)
  •   33:
        Update Archive
  •   34:
    end for
  •   35:
    return Archive