refactor: reorganize optimizers into subfolders and migrate to uv#30
Merged
refactor: reorganize optimizers into subfolders and migrate to uv#30
Conversation
- Move 54 optimizer files into 7 categorical subfolders: - gradient_based/ (11): AdaDelta, AdaGrad, Adam, etc. - swarm_intelligence/ (12): PSO, ACO, Bat, Bee, etc. - evolutionary/ (6): GA, DE, CMA-ES, etc. - classical/ (9): BFGS, Nelder-Mead, etc. - metaheuristic/ (12): Harmony Search, etc. - constrained/ (2): Augmented Lagrangian, SLP - probabilistic/ (2): TPE, LDA - Add __init__.py with exports to each subfolder - Update root opt/__init__.py for backward compatibility - All existing imports still work (from opt import X)"
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes the useful-optimizer project by migrating from Poetry to uv for dependency management and reorganizing 54 optimizer files into 7 logical categorical subfolders. The changes improve project structure and add comprehensive testing.
Key changes:
- Migration from Poetry to uv with PEP 621-compliant
pyproject.tomlusing hatchling as the build backend - Reorganization of optimizers into categorical subdirectories (gradient_based, swarm_intelligence, evolutionary, classical, metaheuristic, constrained, probabilistic)
- Addition of 116 comprehensive tests covering optimizer instantiation, search functionality, and backward compatibility
Reviewed changes
Copilot reviewed 14 out of 70 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
New lock file replacing poetry.lock with uv dependency resolution |
pyproject.toml |
Converted to PEP 621 standard, migrated from Poetry to hatchling build backend |
poetry.lock |
Removed in favor of uv.lock |
opt/test/test_optimizers.py |
New comprehensive test suite with 116 tests for all optimizer categories |
opt/test/__init__.py |
Test module initialization |
opt/swarm_intelligence/*.py |
Moved swarm intelligence optimizers to subdirectory with 12 algorithms |
opt/probabilistic/*.py |
Moved probabilistic optimizers (LDA, ParzenTreeEstimator) to subdirectory |
opt/metaheuristic/*.py |
Moved metaheuristic optimizers to subdirectory with 12 algorithms |
opt/gradient_based/__init__.py |
New categorical module for gradient-based optimizers |
opt/evolutionary/__init__.py |
New categorical module for evolutionary algorithms |
Comment on lines
8
to
64
| from opt import BFGS | ||
| from opt import LBFGS | ||
| from opt import SGD | ||
| from opt import ADAGrad | ||
| from opt import ADAMOptimization | ||
| from opt import AMSGrad | ||
| from opt import AbstractOptimizer | ||
| from opt import AdaDelta | ||
| from opt import AdaMax | ||
| from opt import AdamW | ||
| from opt import AntColony | ||
| from opt import ArtificialFishSwarm | ||
| from opt import AugmentedLagrangian | ||
| from opt import CMAESAlgorithm | ||
| from opt import CatSwarmOptimization | ||
| from opt import CollidingBodiesOptimization | ||
| from opt import ConjugateGradient | ||
| from opt import CrossEntropyMethod | ||
| from opt import CuckooSearch | ||
| from opt import CulturalAlgorithm | ||
| from opt import DifferentialEvolution | ||
| from opt import EagleStrategy | ||
| from opt import EstimationOfDistributionAlgorithm | ||
| from opt import FireflyAlgorithm | ||
| from opt import GeneticAlgorithm | ||
| from opt import GlowwormSwarmOptimization | ||
| from opt import GreyWolfOptimizer | ||
| from opt import HarmonySearch | ||
| from opt import HillClimbing | ||
| from opt import ImperialistCompetitiveAlgorithm | ||
| from opt import LDAnalysis | ||
| from opt import Nadam | ||
| from opt import NelderMead | ||
| from opt import NesterovAcceleratedGradient | ||
| from opt import ParticleFilter | ||
| from opt import ParticleSwarm | ||
| from opt import ParzenTreeEstimator | ||
| from opt import Powell | ||
| from opt import RMSprop | ||
| from opt import SGDMomentum | ||
| from opt import ShuffledFrogLeapingAlgorithm | ||
| from opt import SimulatedAnnealing | ||
| from opt import SineCosineAlgorithm | ||
| from opt import SquirrelSearchAlgorithm | ||
| from opt import StochasticDiffusionSearch | ||
| from opt import StochasticFractalSearch | ||
| from opt import SuccessiveLinearProgramming | ||
| from opt import TabuSearch | ||
| from opt import TrustRegion | ||
| from opt import VariableDepthSearch | ||
| from opt import VariableNeighborhoodSearch | ||
| from opt import VeryLargeScaleNeighborhood | ||
| from opt import WhaleOptimizationAlgorithm | ||
| from opt.benchmark.functions import shifted_ackley | ||
| from opt.benchmark.functions import sphere | ||
|
|
||
|
|
There was a problem hiding this comment.
Import of 'BatAlgorithm' is not used.
Import of 'BeeAlgorithm' is not used.
Owner
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Contributor
…r BatAlgorithm and BeeAlgorithm Co-authored-by: Anselmoo <13209783+Anselmoo@users.noreply.github.com>
fix: resolve BeeAlgorithm typo and add missing test coverage for BatAlgorithm/BeeAlgorithm
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 modernizes the project structure and tooling:
🗂️ Reorganize Optimizers into Categorical Subfolders
Moved 54 optimizer files from flat
opt/directory into 7 logical categories:gradient_based/swarm_intelligence/evolutionary/classical/metaheuristic/constrained/probabilistic/Backward compatible - all existing imports still work:
📦 Migrate from Poetry to uv
pyproject.tomlto PEP 621 standardhatchlingas build backendpoetry.lockwithuv.lockNew commands:
🧪 Add Comprehensive Test Suite
Added
opt/test/test_optimizers.pywith 116 tests covering:🔄 CI/CD Updates
python-publish.yamlto useuv buildtests.yamlworkflow with:Other Changes
.pre-commit-config.yamlwith latest versionsANN101lint ignore__all__exportsTesting
uv sync uv run pytest opt/test/ -v # 116 passed ✅