3. o Cellular automata ↔ life
o Emergent systems ↔ ants, termites, bees, wasps
o Neural networks ↔ the brain
o Artificial immune systems ↔ immune system
o Lindenmayer systems ↔ plant structures
o Communication networks protocols ↔ epidemiology and the spread of disease
o Membrane computers ↔ intra-membrane molecular processes in the living cell
o Sensor networks ↔ sensory organs
o Rendering (computer graphics) ↔ patterning and rendering of animal skins,
bird feathers, mollusc shells and bacterial colonies
o Genetic algorithms ↔ Evolution
Optimization Algorithms
Particles - Glowworm, Ants, Bees, Bats, Firefly, Cuckoo, Moulds - Genes
Aritra Sarkar, Avionics, IIST
5. Terms Biology Computer
Chromosome An individual’s encoded elements String
Gene One segment of the chromosome which
encodes some information
Character
Locus Location of a gene in a chromosome String position
Genotype One generation of individuals Population
Phenotype Characteristics arising from the chromosome Decoded structure
“The genetic algorithm is a probabilistic search algorithm that iteratively transforms
a set (called a population) of mathematical objects (typically fixed-length binary
character strings), each with an associated fitness value, into a new population of
offspring objects using the Darwinian principle of natural selection and using
operations that are patterned after naturally occurring genetic operations, such as
crossover (sexual recombination) and mutation.” – John R. Koza
Aritra Sarkar, Avionics, IIST
6. o Model Problem
o Selection
o Roulette wheel
o Tournament selection
o Elitism
o Crossover
o Local exploration – greedy/random – Pc (0.6-0.8)
o Mutation
o Global exploration – greedy/random – Pm (0.1)
o Stopping Criteria (necessary)
o Fix generations
o Fix error threshold
Aritra Sarkar, Avionics, IIST
7. o Antenna design (2004 satellite NASA)
o Cellular automata
o Truss Structure for complex architecture
o Classification problems
o Robot movements
o Evolving Analog circuits (Darlington Emitter Follower Section, Low V
Balun Circuit, Cubic function generator)
Aritra Sarkar, Avionics, IIST
8. When GP is used?
• Breeding Computer Programs through
Genetic Algorithm
• We have some vague idea about inputs
• We don’t have the formula to be optimized
(how to solve the problem)
• We have a set of acceptable solutions
• Near/Partial optimal solutions are
acceptable (intermediate solution states
useful)
• Don’t have enough time to wait for Hard
Computing to solve it (may take years)
Aritra Sarkar, Avionics, IIST
9. One individual (program)
Gene – Chromosome – Population - Generation
• Available functions
F = {+, -, *, %, ^}
• Available terminals
T = {a, b, c, d, Random Constants}
• The random programs have:
– Different sizes and shapes
– Valid Syntax and executable
Aritra Sarkar, Avionics, IIST
10. Function X Y F # Var
NOT
0 1
1
1 0
AND
0 0 0
>1
0 1 0
1 0 0
1 1 1
OR
0 0 0
>1
0 1 1
1 0 1
1 1 1
NAND
0 0 1
>1
0 1 1
1 0 1
1 1 0
NOR
0 0 1
>1
0 1 0
1 0 0
1 1 0
XOR
0 0 0
>1
0 1 1
1 0 1
1 1 0
XNOR
0 0 1
>1
0 1 0
1 0 0
1 1 1
NOT
Upgradation possible
Quantum Gates :
CNOT, Toffoli, Phase,
Hadamard, C-Swap, Z,
Pauli X,Y,Z,I.
Aritra Sarkar, Avionics, IIST
11. Maximum Number of Generations = 30
Maximum Expression Tree depth for initialization = 7
Population size = 100
Probability of Crossover = 0.6
Probability of Mutation = 0.1
Number of variables = 3
Required Output = 0110101001 < - - - #var >= log (output size)
Functions = { AND, OR, NAND, NOR, XOR, XNOR } < - - - f#(p1,p2)
Terminals = { 00001111, 00110011, 01010101 }
Aritra Sarkar, Avionics, IIST
12. main()
…..
for ( population_size)
population [i] = makeTree()
end for
…..
string makeTree()
if ( treeDepth < maxDepth – 1)
add F[] or T[] to existing tree
if (nodeAdded is F[])
recursive call makeTree() for 2 parameters
if (treeDepth == maxDepth – 1)
terminate with T[]s
return stringExpression
AND
0011
1010
1110
OR
0110
XOR
1010
1000
NOR
NAND
0000
1010
XNOR
1000
0001
Population_size = 4
Max_depth = 3
Aritra Sarkar, Avionics, IIST
13. String pop [ popsz ]
f1(0011,1010)
1110
f2(0110,f5(1011,1000))
f4(f3(0000,1010),f6(1000,0001))
Pre-order Traversal of Expression Tree
(normally we use Infix – a AND b )
Java:
Strings are immutable!
E.g. call by value of string variable doesn’t allocate
new memory, so original string gets modified
StringBuffer datatype used
StringBuffer pop [ ] = new StringBuffer [ popsz ]
Other possibility : LISP (List Programming)
Aritra Sarkar, Avionics, IIST
14. Stack based recursion in parsing
(coded to model specific representation)
Search string population individual expression for ‘f’
If ‘f’ found
Extract # from ‘f’ to ‘(‘
Extract 1st parameter from ‘(‘ to ‘,’ for recursive processing
Extract 2nd parameter from ‘,’ to ‘)’ for recursive processing
Resultant parameters sent as arguments to the specific function – f#
Return result of function f# call
If no ‘f’ found in string
Return value string
Aritra Sarkar, Avionics, IIST
15. Generalized Expression Evaluator format
(coded to suit further upgradation)
For each f#(p1,p2)
Define its use
Eg. Bitwise AND of the two string binary numbers passed, to generate the
new string as return value
StringBuffer instead of String used
While rest of the program is private, this part can be made public to
developers to define their own Logic Gates
Aritra Sarkar, Avionics, IIST
16. Roulette Wheel Technique
(Randomized – more like true Nature)
sum = 1
𝑝𝑜𝑝_𝑠𝑖𝑧𝑒
𝑓𝑖𝑡𝑛𝑒𝑠𝑠 (𝑖)
while (sum > 0)
sum-=fitness(i++)
selected - - > (i – 1)
Limitations and Solutions:
• Best individual may be lost - - > Elitism (Keep best 1 or 2 individuals by
selecting them by default)
• Large fitness individual dominate over many selections - - > Ranking (Rank
the individuals by their fitness instead of using their fitness as the Roulette
sector probability)
• Worst individual may linger around - - > Tournament (Every time take 2
random individuals, and select the better one)
Aritra Sarkar, Avionics, IIST
17. If rand() < Pc = 0.6 (Experimental data suggests 0.6 < Pc < 0.8)
Select crossover points in both trees and exchange function and terminals
May result in a tree height > max_depth
(max_depth valid only for initial population - let it evolve policy)
Originals lost (Solution : Keep best of last generation pair and best of current
generation crossed over pair)
OR
0110
XOR
1010
1000
NOR
NAND
0000
1010
XNOR
1000
0001
OR
0110
NAND
0000
1010
NOR
XOR
1010
1000
XNOR
1000
0001
Aritra Sarkar, Avionics, IIST
18. If rand() < Pm = 0.1 (Experimental data suggests 0.08 < Pc < 0.12)
Select mutation point in the tree and generate new subtree rooted there
May result in a tree height > max_depth
(max_depth valid only for initial population - let it evolve policy)
Originals lost (Solution : Greedy Mutation – accept mutated child only if its
fitness is better than the parent)
NOR
NAND
0000
1010
XNOR
1000
0001
NOR
XOR
1010
1000
XNOR
1000
0001
Aritra Sarkar, Avionics, IIST
19. No. of Variables : 3
Population Size : 100
Max. Tree Depth : 5
Crossover probability : 0.6
Mutation probability : 0.1
Max. Generations : 25
Target Output : 1110101
Warning : MSB in Target Output zero padded to match with Chromosome length
Goal : 01110101
Initial Population Generation.....
Generation : 1
Expression Evaluation .....
Fitness Evaluation .....
Performing Selection .....
Generation fitness : 440/800
Best fitness : 7/8
Best Expression : 01010101
Performing Crossover .....
Performing Mutation .....
………. Similar generations not shown here ……….
Generation : 12
Expression Evaluation .....
Fitness Evaluation .....
Performing Selection .....
Generation fitness : 492/800
Best fitness : 8/8
Best Expression :
f5(f6(f1(01010101,01010101),f6(00110011,00110011)),f4(f2(01010101,f1(01010101,00001111)),f5(f4(00001111,00110011),00001111)))
Maximum fitness reached : Exact solution found
((01010101 AND 01010101) XNOR (00110011 XNOR 00110011)) XOR ((01010101 OR (01010101 AND 00001111)) NOR ((00001111 NOR 00110011) XOR 00001111))
Aritra Sarkar, Avionics, IIST
20. Selection
Crossover Reason: Selection
Mutation
If Pc = Pm = 0, still population converges to best in initial generation
GP converges, but never stops !
Crossover May degrade the best solution, hoping to find
Mutation “better than the best”
Stopping criteria necessary (error acceptance limit)
• Fix maximum generations (curr_gen = max_gen = 100) (estimated by a
few trial runs)
• All bit values match (curr_gen_best == reqd_op)
Aritra Sarkar, Avionics, IIST
21. • Reduce number of Gates
Use digital logic rules/theorems to simplify the final expression (GP
doesn’t take care of that)
• Implement more Gates
NOT gate, > 2 input gates, Quantum Gates, Small modules (D-Latch, 2-
bit adder), and evolve CPU operations
• Auto configure FPGA
Export final result to FPGA through VHDL programming, and generate
hardware circuit design of required output
• Time constraint reduction
Instead of String operations, use Linked List based Syntax Trees,
specialized languages like LISP or functional programming in Python or
Scala
Aritra Sarkar, Avionics, IIST
22. F [] - - > Maxwell’s equations, Relativity Equations, Newton’s Laws of
Motion and Gravity, Fluid Equations, ……. ?
T [] - - > set of all R and C numbers, Universal constants like, G, µ, π, μ, ε,
κ, ђ, e, R, ……. ?
Tremendously fast processor and parallel computer
- - > Quantum Computer running Quantum Algorithms ?
Very low temperature to make such a huge Quantum Computer possible
- - > Quantum Computer hub in a space platform ?
What are we evolving ?
Grand Unified Theory !!
Aritra Sarkar, Avionics, IIST
23. Dr. Narasimhan Sundararajan
For introducing me to this wonderful realm of Genetic
Programming, during his special guest lecture session for
M.Tech students, arranged in IIST in August, 2012.
Aritra Sarkar, Avionics, IIST
24. • “A field guide to genetic programming” – Poli, Langdon,
McPhee
• “Genetic Algorithms + Data Structures = Evolution
Programs” – Zbigniew Michalewicz
• “Genetic programming: a paradigm for genetically breeding
populations of computer programs to solve problems” -
John R. Koza
Aritra Sarkar, Avionics, IIST