-
Notifications
You must be signed in to change notification settings - Fork 65
Add optimization algorithms from GFO #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
7187a41
move gfo-opt-algos into gfo directory and add skeleton files for gfo …
SimonBlanke a9cecdf
rename opt. algos.
SimonBlanke 62e40aa
add test to gfo adapter
SimonBlanke 5ae1a35
add simulated annealing
SimonBlanke a0cf60a
remove unused file
SimonBlanke 4c9048d
add bayesian opt.
SimonBlanke 66e984c
search for test-files in src/hyperactive dir
SimonBlanke 172f516
add differential evolution
SimonBlanke 85857dc
reformat
SimonBlanke 4f8bf49
add direct algo.
SimonBlanke 2d68234
add downhill simplex algo.
SimonBlanke 0ac7c8e
add evolution strategy optimizer
SimonBlanke 2da33f9
add forest optimizer
SimonBlanke 28f86aa
add genetic algorithm optimizer
SimonBlanke 7d758f0
add grid search opt.
SimonBlanke fdd4dbf
add lipschitz optimizer
SimonBlanke ff23a3e
add parallel tempering optimizer
SimonBlanke d41fb3b
add particle swarm optimization
SimonBlanke 584cb27
add pattern search
SimonBlanke 7326172
add powell's method
SimonBlanke 5a8cac7
add random search
SimonBlanke 44aea0e
fix sim. ann. test para
SimonBlanke f833eef
add random rest. hill. climb. opt.
SimonBlanke 49210f2
add spiral opt.
SimonBlanke c7bb77f
add tpe optimizer
SimonBlanke fb74eb6
check_estimator
fkiraly edc33a9
check_estimator
fkiraly a480766
Merge branch 'check_estimator' into feature/add-gfo-algos
fkiraly 0b135be
Merge remote-tracking branch 'upstream/master' into feature/add-gfo-a…
fkiraly 0fdc7f0
add _tags
SimonBlanke f6a0bbd
add docstring examples
SimonBlanke 1eba3bb
add _tags to optimizers
SimonBlanke 7d74989
fix mutable default error
SimonBlanke b6bec07
fix another mutable default error
SimonBlanke d8b5168
check if key is in dict
SimonBlanke 540e4b6
fix syntax error in docstring example
SimonBlanke e87da4a
fix imports in docstring examples
SimonBlanke 9410d4d
fix examples (numpy.arrays to lists in search-space dict-values)
SimonBlanke 4bab535
move from base
fkiraly 0e9d8ab
quick fix for search-space conversion
SimonBlanke 1a4f76d
create separate module for gfo-adapter
SimonBlanke e551eb3
score function takes just one argument
SimonBlanke d44b94a
Revert "score function takes just one argument"
fkiraly f58a5f0
Revert "create separate module for gfo-adapter"
fkiraly d45d284
Revert "quick fix for search-space conversion"
fkiraly 9c0cd8e
fix crossover rate
fkiraly bf0dc75
fix ForestOptimizer param
fkiraly 0b6c4a0
tsp
fkiraly 04b47ff
move generator
fkiraly 53806bd
Update _lipschitz_optimization.py
fkiraly 4f8a15e
Update _gfo.py
fkiraly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| # List of algorithm names and corresponding class names | ||
| algo_info = [ | ||
| ("downhill_simplex", "DownhillSimplexOptimizer"), | ||
| ("simulated_annealing", "SimulatedAnnealingOptimizer"), | ||
| ("direct_algorithm", "DirectAlgorithm"), | ||
| ("lipschitz_optimization", "LipschitzOptimizer"), | ||
| ("pattern_search", "PatternSearch"), | ||
| ("random_restart_hill_climbing", "RandomRestartHillClimbingOptimizer"), | ||
| ("random_search", "RandomSearchOptimizer"), | ||
| ("powells_method", "PowellsMethod"), | ||
| ("differential_evolution", "DifferentialEvolutionOptimizer"), | ||
| ("evolution_strategy", "EvolutionStrategyOptimizer"), | ||
| ("genetic_algorithm", "GeneticAlgorithmOptimizer"), | ||
| ("parallel_tempering", "ParallelTemperingOptimizer"), | ||
| ("particle_swarm_optimization", "ParticleSwarmOptimizer"), | ||
| ("spiral_optimization", "SpiralOptimization"), | ||
| ("bayesian_optimization", "BayesianOptimizer"), | ||
| ("forest_optimizer", "ForestOptimizer"), | ||
| ("tree_structured_parzen_estimators", "TreeStructuredParzenEstimators"), | ||
| ] | ||
|
|
||
| BASE_DIR = Path("generated_opt_algos") | ||
|
|
||
|
|
||
| # Template for the Python class file | ||
| def create_class_file_content(class_name: str) -> str: | ||
| return f'''from hyperactive.opt._adapters._gfo import _BaseGFOadapter | ||
|
|
||
|
|
||
| class {class_name}(_BaseGFOadapter): | ||
|
|
||
| def _get_gfo_class(self): | ||
| """Get the GFO class to use. | ||
|
|
||
| Returns | ||
| ------- | ||
| class | ||
| The GFO class to use. One of the concrete GFO classes | ||
| """ | ||
| from gradient_free_optimizers import {class_name} | ||
|
|
||
| return {class_name} | ||
| ''' | ||
|
|
||
|
|
||
| # Main generation loop | ||
| for name, class_name in algo_info: | ||
| algo_folder = BASE_DIR / name | ||
| algo_folder.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| init_file = algo_folder / "__init__.py" | ||
| class_file = algo_folder / f"_{name}.py" | ||
|
|
||
| # Create __init__.py (empty) | ||
| init_file.touch(exist_ok=True) | ||
|
|
||
| # Write the optimizer class file | ||
| class_file.write_text(create_class_file_content(class_name)) | ||
|
|
||
| print(f"Generated {len(algo_info)} folders in {BASE_DIR.resolve()}") |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,54 @@ | ||
| """Individual optimization algorithms.""" | ||
|
|
||
| # copyright: hyperactive developers, MIT License (see LICENSE file) | ||
|
|
||
| from hyperactive.opt.gridsearch import GridSearchSk | ||
| from hyperactive.opt.hillclimbing import HillClimbing | ||
| from hyperactive.opt.hillclimbing_repulsing import HillClimbingRepulsing | ||
| from hyperactive.opt.hillclimbing_stochastic import HillClimbingStochastic | ||
| from .gfo import ( | ||
| HillClimbing, | ||
| StochasticHillClimbing, | ||
| RepulsingHillClimbing, | ||
| SimulatedAnnealing, | ||
| DownhillSimplexOptimizer, | ||
| RandomSearch, | ||
| GridSearch, | ||
| RandomRestartHillClimbing, | ||
| PowellsMethod, | ||
| PatternSearch, | ||
| LipschitzOptimizer, | ||
| DirectAlgorithm, | ||
| ParallelTempering, | ||
| ParticleSwarmOptimizer, | ||
| SpiralOptimization, | ||
| GeneticAlgorithm, | ||
| EvolutionStrategy, | ||
| DifferentialEvolution, | ||
| BayesianOptimizer, | ||
| TreeStructuredParzenEstimators, | ||
| ForestOptimizer, | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "GridSearchSk", | ||
| "HillClimbing", | ||
| "HillClimbingRepulsing", | ||
| "HillClimbingStochastic", | ||
| "RepulsingHillClimbing", | ||
| "StochasticHillClimbing", | ||
| "SimulatedAnnealing", | ||
| "DownhillSimplexOptimizer", | ||
| "RandomSearch", | ||
| "GridSearch", | ||
| "RandomRestartHillClimbing", | ||
| "PowellsMethod", | ||
| "PatternSearch", | ||
| "LipschitzOptimizer", | ||
| "DirectAlgorithm", | ||
| "ParallelTempering", | ||
| "ParticleSwarmOptimizer", | ||
| "SpiralOptimization", | ||
| "GeneticAlgorithm", | ||
| "EvolutionStrategy", | ||
| "DifferentialEvolution", | ||
| "BayesianOptimizer", | ||
| "TreeStructuredParzenEstimators", | ||
| "ForestOptimizer", | ||
| ] |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """Individual optimization algorithms.""" | ||
|
|
||
| # copyright: hyperactive developers, MIT License (see LICENSE file) | ||
|
|
||
| from ._hillclimbing import HillClimbing | ||
| from ._stochastic_hillclimbing import StochasticHillClimbing | ||
| from ._repulsing_hillclimbing import RepulsingHillClimbing | ||
| from ._simulated_annealing import SimulatedAnnealing | ||
| from ._downhill_simplex import DownhillSimplexOptimizer | ||
| from ._random_search import RandomSearch | ||
| from ._grid_search import GridSearch | ||
| from ._random_restart_hill_climbing import RandomRestartHillClimbing | ||
| from ._powells_method import PowellsMethod | ||
| from ._pattern_search import PatternSearch | ||
| from ._lipschitz_optimization import LipschitzOptimizer | ||
| from ._direct_algorithm import DirectAlgorithm | ||
| from ._parallel_tempering import ParallelTempering | ||
| from ._particle_swarm_optimization import ParticleSwarmOptimizer | ||
| from ._spiral_optimization import SpiralOptimization | ||
| from ._genetic_algorithm import GeneticAlgorithm | ||
| from ._evolution_strategy import EvolutionStrategy | ||
| from ._differential_evolution import DifferentialEvolution | ||
| from ._bayesian_optimization import BayesianOptimizer | ||
| from ._tree_structured_parzen_estimators import TreeStructuredParzenEstimators | ||
| from ._forest_optimizer import ForestOptimizer | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "HillClimbing", | ||
| "RepulsingHillClimbing", | ||
| "StochasticHillClimbing", | ||
| "SimulatedAnnealing", | ||
| "DownhillSimplexOptimizer", | ||
| "RandomSearch", | ||
| "GridSearch", | ||
| "RandomRestartHillClimbing", | ||
| "PowellsMethod", | ||
| "PatternSearch", | ||
| "LipschitzOptimizer", | ||
| "DirectAlgorithm", | ||
| "ParallelTempering", | ||
| "ParticleSwarmOptimizer", | ||
| "SpiralOptimization", | ||
| "GeneticAlgorithm", | ||
| "EvolutionStrategy", | ||
| "DifferentialEvolution", | ||
| "BayesianOptimizer", | ||
| "TreeStructuredParzenEstimators", | ||
| "ForestOptimizer", | ||
| ] |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.