Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """2D parabola.""" |
||
2 | |||
3 | from hyperactive.base import BaseExperiment |
||
4 | |||
5 | |||
6 | class Parabola(BaseExperiment): |
||
7 | """2D parabola. |
||
8 | |||
9 | Parameters |
||
10 | ---------- |
||
11 | a : float, default=1.0 |
||
12 | Coefficient of the parabola. |
||
13 | b : float, default=0.0 |
||
14 | Coefficient of the parabola. |
||
15 | c : float, default=0.0 |
||
16 | Coefficient of the parabola. |
||
17 | """ |
||
18 | |||
19 | def __init__(self, a=1.0, b=0.0, c=0.0): |
||
20 | self.a = a |
||
21 | self.b = b |
||
22 | self.c = c |
||
23 | super().__init__() |
||
24 | |||
25 | def _paramnames(self): |
||
26 | return ["x", "y"] |
||
27 | |||
28 | def _score(self, params): |
||
29 | x = params["x"] |
||
30 | y = params["y"] |
||
31 | |||
32 | return self.a * (x**2 + y**2) + self.b * x + self.c * y, {} |
||
33 |