So, over the next posts I'll show you the code for all these new functions in all the built-in programming languages of GeneXproTools. I'll be using GeneXproTools itself to generate the code automatically using a neat trick to write the code of all the new functions at the same time (more about this trick in a moment, which, by the way, comes in handy to anyone designing their own custom grammars.)
Overall, we've ended up with 39 new math functions! These functions include not only the new classifier functions we've been talking about, but also new Step and Ramp functions of one argument that complement nicely this new set of discrete functions.
The neat trick consists of creating a Karva program by hand (through the Change Seed Window) that includes all the new 39 functions. As an illustration I'm including here a much simpler program with just 3 functions, namely the 3-output classifier functions described in the posts "Function Design: The BUY-SELL-WAIT Function" and "Function Design: More 3-Output Classifier Functions":
from math import *
y = 0.0
y = gepCL3A(d,d)
y = y + gepCL3B(d,d)
y = y + gepCL3C(d,d)
def gepCL3A(x, y):
if ((x > 0.0) and (y < 0.0)):
elif ((x < 0.0) and (y > 0.0)):
def gepCL3B(x, y):
if ((x >= 1.0) and (y >= 1.0)):
elif ((x <= -1.0) and (y <= -1.0)):
def gepCL3C(x, y):
if ((x > 0.0) and (y > 0.0)):
elif ((x < 0.0) and (y < 0.0)):
As you can see in this simple Python code, I'm using a different gene to encode a different function. So, here in this simple example, I'm using 3 genes to encode 3 different functions. To show all the 39 new functions I'll have to use a total of 39 such simple genes with a head size of 1. And I can use the same Karva program again and again to generate the code for all these new functions in all the programming languages of GeneXproTools (I had of course to program them first, but now it's easy; this is also useful to check for bugs when you’re creating a Custom Grammar).
There are currently no comments on this article.