diff --git a/src/surfaces/__init__.py b/src/surfaces/__init__.py index f445b0d..6ab5c14 100644 --- a/src/surfaces/__init__.py +++ b/src/surfaces/__init__.py @@ -7,14 +7,14 @@ __version__ = importlib.metadata.version("surfaces") __license__ = "MIT" -from .mathematical_functions import ( +from .test_functions import ( mathematical_functions, mathematical_functions_1d, mathematical_functions_2d, mathematical_functions_nd, + machine_learning_functions, ) -from .machine_learning_functions import machine_learning_functions test_functions: list = mathematical_functions + machine_learning_functions diff --git a/src/surfaces/search_data.db b/src/surfaces/search_data.db index 8f6dd03..d9b00ed 100644 Binary files a/src/surfaces/search_data.db and b/src/surfaces/search_data.db differ diff --git a/src/surfaces/test_functions/__init__.py b/src/surfaces/test_functions/__init__.py new file mode 100644 index 0000000..00f0c03 --- /dev/null +++ b/src/surfaces/test_functions/__init__.py @@ -0,0 +1,135 @@ +# Author: Simon Blanke +# Email: simon.blanke@yahoo.com +# License: MIT License + +from .mathematical import ( + AckleyFunction, + BealeFunction, + BoothFunction, + BukinFunctionN6, + CrossInTrayFunction, + DropWaveFunction, + EasomFunction, + EggholderFunction, + GoldsteinPriceFunction, + GramacyAndLeeFunction, + GriewankFunction, + HimmelblausFunction, + HölderTableFunction, + LangermannFunction, + LeviFunctionN13, + MatyasFunction, + McCormickFunction, + RastriginFunction, + RosenbrockFunction, + SchafferFunctionN2, + SimionescuFunction, + SphereFunction, + StyblinskiTangFunction, + ThreeHumpCamelFunction, +) +from .machine_learning import ( + KNeighborsClassifierFunction, + GradientBoostingRegressorFunction, + KNeighborsRegressorFunction, +) + + +__all__ = [ + "AckleyFunction", + "BealeFunction", + "BoothFunction", + "BukinFunctionN6", + "CrossInTrayFunction", + "DropWaveFunction", + "EasomFunction", + "EggholderFunction", + "GoldsteinPriceFunction", + "GramacyAndLeeFunction", + "GriewankFunction", + "HimmelblausFunction", + "HölderTableFunction", + "LangermannFunction", + "LeviFunctionN13", + "MatyasFunction", + "McCormickFunction", + "RastriginFunction", + "RosenbrockFunction", + "SchafferFunctionN2", + "SimionescuFunction", + "SphereFunction", + "StyblinskiTangFunction", + "ThreeHumpCamelFunction", + "KNeighborsClassifierFunction", + "GradientBoostingRegressorFunction", + "KNeighborsRegressorFunction", +] + +mathematical_functions = [ + AckleyFunction, + BealeFunction, + BoothFunction, + BukinFunctionN6, + CrossInTrayFunction, + DropWaveFunction, + EasomFunction, + EggholderFunction, + GoldsteinPriceFunction, + GramacyAndLeeFunction, + GriewankFunction, + HimmelblausFunction, + HölderTableFunction, + LangermannFunction, + LeviFunctionN13, + MatyasFunction, + McCormickFunction, + RastriginFunction, + RosenbrockFunction, + SchafferFunctionN2, + SimionescuFunction, + SphereFunction, + StyblinskiTangFunction, + ThreeHumpCamelFunction, +] + + +mathematical_functions_1d = [ + GramacyAndLeeFunction, +] + + +mathematical_functions_2d = [ + AckleyFunction, + BealeFunction, + BoothFunction, + BukinFunctionN6, + CrossInTrayFunction, + DropWaveFunction, + EasomFunction, + EggholderFunction, + GoldsteinPriceFunction, + HimmelblausFunction, + HölderTableFunction, + LangermannFunction, + LeviFunctionN13, + MatyasFunction, + McCormickFunction, + RosenbrockFunction, + SchafferFunctionN2, + SimionescuFunction, + ThreeHumpCamelFunction, +] + + +mathematical_functions_nd = [ + GriewankFunction, + RastriginFunction, + SphereFunction, + StyblinskiTangFunction, +] + +machine_learning_functions = [ + KNeighborsClassifierFunction, + GradientBoostingRegressorFunction, + KNeighborsRegressorFunction, +] diff --git a/src/surfaces/_base_test_function.py b/src/surfaces/test_functions/_base_test_function.py similarity index 96% rename from src/surfaces/_base_test_function.py rename to src/surfaces/test_functions/_base_test_function.py index 82beb5f..27df5e3 100644 --- a/src/surfaces/_base_test_function.py +++ b/src/surfaces/test_functions/_base_test_function.py @@ -4,7 +4,7 @@ import time -from .data_collector import SurfacesDataCollector +from ..data_collector import SurfacesDataCollector class BaseTestFunction: diff --git a/src/surfaces/machine_learning_functions/__init__.py b/src/surfaces/test_functions/machine_learning/__init__.py similarity index 100% rename from src/surfaces/machine_learning_functions/__init__.py rename to src/surfaces/test_functions/machine_learning/__init__.py diff --git a/src/surfaces/machine_learning_functions/base_machine_learning_function.py b/src/surfaces/test_functions/machine_learning/base_machine_learning_function.py similarity index 100% rename from src/surfaces/machine_learning_functions/base_machine_learning_function.py rename to src/surfaces/test_functions/machine_learning/base_machine_learning_function.py diff --git a/src/surfaces/machine_learning_functions/datasets/__init__.py b/src/surfaces/test_functions/machine_learning/datasets/__init__.py similarity index 100% rename from src/surfaces/machine_learning_functions/datasets/__init__.py rename to src/surfaces/test_functions/machine_learning/datasets/__init__.py diff --git a/src/surfaces/machine_learning_functions/datasets/tabular_classification.py b/src/surfaces/test_functions/machine_learning/datasets/tabular_classification.py similarity index 100% rename from src/surfaces/machine_learning_functions/datasets/tabular_classification.py rename to src/surfaces/test_functions/machine_learning/datasets/tabular_classification.py diff --git a/src/surfaces/machine_learning_functions/datasets/tabular_regression.py b/src/surfaces/test_functions/machine_learning/datasets/tabular_regression.py similarity index 100% rename from src/surfaces/machine_learning_functions/datasets/tabular_regression.py rename to src/surfaces/test_functions/machine_learning/datasets/tabular_regression.py diff --git a/src/surfaces/test_functions/machine_learning/tabular/__init__.py b/src/surfaces/test_functions/machine_learning/tabular/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/surfaces/test_functions/machine_learning/tabular/classification/__init__.py b/src/surfaces/test_functions/machine_learning/tabular/classification/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/surfaces/test_functions/machine_learning/tabular/regression/__init__.py b/src/surfaces/test_functions/machine_learning/tabular/regression/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/surfaces/machine_learning_functions/tabular_classifiers.py b/src/surfaces/test_functions/machine_learning/tabular_classifiers.py similarity index 100% rename from src/surfaces/machine_learning_functions/tabular_classifiers.py rename to src/surfaces/test_functions/machine_learning/tabular_classifiers.py diff --git a/src/surfaces/machine_learning_functions/tabular_regressors.py b/src/surfaces/test_functions/machine_learning/tabular_regressors.py similarity index 100% rename from src/surfaces/machine_learning_functions/tabular_regressors.py rename to src/surfaces/test_functions/machine_learning/tabular_regressors.py diff --git a/src/surfaces/mathematical_functions/__init__.py b/src/surfaces/test_functions/mathematical/__init__.py similarity index 100% rename from src/surfaces/mathematical_functions/__init__.py rename to src/surfaces/test_functions/mathematical/__init__.py diff --git a/src/surfaces/mathematical_functions/_base_objective_function.py b/src/surfaces/test_functions/mathematical/_base_objective_function.py similarity index 100% rename from src/surfaces/mathematical_functions/_base_objective_function.py rename to src/surfaces/test_functions/mathematical/_base_objective_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_1d/__init__.py b/src/surfaces/test_functions/mathematical/test_functions_1d/__init__.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_1d/__init__.py rename to src/surfaces/test_functions/mathematical/test_functions_1d/__init__.py diff --git a/src/surfaces/mathematical_functions/test_functions_1d/gramacy_and_lee_function.py b/src/surfaces/test_functions/mathematical/test_functions_1d/gramacy_and_lee_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_1d/gramacy_and_lee_function.py rename to src/surfaces/test_functions/mathematical/test_functions_1d/gramacy_and_lee_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/__init__.py b/src/surfaces/test_functions/mathematical/test_functions_2d/__init__.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/__init__.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/__init__.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/ackley_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/ackley_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/ackley_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/ackley_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/beale_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/beale_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/beale_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/beale_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/booth_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/booth_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/booth_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/booth_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/bukin_function_n6.py b/src/surfaces/test_functions/mathematical/test_functions_2d/bukin_function_n6.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/bukin_function_n6.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/bukin_function_n6.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/cross_in_tray_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/cross_in_tray_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/cross_in_tray_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/cross_in_tray_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/drop_wave_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/drop_wave_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/drop_wave_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/drop_wave_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/easom_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/easom_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/easom_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/easom_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/eggholder_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/eggholder_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/eggholder_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/eggholder_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/goldstein_price_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/goldstein_price_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/goldstein_price_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/goldstein_price_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/himmelblaus_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/himmelblaus_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/himmelblaus_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/himmelblaus_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/hoelder_table_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/hoelder_table_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/hoelder_table_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/hoelder_table_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/langermann_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/langermann_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/langermann_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/langermann_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/levi_function_n13.py b/src/surfaces/test_functions/mathematical/test_functions_2d/levi_function_n13.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/levi_function_n13.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/levi_function_n13.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/matyas_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/matyas_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/matyas_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/matyas_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/mccormick_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/mccormick_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/mccormick_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/mccormick_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/schaffer_function_n2.py b/src/surfaces/test_functions/mathematical/test_functions_2d/schaffer_function_n2.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/schaffer_function_n2.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/schaffer_function_n2.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/simionescu_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/simionescu_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/simionescu_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/simionescu_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_2d/three_hump_camel_function.py b/src/surfaces/test_functions/mathematical/test_functions_2d/three_hump_camel_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_2d/three_hump_camel_function.py rename to src/surfaces/test_functions/mathematical/test_functions_2d/three_hump_camel_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_nd/__init__.py b/src/surfaces/test_functions/mathematical/test_functions_nd/__init__.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_nd/__init__.py rename to src/surfaces/test_functions/mathematical/test_functions_nd/__init__.py diff --git a/src/surfaces/mathematical_functions/test_functions_nd/griewank_function.py b/src/surfaces/test_functions/mathematical/test_functions_nd/griewank_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_nd/griewank_function.py rename to src/surfaces/test_functions/mathematical/test_functions_nd/griewank_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_nd/rastrigin_function.py b/src/surfaces/test_functions/mathematical/test_functions_nd/rastrigin_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_nd/rastrigin_function.py rename to src/surfaces/test_functions/mathematical/test_functions_nd/rastrigin_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_nd/rosenbrock_function.py b/src/surfaces/test_functions/mathematical/test_functions_nd/rosenbrock_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_nd/rosenbrock_function.py rename to src/surfaces/test_functions/mathematical/test_functions_nd/rosenbrock_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_nd/sphere_function.py b/src/surfaces/test_functions/mathematical/test_functions_nd/sphere_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_nd/sphere_function.py rename to src/surfaces/test_functions/mathematical/test_functions_nd/sphere_function.py diff --git a/src/surfaces/mathematical_functions/test_functions_nd/styblinski_tang_function.py b/src/surfaces/test_functions/mathematical/test_functions_nd/styblinski_tang_function.py similarity index 100% rename from src/surfaces/mathematical_functions/test_functions_nd/styblinski_tang_function.py rename to src/surfaces/test_functions/mathematical/test_functions_nd/styblinski_tang_function.py diff --git a/src/surfaces/test_functions/mathematical/test_search_space.py b/src/surfaces/test_functions/mathematical/test_search_space.py new file mode 100644 index 0000000..4d9152e --- /dev/null +++ b/src/surfaces/test_functions/mathematical/test_search_space.py @@ -0,0 +1,51 @@ +import pytest + +from surfaces import ( + mathematical_functions_1d, + mathematical_functions_2d, + mathematical_functions_nd, + machine_learning_functions, +) + + +mathematical_functions_1d = ( + "test_function", + mathematical_functions_1d, +) + +mathematical_functions_2d = ( + "test_function", + mathematical_functions_1d, +) + +mathematical_functions_nd = ( + "test_function", + mathematical_functions_1d, +) + + +machine_learning_functions_d = ( + "test_function", + machine_learning_functions, +) + + +@pytest.mark.parametrize(*mathematical_functions_d) +def test_(test_function): + try: + test_function_ = test_function() + except TypeError: + test_function_ = test_function(n_dim=2) + + objective_function = test_function_.objective_function + search_space = test_function_.search_space(value_types="array") + n_iter = 20 + + +@pytest.mark.parametrize(*machine_learning_functions_d) +def test_all_(test_function): + test_function_ = test_function() + + objective_function = test_function_.objective_function + search_space = test_function_.search_space() + n_iter = 20