The document discusses implementing parallel evolutionary algorithms in concurrent and functional programming paradigms. It introduces new trends in parallel genetic algorithms (pGAs) involving new parallel platforms and unexplored software platforms. It then models pGAs components, compares languages like Clojure, Erlang and Scala, and provides samples of implementing island models in each language. It presents results of experiments showing Scala had the best performance. The conclusion is that functional-concurrent languages allow simple implementation of hybrid parallel genetic algorithms and their built-in concurrency makes them a parallel platform. Scala performed best while Erlang showed good scalability.
Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014
1. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Implementing parallel evolutionary algorithms
in concurrent and functional paradigms
Author: MSc. Jos´e Albert Cruz Almaguer
Tutors: Dr. Juan Juli´an Merelo Guerv´os (UGR)
Dr.C. Liesner Acevedo Mart´ınez (UCI)
Universidad de Granada, Grupo GENEURA
2. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Summary
1 New Trends in pGAs
Novelty
2 Modeling pGAs
pGA’s Concepts
Language comparisons
3 Sample of Canonicals island/GA
Scala samples
Erlang samples
Clojure samples
4 Results
5 Conclusions
3. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Novelty
Evolutionary Algorithms
New parallel platforms are identified as new
trends in pGAs
Only hardware is considered and software
platforms remains practically unexplored
4. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Novelty
Software industry
Developing correct software
Two of the more promising are: functional and
concurrent
5. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Novelty
Programming paradigms
Functional: functions like first class concepts,
and for encouraging to do not use state changes
Concurrent: characterized by the presence of
programming constructs for managing processes
like first class objects
6. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Novelty
Programming languages: Clojure
Lisp variant
STM/agent/futures
JVM
7. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Novelty
Programming languages: Erlang
Prolog-like
Functional
Actor based concurrency
8. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Novelty
Programming languages: Scala
OO/Functional
Akka: Actor based concurrency
JVM
9. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
pGA’s Concepts
Parallel GA’s components
AG Component Rol
chromosome Representing the solution.
evaluated
chromosome
Pair {chromosome, fitness}.
population Set of chromosomes.
crossover Relation between two chromo-
somes producing other two new
ones.
mutation A chromosome modification.
selection Means of population filtering.
pool Shared population among no-
de’s calculating units.
island Topology’s node.
migration Chromosome interchange.
evolution/evaluation Execution.
10. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Language comparisons
Language comparisons
Erlang Scala Clojure
Parallel executing
unit
actor actor agent
Communication
(messages)
tuple tuple function
(protocol)
pool ets HashMap hash-map
DS chromosome list list vector
DS population list list lazy list
Compound data tuple tuple/object record/vector
Runtime environ-
ment
Erlang VM Java VM Java VM
11. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Scala samples
Scala
Listing 1: Actor declaration.
class Island extends Actor {
// Set of actors (workers)
var workers: Set[ActorRef] = _
def receive = {
case ’start =>
// All executing units to work!
workers.forEach(_ ! ’start)
}
}
12. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Scala samples
Scala
Listing 2: Functional processing of data.
def bestSolution(): (AnyRef, Int) = {
val evals = table.filter((a: (List, (Int, Int))) =>
a._2._2 == 2).toList
if (evals.isEmpty) (null, -1)
else {
val red = evals.reduce(
(a: (List, (Int, Int)), b: (List, (Int, Int))) =>
if (a._2._1 < b._2._1) b else a)
(red._1, red._2._1)
}
}
13. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Scala samples
Scala
Listing 3: Main code.
// Creating 4 i s l a n d s
val i s l a n d s = for ( <− 1 to 4)
yi el d sys . actorOf ( Props [ I s l a n d ] )
// Puting the migrants d e s t i n a t i o n & s t a r t
// each i s l a n d
for ( i <− 0 to 3){
i s l a n d s ( i ) ! ( ’ migrantsDest ,
i s l a n d s (( i +1) %4))
i s l a n d s ( i ) ! ’ s t a r t
}
14. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Erlang samples
Erlang
Listing 4: Actor declaration.
-record(island, {
workers
}).
-module(island).
start() ->
Pid = spawn(island, loop, [#island{}]),
Pid.
loop(D) ->
receive
start ->
lists:foreach(fun(W) -> W ! start end, D#island.workers),
loop(D)
end.
15. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Erlang samples
Erlang
Listing 5: Functional processing of data.
bestSolution(TableName) ->
Sels = ets:select(TableName,
ets:fun2ms(fun({Ind, Fit, State})
when State == 2 -> {Ind, Fit} end)),
LSels = length(Sels),
if
LSels > 0 ->
lists:foldl(
fun({I1, F1}, {I2, F2}) ->
if F1 < F2 ->
{I2, F2};
true -> {I1, F1}
end
end, lists:last(Sels), Sels);
true -> {null, -1}
end.
16. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Erlang samples
Erlang
Listing 6: Main code.
I s l a n d s = [ i s l a n d : s t a r t () | | <− l i s t s : seq (1 , 4) ]
l i s t s : foreach ( fun ( I ) −>
I e = l i s t s : nth ( I , I s l a n d s ) ,
I e ! { migrantsDest ,
l i s t s : nth (( i +1) rem 4 , I s l a n d s ) } ,
I e ! s t a r t
end ,
l i s t s : seq (0 , 3))
17. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Clojure samples
Clojure
Listing 7: Data structure declaration.
(defrecord TIsland [workers])
(ns island)
(defprotocol Island
(start [self])
)
(extend-type TIsland
island/Island
(start [self]
(doseq [w @(.workers self)]
(send w worker/start)
)
)
)
19. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Clojure samples
Clojure
Listing 9: Main code.
( l et
[ i s l a n d s ( for [ ( range 4) ]
( agent ( i s l a n d / c r e a t e ) ) )
]
( doseq [ i ( range 4) ]
( send ( nth i s l a n d s i )
i s l a n d / migrantsDest
( nth i s l a n d s
(mod ( inc i ) 4)))
( send ( nth i s l a n d s i )
i s l a n d / s t a r t )
)
)
20. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Results
Experiment results for the minimum parallel time of all combinations
tested
Lang Parallel time
± SD (ms)
Ws
comb
Seq time
(ms)
RSpeedup Speedup
Erlang 2920.40 ±
126
25 E,
1 R
8143.3 2.7884 0.5519
Clojure 1734.66 ±
28.32
10 E,
1 R
3340.2222 1.9255 0.9292
Scala 563 ± 24.32 6 E, 1
R
1651.8 2.8632 2.8632
21. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Results
Experiment results
Fig. 1. Parallel running times
for one reproducer.
0 5 10 15 20 25 30
1,000
2,000
3,000
4,000
Number of evaluators
Paralleltime(ms)
Erlang
Clojure
Scala
Fig. 2. Parallel running times
for two reproducers.
0 5 10 15 20 25 30
0
2,000
4,000
6,000
8,000
Number of evaluatorsParalleltime(ms)
Erlang
Clojure
Scala
22. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Conclusions
Conclusions
Simplicity of the implementation of a hybrid parallel
genetic algorithm in functional-concurrent languages
When a shared data structure is needed this language
allows a more direct access and that could be an
advantage
Among the new trends in pGAs are new parallel platforms,
the new languages with concurrent abstractions build-in
are parallel platforms too
23. New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions
Conclusions
Conclusions
The functional side is a key component to compose
software components and simplify the communication
strategies among concurrent activities
The performance of Scala is the best and point to Erlang
as a very scalable runtime