Ejemplos de Vida. Words and Phrases

Author of the program: Manuel de la Herrán Gascón

Words and Phrases

Note important: If the phrase that it is there is of to seek possess words that not exist in the diccionario, it is introducirán automatically in he, of form that any word, though it will be inventada, always will exist in the diccionario.

This is a Algorithm Genetic where it is try of to guess a phrase that there is introduced the user.

The Algorithm Genetic is the commissioned of to propose different phrases as solution to the problem. A Function of Evaluation will direct the evolution of the population of phrases. For this, The Function of Evaluation will say until what point is correct a phrase, is to say, evaluates the usefulness of the entity. In this case, the kindness of a phrase it is calculate comparando each word with the word corresponding in the phrase sought, according to its position.

With a function of evaluation thus, the only usefulness of this algorithm is to illustrate the operation of the AG. Without embargo, this same code it is there is reutilizado for to accomplish a prototype of a product comercial, in a problem real. The prototype it is desarrolló in only 2 given, accomplishing small changes in the types of data handled and sustituyendo the Function of Evaluation for other that was reflecting the problem concrete that it is was wanting to solve.

Us we referred to the phrases as entities or agents. Also it is you flame chains, standards, solutions, insects, population or beings live artificial. In the nature, a genotipo is the information genetic that to the it be developed create a fenotipo or be live. When this distinction not exist, also it is speech of genotipo, fenotipo or cromosomas.

Palabras y Frases

In the program, the Function of Evaluation returns a value between 0 and 1. To this number it is to him flame weight. The 1 indicate that it is there is succeeded the phrase completes. A weight 0.5 is sign of that it is they have guessed the half of the words that compose the phrase.

The Algorithm Genetic operate of the following form. In first place, it is generate several phrases to the random, for example, 40 phrases, combining words taken aleatoriamente of a dicciónario.

After it is evaluate these phrases through the Function of Evaluation. In many phrases not it is there is succeeded no word, and will will have a weight 0. Other, in change, they could have succeeded in some and will will have weights more high: 0.1, 0.2, ...

Now it is order the phrases of greater to smaller weight and it is eliminate the of smaller weight. For example, "survive" the 20 first and "dies" the rest.

Is the moment of the reproduction. The 20 phrases that remain it is combine between yes, mixing the words that the compose and generating new phrases. For example, we take phrases of two in two and we generate, for each couple, other new couple of phrases with the words of a and other intercalated.

To the have combined phrases of weights high, is very probable that emerge phrases still more nearby to the solution. Now it is return to to evaluate, to order and to reproduce, repitiéndose the cycle until to find the phrase sought.

But in a algorithm genetic exist other component. If in the joint initial of 40 phrases not exist the words that compose the phrase sought, for many combinations that we make, never we will arrive to the solution. Is necessary power to take words new of time in when.

For this, to the to generate new phrases, it is will permit that, with a certain probability, the word it is take to the random of the dicciónario and not of its progenitors. To this value it is to him flame rate of mutation.

In the program, a rate of mutation negative mean that not it is will effect mutations, and it is puede to observe how the algorithm converge until certain value that not puede to surpass.

A rate of mutation 0 ó 1 indicate that exist mutation always, or it that is it same, that not exist reproduction as such, only search to the random. The characteristic of the parents not it is transmit to the children, and the algorithm convergerá very slowly.

It customary is to use values as 5 or 10 (a mutation each 5 or each 10 generations) and thus the algorithm convergerá much more rapid toward the solution sought.

A Algorithm Genetic try of to explore the regions more promising of a huge space of possibilities. To the to find a zone with weights high, this it is explore more to fund. But there is that to avoid that the algorithm it is reservoir in a determined zone.

The increase of variety it is procures with the mutations, but this not tend to suffice.

Other options that permit the program for to increase the variety they are:

- A solution is seleccionar a great number of agents, for to avoid that a small group repeats its characteristic in a great population. Case To)

- Selecciónar, furthermore of the population with greater weight, a fraction of the of smaller weight. Case D)

- Also it is there is of to procure that, to the hour of the reproduction, the progenitors it is take to the random and not in order of weights, already that is more probable that phrases of weights seemed possess words similar. (Election of parents to the random)

- To make that if it is reproduce two chains equal, the children they will be mutations in all its elements (Parents identical produce mutations)

- Also we can to generate blasts of mutations: in time of to establish a probability of mutation independent for each creation of a word, we can to make that if it is produces a mutation in a element, the following element has a probability of mutation greater. (Frequency of mutation accumulated)

Other aspects to to have in account they are:

- We work with random, and a alone execution not is very meaningful

- Puede have options that "logically" they will be better, already that reduce the number of cycles necessary for to arrive to the weight maximum, but that in the practical not they are profitable for the increase of the time of process had to to the complexity of the calculations.

- The size of the population is constant and puede be 40, 80, 160 ó 320. The number of births is equal to the of deaths.

- The i number maximo of words of the dicciónario is 2086.

- The phrase to to seek is of a length maximum of 1000 words.

- For it be reproduced, it is take always two phrases as progenitors.

- In each birth born the number of phrases necessary for that the population it is maintain constant.

- Is possible that a phrase not dies never. The phrases seleccionadas not alone it is reproduce, but that furthermore not die.

[Back to Index]

To download source code

This program and its files source they are free of charge and of free distribution. The code source it is available and puede be modified, distributed, or used in other programs with deposit freedom.

For to obtain the last version of the program, for to suggest possible amplifications, if it is detected some mistake in the programming or if wish to communicate that it is is going to to widen or to use a part or all this program, not doubt in it be put in contact with the author in the address: E-mail

Click here for to download source code.
¡You are guest to to hold, criticize and collaborate with your ideas!
Send your commentaries, questions, suggestions, or criticize to to the following address:

[Back to Index]

[ Home Page Spanish | Home Page English ]
The software of Gaia is free, sources available. There is not
commercial interests, only to research and amusement.
You can send your suggestions about
the face of the web or its contents to the E-mail