MilesCranmer commited on
Commit
399aef5
1 Parent(s): 0d82add

Add subtraction operator

Browse files
Files changed (4) hide show
  1. TODO.md +3 -0
  2. docs/operators.md +1 -1
  3. julia/operators.jl +1 -0
  4. pysr/sr.py +1 -0
TODO.md CHANGED
@@ -78,6 +78,8 @@
78
 
79
  ## Algorithmic performance ideas:
80
 
 
 
81
  - [ ] Idea: use gradient of equation with respect to each operator (perhaps simply add to each operator) to tell which part is the most "sensitive" to changes. Then, perhaps insert/delete/mutate on that part of the tree?
82
  - [ ] Start populations staggered; so that there is more frequent printing (and pops that start a bit later get hall of fame already)?
83
  - [ ] Consider adding mutation for constant<->variable
@@ -93,6 +95,7 @@
93
 
94
  ## Code performance ideas:
95
 
 
96
  - [ ] Try defining a binary tree as an array, rather than a linked list. See https://stackoverflow.com/a/6384714/2689923
97
  - [ ] Add true multi-node processing, with MPI, or just file sharing. Multiple populations per core.
98
  - Ongoing in cluster branch
 
78
 
79
  ## Algorithmic performance ideas:
80
 
81
+ - [ ] When doing equation warmup, only migrate those equations with almost the same complexity. Rather than having to consider simple equations later in the game.
82
+ - [ ] Right now we only update the score based on some. Need to update score based on entire data! Note that optimizer only is used sometimes.
83
  - [ ] Idea: use gradient of equation with respect to each operator (perhaps simply add to each operator) to tell which part is the most "sensitive" to changes. Then, perhaps insert/delete/mutate on that part of the tree?
84
  - [ ] Start populations staggered; so that there is more frequent printing (and pops that start a bit later get hall of fame already)?
85
  - [ ] Consider adding mutation for constant<->variable
 
95
 
96
  ## Code performance ideas:
97
 
98
+ - [ ] How hard is it to turn the recursive array evaluation into a for loop?
99
  - [ ] Try defining a binary tree as an array, rather than a linked list. See https://stackoverflow.com/a/6384714/2689923
100
  - [ ] Add true multi-node processing, with MPI, or just file sharing. Multiple populations per core.
101
  - Ongoing in cluster branch
docs/operators.md CHANGED
@@ -8,7 +8,7 @@ of these and other valid operators are stated below.
8
 
9
  **Binary**
10
 
11
- `plus`, `mult`, `pow`, `div`, `greater`, `mod`, `beta`, `logical_or`,
12
  `logical_and`
13
 
14
  **Unary**
 
8
 
9
  **Binary**
10
 
11
+ `plus`, `sub`, `mult`, `pow`, `div`, `greater`, `mod`, `beta`, `logical_or`,
12
  `logical_and`
13
 
14
  **Unary**
julia/operators.jl CHANGED
@@ -2,6 +2,7 @@ import SpecialFunctions: gamma, lgamma, erf, erfc, beta
2
 
3
  # Define allowed operators. Any julia operator can also be used.
4
  plus(x::Float32, y::Float32)::Float32 = x+y #Do not change the name of this operator.
 
5
  mult(x::Float32, y::Float32)::Float32 = x*y #Do not change the name of this operator.
6
  pow(x::Float32, y::Float32)::Float32 = sign(x)*abs(x)^y
7
  div(x::Float32, y::Float32)::Float32 = x/y
 
2
 
3
  # Define allowed operators. Any julia operator can also be used.
4
  plus(x::Float32, y::Float32)::Float32 = x+y #Do not change the name of this operator.
5
+ sub(x::Float32, y::Float32)::Float32 = x-y #Do not change the name of this operator.
6
  mult(x::Float32, y::Float32)::Float32 = x*y #Do not change the name of this operator.
7
  pow(x::Float32, y::Float32)::Float32 = sign(x)*abs(x)^y
8
  div(x::Float32, y::Float32)::Float32 = x/y
pysr/sr.py CHANGED
@@ -17,6 +17,7 @@ sympy_mappings = {
17
  'div': lambda x, y : x/y,
18
  'mult': lambda x, y : x*y,
19
  'plus': lambda x, y : x + y,
 
20
  'neg': lambda x : -x,
21
  'pow': lambda x, y : sympy.sign(x)*abs(x)**y,
22
  'cos': lambda x : sympy.cos(x),
 
17
  'div': lambda x, y : x/y,
18
  'mult': lambda x, y : x*y,
19
  'plus': lambda x, y : x + y,
20
+ 'sub': lambda x, y : x - y,
21
  'neg': lambda x : -x,
22
  'pow': lambda x, y : sympy.sign(x)*abs(x)**y,
23
  'cos': lambda x : sympy.cos(x),