-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pypop7/optimizers/cc/test_cosyne.py
- Loading branch information
1 parent
b636b26
commit df1bfc9
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,15 @@ | ||
def test_optimize(): | ||
import numpy # engine for numerical computing | ||
from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized | ||
from pypop7.optimizers.cc.cosyne import COSYNE | ||
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, | ||
'sigma': 1.0} | ||
cosyne = COSYNE(problem, options) # to initialize the black-box optimizer class | ||
results = cosyne.optimize() # to run its optimization/evolution process | ||
assert results['n_function_evaluations'] == 5000 | ||
assert results['best_so_far_y'] < 1.0 |