-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f5f514
commit b10a409
Showing
6 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,34 @@ | ||
import pytest | ||
|
||
from hyperactive import Hyperactive | ||
from surfaces.test_functions import test_functions | ||
|
||
|
||
test_functions_d = ( | ||
"test_function", | ||
test_functions, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize(*test_functions_d) | ||
def test_all_functions(test_function): | ||
try: | ||
test_function_ = test_function() | ||
except TypeError: | ||
test_function_ = test_function(n_dim=3) | ||
|
||
try: | ||
search_space = test_function_.search_space(value_types="list") | ||
except TypeError: | ||
search_space = test_function_.search_space() | ||
|
||
objective_function = test_function_.objective_function | ||
n_iter = 5 | ||
|
||
hyper = Hyperactive() | ||
hyper.add_search( | ||
objective_function, | ||
search_space, | ||
n_iter=n_iter, | ||
) | ||
hyper.run() |
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,36 @@ | ||
import pytest | ||
|
||
from surfaces.test_functions import mathematical_functions, machine_learning_functions | ||
|
||
|
||
mathematical_functions_d = ( | ||
"test_function", | ||
mathematical_functions, | ||
) | ||
|
||
|
||
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 |
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,36 @@ | ||
import pytest | ||
|
||
from surfaces.test_functions import mathematical_functions, machine_learning_functions | ||
|
||
|
||
mathematical_functions_d = ( | ||
"test_function", | ||
mathematical_functions, | ||
) | ||
|
||
|
||
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 |
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,116 @@ | ||
import pytest | ||
from gradient_free_optimizers import RandomSearchOptimizer | ||
from hyperactive import Hyperactive | ||
|
||
|
||
from surfaces.test_functions import ( | ||
machine_learning_functions, | ||
) | ||
from surfaces.test_functions.mathematical import ( | ||
mathematical_functions_1d, | ||
mathematical_functions_2d, | ||
mathematical_functions_nd, | ||
) | ||
|
||
mathematical_functions_1d = ( | ||
"test_function", | ||
mathematical_functions_1d, | ||
) | ||
|
||
mathematical_functions_2d = ( | ||
"test_function", | ||
mathematical_functions_2d, | ||
) | ||
|
||
mathematical_functions_nd = ( | ||
"test_function", | ||
mathematical_functions_nd, | ||
) | ||
|
||
|
||
machine_learning_functions_d = ( | ||
"test_function", | ||
machine_learning_functions, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize(*mathematical_functions_1d) | ||
def test_search_space_1d_0(test_function): | ||
test_function_ = test_function() | ||
|
||
objective_function = test_function_.objective_function | ||
search_space = test_function_.search_space(min=-1, max=1, value_types="array") | ||
n_iter = 20 | ||
|
||
opt = RandomSearchOptimizer(search_space) | ||
opt.search(objective_function, n_iter=n_iter) | ||
|
||
|
||
@pytest.mark.parametrize(*mathematical_functions_2d) | ||
def test_search_space_2d_0(test_function): | ||
print("\n test_function", test_function, "\n") | ||
test_function_ = test_function() | ||
|
||
objective_function = test_function_.objective_function | ||
search_space = test_function_.search_space(min=-1, max=1, value_types="array") | ||
n_iter = 20 | ||
|
||
opt = RandomSearchOptimizer(search_space) | ||
opt.search(objective_function, n_iter=n_iter) | ||
|
||
|
||
@pytest.mark.parametrize(*mathematical_functions_2d) | ||
def test_search_space_2d_1(test_function): | ||
test_function_ = test_function() | ||
|
||
objective_function = test_function_.objective_function | ||
search_space = test_function_.search_space( | ||
min=[-1, -1], max=[1, 1], value_types="array" | ||
) | ||
n_iter = 20 | ||
|
||
opt = RandomSearchOptimizer(search_space) | ||
opt.search(objective_function, n_iter=n_iter) | ||
|
||
|
||
@pytest.mark.parametrize(*mathematical_functions_nd) | ||
def test_search_space_nd_0(test_function): | ||
test_function_ = test_function(n_dim=3) | ||
|
||
objective_function = test_function_.objective_function | ||
search_space = test_function_.search_space(min=-1, max=1, value_types="array") | ||
n_iter = 20 | ||
|
||
opt = RandomSearchOptimizer(search_space) | ||
opt.search(objective_function, n_iter=n_iter) | ||
|
||
|
||
@pytest.mark.parametrize(*mathematical_functions_nd) | ||
def test_search_space_nd_1(test_function): | ||
test_function_ = test_function(n_dim=3) | ||
|
||
objective_function = test_function_.objective_function | ||
search_space = test_function_.search_space( | ||
min=[-1, -1, -1], max=[1, 1, 1], value_types="array" | ||
) | ||
n_iter = 20 | ||
|
||
opt = RandomSearchOptimizer(search_space) | ||
opt.search(objective_function, n_iter=n_iter) | ||
|
||
|
||
@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 = 3 | ||
|
||
hyper = Hyperactive() | ||
hyper.add_search( | ||
objective_function, | ||
search_space, | ||
n_iter=n_iter, | ||
) | ||
hyper.run() |
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,36 @@ | ||
import pytest | ||
|
||
from surfaces.test_functions import mathematical_functions, machine_learning_functions | ||
|
||
|
||
mathematical_functions_d = ( | ||
"test_function", | ||
mathematical_functions, | ||
) | ||
|
||
|
||
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 |