File convex_hull.py changed (mode: 100644) (index 01bb901..ec8d9e7) |
... |
... |
from .IS_stat import PushAndPull # for Shell_IS |
24 |
24 |
#č nepodařílo se mi nějak rozumně zobecnit pro libovolný prostor |
#č nepodařílo se mi nějak rozumně zobecnit pro libovolný prostor |
25 |
25 |
#č takže Gauss |
#č takže Gauss |
26 |
26 |
#č (každá třida implementuje zvlášť) |
#č (každá třida implementuje zvlášť) |
27 |
|
#def fire(design_point_G, ns): |
|
28 |
|
# to_fire_G = design_point.G[0] |
|
29 |
|
# r = np.sqrt(np.sum(np.square(to_fire_G))) |
|
30 |
|
# a = to_fire_G / r |
|
31 |
|
# fire_from = stats.norm.cdf(r) |
|
32 |
|
# t = np.linspace(fire_from, 1, ns) |
|
33 |
|
# t = stats.norm.ppf(t) |
|
34 |
|
# fire_G = t.reshape(-1,1) @ a.reshape(1,-1) |
|
35 |
|
# return design_point. |
|
|
27 |
|
|
|
28 |
|
def fire(hull, ns): |
|
29 |
|
if hull.space == 'G': |
|
30 |
|
to_fire = np.nanargmax(hull.b) |
|
31 |
|
a = hull.A[to_fire] |
|
32 |
|
fire_from = stats.norm.sf(hull.get_r()) |
|
33 |
|
t = np.linspace(fire_from, 0, ns, endpoint=False) |
|
34 |
|
t = stats.norm.isf(t) |
|
35 |
|
fire_G = t.reshape(-1,1) @ a.reshape(1,-1) |
|
36 |
|
|
|
37 |
|
return hull.sample.f_model.new_sample(fire_G, space='G') |
36 |
38 |
|
|
37 |
39 |
#č jistě musíme mít nějaký zbytečný kus kódu |
#č jistě musíme mít nějaký zbytečný kus kódu |
38 |
40 |
#č třida jen pro formu, jen tak na hračku |
#č třida jen pro formu, jen tak na hračku |
|
... |
... |
class BrickHull: #č nebo BoundingBrick |
203 |
205 |
|
|
204 |
206 |
|
|
205 |
207 |
class DirectHull: |
class DirectHull: |
|
208 |
|
# take global function for fire() |
|
209 |
|
fire = fire |
|
210 |
|
|
206 |
211 |
def __init__(hull, sample, direct_plan, space='G'): |
def __init__(hull, sample, direct_plan, space='G'): |
207 |
212 |
hull.sample = sample |
hull.sample = sample |
208 |
213 |
hull.direct_plan = direct_plan |
hull.direct_plan = direct_plan |
|
... |
... |
class DirectHull: |
285 |
290 |
else: |
else: |
286 |
291 |
return 0 |
return 0 |
287 |
292 |
|
|
288 |
|
def fire(hull, ns): |
|
289 |
|
if hull.space == 'G': |
|
290 |
|
A = hull.equations[:,:-1] |
|
291 |
|
b = hull.equations[:,-1] |
|
292 |
|
|
|
293 |
|
to_fire = np.nanargmax(b) |
|
294 |
|
a = A[to_fire] |
|
295 |
|
fire_from = stats.norm.cdf(hull.get_r()) |
|
296 |
|
t = np.linspace(fire_from, 1, ns, endpoint=False) |
|
297 |
|
t = stats.norm.ppf(t) |
|
298 |
|
fire_G = t.reshape(-1,1) @ a.reshape(1,-1) |
|
299 |
|
|
|
300 |
|
return hull.sample.f_model.new_sample(fire_G, space='G') |
|
|
293 |
|
|
301 |
294 |
|
|
302 |
295 |
|
|
303 |
296 |
class CompleteHull: |
class CompleteHull: |
|
297 |
|
# take global function for fire() |
|
298 |
|
fire = fire |
|
299 |
|
|
304 |
300 |
def __init__(hull, sample, direct_plan, space='G'): |
def __init__(hull, sample, direct_plan, space='G'): |
305 |
301 |
hull.sample = sample |
hull.sample = sample |
306 |
302 |
hull.direct_plan = direct_plan |
hull.direct_plan = direct_plan |
|
... |
... |
class CompleteHull: |
411 |
407 |
else: |
else: |
412 |
408 |
return 0 |
return 0 |
413 |
409 |
|
|
414 |
|
def fire(hull, ns): |
|
415 |
|
if hull.space == 'G': |
|
416 |
|
A = hull.equations[:,:-1] |
|
417 |
|
b = hull.equations[:,-1] |
|
418 |
|
|
|
419 |
|
to_fire = np.nanargmax(b) |
|
420 |
|
a = A[to_fire] |
|
421 |
|
fire_from = stats.norm.cdf(hull.get_r()) |
|
422 |
|
t = np.linspace(fire_from, 1, ns, endpoint=False) |
|
423 |
|
t = stats.norm.ppf(t) |
|
424 |
|
fire_G = t.reshape(-1,1) @ a.reshape(1,-1) |
|
425 |
|
|
|
426 |
|
return hull.sample.f_model.new_sample(fire_G, space='G') |
|
427 |
410 |
|
|
428 |
411 |
|
|
429 |
412 |
class QHull: |
class QHull: |
|
... |
... |
class QHull: |
538 |
521 |
return 0 |
return 0 |
539 |
522 |
|
|
540 |
523 |
def fire(hull, ns): |
def fire(hull, ns): |
541 |
|
if hull.space == 'G': |
|
542 |
|
try: |
|
543 |
|
A = hull.equations[:,:-1] |
|
544 |
|
b = hull.equations[:,-1] |
|
545 |
|
|
|
546 |
|
to_fire = np.nanargmax(b) #č tak, pro jistotu |
|
547 |
|
a = A[to_fire] |
|
548 |
|
fire_from = stats.norm.cdf(hull.get_r()) |
|
549 |
|
t = np.linspace(fire_from, 1, ns, endpoint=False) |
|
550 |
|
t = stats.norm.ppf(t) |
|
551 |
|
fire_G = t.reshape(-1,1) @ a.reshape(1,-1) |
|
552 |
|
|
|
553 |
|
return hull.sample.f_model.new_sample(fire_G, space='G') |
|
554 |
|
except: |
|
555 |
|
pass |
|
|
524 |
|
try: |
|
525 |
|
# take global function for fire() |
|
526 |
|
return fire(hull, ns) |
|
527 |
|
except: |
|
528 |
|
pass |
556 |
529 |
|
|
557 |
530 |
|
|
558 |
531 |
#č mým úkolem při návrhu této třidy je pořádně všecko zkomplikovat. |
#č mým úkolem při návrhu této třidy je pořádně všecko zkomplikovat. |