Comments (5)
The code assumes that binary operators are infix. No prefix binary operator is handled correctly, viz., 'atan2(a,b)', 'pow(a,b)'. While atan2 is noted as "NOT supported at this time" in file operators_list.txt, we do not so denote pow.
- I propose to add 'pow(a,b)' to the "NOT supported" list, with a parenthetical note that the infix form (a**b) is supported.
Additionally, 'pow' appears twice in the set 'operators' in base_class.py, first as "ast.Pow: tf.pow, # e.g., a ** 2", and later as "'pow': tf.pow, # e.g., pow(a, b)".
- I propose striking the latter.
Hello,
a^b is a good idea, I've been looking for operators to add.
Will do it and post the method.
Regards
Aymen
from karoo_gp.
from karoo_gp.
No, I do not, but the suggestion I made above is a two line fix.
I have not heard from Asksak, so I don't know if he has anything.
from karoo_gp.
No, I do not, but the suggestion I made above is a two line fix.
I have not heard from Asksak, so I don't know if he has anything.
Hello,
The first (pow) is ** in operators and is x^2, while the second (pow) is pow in operators which is a^b so I did this in labels:
def fx_eval_label(self, tree, node_id):
'''
Evaluate all or part of a Tree (starting at node_id) and return a raw mutivariate expression ('algo_raw').
This method is called once per Tree, but may be called at any time to prepare an expression for any full or
partial (branch) Tree contained in 'population'. Pass the starting node for recursion via the local variable
'node_id' where the local variable 'tree' is a copy of the Tree you desire to evaluate.
Called by: fx_eval_poly, fx_eval_label (recursively)
Arguments required: tree, node_id
'''
# if tree[6, node_id] == 'not': tree[6, node_id] = ', not' # temp until this can be fixed at data_load
node_id = int(node_id)
if tree[8, node_id] == '0': # arity of 0 for the pattern '[term]'
return tree[6, node_id] # 'node_label' (function or terminal)
else:
if tree[8, node_id] == '1': # arity of 1 for the explicit pattern 'not [term]'
return tree[6, node_id] + self.fx_eval_label(tree, tree[9, node_id]) # rll 20210201
elif tree[8, node_id] == '2': # arity of 2 for the pattern '[func] [term] [func]'
if tree[6, node_id] == 'min':
return tree[6, node_id] + self.fx_eval_label(tree, tree[9, node_id]) + self.fx_eval_label(tree, tree[10, node_id]) #asksak
if tree[6, node_id] == 'max':
return tree[6, node_id] + self.fx_eval_label(tree, tree[9, node_id]) + self.fx_eval_label(tree, tree[10, node_id]) #asksak
if tree[6, node_id] == 'pow':
return tree[6, node_id] + self.fx_eval_label(tree, tree[9, node_id]) + self.fx_eval_label(tree, tree[10, node_id]) #asksak, could combine all three lines with OR
else:
return self.fx_eval_label(tree, tree[9, node_id]) + tree[6, node_id] + self.fx_eval_label(tree, tree[10, node_id]) #asksak
elif tree[8, node_id] == '3': # arity of 3 for the explicit pattern 'if [term] then [term] else [term]'
# This fails in sympify. rll 20210206
#This needs a new set of code. #asksak
return tree[6, node_id] + self.fx_eval_label(tree, tree[9, node_id]) + ' then ' + self.fx_eval_label(tree, tree[10, node_id]) + ' else ' + self.fx_eval_label(tree, tree[11, node_id])
Note THE ARITY:
operator, arity
+,2
-,2
*,2
/,2
**,2
min,2
max,2
pow,2
sqrt,1
abs,1
log,1
cos,1
sin,1
exp,1
expm1,1
I will add all the code when I learn where and how to upload on GitHub.
As a side note (so far)
- I added min, max
- I fixed arity
- I modified fx_eval_label for compatibility
- I added dynamic mutation and standard mutation, both selectable at program startup
- I optimized memory utilization of the program (collected garbage)
- I optimized variable assignment
- I optimized loops
- I removed all '(' and ',' from fx_eval_label which I had added but turned out to interfere with sympy, kstaats version was better.
- I tested all the above with known test functions and all results solved in a few generations.
Will update u soon
from karoo_gp.
from karoo_gp.
Related Issues (20)
- Redo Tensorflow Comparison properly (CPU vs GPU)
- Conditionals and Logical Operators HOT 1
- Sporadic `ERROR! In fx_evolve_grow_mutate: branch_depth -1 < 0` HOT 6
- Add a machine-parsable `log_test.json` HOT 1
- Tensorflow v2 behaviour HOT 2
- tf.map_fn in population.py problem HOT 2
- Tensorflow meta-issue HOT 13
- Error HOT 9
- Tree Error! HOT 1
- Latest KarooGP Issues
- Functions that produce nan/inf values HOT 7
- Use joblib to use multithreading/multiprocessing computing
- Use ncurses for display HOT 1
- Switch tree navigation from breadth-first to depth-first HOT 3
- Logic & Comparison HOT 3
- Error HOT 6
- Karoo 3.0 meta-issue HOT 2
- Sympy & Numpy Issue HOT 3
- Fittest tree issue HOT 4
- TypeError: '<' not supported between instances of 'GreaterThan' and 'GreaterThan' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karoo_gp.