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)
dicebox: add helper _exploration module 836ae6cd12f1a04f1e2fc3423e46777d16ebad7d I am 2022-12-15 01:30:20
convex_hull: add get_exploration_vector() method 795259d91b64c732e60a83a1d9e3b89c2141b003 I am 2022-12-15 01:28:12
qt_gui.qt_gui: dot not create graph widgets if estimations are not present f070ed140a135a980e4436ed3779455c0e1bf399 I am 2022-12-14 02:25:45
qt_gui.gl_plot.CandidatesWidget: apply changes for GLplot too 03550040b60c67d247e26425e35fac565dd88886 Aleksei Gerasimov 2022-12-14 01:56:01
qt_gui.qt_plot.CandidatesWidget: add CandyNodes support 2357cdd92170b1f660b15c92aec695d3f7c108b3 I am 2022-12-14 01:08:30
qt_gui.qt_graph_widgets.EstimationGraph: reimplement piece of zerosafe logic 342a1b7bfddb7ba5695b3f0e017c7f75811db1f0 I am 2022-12-13 22:15:54
qt_gui.qt_graph_widgets: update x range when box runned c52052a9c3f6926d03e8c39f7642aa0a8864fdc3 I am 2022-12-13 10:23:45
qt_gui.qt_graph_widgets.EstimationGraph: add outside and mixed lines df6c06e4287492855d613b1ae46edfca6a4757d3 I am 2022-12-12 06:13:55
qt_gui: replace old copypaste by cleaned up EstimationGraph 515d0d8a892984f8a7667da874972daff3318d74 I am 2022-12-12 05:36:43
qt_gui: prepare new BoxEstimationData class; rework ErrorGraph 37387100715f980771a8a37f99eec3e723759cd3 I am 2022-12-11 23:17:06
dicebox.circumtri: replace ndim by nvar to make TriEstimation pandas-friendly 0824222ae4c9c1f3fede971481816ed9ded9707a I am 2022-12-11 23:14:05
step back: introduce box_estimations, keep "estimations" for user ones dde983d57423e28083980cbae05f0a81fc8311e6 I am 2022-12-10 03:54:09
simplex.BetterCubatureIntegration: hotfix f8a607e5d60c591eb81037010717519c1fe6e993 I am 2022-12-08 00:29:57
qt_gui.qt_gui: add EstimationTableWidget bb44fc8a056ed90906c217cfc95f7cabc6ef71eb I am 2022-12-07 23:17:42
remove deprecated never used Plotly code d42ebb3535e4736a1e9fdb84c8d6dae633c83a33 I am 2022-12-07 15:03:51
dicebox.circumtri.CircumTri: enable estimations 4fe25ad47d71b1fd19fe00ad03d9b320b8c8614c I am 2022-12-07 14:30:46
dicebox: introduce new clean experimental CircumTri box aca3e971212590a59e9d07a3ff1aa952d02a848b I am 2022-12-07 04:19:55
simplex.Triangulation: keep locally pdfs and failsi, send tuple on simplex invalidation d2885ce44585e22294f9940159d6313642164f4c I am 2022-12-07 04:14:05
convex_hull.QHull: manual update() fix 5ccff702b9920c7525c88d306f2300cd43b2e76b I am 2022-12-07 04:02:39
simplex: implement BetterCubatureIntegration 88b14adc4423f0587bd51bed06e74ce6d0d60bd1 I am 2022-12-05 22:20:31
Commit 836ae6cd12f1a04f1e2fc3423e46777d16ebad7d - dicebox: add helper _exploration module
Author: I am
Author date (UTC): 2022-12-15 01:30
Committer name: I am
Committer date (UTC): 2022-12-15 01:30
Parent(s): 795259d91b64c732e60a83a1d9e3b89c2141b003
Signer:
Signing key:
Signing status: N
Tree: ba2bcdc0397f087e7416190eff727e41b62b6418
File Lines added Lines deleted
wellmet/dicebox/_exploration.py 248 0
File wellmet/dicebox/_exploration.py added (mode: 100644) (index 0000000..784631e)
1 #!/usr/bin/env python
2 # coding: utf-8
3
4
5 import numpy as np
6 import quadpy
7
8 from ..ghull import Ghull
9 from ..convex_hull import Grick
10 from .. import simplex as sx
11 from ..reader import Store
12 from .. import sball
13
14
15 from collections import namedtuple
16 from sortedcollections import ValueSortedDict
17
18
19
20
21
22
23
24
25 class _Exploration:
26
27
28 def __call__(bx):
29 if bx.nsim < 1: # je to legální
30 return bx.f_model.new_sample([], space='G', extend=True)
31 elif np.random.random() > bx.exploration_ratio:
32 bx._logger(bx.exploration_ratio, msg='refine!')
33 return bx.refine()
34 else:
35 return bx.explore()
36
37
38
39 def explore(bx):
40 p_desired = np.exp(-np.sqrt(bx.q * bx.nsim))
41 r = bx.sball.get_r(p_desired)
42 if bx.nsim > len(bx.direct_plan):
43 a, b = bx.convex_hull.get_exploration_vector()
44 R = -b
45 else:
46 a = bx.direct_plan[bx.nsim-1]
47 R = bx.ghull.get_R()
48
49 if r < R:
50 bx._logger(bx.exploration_ratio, msg='refine (fallbacked)!')
51 return bx.refine()
52
53 sample_G = a * r
54 bx._logger(bx.exploration_ratio, msg='explore!')
55 return bx.f_model.new_sample(sample_G, space='G')
56
57
58
59
60
61
62
63
64
65
66 ExplorationLog = namedtuple('ExplorationLog', (
67 "nsim",
68 "nvar",
69 "nfacets",
70 "r","R",
71 "inner",
72 "shell",
73 "outer",
74 "FORM_outside",
75 "TwoFORM_outside",
76 "orth_outside",
77 "inside",
78 "outside",
79 "success_points",
80 "failure_points",
81 "success",
82 "failure",
83 "mix",
84 "vertex_estimation",
85 "weighted_vertex_estimation"
86 ))
87
88
89 class DumbExploration(_Exploration):
90
91 #č hull musí být v G prostoru s auto_update=True
92 def __init__(bx, sample_box, q=10):
93 bx.sample_box = sample_box
94
95 bx.direct_plan = quadpy.un.mysovskikh_1(bx.nvar).points
96
97 bx.convex_hull = Grick(bx.f_model, bx.direct_plan, nrandom=50)
98 bx.q = q
99
100 bx.ghull = Ghull(bx.convex_hull)
101 bx.sball = sball.Sball(bx.nvar)
102
103 bx.exploration_ratio = 2 # never refine
104
105 #č přece ponechame složku pro uživatelské odhady
106 #č stm kód může semka něco ukladat
107 bx.estimations = []
108
109 #č vítejte nové uložiště odhadů.
110 #č Odhady z stm kódu už ale nemají na tohle sahat
111 if hasattr(bx, 'filename'):
112 bx.box_estimations = Store.create(bx.filename + "_exp", ExplorationLog)
113 else:
114 bx.box_estimations = []
115
116 bx.regen()
117
118
119 def init_parameters(bx):
120 """
121 Returns dictionary of parameters the DiceBox was initialized with
122 """
123 return {'sample_box':bx.sample_box, 'hull':bx.hull, 'q':bx.q}
124
125
126 def __repr__(bx):
127 return "%s(**%s)"%(bx.__class__.__name__, repr(bx.init_parameters()))
128
129 def __str__(bx):
130 return "%s(%s)"%(bx.__class__.__name__, str(bx.init_parameters()))
131
132
133
134
135 def regen(bx):
136 if bx.nsim > 0:
137 bx.estimate_outside()
138 bx._nsim = bx.nsim
139
140
141
142
143
144 def __len__(bx):
145 return bx.sample_box.nsim
146
147 def __getitem__(bx, slice):
148 #č stačí vratit sample_box
149 return bx.sample_box[slice]
150
151 def __getattr__(dx, attr):
152 if attr == 'dicebox':
153 return dx
154
155 #č branime sa rekurzii
156 # defend against recursion
157 #оӵ рекурсилы пезьдэт!
158 if attr == 'sample_box':
159 raise AttributeError
160
161 #ё По всем вопросам обращайтесь
162 #ё на нашу горячую линию
163 else:
164 return getattr(dx.sample_box, attr)
165
166
167 # The DiceBox Observer
168 def _logger(self, *args, msg="", indent=0, **kwargs):
169 if not kwargs:
170 kwargs = "" #č ať se nám prázdné závorky nezobrazujou
171 print(self.__class__.__name__ + ":", msg, *args, kwargs)
172
173
174 # inspired by Qt
175 def connect(self, slot): self._logger = slot
176 def disconnect(self): del(self._logger)
177
178
179 # přidávání vzorků musí bejt explicitní!
180 def add_sample(bx, input_sample):
181 bx.sample_box.add_sample(input_sample)
182 bx.increment(bx.sample_box[bx._nsim:])
183 bx._nsim = bx.nsim
184
185
186
187
188 def increment(bx, input_sample):
189 bx.estimate_outside()
190
191 bx.box_estimations.append(bx.get_pf_estimation())
192
193
194
195
196
197
198
199
200
201 def estimate_outside(bx):
202 #č konečně mám pořádnou stejtful třídu
203 #č pokud mám aspoň jednu tečku, tak už je mi šuma
204 #č zda se konvexní obálka vytvořila, či nikoliv
205
206
207 shell_estimation, global_stats = bx.ghull.get_shell_estimation()
208
209 # shell_estimation -22: inner, -3: shell, -11: outer
210 bx.shell_estimation = shell_estimation
211
212 #č kvůli názvu neleze do namedtuple
213 global_stats['TwoFORM_outside'] = global_stats.pop('2FORM_outside')
214 #č ndim se nelibí pandas
215 global_stats['nvar'] = global_stats.pop('ndim')
216
217 bx.global_stats = global_stats
218
219
220
221
222
223 def get_pf_estimation(bx):
224 global_stats = bx.global_stats
225 orth_outside = global_stats['outside'] = global_stats['orth_outside']
226 pf_inside = global_stats['inside'] = 1 - orth_outside
227
228 #č takže celou skříňku prostě bereme jako simplex
229 event, event_id, fr, wfr = sx.get_simplex_event(bx, weighting_space='G')
230 # -1=outside, 0=success, 1=failure, 2=mix
231 tri_estimation = {0:0, 1:0, 2:0}
232 tri_estimation[event_id] = pf_inside
233
234 vertex_estimation = pf_inside * fr
235 weighted_vertex_estimation = pf_inside * wfr
236
237
238 failsi = bx.failsi
239 global_stats['success_points'] = len(failsi[~failsi])
240 global_stats['failure_points'] = len(failsi[failsi])
241 global_stats['success'] = tri_estimation[0]
242 global_stats['failure'] = tri_estimation[1]
243 global_stats['mix'] = tri_estimation[2]
244 global_stats['vertex_estimation'] = vertex_estimation
245 global_stats['weighted_vertex_estimation'] = weighted_vertex_estimation
246
247 return ExplorationLog(**global_stats)
248
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