-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplifying constants in result or during search #128
Comments
Interesting question. I see two options: 1. Post-process expressions.You could do is use options = Options(
# Make constants prohibitively expensive:
complexity_of_constants=100,
unary_operators=(sqrt, square),
binary_operators=(+, *, /, -),
mutationWeights=[0.0, 0.47, 0.79, 5.1, 1.7, 0.0020, 0.00023, 0.21],
# ^ Set p(mutate_constant)=0.0
shouldOptimizeConstants=false,
# ^ Set constant optimization off (so we don't waste cycles)
parsimony=0.001,
)
# Integers from 1 to 10:
X = reshape(collect(1.0:10.0), 10, 1)
y = [float(pi)]
EquationSearch(X, y; options=options, multithreading=true, niterations=1000) This gives me as output: You could do something similar for other constants you wish to include - you could also set 2. Search directly for integer/rationals.One option is to basically apply the solution 1., but use it for the search itself. (i.e., concatenate the constants/integers with the data features, at each row) More generally (say you want to include any integer), this is a bit tricky, especially because Right now, the library assumes that Another option is to implement a function function val(tree::Node{T})::Int
convert(Int, tree.val)
end and make it so that every time |
This comment was marked as off-topic.
This comment was marked as off-topic.
Hi @qwertyjl - I think this question is unrelated to the use of SymbolicRegression.jl/PySR - apologies but I do not have time to answer general math/science questions. |
I have used this package for a work-flow that is basically: Solve a differential equation (DE) using
DifferentialEquations.jl
and then giving that solution toSymbolicRegression.jl
to find the analytical expression. From the DE it is quite obvious that the resulting expression should only contain integers or rationals. The optimization that is carried out for constants in the expressions gets very close, but it would be nice if there was either:Is there such functionality already in
SymbolicRegression.jl
that I have missed, or would it be useful to have?Simple examples would be having solutions like
5.0000000002*x1
, or whatever, rounded to5.0 * x1
, more advanced being the rationals having0.200000002 * x2
fixed tox2 / 5.0
or similar, or more advanced stillsin(x1 * 0.31830988618454)
tosin(x1 / π)
. In SymPy there is a functionnsimplify
that can handle the numerical part of such functionality, and works quite well, e.g.but I don't know if there is a Julia package that does the same thing.
The text was updated successfully, but these errors were encountered: