# Representation of real numbers in Genetic Algorithm

Take a look at section 2.2.2 of this book (from Page-15 to 16).

2.2.2 Representation and Evaluation

$$max f (x)= x sin(10πx)+2.0 ... ... ... (2.8)$$ $$s.t. −1 ≤ x ≤ 2$$

We can use a real number, in the range $$[−1,2]$$, to represent a solution in Eq. $$2.8$$ directly. Many operators can handle real number representation. But we use the binary code or binary representation here for two reasons. GAs were originally proposed to be binary code to imitate the genetic encoding of natural organisms. On the other hand, binary code is good for pedagogy. A binary chromosome is necessary to represent a solution x in the scale $$[−1,2]$$. The same holds for the binary representation of real numbers in a computer.

In binary code, we cannot represent a real number completely correctly, so a trade-off is necessary. A tolerance needs to be deﬁned by the user, which means the errors below the tolerance are extraneous. If we divide the deﬁnition domain into $$2^1 = 2$$ parts evenly and select the smallest number in the parts to represent any number in the division, we can only represent $$−1$$ and $$0.5$$ by $$0$$ and $$1$$ respectively. $$2^2 = 4$$ divisions make the $$00$$, $$01$$, $$10$$, and $$11$$ represent $$−1$$, $$−0.25$$, $$0.5$$, and $$1.25$$, respectively. The larger division number we select, the less error there is in representing a real number on binary code. Suppose we use $$100$$ binary codes to represent a real number in the range $$[−1,2]$$; the maximum error is $$\frac{3}{2100} ≈ {2.37}^{−30}$$, which would be satisfactory for most users. In this way, we can represent a real number with any accuracy requirements.

In this problem, we use $$l = 12$$ binary codes to represent one real number as follows, which constitutes a chromosome to be evolved.

Actually, I haven't understood this text. I know that binary numbers are already able to represent fractions.

So, what are they talking about?

The authors want to use a binary genome which contains specific interpretation/mapping to a fixed precision real number. They could use one or more existing schemes, but these typically won't represent the exact precision and range of real numbers they want to use in the example problem.

They use their own encoding scheme and explain it in the text for completeness. Any similarities between their scheme and other binary representations of real numbers are to be expected, and if you understand them, it will help understand what they are doing here too.

GAs don't have to use this sort of scheme for real numbers. Often they use standard floating-point representation as separate elements. But the authors want a binary code here to help teach some basic concepts, which is what they mean by "on the other hand, binary code is good for pedagogy"

Discrete Experiments

The first impression is that real numbers (or IEEE floating point approximations of them) don't belong in genetic algorithms because DNA genetics is based on binary representations based on the presence of either adenine-thymine or cytosine-guanine in a position along a chromosome. Sub-sequences of those bits correspond to specific triggers and resulting protein syntheses. Genetic information is discrete, not continuous.

That is true, but, as the number of instances being represented probabilistically approach infinity, the distance between rational numbers that represent the potential probability values tend toward zero. That is, where $$\mathbb{I}$$ is the set of indices for all possible probabilities for a given discrete scenario, we have this limit that tends toward but never reaches continuity.

$$\forall \, j \in \mathbb{I}, \, \lim_{n \rightarrow \infty} P_j - P_{j-1} = 0$$

Also, as the number of bits in the mantissa of a fixed point number increases, the distance between their values similarly decrease toward the limit of zero.

When the authors state, "Binary code is good for pedagogy," they probably mean that it is difficult to store a voltage without sampling it and representing it as an integer that can be stored in noise and drift resistant ways using binary encoding and error correction strategies. If this is a correct expansion of what that phrase means, then it makes much sense. In analog circuitry, a voltage may be latched for a few microseconds while it is sampled, capacitor leakage is too high to trust the value much longer.

Furthermore, far more samples are often taken than what is prescribed by the Nyquist criteria so that noise cancellation improves the signal to noise ratio. Once the signal is in digital form, error correction and detection reduces these phenomena significantly. Although we can prove this using mathematics, the hyper-evolution of the evolutionary mechanism itself has proven these facts over a few billion years.

At this point, the theory presented from the authors is clear. They are stating three things.

• Real numbers represented in computers as integers, IEEE floating point numbers, or arbitrary precision numbers using appropriate libraries are discrete approximations of continuous values.
• DNA represent in binary state-action relationships the action plans based on continuous probability distributions in the environment with which the system interacts.
• These two facts create a fundamental correlation between genetic information and binary approximations of real numbers in computers.

Although the first two statements are correct, the third is not. This is the kind of fundamental error common in statements made by people with excellence in mathematics and computer science but somewhat less profoundly educated in the nuances of biology and probability. Consider these discrete events that affect the probabilities that some enzyme or protein should be generated under some particular threshold condition in the cellular machinery.

• A lion kills a jackal of two
• One of the two had a child jackal
• The other did not
• A particular combination of AT versus CG bits led to the manufacture of a protein that allowed a faster muscular response, which allowed the remaining jackal to propagate

The function representing the event of capture is not continuous. The probability of a death event between birth and conception of the child jackal is effectively continuous. For a child jackal, the probabilities of their conception is irrelevant. The pertinent function from the perspective of that specific line of jackals outputs exactly one bit. Zero is nonexistence and one is existence.

The function that may model evolution surrounding this scenario is a continuous appearing function, but it is made up of discrete events that may be conditioned by real numbers but, since injured jackals can still reproduce, do not result in real number outcomes. This is where the authors are not accurately modeling biological reality. A functional representation of selection on the basis of a single genetic bit is

$$S_i = S(E, P(G_i, T)) \, \text{,}$$

where the survival bit $$S_i$$ for a given offspring is an effectively randomized selection from the set $$\{0, 1\}$$, given the environmental scenario in which the parent lived from birth to the spawning of an offspring $$E$$, and the probability of a phenotype $$P$$, which is a function of the set of genetic bits in the genotype $$G_i$$ (the bits in question), and the triggers $$T$$ of the expression of that genotype presented by both internal and external organism state.

Here is where the authors clearly diverge from what is known about the genetic machinery in the context of adaptation of a species.

We can use both 101001101011 and 0.9534 to represent an individual (or a chromosome); the former is called a genotype representation of an individual and the latter a phenotype representation of an individual.

The items that lead to the event is not a single real number but a set of discrete genotypes. To encode them as a real number is to obfuscate the discrete separations between multiple discrete genotypes that impact any given risk event, such as a lion, the attack of which can potentially eliminate the genotypes and the entire DNA strand of which they are a part. Neither a real number nor its digital approximation would be a straightforward and efficient representation of separate genetic characteristics that may impact a large number of genetic expressions, protein manufacturing runs, phenotypes, more continuous physical traits, and probabilistic advantages related to risks to the spawning of offspring.

Therefore, the confusion expressed in the question may be founded in a legitimate sense of a flaw in the logic of the presented material. Of course, that does not discount the possible expertise and legitimacy of other information presented in the same text.