Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 4af45b7

Browse files
author
Tanguy Pierre Louis Damart
committed
- Add tests for hype algorithm
- Increase the sampling rate for the hype algorithm in MO-CMA
1 parent 0805bc3 commit 4af45b7

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

bluepyopt/deapext/CMA_MO.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_hyped(pop, ubound_score=250., threshold_improvement=240.):
7171
ubounds = numpy.max(points, axis=0) + 2.0
7272

7373
hv = hype.hypeIndicatorSampled(
74-
points=points, bounds=ubounds, k=5, nrOfSamples=200000
74+
points=points, bounds=ubounds, k=5, nrOfSamples=1000000
7575
)
7676
return hv
7777

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""bluepyopt.deapext.hype tests"""
2+
3+
import numpy
4+
5+
import bluepyopt.deapext.hype
6+
7+
import pytest
8+
9+
10+
@pytest.mark.unit
11+
def test_hypeIndicatorExact():
12+
"""deapext.hype: Testing hypeIndicatorExact"""
13+
14+
points = numpy.asarray([[250., 250.], [0., 0.], [240., 240.]])
15+
bounds = numpy.asarray([250., 250.])
16+
17+
hv = bluepyopt.deapext.hype.hypeIndicatorExact(points, bounds, k=5)
18+
19+
assert hv[0] == 0
20+
assert hv[1] == 62500
21+
assert hv[2] == 100
22+
23+
24+
@pytest.mark.unit
25+
def test_hypeIndicatorSampled():
26+
"""deapext.hype: Testing hypeIndicatorSampled"""
27+
28+
points = numpy.asarray([[250., 250.], [0., 0.], [240., 240.]])
29+
bounds = numpy.asarray([250., 250.])
30+
31+
numpy.random.seed(42)
32+
hv = bluepyopt.deapext.hype.hypeIndicatorSampled(
33+
points, bounds, nrOfSamples=1000000, k=5
34+
)
35+
36+
assert hv[0] == 0
37+
assert hv[1] == 62500
38+
assert numpy.abs((hv[2] / 100) - 1) < 0.05

bluepyopt/tests/test_deapext/test_optimisationsCMA.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ def test_optimisationsCMA_MO_run():
5555
)
5656
pop, hof, log, hist = optimisation.run(max_ngen=2)
5757

58-
assert abs(log.select("avg")[-1] - 120.) < 1e-4
59-
assert abs(log.select("std")[-1] - 74.8331) < 1e-4
60-
assert pop[0] == [0.07506300058169628, 0.01000000003249999]
58+
assert abs(log.select("avg")[-1] - 40.) < 1e-4
59+
assert abs(log.select("std")[-1] - 16.32993) < 1e-4
60+
assert pop[0] == [0.09601241274168831, 0.024646650865379722]

0 commit comments

Comments
 (0)