From afc4931f58620a2e9fca0c229557d068551a554f Mon Sep 17 00:00:00 2001 From: WrathfulSpatula Date: Sat, 18 Jan 2025 17:56:50 -0500 Subject: [PATCH] Set batch_size_variance low as is effective --- FindAFactor/find_a_factor.py | 2 +- README.md | 6 +++--- find_a_factor | 2 +- pyproject.toml | 2 +- setup.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FindAFactor/find_a_factor.py b/FindAFactor/find_a_factor.py index 6acaf26..80cce56 100644 --- a/FindAFactor/find_a_factor.py +++ b/FindAFactor/find_a_factor.py @@ -18,7 +18,7 @@ def find_a_factor(n, wheel_factorization_level=int(os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL') else 11, smoothness_bound_multiplier=float(os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER')) if os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER') else 1.0, batch_size_multiplier=float(os.environ.get('FINDAFACTOR_BATCH_SIZE_MULTIPLIER')) if os.environ.get('FINDAFACTOR_BATCH_SIZE_MULTIPLIER') else 256.0, - batch_size_variance=int(os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE')) if os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE') else 3, + batch_size_variance=int(os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE')) if os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE') else 2, ladder_multiple=int(os.environ.get('FINDAFACTOR_LADDER_MULTIPLE')) if os.environ.get('FINDAFACTOR_LADDER_MULTIPLE') else 5): return int(_find_a_factor._find_a_factor(str(n), int(method), diff --git a/README.md b/README.md index f29b442..749af97 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ factor = find_a_factor( wheel_factorization_level=11, smoothness_bound_multiplier=1.0, batch_size_multiplier=256.0, - batch_size_variance=3, + batch_size_variance=2, ladder_multiple=5 ) ``` @@ -49,8 +49,8 @@ The `find_a_factor()` function should return any nontrivial factor of `to_factor - `wheel_factorization_level` (default value: `11`): "Wheel" vs. "gear" factorization balances two types of factorization wheel ("wheel" vs. "gear" design) that often work best when the "wheel" is only a few prime number levels lower than gear factorization. Optimized implementation for wheels is only available up to `13`. The primes above "wheel" level, up to "gear" level, are the primes used specifically for "gear" factorization. - `smoothness_bound_multiplier` (default value: `1.0`): starting with the first prime number after wheel factorization, the congruence of squares approach (with Quadratic Sieve) has a "smoothness bound" unit with as many distinct prime numbers as bits in the number to factor (for argument of `1.0` multiplier). To increase or decrease this number, consider it multiplied by the value of `smoothness_bound_multiplier`. - `batch_size_multiplier` (default value: `256.0`): For `FACTOR_FINDER`/`1` method, each `1.0` increment of the multiplier adds `k ln k` Markov mixing replacement steps for `k` count of smooth primes, before reseeding Monte Carlo. -- `batch_size_variance` (default value: `3`): For `FACTOR_FINDER`/`1` method, `k ln k` is the right proportionality for a Markov mixing process, but a linear factor in front is hard to predict. As such, it can be useful to dynamically vary the batch size, as if to cover and amortize the cost of several different batch sizes at once. In sequence, each batch size will be multiplied by `2 ** i` for `i` in `range(batch_size_variance)`, repeating from `0`. -- `ladder_multiple` (default value: `5`): Controls how many times randomly-selected square prime multiplication is repeated with the same square prime per random selection, in ascending a "ladder" of smooth perfect squares. (Any smooth perfect square can be multiplied by any square prime in the factor base, or any other smooth perfect square, and produce a different smooth perfect square.) +- `batch_size_variance` (default value: `2`): For `FACTOR_FINDER`/`1` method, `k ln k` is the right proportionality for a Markov mixing process, but a linear factor in front is hard to predict. As such, it can be useful to dynamically vary the batch size, as if to cover and amortize the cost of several different batch sizes at once. In sequence, each batch size will be multiplied by `2 ** i` for `i` in `range(batch_size_variance)`, repeating from `0`. +- `ladder_multiple` (default value: `5`): Controls how many times randomly-selected square prime multiplication is repeated with the same square prime per random selection, in ascending a "ladder" of smooth perfect squares, while division still occurs 1 square prime multiple at a time. (Any smooth perfect square can be multiplied by any square prime in the factor base, or any other smooth perfect square, and produce a different smooth perfect square.) All variables defaults can also be controlled by environment variables: - `FINDAFACTOR_METHOD` (integer value) diff --git a/find_a_factor b/find_a_factor index d6681b3..74f8215 100755 --- a/find_a_factor +++ b/find_a_factor @@ -22,7 +22,7 @@ def main(): wheel_factorization_level = int(os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL') else 11 smoothness_bound_multiplier = float(os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER')) if os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER') else 1.0 batch_size_multiplier=float(os.environ.get('FINDAFACTOR_BATCH_SIZE_MULTIPLIER')) if os.environ.get('FINDAFACTOR_BATCH_SIZE_MULTIPLIER') else 256.0 - batch_size_variance=int(os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE')) if os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE') else 3 + batch_size_variance=int(os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE')) if os.environ.get('FINDAFACTOR_BATCH_SIZE_VARIANCE') else 2 ladder_multiple=int(os.environ.get('FINDAFACTOR_LADDER_MULTIPLE')) if os.environ.get('FINDAFACTOR_LADDER_MULTIPLE') else 5 if argv_len > 2: diff --git a/pyproject.toml b/pyproject.toml index 6eec9f9..a525eaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "FindAFactor" -version = "4.7.6" +version = "4.7.7" requires-python = ">=3.8" description = "Find any nontrivial factor of a number" readme = {file = "README.txt", content-type = "text/markdown"} diff --git a/setup.py b/setup.py index 75372bf..8cc34de 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def build_extension(self, ext): setup( name='FindAFactor', - version='4.7.6', + version='4.7.7', author='Dan Strano', author_email='stranoj@gmail.com', description='Find any nontrivial factor of a number',