|
Algorithm 1 Spark-MOPSO-Avg. |
|
Input: dataset, Repository, Archive, Itermax, n,
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 is the data cached in the working node c
-
7:
localFitnessRDD ← dataRDD.mapPartition(calFitness())
-
8:
localFitness ← localFitnessRDD.collect()
-
9:
for each particle in particleSwarm do
-
10:
particle’s ←
-
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 is the data cached in the working node c
-
22:
localFitnessRDD ←
dataRDD.mapPartition(calFitness())
-
23:
localFitness ← localFitnessRDD.collect()
-
24:
for each particle in particleSwarm do
-
25:
particle’s ←
-
26:
end for
-
27:
for each particle in particleSwarm do
-
28:
if particle’s 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
|