| Conditions | 2 |
| Total Lines | 27 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 24 | @pytest.mark.parametrize(*opt_global_l) |
||
| 25 | def test_global_perf(Optimizer): |
||
| 26 | ackley_function = RastriginFunction(n_dim=1, metric="score") |
||
| 27 | |||
| 28 | search_space = {"x0": np.arange(-100, 101, 1)} |
||
| 29 | initialize = {"vertices": 2} |
||
| 30 | |||
| 31 | n_opts = 33 |
||
| 32 | n_iter = 100 |
||
| 33 | |||
| 34 | scores = [] |
||
| 35 | for rnd_st in tqdm(range(n_opts)): |
||
| 36 | opt = Optimizer(search_space, initialize=initialize) |
||
| 37 | opt.search( |
||
| 38 | ackley_function, |
||
| 39 | n_iter=n_iter, |
||
| 40 | random_state=rnd_st, |
||
| 41 | memory=False, |
||
| 42 | verbosity=False, |
||
| 43 | ) |
||
| 44 | |||
| 45 | scores.append(opt.best_score) |
||
| 46 | score_mean = np.array(scores).mean() |
||
| 47 | |||
| 48 | print("\n score_mean", score_mean) |
||
| 49 | |||
| 50 | assert score_mean > -5 |
||
| 51 |