kstaats / karoo_gp

A Genetic Programming platform for Python with TensorFlow for wicked-fast CPU and GPU support.
Other
157 stars 61 forks source link

Latest KarooGP Issues #81

Open asksak opened 2 years ago

asksak commented 2 years ago

Hello Kai,

I tested the latest version of KarooGP. It seems it runs for arithmetic operators only at the moment, however, slick and fast as never before. Brilliant progress. Math and Logic are not supported as far as my test shows.

Now, as I have already converted the original KarooGP to work with all operators, I suggest the following:

1. For logical operators I used this:

ifgreaterthan(a,b)

This is mapped to tf.math.greater, otherwise order of operations does not work in sympify as it does sporadic evaluations even when EVALUATE is set to FALSE.

2. For arithmetic and math operators I used one of two:

addK(a,b) etc... where addK is a string that tensorflow is set to map it to tf.math.add or a+b

both work fine, but the first works flawlessly. Something to think about.

3. For Logical evaluations:

Since the result of a full logical tree will be 1 or 0, the fastest way was to cast the final result of the evaluation to float, so I did not have to modify anything else in the code.

In fx_fitness_node_parse #Do this

elif isinstance(node, ast.Call):

print("()")

        return tf.cast(operators[node.func.id](*[self.fx_fitness_node_parse(arg, tensors) for arg in node.args]), tf.float32)

NOTE: My version of KarooGP works flawlessly with all operators including logic, however, long equations with brackets take forever to crossover. Therefore, the current development process is clearly overcoming the biggest problem.

I hope the team get some good insight into some possible options.

Best,

Aymen