iam-git / WellMet (public) (License: MIT) (since 2021-08-31) (hash sha1)
WellMet is pure Python framework for spatial structural reliability analysis. Or, more specifically, for "failure probability estimation and detection of failure surfaces by adaptive sequential decomposition of the design domain".
List of commits:
Subject Hash Author Date (UTC)
simplex.Triangulation: WIP 44bdae7876aac717f3d34c4bc6c818fc4ec65169 Alex 2021-01-13 10:43:59
simplex.Triangulation: WIP 47fe5e817878bc6bfd43db208d256a60ee573f9c Alex 2021-01-12 15:41:32
simplex.Triangulation: WIP 57f90b4ae9608d3f2fb5bc081934fa17523998f5 Alex 2021-01-10 11:12:30
simplex.get_failure_ratio() added 65e2940cfa549236cfb09a0e7cadb576a471070f Alex 2021-01-09 09:40:12
simplex.Shull: design support added fe2c0c6b23b32ce99aaa0f824424b32694978615 Alex 2021-01-07 14:22:58
IS_stat: add IS_norm() method 6d1d11c4591143a26c92551ec3f722ea642711ae Alex 2021-01-07 05:33:21
misc: add comment 3d735585d49ac9d5f831b860cf95d3f41fd0d93e I am 2021-01-04 10:29:24
stm_df added (as is for now) 55402101bfabf4b9fe7d70fbd8f1469aea401bc7 Alex 2020-12-26 01:26:17
qt_plot.Isocurves: Isocurves-isolevels reworked 330b3387cfe46f75be6bf70f41c3f289303bdba2 I am 2020-12-23 02:36:39
qt_plot.Isocurves: infs issue fix 276a727723579be523e43b9748b7d36f6d151b0d I am 2020-12-18 00:14:14
qt_plot.Isocurves: extendEdge fix (there was an issue in P and U) 6a836879cc5d280862f4534dc824be86d34bfb4c I am 2020-12-17 23:49:44
qt_plot.Isocurves: bias fix 7c13581235e8e1bac726381b22db46057d1ac188 I am 2020-12-17 14:42:39
qt_plot: Isocurves nan check added + simplex error graph committed (as is) 3b2882661f7af4bb51e518bcd3a37dba6c67f7b2 I am 2020-12-17 03:55:44
f_models.Nataf: little clean up d2b0bba458847b7ef42cf68174311847d438bc84 I am 2020-12-17 03:19:35
qt_plot.Isocurves: dal jsem ty isočáry do pořádku b7ef4ed093c25f84e581000878d9f2d1b8d686c5 I am 2020-12-17 02:16:18
qt_plot: Isocurves added (with issues) b35517b3372f77a6efbeb1a10d6b0e994c7d0082 Alex 2020-12-16 10:13:07
f_models: .alpha init fix 5b5a518be135627bc70354be287f0a36c84cb088 Alex 2020-12-15 20:55:43
f_models.Nataf: prevent from nans in pdfs a4119069f7fdaf11b794f0623daff3dba8997b82 Alex 2020-12-15 08:03:00
f_model.Nataf: fixes 53912fc25e9d048f1ee32039dce32f0b011e470f Alex 2020-12-15 06:55:47
f_models.Nataf: fixes 1bc1d5128d60016be0f29e7c18a818c5a5a243af Alex 2020-12-15 03:56:15
Commit 44bdae7876aac717f3d34c4bc6c818fc4ec65169 - simplex.Triangulation: WIP
Author: Alex
Author date (UTC): 2021-01-13 10:43
Committer name: Alex
Committer date (UTC): 2021-01-13 10:43
Parent(s): 47fe5e817878bc6bfd43db208d256a60ee573f9c
Signer:
Signing key:
Signing status: N
Tree: 3c5bd0919c91c90eb303a2568eedb407ad8c1533
File Lines added Lines deleted
simplex.py 82 169
File simplex.py changed (mode: 100644) (index 8288034..47f1a91)
... ... class Shull: # issi_estimate_outside
182 182 nodes = IS_stat.IS_norm(sx.f, std=std, \ nodes = IS_stat.IS_norm(sx.f, std=std, \
183 183 sampling_space=sx.sampling_space, nis=nis, design=sx.design) sampling_space=sx.sampling_space, nis=nis, design=sx.design)
184 184
185 outside_measure = sx._apply_nodes(nodes)
185 outside_measure = sx._apply_nodes(nodes, nis)
186 186
187 187 #č pro přiště #č pro přiště
188 188 sx.p_out = (sx.p_out + outside_measure) / 2 sx.p_out = (sx.p_out + outside_measure) / 2
 
... ... class Shull: # issi_estimate_outside
190 190 return nodes return nodes
191 191
192 192
193 def _apply_nodes(sx, nodes):
193 def _apply_nodes(sx, nodes, nis):
194 194 #č indikatorová funkce #č indikatorová funkce
195 195 sx.is_outside(nodes) sx.is_outside(nodes)
196 196
 
... ... class _Triangulation:
265 265 # incremental triangulation require one more point # incremental triangulation require one more point
266 266 tri_plan = getattr(sample_box, tri_space) tri_plan = getattr(sample_box, tri_space)
267 267 sx.tri = spatial.Delaunay(tri_plan, incremental=incremental) sx.tri = spatial.Delaunay(tri_plan, incremental=incremental)
268 #č koplanar neřeším
268 if len(sx.tri.coplanar):
269 #print('triangulace v pořádku není')
270 print('Triangulation is coplanar:', sx.tri.coplanar)
271 else:
272 #print('triangulace je v pořádku')
273 print('Triangulation is OK')
269 274
270 275
271 276
 
... ... class _Triangulation:
376 381 return np.logical_xor(has_failure, all_failure) return np.logical_xor(has_failure, all_failure)
377 382
378 383
379
380
381
382 def get_pf_estimation(bx):
383 # TRI-compatible estimation
384 # -1=outside, 0=success, 1=failure, 2=mix
385 #č dostaneme vyrovnané odhady Brna-města (-2) a Brna-venkova (-1)
386 tri_estimation = dict()
387 tri_estimation[-1] = bx.siss.estimations[-1]
388
389 # set initial values
390 tri_estimation[0] = 0
391 tri_estimation[1] = 0
392 tri_estimation[2] = 0
393
394 #č něco konkretnějšího
395 vertex_estimation = 0
396 weighted_vertex_estimation = 0
397
398 pf_inside = bx.siss.estimations[-2]
399 if "tri" in dir(bx):
400 # let's iterate over all simplices we have
401 # (calling code is responsible for the .simplex_stats validity)
402 for event_id, simplex_measure, fm, wfm in bx.simplex_stats.values():
403 tri_estimation[event_id] += simplex_measure
404 vertex_estimation += fm
405 weighted_vertex_estimation += wfm
406
407 #č success klidně může být i záporným
408 tri_estimation[0] = pf_inside - tri_estimation[1] - tri_estimation[2]
409
410 elif np.all(bx.failsi[:len(bx.convex_hull.points)]):
411 #č veškerej vnitršek je v poruše
412 tri_estimation[1] = pf_inside
413 vertex_estimation = pf_inside
414 weighted_vertex_estimation = pf_inside
415 else:
416 #č vnitršek je asi v pořadku
417 tri_estimation[0] = pf_inside
418
419 np.array(tuple(c.values()))
420
421 #č success zustané nulovým
422 global_stats = {'failure':0, 'success':0, 'mix':0, 'outside':outside}
423 global_stats['vertex_estimation'] = 0
424 global_stats['weighted_vertex_estimation'] = 0
425
426
427 return {'TRI_estimation': tri_estimation, \
428 'vertex_estimation' : vertex_estimation, \
429 'weighted_vertex_estimation' : weighted_vertex_estimation}
430
431 384
432 385
433 386
 
... ... class _Triangulation:
447 400 event, event_id, fr, wfr = get_indices_event(sx.sample_box,\ event, event_id, fr, wfr = get_indices_event(sx.sample_box,\
448 401 indices, sx.weighting_space) indices, sx.weighting_space)
449 402
450 sx.integrate_simplex(simplex, event, event_id, fr, wfr)
451
403 sx.integrate_simplex(indices, event, event_id, fr, wfr)
452 404
453 #č vyhodil jsem simplex_id'y
454 def estimate_simplex(bx, indices):
455
456 #č zkusím funkci návrhnout tak, že
457 #ё вызывающая функция запускает estimate_simplex
458 #ё на всём подряд без разбору.
459 #č Našim úkolem je zjistit co je simplex zač
460 #č a ty zelené ignorovat
461
462 #č ty množiny jsou tak trošku overkill, ale budiž
463 bx.simplices_set.add(tuple(indices))
464
465
466 # I'll use tree_space as a weigthing space
467 # It could be separeted, but I am a little bit tired
468 # from so much different spaces over there
469 event, event_id, fr, wfr = sx.get_indices_event(bx, indices, bx.tree_space)
470
471 # -1 = 'outside', 0=success, 1=failure, 2=mix
472 if event_id != 0:
473 #оӵ чылкыт f_model
474 #č do sample_simplexu musíme poslat čístý f_model
475 # we should send pure f_model to sample_simplex()
476 vertices = bx.f_model[indices]
477 print("estimate", indices)
478 h_plan, convex_hull, simplex_measure = sx.sample_simplex(vertices,\
479 model_space=bx.tri_space, sampling_space=bx.sampling_space, nis=bx.simplex_budget)
480
481
482 fm = simplex_measure * fr
483 wfm = simplex_measure * wfr
484
485 #č ISSI tu nemáme, místo toho prostě ukladáme co máme do slovníku
486 bx.simplex_stats[tuple(indices)] = (event_id, simplex_measure, fm, wfm)
487
488 if sx.on_add_simplex is not None:
489 sx.on_add_simplex(indices=indices)
490 405
491
492 #č vyhodil jsem simplex_id'y
493 def _invalidate_simplex(sx, indices):
494 simplex = tuple(indices)
495
496 #č ten simplex tam musí být,
497 #č pokud teda bo boxu nikdo nesahá...
498 sx.simplices_set.remove(simplex)
499
500 if simplex in sx.simplex_stats:
501 sx.simplex_stats.pop(simplex)
502
503 if sx.on_delete_simplex is not None:
504 sx.on_delete_simplex(indices=indices)
505 406
506 407
507 408
 
... ... class _Triangulation:
509 410
510 411
511 412
512 class FullTriangulation:
513 def __init__(sx, sample_box, tri_space='Rn', sampling_space=None, \
514 simplex_budget=100, incremental=True, design=None, callback=None):
515
516 sx.sample_box = sample_box
517 sx.tri_space = tri_space
413 class FullTriangulation(_Triangulation):
414 def __init__(sx, sample_box, tri_space='Rn', issi=None, weighting_space=None, \
415 incremental=True, on_add_simplex=None, on_delete_simplex=None, \
416 sampling_space=None, simplex_budget=100, design=None):
518 417
519 418 if sampling_space is None: if sampling_space is None:
520 419 sx.sampling_space = tri_space sx.sampling_space = tri_space
521 420 else: else:
522 421 sx.sampling_space = sampling_space sx.sampling_space = sampling_space
523 422
524 if weighting_space is None:
525 sx.weighting_space = tri_space
526 else:
527 sx.weighting_space = weighting_space
528
529 sx.design = design
530 423 sx.simplex_budget = simplex_budget sx.simplex_budget = simplex_budget
424 sx.design = design
531 425
532
533 #č jsou to informace pro callback
534 estimation={'method': "fast_simplex_cubature", 'nsim':nsim}
535 estimation['model_space'] = model_space
536 estimation['sampling_space'] = sampling_space
537 estimation['weighting_space'] = weighting_space
538 estimation['outside_budget'] = outside_budget
539 estimation['tn_scheme'] = tn_scheme.name
540
541
542 siss, outside = _issi_estimate_outside(f, estimation, callback)
543
544 #č success zustané nulovým
545 global_stats = {'failure':0, 'success':0, 'mix':0, 'outside':outside}
546 global_stats['vertex_estimation'] = 0
547 global_stats['weighted_vertex_estimation'] = 0
548
549
550 #č žádné chyby nechytám
551 #čs když se tringulace nepovede tak nemáme čo robiť
552 sampled_plan_model = getattr(sample_box, model_space)
553 tri = Delaunay(sampled_plan_model)
554 #č koplanar neřeším (ale vrátím spolu s ostatníma věcma na konci)
555
556
557 #оӵ кылсузъет кылдытом
558 bx.simplex_stats = dict()
559 # create .tri triangulation
560 #č tri - Deloneho triangulace
561 # incremental triangulation require one more point
562 bx.tri = spatial.Delaunay(getattr(bx.sampled_plan, bx.tri_space), incremental=True)
563 if len(bx.tri.coplanar):
564 #print('triangulace v pořádku není')
565 bx._logger(msg='triangulation is coplanar')
566 else:
567 #print('triangulace je v pořádku')
568 bx._logger(msg='triangulation is OK')
569
570 #č vyhodil jsem simplex_id'y
571 bx.simplex_events = bx.get_events()
572 #č ty množiny jsou tak trošku overkill, ale budiž
573 bx.simplices_set = set()
574 for simplex in bx.tri.simplices:
575 # zde jen počítame
576 bx.estimate_simplex(simplex)
426 sx.setup(sample_box, tri_space=tri_space, issi=issi,\
427 weighting_space=weighting_space, incremental=incremental,\
428 on_add_simplex=on_add_simplex,\
429 on_delete_simplex=on_delete_simplex)
577 430
578 431
579 432
 
... ... class FullTriangulation:
590 443 sx.simplices_set.add(tuple(simplex)) sx.simplices_set.add(tuple(simplex))
591 444
592 445 # -1 = 'outside', 0=success, 1=failure, 2=mix # -1 = 'outside', 0=success, 1=failure, 2=mix
593 event, fr, wfr = six.get_failure_ratio(sample_box, event_id, simplex, weighting_space)
446 event, fr, wfr = get_failure_ratio(sx.sample_box, event_id,\
447 simplex, sx.weighting_space)
594 448 sx.integrate_simplex(simplex, event, event_id, fr, wfr) sx.integrate_simplex(simplex, event, event_id, fr, wfr)
595 449
596 450
 
... ... class FullTriangulation:
613 467 weighted_vertex_estimation = 0 weighted_vertex_estimation = 0
614 468
615 469 #č otside asi necháme nulovým #č otside asi necháme nulovým
616 global_stats = {'failure':0, 'success':0, 'mix':0, 'outside':0}
470 global_stats = {-1:0, 0:0, 1:0, 2:0}
617 471
618 472 # let's iterate over all simplices we have # let's iterate over all simplices we have
619 473 # (calling code is responsible for the .simplex_stats validity) # (calling code is responsible for the .simplex_stats validity)
620 474 for key, simplex_measure in sx.issi.estimations.items(): for key, simplex_measure in sx.issi.estimations.items():
621
475 if key == -1:
476 continue
622 477 event_id, _simplex_measure, fr, wfr = sx.simplex_stats[key] event_id, _simplex_measure, fr, wfr = sx.simplex_stats[key]
623 478 tri_estimation[event_id] += simplex_measure tri_estimation[event_id] += simplex_measure
624 479 global_stats[event_id] += _simplex_measure global_stats[event_id] += _simplex_measure
625 480 vertex_estimation += fr * simplex_measure vertex_estimation += fr * simplex_measure
626 481 weighted_vertex_estimation += wfr * simplex_measure weighted_vertex_estimation += wfr * simplex_measure
627 482
483 #ё так, для красоты
484 global_stats['outside'] = global_stats.pop(-1)
485 global_stats['success'] = global_stats.pop(0)
486 global_stats['failure'] = global_stats.pop(1)
487 global_stats['mix'] = global_stats.pop(2)
628 488
629 489 return {'TRI_estimation': tri_estimation, 'global_stats': global_stats, \ return {'TRI_estimation': tri_estimation, 'global_stats': global_stats, \
630 490 'vertex_estimation' : vertex_estimation, \ 'vertex_estimation' : vertex_estimation, \
 
... ... class FullTriangulation:
653 513
654 514 #č ještě navíc ukložime co máme do slovníku #č ještě navíc ukložime co máme do slovníku
655 515 #č zde slovník obsahuje odlišné hodnoty! fr a wfr místo fm a wfm! #č zde slovník obsahuje odlišné hodnoty! fr a wfr místo fm a wfm!
656 bx.simplex_stats[tuple(indices)] = (event_id, simplex_measure, fr, wfr)
516 sx.simplex_stats[tuple(indices)] = (event_id, simplex_measure, fr, wfr)
657 517
658 518
659 519
 
... ... class FullTriangulation:
673 533 sx.on_add_simplex(sx, indices=indices, simplex=vertices,\ sx.on_add_simplex(sx, indices=indices, simplex=vertices,\
674 534 nodes=nodes, cell_stats=cell_stats, out_nodes=out_nodes) nodes=nodes, cell_stats=cell_stats, out_nodes=out_nodes)
675 535
536
537
538 #č vyhodil jsem simplex_id'y
539 def _invalidate_simplex(sx, indices):
540 simplex = tuple(indices)
541
542 #č ten simplex tam musí být,
543 #č pokud teda bo boxu nikdo nesahá...
544 sx.simplices_set.remove(simplex)
545 sx.simplex_stats.pop(simplex)
546 sx.issi.delete_event_data(simplex)
676 547
548
549 if sx.on_delete_simplex is not None:
550 sx.on_delete_simplex(indices=indices)
677 551
678 552
679 553
 
... ... class FastTriangulation:
797 671
798 672
799 673
674
675 #č vyhodil jsem simplex_id'y
676 def estimate_simplex(bx, indices):
677
678 #č zkusím funkci návrhnout tak, že
679 #ё вызывающая функция запускает estimate_simplex
680 #ё на всём подряд без разбору.
681 #č Našim úkolem je zjistit co je simplex zač
682 #č a ty zelené ignorovat
683
684 #č ty množiny jsou tak trošku overkill, ale budiž
685 bx.simplices_set.add(tuple(indices))
686
687
688 # I'll use tree_space as a weigthing space
689 # It could be separeted, but I am a little bit tired
690 # from so much different spaces over there
691 event, event_id, fr, wfr = sx.get_indices_event(bx, indices, bx.tree_space)
692
693 # -1 = 'outside', 0=success, 1=failure, 2=mix
694 if event_id != 0:
695 #оӵ чылкыт f_model
696 #č do sample_simplexu musíme poslat čístý f_model
697 # we should send pure f_model to sample_simplex()
698 vertices = bx.f_model[indices]
699 print("estimate", indices)
700 h_plan, convex_hull, simplex_measure = sx.sample_simplex(vertices,\
701 model_space=bx.tri_space, sampling_space=bx.sampling_space, nis=bx.simplex_budget)
702
703
704 fm = simplex_measure * fr
705 wfm = simplex_measure * wfr
706
707 #č ISSI tu nemáme, místo toho prostě ukladáme co máme do slovníku
708 bx.simplex_stats[tuple(indices)] = (event_id, simplex_measure, fm, wfm)
709
710 if sx.on_add_simplex is not None:
711 sx.on_add_simplex(indices=indices)
712
800 713
801 714
802 715 #č vyhodil jsem simplex_id'y #č vyhodil jsem simplex_id'y
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/WellMet

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/WellMet

Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/WellMet

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main