Top Banner
@GeneticIO NoSQLMatters 2015 #NoSQLMatters NoSQL Matters Paris – Mar 27, 2015 Genetic. io Yves Corsaire Julien Sebrien [email protected] Building Scalable Applications That Implement Genetic Algorithms for free
30

Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

Aug 11, 2015

Download

Technology

GeneticIO
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

NoSQL Matters Paris – Mar 27, 2015

Genetic.io

Yves CorsaireJulien Sebrien

[email protected]

Building Scalable Applications That Implement Genetic Algorithms

for free

Page 2: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Genetic Algorithm?

A genetic algorithm (GA) is a search technique used to find exact or approximate solutions to optimization and search problems

Wikipedia ;)

Page 3: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Sure…

Page 4: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Show me an real life

example!

Page 5: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Satellite orbit selection!

No kidding ! http://goo.gl/eauC32

philae

tchoury 

Page 6: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

What do I need?

• A genetic encoding of each solutionEach individual holds information already present in the problem (e.g. velocity, weights), and information that needs to be computed or derived.

• A selection method : Determines how individuals are retained between each generation (Fitness Proportionate, Tournament, Rank).

• A fitness functionEvaluates the "goodness" of each individual (candidate solution).

.

Page 7: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Evolution process

Build Initial Population Evaluation

Terminated?

Mutation

Crossover

Selection

Done!

Yes

No

Page 8: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Problem Modeling

find a route to « tchoury » comet

a sequence of n chromosomes, each chromosome being a unitary 2D movement

the closest from the comet a candidate is, the highest is its rate.

f(x) = 1/ R (R=remaining distance from comet)

• Requirements

• Candidate Implementation

• Fitness Function

Page 9: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Selection

Multiple ways to select individuals exist : Fitness Proportionate, Tournament, Rank, etc.

Tournament Example

1.Randomly select two individuals from the population.

2.Generate a random value to decide whether to select the fitter individual or the weaker one.

3.Add the chosen individual to the current selection. The two individuals are then returned to the original population and can be selected again.

This type of selection tends to favor the fitter one more as the tournament size increases.

Page 10: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Crossover

NE N E NE S W SW E

E NE N NW W E E NW

one crossover point one crossover point

parent 1 parent 2

child 1 child 2

NE N E NE S E E NW

E NE N NW W W SW E

Page 11: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

MutationObjective : inject diversity into the population, prompting the genetic algorithms to explore new solutions and as such lower the risk of being trapped in a local optimum

Description : generate a random number. If it’s less than the chosen probability of mutation (ie. Mutation Rate), then mutation takes place, else aborts.

Graph from : http://www.codeproject.com/Articles/707505/Genetic-Algorithms-Demystified

child 2

… W …

… E …

Page 12: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Evaluation

Fitness Function = remaining distance

tchoury 

philaephilae

philae

philaephilae

philae

philae

philae

philae

philae

philaephilae

Page 13: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Terminated?

The algorithm terminates once at least one stopping criteria is met:

1. A pre-determined number of iterations or generations is reached.

2. A candidate that meets or exceeds a target fitness value is found.

3. The algorithm runs for a too much amount of time.

Page 14: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

What choice do we have?

Page 15: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Current librairies

• Numerous exist (JGAP, ECJ, EpochX) in multiple languages (Java, C++, Python, etc.)

• None of them actually :

– Provide Modern Web UIs…

– Work with multiple languages…

– Run on distributed architectures…

Page 16: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Until now;)

Page 17: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Easy Set Up• Install Genetic.io using provided scripts (windows, unix, mac)

• Create user accounts

• Import your data using various importation methods (local file, upload, remote database, etc.)

• Configure your job parameters (evolution engine type, classes dependencies, termination conditions, etc.)

• Set up fitness computation parallelism method (spark, jppf, multitheading)

• Start and see realtime results!

Page 18: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Software Stack

Web Application Server

Web Client

HTTPWebSocket

Database Cluster

Grid Computing Cluster

Batch

CQL

CQL

Wire

Wire Data Computing Cluster

Page 19: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Infrastructure

start genetic jobs, get re

al-time progress

Store/Loadaccounts, datasources, jobs conf.

compute candidates fitnesses

Load

can

dida

tes

(with

dat

a lo

cality

)

Load jobs configuration, store progress

Page 20: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Data Importation

Page 21: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Data conversion

Page 22: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Fitness Calculator

public class PhilaeFitnessCalculator implements FitnessCalculator{@Overridepublic double calculate(IndividualBean bean, ...) {

double remainingDistance = computeRemainingDistance(bean);

return 1/remainingDistance;}@Overridepublic boolean isNatural() {

return true;}

private double computeRemainingDistance(IndividualBean bean){return ...;

}}

Page 23: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Crossover Operatorpublic class PhilaeCrossoverOperator implements CrossoverOperator {

...@Overridepublic List<IndividualBean> crossover(IndividualBean firstParent, IndividualBean

secondParent, Random rng) {IndividualBean firstChild = new IndividualBean(firstParent);IndividualBean secondChild = new IndividualBean(secondParent);int numberOfCrossoverPoints = getNbCrossoverPoints(); for (int i = 0; i < numberOfCrossoverPoints; i++){ int max = Math.min(firstChild.getNbAttributes(),

secondChild.getNbAttributes()); if (max > 1){

int crossoverIndex = (1 + rng.nextInt(max - 1)); for (int j = 0; j < crossoverIndex; j++){ Object temp = firstChild.getValue(j); firstChild.setValue(j, secondChild.getValue(j)); secondChild.setValue(j, temp); } }}return Arrays.asList(firstChild, secondChild);

}@Overridepublic int getNbCrossoverPoints() {

return this.nbCrossoverPoints;}...

}

Page 24: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Mutation Operator

public class PhilaeMutationOperator implements MutationOperator{...@Overridepublic IndividualBean mutate(IndividualBean individual, Random rng) {

individual.setValue("direction", mutateDirection(individual.getValue("direction"),

rng));return individual;

}private String mutateDirection(String direction, Random rng) {

return ...;}

}

Page 25: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Job Configuration

Page 26: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Fitness Score

Page 27: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Custom Candidate Display

Page 28: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Features• Embedded Secure User Account Management

• Data locality on most popular distributed databases (MongoDB, Cassandra)

• Parallelized Fitness Function Computation with Spark, JPPF or multithreading

• Fully Distributed Job Processing with JPPF

• Customisable candidates representation with D3.js SVG shapes

• Ability to replay jobs for in-depth algorithm evolution diagnosis

• Multilanguage (Java, Scala…), multiplatform (Windows, Unix, Mac)

• Open source!

Page 29: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Demo!

Page 30: Building Scalable Applications That Implement Genetic Algorithms with Genetic.io

@GeneticIO NoSQLMatters 2015 #NoSQLMatters

Questions?