Closed MilesCranmer closed 1 year ago
Could it be that some of the default simplification rules assume that an expression is already in simplified polynomial form?
@YingboMa @shashi would one of you be willing to look into this? This issue is preventing me from upgrading my SymbolicUtils.jl version for SymbolicRegression.jl
@YingboMa @shashi sorry for the spam but just wanted to ping this as it is still blocking me from upgrading. Please let me know if there's anything at all I can do to help debug this. Thanks! - Miles
Hey sorry, yes I will look at this now.
Thanks!!
Pinging this. Anything I can help with?
Hm, still some infinite loops somewhere @shashi. I would leave this issue open if that's okay?
I don't have an MWE I can show you yet, but something in the following expression is freezing up the simplification, whereas with version < 1.0.0
, it works fine (this expression is in the DynamicExpressions.jl test)
pow_abs(x, y) = abs(x)^y
custom_cos(x) = cos(x)^2
tree = (
((x2 + x2) * ((-0.5982493 / pow_abs(x1, x2)) / -0.54734415)) + (
sin(
custom_cos(
sin(1.2926733 - 1.6606787) /
sin(((0.14577048 * x1) + ((0.111149654 + x1) - -0.8298334)) - -1.2071426),
) * (custom_cos(x3 - 2.3201916) + ((x1 - (x1 * x2)) / x2)),
) / (0.14854191 - ((custom_cos(x2) * -1.6047639) - 0.023943262))
)
)
This also simplifies fine with normal symbols; it's just LiteralReal that breaks.
Maybe there should be a unit test that does a brute force search over expression trees, and sees if they hit an infinite loop or not?
Okay, here is a MWE:
@syms x1::LiteralReal
simplify(sin((0.14577048 * x1) + ((0.111149654 + x1) - -0.8298334)))
this hangs indefinitely. If you point out where I could debug this I'd be happy to help, so I can merge the update faster
That does not hang for me on v1.0.3...
It's hanging for me on that version. Here's a video of what I am seeing: https://asciinema.org/a/576406 (I manually stop it after 2 minutes).
Maybe I'm just not waiting long enough?
Here's my versioninfo in case that is relevant:
Julia Version 1.9.0-rc2
Commit 72aec423c2a (2023-04-01 10:41 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin21.3.0)
CPU: 8 × Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
Threads: 6 on 6 virtual cores
Environment:
JULIA_NUM_THREADS = auto
Thanks! I might have been on a branch and it was showing me v1.0.3, did you try it on master of SymbolicUtils?
Sweet!! v1.0.4 worked. Thanks!!
*master worked; I think the v1.0.4 on the registry still has the issue
Yes, that's right. I see a CI failure from an unrelated PR, will fix and release.
The following code hits an infinite loop:
On v1, this code hangs on the
simplify(s)
and hasn't completed in 30 minutes. This works on v0.19.Defining
@syms x1 x2
works (auto-simplifies).When I interrupt the simplification, this is the stacktrace (it changes every time I interrupt it):