Open arungiridhar opened 1 year ago
probabalistic finding of factors of large numbers will not yield consistent times. You can read to see if there are options that can be supplied to a given method to ensure that it always takes the same time, but is your goal factorization or consistent time in finding the factorization?
Both. It's acceptable for two similar but different inputs to take very different times, but it would be nice if the same input at least took the same time each time. Is it feasible for SymPy to use a deterministic sequence of divisors in Pollard Rho?
ecm uses rgen = random.Random()
; it should be using the sympy-seeded generator, as I recall. And within factor_.py
there are instantiations like prng = random.Random(seed + retries)
which might be ok since they always use the same seed. primefactors
should really accept keywords and pass those to factorint
. Since it doesn't, call factorint
directly (or write your own version of primefactors
) and pass use_ecm=False
(and a smaller prime to test) and the times will all be about the same. With ecm
times to factor 11111111111111111111111111111111111111111111111111
ranged from 0.2 to 3.6; without ecm
the times were all about 17 seconds.
I wonder if we should implement some retrying in case it gets stuck on a bad seed. We would need some rough estimate of how long a given value should take.
I wonder if we should implement some retrying in case it gets stuck on a bad seed.
Is it about _ecm_one_factor
or ecm
? Each trial ends with a max_curve
trial, although there is an element of luck since the sigma
is chosen at random.
Greetings.
Integer factorization using code such as this:
takes very different runtimes for each call. One user reports runtimes of:
seconds, all on the same computer and another user reports:
seconds on a different computer.
(Originally discussed and localized here: https://octave.discourse.group/t/symbolic-pkg-has-a-strange-delay/4611/11)
It would be nice if SymPy could return the same runtime for the same input.