Skip to content

Commit

Permalink
Merge pull request #377 from Chang-SHAO/main
Browse files Browse the repository at this point in the history
upload files
  • Loading branch information
Evolutionary-Intelligence authored Jul 3, 2024
2 parents 889ca38 + 774c1aa commit 0a0a719
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pypop7/optimizers/ds/test_cs.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions pypop7/optimizers/ds/test_gps.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions pypop7/optimizers/ds/test_hj.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions pypop7/optimizers/ds/test_nm.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions pypop7/optimizers/ds/test_powel.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0a0a719

Please sign in to comment.