implementing parallel evolutionary algorithms in concurrent and functional paradigmsconcurrent lps-p...

23
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

Upload: jose-almaguer

Post on 15-Jun-2015

105 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Implementing parallel evolutionary algorithms

in concurrent and functional paradigms

Author: MSc. Jose Albert Cruz AlmaguerTutors: Dr. Juan Julian Merelo Guervos (UGR)

Dr.C. Liesner Acevedo Martınez (UCI)

Universidad de Granada, Grupo GENEURA

Page 2: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Summary

1 New Trends in pGAsNovelty

2 Modeling pGAspGA’s ConceptsLanguage comparisons

3 Sample of Canonicals island/GAScala samplesErlang samplesClojure samples

4 Results

5 Conclusions

Page 3: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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 softwareplatforms remains practically unexplored

Page 4: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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

Page 5: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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 ofprogramming constructs for managing processes

like first class objects

Page 6: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Novelty

Programming languages: Clojure

Lisp variant

STM/agent/futures

JVM

Page 7: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Novelty

Programming languages: Erlang

Prolog-like

Functional

Actor based concurrency

Page 8: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Novelty

Programming languages: Scala

OO/Functional

Akka: Actor based concurrency

JVM

Page 9: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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.

evaluatedchromosome

Pair {chromosome, fitness}.

population Set of chromosomes.

crossover Relation between two chromo-somes producing other two newones.

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.

Page 10: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Language comparisons

Language comparisons

Erlang Scala Clojure

Parallel executingunit

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

Page 11: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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)

}}

Page 12: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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).toListif (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)}

}

Page 13: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Scala samples

Scala

Listing 3: Main code.

// C r ea t i n g 4 i s l a n d sva l i s l a n d s = f o r ( <− 1 to 4)

y i e l d s y s . a c to rO f ( Props [ I s l a n d ] )

// Put ing the m ig ran t s d e s t i n a t i o n & s t a r t// each i s l a n df o r ( i <− 0 to 3){

i s l a n d s ( i ) ! ( ’ migrant sDes t ,i s l a n d s ( ( i +1)%4))

i s l a n d s ( i ) ! ’ s t a r t}

Page 14: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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) ->receivestart ->lists:foreach(fun(W) -> W ! start end, D#island.workers),loop(D)

end.

Page 15: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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}

endend, lists:last(Sels), Sels);

true -> {null, -1}end.

Page 16: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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 : f o r e a ch ( fun ( I ) −>I e = l i s t s : nth ( I , I s l a n d s ) ,I e ! {migrant sDes t ,

l i s t s : nth ( ( i +1) rem 4 , I s l a n d s ) } ,I e ! s t a r tend ,l i s t s : seq (0 , 3 ) )

Page 17: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

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 TIslandisland/Island

(start [self](doseq [w @(.workers self)](send w worker/start)

))

)

Page 18: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Clojure samples

Clojure

Listing 8: Functional processing of data.

(bestSolution [self](let [

evals (for [[ind [fit state]] @(.table self):when (= state 2)]

[ind fit])

](if (empty? evals)

[nil -1](reduce #(if (< (%1 1) (%2 1)) %2 %1) evals))

))

Page 19: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Clojure samples

Clojure

Listing 9: Main code.

( l e t[ i s l a n d s ( f o r [ ( 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 /mig ran t sDes t( 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 ))

)

Page 20: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Results

Experiment results for the minimum parallel time of all combinationstested

Lang Parallel time± SD (ms)

Wscomb

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, 1R

1651.8 2.8632 2.8632

Page 21: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Results

Experiment results

Fig. 1. Parallel running timesfor one reproducer.

0 5 10 15 20 25 30

1,000

2,000

3,000

4,000

Number of evaluators

Paralleltime(m

s)

ErlangClojureScala

Fig. 2. Parallel running timesfor two reproducers.

0 5 10 15 20 25 300

2,000

4,000

6,000

8,000

Number of evaluatorsParalleltime(m

s)

ErlangClojureScala

Page 22: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Conclusions

Conclusions

Simplicity of the implementation of a hybrid parallelgenetic algorithm in functional-concurrent languages

When a shared data structure is needed this languageallows a more direct access and that could be anadvantage

Among the new trends in pGAs are new parallel platforms,the new languages with concurrent abstractions build-inare parallel platforms too

Page 23: Implementing parallel evolutionary algorithms in concurrent and functional paradigmsConcurrent lps-p e-as - jalbert - geneura 2014

New Trends in pGAs Modeling pGAs Sample of Canonicals island/GA Results Conclusions

Conclusions

Conclusions

The functional side is a key component to composesoftware components and simplify the communicationstrategies among concurrent activities

The performance of Scala is the best and point to Erlangas a very scalable runtime