File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -90,3 +90,37 @@ is a result of the fact that the learner chooses points in 3 dimensions
90
90
and the simplices are not in the same face as we try to interpolate our
91
91
lines. However, as always, when you sample more points the graph will
92
92
become gradually smoother.
93
+
94
+ Using any convex shape as domain
95
+ --------------------------------
96
+
97
+ Suppose you do not simply want to sample your function on a square (in 2D) or in
98
+ a cube (in 3D). The LearnerND supports using a `scipy.spatial.ConvexHull ` as
99
+ your domain. This is best illustrated in the following example.
100
+
101
+ Suppose you would like to sample you function in a cube split in half diagonally.
102
+ You could use the following code as an example:
103
+
104
+ .. jupyter-execute ::
105
+
106
+ import scipy
107
+
108
+ def f(xyz):
109
+ x, y, z = xyz
110
+ return x**4 + y**4 + z**4 - (x**2+y**2+z**2)**2
111
+
112
+ # set the bound points, you can change this to be any shape
113
+ b = [(-1, -1, -1),
114
+ (-1, 1, -1),
115
+ (-1, -1, 1),
116
+ (-1, 1, 1),
117
+ ( 1, 1, -1),
118
+ ( 1, -1, -1)]
119
+
120
+ # you have to convert the points into a scipy.spatial.ConvexHull
121
+ hull = scipy.spatial.ConvexHull(b)
122
+
123
+ learner = adaptive.LearnerND(f, hull)
124
+ adaptive.BlockingRunner(learner, goal=lambda l: l.npoints > 2000)
125
+
126
+ learner.plot_isosurface(-0.5)
You can’t perform that action at this time.
0 commit comments