From b53b8ea997d363c4f1fca1197683391e0872dad3 Mon Sep 17 00:00:00 2001 From: Chang-SHAO <101379630+Chang-SHAO@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:54:20 +0800 Subject: [PATCH 1/2] Add files via upload --- pypop7/optimizers/ds/test_powel.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pypop7/optimizers/ds/test_powel.py diff --git a/pypop7/optimizers/ds/test_powel.py b/pypop7/optimizers/ds/test_powel.py new file mode 100644 index 000000000..c050ed6c0 --- /dev/null +++ b/pypop7/optimizers/ds/test_powel.py @@ -0,0 +1,14 @@ +def test_optimize(): + import numpy # engine for numerical computing + from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized + from pypop7.optimizers.ds.powell import POWELL + problem = {'fitness_function': rosenbrock, # to define problem arguments + 'ndim_problem': 2, + 'lower_boundary': -5.0 * numpy.ones((2,)), + 'upper_boundary': 5.0 * numpy.ones((2,))} + options = {'max_function_evaluations': 5000, # to set optimizer options + 'seed_rng': 2022} + powel = POWELL(problem, options) # to initialize the black-box optimizer class + results = powel.optimize() # to run its optimization/evolution process + assert results['n_function_evaluations'] == 5000 + assert results['best_so_far_y'] < 1.0 From 774c1aa94607577c01deeb3776bd06bd65d779f8 Mon Sep 17 00:00:00 2001 From: Chang-SHAO <101379630+Chang-SHAO@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:59:35 +0800 Subject: [PATCH 2/2] Add files via upload --- pypop7/optimizers/ds/test_cs.py | 14 ++++++++++++++ pypop7/optimizers/ds/test_gps.py | 14 ++++++++++++++ pypop7/optimizers/ds/test_hj.py | 14 ++++++++++++++ pypop7/optimizers/ds/test_nm.py | 14 ++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 pypop7/optimizers/ds/test_cs.py create mode 100644 pypop7/optimizers/ds/test_gps.py create mode 100644 pypop7/optimizers/ds/test_hj.py create mode 100644 pypop7/optimizers/ds/test_nm.py diff --git a/pypop7/optimizers/ds/test_cs.py b/pypop7/optimizers/ds/test_cs.py new file mode 100644 index 000000000..a006bdacb --- /dev/null +++ b/pypop7/optimizers/ds/test_cs.py @@ -0,0 +1,14 @@ +def test_optimize(): + import numpy # engine for numerical computing + from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized + from pypop7.optimizers.ds.cs import CS + problem = {'fitness_function': rosenbrock, # to define problem arguments + 'ndim_problem': 2, + 'lower_boundary': -5.0 * numpy.ones((2,)), + 'upper_boundary': 5.0 * numpy.ones((2,))} + options = {'max_function_evaluations': 5000, # to set optimizer options + 'seed_rng': 2022} + cs = CS(problem, options) # to initialize the black-box optimizer class + results = cs.optimize() # to run its optimization/evolution process + assert results['n_function_evaluations'] == 5000 + assert results['best_so_far_y'] < 1.0 diff --git a/pypop7/optimizers/ds/test_gps.py b/pypop7/optimizers/ds/test_gps.py new file mode 100644 index 000000000..27df808fd --- /dev/null +++ b/pypop7/optimizers/ds/test_gps.py @@ -0,0 +1,14 @@ +def test_optimize(): + import numpy # engine for numerical computing + from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized + from pypop7.optimizers.ds.gps import GPS + problem = {'fitness_function': rosenbrock, # to define problem arguments + 'ndim_problem': 2, + 'lower_boundary': -5.0 * numpy.ones((2,)), + 'upper_boundary': 5.0 * numpy.ones((2,))} + options = {'max_function_evaluations': 5000, # to set optimizer options + 'seed_rng': 2022} + gps = GPS(problem, options) # to initialize the black-box optimizer class + results = gps.optimize() # to run its optimization/evolution process + assert results['n_function_evaluations'] == 5000 + assert results['best_so_far_y'] < 10.0 diff --git a/pypop7/optimizers/ds/test_hj.py b/pypop7/optimizers/ds/test_hj.py new file mode 100644 index 000000000..124a97245 --- /dev/null +++ b/pypop7/optimizers/ds/test_hj.py @@ -0,0 +1,14 @@ +def test_optimize(): + import numpy # engine for numerical computing + from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized + from pypop7.optimizers.ds.hj import HJ + problem = {'fitness_function': rosenbrock, # to define problem arguments + 'ndim_problem': 2, + 'lower_boundary': -5.0 * numpy.ones((2,)), + 'upper_boundary': 5.0 * numpy.ones((2,))} + options = {'max_function_evaluations': 5000, # to set optimizer options + 'seed_rng': 2022} + hj = HJ(problem, options) # to initialize the black-box optimizer class + results = hj.optimize() # to run its optimization/evolution process + assert results['n_function_evaluations'] == 5000 + assert results['best_so_far_y'] < 1.0 diff --git a/pypop7/optimizers/ds/test_nm.py b/pypop7/optimizers/ds/test_nm.py new file mode 100644 index 000000000..c12ca28d5 --- /dev/null +++ b/pypop7/optimizers/ds/test_nm.py @@ -0,0 +1,14 @@ +def test_optimize(): + import numpy # engine for numerical computing + from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized + from pypop7.optimizers.ds.nm import NM + problem = {'fitness_function': rosenbrock, # to define problem arguments + 'ndim_problem': 2, + 'lower_boundary': -5.0 * numpy.ones((2,)), + 'upper_boundary': 5.0 * numpy.ones((2,))} + options = {'max_function_evaluations': 5000, # to set optimizer options + 'seed_rng': 2022} + nm = NM(problem, options) # to initialize the black-box optimizer class + results = nm.optimize() # to run its optimization/evolution process + assert results['n_function_evaluations'] == 5000 + assert results['best_so_far_y'] < 1.0