You are on page 1of 21

Random Feature


Karim Gaber Ahmed El-Naggar
Genetic Algorithm
Introduction

 Genetic Algorithms are a way of solving problems by mimicking the same
processes mother nature uses to evolve a solution to a problem.
 Every organism has a set of rules, a blueprint so to speak.
 describing how that organism is built up.
 These rules are encoded in the genes of an organism, which in turn are
connected together into long strings called chromosomes.
Genetic Algorithm
Introduction

Genetic Algorithm
Introduction

 Each gene represents a specific trait of the organism, like eye color or hair
color, and has several different settings.
 Goal: create the random feature
 Benefits:
 easily distributed
 Many random parameters
 Always an answer
 Answer get better with time
 Depend on fitness function, which we design
An Overview

 Before you can use a genetic algorithm to solve a problem, a way must be
found of encoding any potential solution to the problem.
 This could be as a string of binary bit string which is known as the chromosome
which may look like this:
10010101110101001010011101101110111111101
 At the beginning of a run of a genetic algorithm a large population
of random chromosomes is created.
An Overview

 Each one, when decoded will represent a different solution to the problem at
hand.
 Then the following steps are repeated until a solution is found:
An Overview

 Test each chromosome to see how good it is at solving the problem at hand
and assign a fitness score accordingly.
 The fitness score is a measure of how good that chromosome is at solving the
problem to hand.
 Select two members from the current population. The chance of being
selected is proportional to the chromosomes fitness
An Overview

 Dependent on the crossover rate crossover the bits from each chosen
chromosome at a randomly chosen point.
 Step through the chosen chromosomes bits and flip dependent on
the mutation rate
 Repeat step 2, 3, 4 until a new population of N members has been created.
Random Feature
Introduction

 Description: It is a unique feature for our editor which it will help you in
choosing harmonious colors which can be used for:
 fashion
 Décor
 Art
 etc.
 Goal: Create an infinite set of palettes.
 Two color palettes and three color palettes.
How does it work

 We create 10 sets of two random colors in rgb color space.
rgb(248, 104, 50)

rgb(32, 52, 200)

 Then we check each set for repeated colours if there a repeated colour we
create a new one and replace it with a new random one.
How does it work

 We convert them to their hex value



#F86832
#2034c8
 We convert each color in a binary string, the gene.
111110000110100000110010
001000000011010011001000
How does it work

 We combine the two strings(genes) to create our chromosomes
111110000110100000110010001000000011010011001000
 We calculate the difference which is the fitness function.
 We mutate if the difference is 12 or less.
We flip random bits
111110000110100010110001001000000011010011001001
How does it work

 We cross-over If the difference is <= 13 and >= 65
We recombine the two stings with each other
 So if we have to chromosomes:
111110000110100000110010001000000011010011001000
111101110111100010110101001010001000100111001000
 Would be:
111101110111100000110010001010001000010011001000
111110000110100010110101001000000011100111001000
How does it work

 We repeated this process until we reach the desired value.
 Then we spilt the chromosome into two genes
 We convert each into their hex value
 Convert the hex into rgb colors.
 We display them
How does it work

 The result would give:



rgb(1, 93, 138)

rgb(248, 104, 177)


Output

Output

Output

Output

Conclusion

Conclusion

 We choose diff less than 13 for mutation because the rate of mutation is very
small
 We wanted the difference 65 or greater because it gave harmonic results
 we concluded that after many trail and error.

You might also like