fix + feat: resolve 10 stale issues in a single PR - #32
Merged
Conversation
…gence All stopping-search print statements now respect the debug flag so that debug=False (the default) produces no output at all (closes #20). A new patience parameter (default 0, meaning disabled) counts consecutive iterations without improvement and stops the search when that count reaches patience. This lets callers avoid needless iterations when the swarm has converged to an exact optimum where fp[i_min] == fg indefinitely (closes #22). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Accept bounds as a list of (lo, hi) pairs in addition to the existing separate lb and ub arrays, matching the convention used by scipy.optimize. When bounds is provided it takes precedence; lb and ub may be omitted. Fully backwards-compatible — existing callers using lb/ub are unaffected. Closes #5, closes #6. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Callers can now pass any object with a map() method (multiprocessing.Pool, ipyparallel, dask, etc.) via the pool keyword argument. When pool is given, processes is ignored and the caller manages the pool lifecycle. When the library creates its own pool (processes > 1, pool=None) it now correctly terminates and joins it via try/finally, fixing the silent resource leak in the original implementation where the pool was never closed. Closes #12, closes #16. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Users can now seed the swarm with known good starting points by passing an (swarmsize × ndim) array via the init keyword argument. This is useful for warm-starting from a previous run or for incorporating domain knowledge about where good solutions are likely to lie. Out-of-bounds values are silently clipped to [lb, ub]. Closes #21. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pass a list of dimension indices via intvar to constrain those variables to integer values. After each position update (and on initial placement) the selected dimensions are rounded to the nearest integer and clipped to [lb, ub]. This enables mixed-integer PSO without changing the continuous variables. Closes #14, closes #17. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
This PR addresses the concrete, solvable problems from the backlog of closed stale issues and PRs. Each commit is self-contained and references the original issue(s) it closes.
1c93b1edebug; addpatienceparam for plateau early-stopd221828boundsparameter (backwards-compatible)1943564poolparameter; fix resource leak (pool was never closed)c048faainitparameter for warm-start / fixed initial positions50a9a42intvarparameter for mixed-integer PSODecisions / trade-offs
patience(issue “minfunc ”convergence check misses equal objective values #22): Apatience=0default means the old plateau-ignoring behaviour is preserved. Settingpatience=Nstops after N consecutive non-improving iterations — this is the clean, composable fix vs. silently changingminfuncsemantics.bounds(issues Scipy style bounds #5/scipy style bounds (replacement for list of lower and upper bounds) #6):lb/ubare now optional keyword args; callers using positional args are unaffected.pool(PRs Implement custom pool object in order to allow clustered computing #12/Accept pool argument, instead of instantiating multiprocessing #16): When the caller supplies a pool we never touch its lifecycle. When we create one internally (processes > 1) we now correctly terminate/join it viatry/finally, fixing the silent resource leak in the original code.intvar(issues New generation with only integer numbers #14/Problems with integer and float decision variables #17): Rounding happens after both initial placement and each bound-correction step; values are clipped to[lb[i], ub[i]]so they stay in range.Test plan
uv run pytest tests/ -v)uv run ruff check pyswarm/pso.py)🤖 Generated with Claude Code