Generating Code Automatically

Endogenous Karva Code
 
Karva code is the native language of Gene Expression Programming (GEP), the algorithm used by GeneXproTools 4.0 to create complex and accurate models.

To see your model in Karva notation, on the GeneXproTools modeling environment, select the Model Panel, and then, on the Language list box, select Karva.

And by choosing K-expressions in the Language list box, GeneXproTools shows you only the elements that are part of the model. In both cases, either Genes or K-expressions, the head elements are shown in blue.

Karva notation was developed specifically for Gene Expression Programming and consists of a universal way of representing any mathematical or logical expression that can be represented as a tree. Here we are going to present it briefly, but you can learn more about it in the chapter The Architectures of GeneXproTools Learning Algorithms.

The chromosomes of Gene Expression Programming code for one or more K-expressions (from Karva notation), and each K-expression is encoded in a gene. Genes and K-expressions are very easy to interpret. For example, the gene:

0123456
+/*abcd

can be represented as a diagram or expression tree (ET):

The translation of a gene into its corresponding ET is straightforward: The first element in the gene (position 0) corresponds to the root of the ET; then, below that node, are attached as many nodes as there are arguments to that function (two, in this case); then these nodes are filled consecutively with the elements in the gene (in this case, positions 1 and 2), and so forth. The process is repeated until a line composed of only terminals is formed (in this case, the third line).

More formally, the gene and ET above can be represented by the expression:

Usually the genes evolved by GEP are more complex than the gene presented above, with noncoding regions at the end. Consider the following gene (the head is shown in blue):

01234567890123456
Q/a*+b-cbabaccbac

where “Q” represents the square root function. This gene has a head of length 8 and a tail of length 9. Note that the head contains both functions and terminals, whereas the tail contains exclusively terminals. The translation of such genes is done exactly as in the previous example, obtaining:

Note that, in this case, not all the elements in the gene were used to construct the ET, as the translation ends whenever a line containing only terminals is formed. In this case, the gene ends at position 16 whereas the K-expression ends at position 9.

Furthermore, GEP chromosomes are usually multigenic, and each gene codes for a sub-ET or sub-program. After translation, the sub-ETs are linked by a particular linking function: addition, subtraction, multiplication, or division for all kinds of mathematical models and And, Or, Nand, Nor, Xor, Nxor, Less Than, Greater Than, Less Or Equal, or Greater Or Equal for logical expressions.

For example, the following chromosome composed of three genes (position 0 indicates the beginning of each gene):

012345678012345678012345678
*aQ+abbaa/Q*/aababa*+Qaabba

encodes the following sub-ETs:

Then the sub-ETs are afterwards linked by one of the available linking functions. For instance, if the linking function were addition, then the following program would be obtained:

   Linking Function

Note that the ET above can be easily linearized into a single K-expression:

01234567890123456
++a*/aQQ*+/aaabba

These manipulations are important in order to fully explore all the GeneXproTools features, especially the Change Seed method, which allows you to change or create a particular program and then use this program to breed even better programs.

Obviously you’ll need to be familiar with the symbols used to represent all the 278 built-in mathematical functions and the 258 built-in logical functions of GeneXproTools 4.0 in Karva if you wish to create seed programs with them. But they are quite easy to learn as most of the times their names obey common rules of naming mathematical/logical functions in programming languages.

So, GeneXproTools 4.0 evolves models in its native Karva code, but the models evolved by GeneXproTools in its native language can be automatically parsed into visually appealing expression trees, allowing a quicker and more complete understanding of their mathematical/logical intricacies.

Additionally, GeneXproTools 4.0 offers a total of 16 built-in grammars so that the models evolved by GeneXproTools in its native language can be automatically translated into the most commonly used programming languages (Ada, C, C++, C#, Fortran, Java, Java Script, Matlab, Pascal, Perl, PHP, Python, Visual Basic, VB.Net, Verilog, and VHDL). This code can then be used in other applications.

And finally, GeneXproTools 4.0 allows also the design of User Defined Grammars so that the models evolved by GeneXproTools in its native language can be automatically translated into the programming language of your choice if you happen to prefer a programming language not already covered by the 16 built-in grammars of GeneXproTools 4.0 (Ada, C, C++, C#, Fortran, Java, Java Script, Matlab, Pascal, Perl, PHP, Python, Visual Basic, VB.Net, Verilog, and VHDL).

Home | Contents | Previous | Next