You are on page 1of 31

GPdotNET

Darwin's theory of evolution in solving engineering problems by C#

Bahrudin Hrnjica, C# MVP


blog: bhrnjica.net
twitter: @bhrnjica

Thanks to all our sponsors,


they made this possible!

AGENDA
What is GP
GPdotNET user perspective
Running GPdotNET on Fedora17
Demos with real data samples

GPdotNET developer perspective

GPdotNET Architecture
Thread-Safe Random number generator
Memory Pooling
ParallelFX implementation in GPdotNET

Demos

GENETIC
ALGORITHM
Genetic Algorithm (GA) is heuristic method
that mimics the proces of natural selection.
GA represents population of strings
(chromosomes) which encode posible
solutions (phenotypes)
In GA every chromosom is defined with
fixed size.
Most GA problems used chromsomes in
form of string of binary numbers.

GENETIC
PROGRAMMING
GP is variation of GA, with diferent
Chromosome sizes.
GP envolves computer programs,
represented as tree structure.
Every tree contains: terminals and functions
Inner nodes represent functions
Outer nodes represent terminals

GP
FLOWCHART

A COMPUTER
PROGRAM IN C
int foo (int time)
{
int temp1, temp2;
if (time > 10)
temp1 = 3;
else
temp1 = 4;
temp2 = temp1 + 1 + 2;
return (temp2);
}

Time

Output

10

11

12

OUTPUT OF C
PROGRAM

PROGRAM TREE

(+ 1 2 (IF (> TIME 10) 3 4))

CREATING RANDOM
PROGRAMS
Available functions
F = {+, -, *, %, IFLTE}
Available terminals
T = {X, Y, Random-Constants}
The random programs are:
Of different sizes and shapes
Syntactically valid
Executable

GP GENETIC
OPERATIONS

Reproduction
Mutation
Crossover (sexual recombination)
Others

MUTATION
OPERATION

CROSSOVER
OPERATION

REPRODUCTION
OPERATION
Select parent probabilistically
based on fitness
Copy it (unchanged) into the next
generation of the population

RUNNING GP

FIVE MAJOR PREPARATORY


STEPS FOR GP

Determining the set of terminals


Determining the set of functions
Determining the fitness measure
Determining the parameters for the run
Determining the method for designating a result
and the criterion for terminating a run

GPdotNET

Codeplex open source project


Started with development in 2006, as PGS
First published on Codeplex at 5 Nov. 2009.
WinForms, C#, .NET4.0, Mono2.8
This year will be released v2.0
Cross-OS and Cross Platform application
.NET and Mono

GPDOTNET USER PERSPECTIVE

GPDOTNET DEV. PERSPECTIVE

GPdotNET
Implementation

Core
Engine
Util
Common.Tools
Application

Chromosome
implementation
-

Tree based GP Chromosome


Binary Type GA Chromosome
Continuous Type GA Chromosome
Derived from IChromosome
MemoryPool support at compile time

Memory Pooling
Chromosome Level
Simple Stack implementation of
Pool
Memory Pooling has to be Thread Safe

DEMO
MEMORY POOLING
IMPLEMENTATION

Random Number
Generation

Most important in this project


Almost all data is generated randomly
Random has to be Thread-Safe
ThreadLocal<Random> implementation

DEMO
RANDOM IMPLEMENTATION

Parallel GP
3 kind of parallelisation in GP
Fitness level of parallelisation
Chromosome level of parallelisation
Level on Independent runs

Fitness level GP
paralelization

Chromosome level of
Paralelization

Paralelization at level
of Independent runs

DEMO
PARALIZATION IN GPDOTNET

More info
www.genetic-programming.org oficial web page
http://gpdotnet.codeplex.com
http://bhrnjica.wordpress.com/gpdotnet latest information
about the GPdotNET

You might also like