-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup code, add testing for global optima with fitness 0, and add 2…
… more bbob function definitions
- Loading branch information
timothyatkinson
committed
Nov 1, 2022
1 parent
f0248c6
commit 67c7df8
Showing
4 changed files
with
90 additions
and
62 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
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
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
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,22 @@ | ||
import numpy as np | ||
import torch | ||
|
||
from evotorch.bbo import bbob_noiseless_suite, bbob_problem | ||
|
||
|
||
def test_bbob_noiseless_suite_global_optima(): | ||
|
||
n_functions = len(bbob_noiseless_suite._functions) | ||
|
||
dimensions = [2, 5, 10, 20, 40] | ||
|
||
for dimension in dimensions: | ||
|
||
for function_idx in range(1, n_functions + 1): | ||
func: bbob_problem.BBOBProblem = bbob_noiseless_suite.get_function_i(function_idx)(dimension) | ||
batch = func.generate_batch(5) | ||
batch[0].set_values(func._x_opt) | ||
func.evaluate(batch) | ||
eval_of_x_opt = float(batch.evals[0] - func._f_opt) | ||
|
||
assert np.abs(eval_of_x_opt - 0.0) < 1e-7 |