|
15 | 15 | import pytest
|
16 | 16 | import scipy.spatial
|
17 | 17 |
|
18 |
| -from ..learner import (AverageLearner, BalancingLearner, DataSaver, |
| 18 | +import adaptive |
| 19 | +from adaptive.learner import (AverageLearner, BalancingLearner, DataSaver, |
19 | 20 | IntegratorLearner, Learner1D, Learner2D, LearnerND)
|
20 |
| -from ..runner import simple |
| 21 | +from adaptive.runner import simple |
21 | 22 |
|
22 | 23 |
|
23 | 24 | try:
|
24 | 25 | import skopt
|
25 |
| - from ..learner import SKOptLearner |
| 26 | + from adaptive.learner import SKOptLearner |
26 | 27 | except ModuleNotFoundError:
|
27 | 28 | SKOptLearner = None
|
28 | 29 |
|
@@ -75,26 +76,37 @@ def maybe_skip(learner):
|
75 | 76 | # returns a random value for that parameter.
|
76 | 77 |
|
77 | 78 |
|
78 |
| -@learn_with(Learner1D, bounds=(-1, 1)) |
| 79 | +@learn_with(Learner1D, bounds=(-1, 1), loss_per_interval=adaptive.learner.learner1D.default_loss) |
| 80 | +@learn_with(Learner1D, bounds=(-1, 1), loss_per_interval=adaptive.learner.learner1D.uniform_loss) |
| 81 | +@learn_with(Learner1D, bounds=(-1, 1), loss_per_interval=adaptive.learner.learner1D.curvature_loss_function()) |
79 | 82 | def quadratic(x, m: uniform(0, 10), b: uniform(0, 1)):
|
80 | 83 | return m * x**2 + b
|
81 | 84 |
|
82 | 85 |
|
83 |
| -@learn_with(Learner1D, bounds=(-1, 1)) |
| 86 | +@learn_with(Learner1D, bounds=(-1, 1), loss_per_interval=adaptive.learner.learner1D.default_loss) |
| 87 | +@learn_with(Learner1D, bounds=(-1, 1), loss_per_interval=adaptive.learner.learner1D.uniform_loss) |
| 88 | +@learn_with(Learner1D, bounds=(-1, 1), loss_per_interval=adaptive.learner.learner1D.curvature_loss_function()) |
84 | 89 | def linear_with_peak(x, d: uniform(-1, 1)):
|
85 | 90 | a = 0.01
|
86 | 91 | return x + a**2 / (a**2 + (x - d)**2)
|
87 | 92 |
|
88 | 93 |
|
89 |
| -@learn_with(LearnerND, bounds=((-1, 1), (-1, 1))) |
90 |
| -@learn_with(Learner2D, bounds=((-1, 1), (-1, 1))) |
| 94 | +@learn_with(LearnerND, bounds=((-1, 1), (-1, 1)), loss_per_simplex=adaptive.learner.learnerND.default_loss) |
| 95 | +@learn_with(LearnerND, bounds=((-1, 1), (-1, 1)), loss_per_simplex=adaptive.learner.learnerND.std_loss) |
| 96 | +@learn_with(LearnerND, bounds=((-1, 1), (-1, 1)), loss_per_simplex=adaptive.learner.learnerND.uniform_loss) |
| 97 | +@learn_with(Learner2D, bounds=((-1, 1), (-1, 1)), loss_per_triangle=adaptive.learner.learner2D.default_loss) |
| 98 | +@learn_with(Learner2D, bounds=((-1, 1), (-1, 1)), loss_per_triangle=adaptive.learner.learner2D.uniform_loss) |
| 99 | +@learn_with(Learner2D, bounds=((-1, 1), (-1, 1)), loss_per_triangle=adaptive.learner.learner2D.minimize_triangle_surface_loss) |
| 100 | +@learn_with(Learner2D, bounds=((-1, 1), (-1, 1)), loss_per_triangle=adaptive.learner.learner2D.resolution_loss_function()) |
91 | 101 | def ring_of_fire(xy, d: uniform(0.2, 1)):
|
92 | 102 | a = 0.2
|
93 | 103 | x, y = xy
|
94 | 104 | return x + math.exp(-(x**2 + y**2 - d**2)**2 / a**4)
|
95 | 105 |
|
96 | 106 |
|
97 |
| -@learn_with(LearnerND, bounds=((-1, 1), (-1, 1), (-1, 1))) |
| 107 | +@learn_with(LearnerND, bounds=((-1, 1), (-1, 1), (-1, 1)), loss_per_simplex=adaptive.learner.learnerND.default_loss) |
| 108 | +@learn_with(LearnerND, bounds=((-1, 1), (-1, 1), (-1, 1)), loss_per_simplex=adaptive.learner.learnerND.std_loss) |
| 109 | +@learn_with(LearnerND, bounds=((-1, 1), (-1, 1), (-1, 1)), loss_per_simplex=adaptive.learner.learnerND.uniform_loss) |
98 | 110 | def sphere_of_fire(xyz, d: uniform(0.2, 1)):
|
99 | 111 | a = 0.2
|
100 | 112 | x, y, z = xyz
|
|
0 commit comments