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)
voronoi: add some preliminary lines of ContactSolver. WIP 6a203b278c9fa6de7da75c402c80f78d40164fdf I am 2022-10-12 23:38:59
voronoi: přídat pár těžkých smyček. WIP 7b0ffb602ae00ab2f12dc98d34c35ec20afa3cc4 I am 2022-10-12 00:13:36
add to repo voronoi module. WIP f43768c22d88fac7c7095be02d8c9b5620153976 I am 2022-10-11 03:29:49
convex_hull.Grick: malý puntičkářský fix v get_r() cfa07257b9ebadc21f2bd295d35978072fac19e9 I am 2022-10-10 07:14:26
qt_gui.qt_plot: add Grick to Ghull widget d90b9a87c3ef0989951a45b2a22346381ce16f02 I am 2022-10-10 03:17:24
convex_hull: implement Grick convex hull aproximation d09ca2e6aca41cfc67f3303eb97b97dd9c6f1fba I am 2022-10-10 03:15:52
qt_gui.qt_gui: distance matrix viewer is ready a532e5259c081a1aff193d3b61e0104c42b08f20 I am 2022-10-08 20:52:14
qt_gui.qt_gui: prepare distance matrix window 4eaea3305643c60c35f0b22421a7e57dbe7a7817 I am 2022-10-08 02:59:01
qt_gui.qt_graph_widgets: set up x limits for all graph widgets 413d114f6a4e4b45c6cd44959cc42588bb7c8008 I am 2022-10-07 22:54:46
qt_gui.qt_plot: set up equal aspect by default 11bfe09b3e96881ef6f7c8202a6723b6e8adc03a I am 2022-10-07 21:41:18
qt_gui.qt_gui: hide "connect/disconnect" button. It wasn't really supported d9f195fe0611d6cf9a8154f0175c6c9506d56247 I am 2022-10-07 21:33:07
qt_gui.qt_plot: fix zero r cirkle (off by one error) 681397de6d075b693897d5f64004c0eb481fd36f I am 2022-10-07 20:34:44
qt_gui: replace globally QtGui by QtWidgets 969a659ae31728e75f587f25f54bab1ae5d6bfff I am 2022-10-07 12:45:34
qt_gui: add radia in Gaussian space (GRaph) widget e3f5be57dcdc6bdd06cda0594ffd795ef5bc8ccc I am 2022-10-07 01:15:38
testcases.testcases_2d: fix natafm_plane pf 75006ccd448c9717c13659e8ceb68800fbda39a7 I am 2022-06-26 12:03:39
misc: add entropy formula 72736d485b4f0fa912a47a49f72954e1ec06c03f I am 2022-06-26 12:02:52
testcases.gaussian_2D: one more product... e835ab15321169c2da085a6bb74e1ed749e67f14 I am 2022-05-11 15:38:24
whitebox: add explicitly solved Gaussian 2D product distribution 23d243baed0b7b71ba887444665420d673dc3fe9 I am 2022-05-11 15:37:19
whitebox: simplify Bessel solutions d097f681f9c96d7f8c6e0c044479681bae110e98 I am 2022-05-08 03:33:44
reorganize the repo 5226fda5d5cba79b6d3471540a4a5f47109d0061 I am 2022-04-30 17:11:21
Commit 6a203b278c9fa6de7da75c402c80f78d40164fdf - voronoi: add some preliminary lines of ContactSolver. WIP
Author: I am
Author date (UTC): 2022-10-12 23:38
Committer name: I am
Committer date (UTC): 2022-10-12 23:38
Parent(s): 7b0ffb602ae00ab2f12dc98d34c35ec20afa3cc4
Signer:
Signing key:
Signing status: N
Tree: f0cc8d40d167501d354c893834a010b6bbf53df1
File Lines added Lines deleted
wellmet/voronoi.py 117 34
File wellmet/voronoi.py changed (mode: 100644) (index b5cb457..73c7f8d)
... ... import numpy as np
5 5 import numpy.ma as ma import numpy.ma as ma
6 6 import scipy.stats as stats import scipy.stats as stats
7 7
8 from scipy.spatial import cKDTree
8 from scipy.spatial import KDTree
9 9 from scipy.spatial import Delaunay from scipy.spatial import Delaunay
10 10 from scipy import spatial from scipy import spatial
11 11 from scipy import interpolate from scipy import interpolate
12 from scipy.optimize import linprog
12 13
13 14 import collections # for defaultdict import collections # for defaultdict
14 15
 
... ... from . import sball
21 22
22 23
23 24
25
26 class ContactSolver:
27 """
28 č Hlavní pointa třídy:
29 č pokud dva body zvednuté na povrch convexního paraboloidu
30 č v prostoru ndim+1 (feature space, quadratic kernel)
31 č lze lineárně separovat (hyperrovinou) od ostatních bodů,
32 č znamená to, že v původním prostoru
33 č jejich Voroného buňky budou mít společnou stěnu (kontakt),
34 č neboli, což je totež, u Delone triangulace by měly společné simplexy
35
36 linprog:
37 minimize c @ x
38 such that:
39 A_ub @ x <= b_ub
40 A_eq @ x == b_eq
41 lb <= x <= ub
42
43 č rovnice hyperroviny
44 H = ax + b = a1x1 + a2x2 + ... + b = 0
45 č ačka a bčko jsou pro nás neznamé
46 č takže máme ndim+1 iksů do tamtoho lineárního solveru
47
48 č nebudeme puntičkařit a pro jednoduchost předepíšeme,
49 č nechť dva body zájmu leží přímo v hyperrovině
50 č (bude to hlasít existence rozhraní i v degenerovaných případech
51 č jako např. tří teček na jedné přímce. Mně to ale nevadí)
52 č Takže.
53
54 č pro linprog zadáme constrains Ax=b
55 A = [[ x_1i, x_2i, ..., x_ni, 1],
56 [ x_1j, x_2j, ..., x_nj, 1]]
57 b = [0, 0]
58
59
60 č Zbytek nechť splnuje nerovnost, tj.
61 "Convex hull inequalities of the form Ax + b <= 0"
62
63 A = [[ x_1i, x_2i, ..., x_ni, 1],
64 [ x_1j, x_2j, ..., x_nj, 1]]
65 b = [0, 0]
66
67
68 """
69 def __init__(self, points):
70 nsim, ndim = points.shape
71 # kind of datascience. feature space, quadratic kernel...
72 self.lifted_points = np.empty((nsim, ndim + 1))
73 self.lifted_points[:, :ndim] = points
74 self.lifted_points[:, -1] = np.sum(np.square(points), axis=1)
75
76 #č pro linprog zadáme constrains Ax=b
77 # A = [[ x_1i, x_2i, ..., x_ni, 1],
78 # [ x_1j, x_2j, ..., x_nj, 1]]
79 # b = [0, 0]
80 self.A_eq = np.empty((2, ndim + 2))
81 self.A_eq[:, -1] = 1
82 self.b_eq = np.zeros(2)
83
84 self.A_ub = np.empty((nsim, ndim + 2))
85 self.A_ub[:, :ndim] = points
86 self.A_ub[:, -1] = np.sum(np.square(points), axis=1)
87
88 def is_couple(self, couple_indices):
89 i, j = couple_indices
90
91 #č pro linprog zadáme constrains Ax=b
92 # A = [[ x_1i, x_2i, ..., x_ni, 1],
93 # [ x_1j, x_2j, ..., x_nj, 1]]
94 self.A_eq[:, :ndim] = self.lifted_points[[i, j]]
95 #self.A_eq[:, -1] = 1
96
97
98
99 # Ax + b < 0
100
101 # Ax + b = 0
102
103 # Ax < b
104
105 c = np.array([-29.0, -45.0, 0.0, 0.0])
106 >>> A_ub = np.array([[1.0, -1.0, -3.0, 0.0],
107 ... [-2.0, 3.0, 7.0, -3.0]])
108 >>> b_ub = np.array([5.0, -10.0])
109 >>> A_eq = np.array([[2.0, 8.0, 1.0, 0.0],
110 ... [4.0, 4.0, 0.0, 1.0]])
111 >>> b_eq = np.array([60.0, 60.0])
112 >>> x0_bounds = (0, None)
113 >>> x1_bounds = (0, 5.0)
114 >>> x2_bounds = (-np.inf, 0.5) # +/- np.inf can be used instead of None
115 >>> x3_bounds = (-3.0, None)
116 >>> bounds = [x0_bounds, x1_bounds, x2_bounds, x3_bounds]
117 >>> result = linprog(c, A_ub=A_ub, b_ub=b_ub, A_eq=A_eq, b_eq=b_eq, bounds=bounds)
118
119
24 120 #оӵ кык точкаен Вороной #оӵ кык точкаен Вороной
25 121 # KickTouchCayenneVoronoi # KickTouchCayenneVoronoi
26 122
 
... ... class ContactVoronoi:
101 197 nsim = self.sample_box.nsim nsim = self.sample_box.nsim
102 198 if nsim < 2: if nsim < 2:
103 199 return None return None
104
105 # # ощень, ощень скромненько
106 # p_base = 0.3 # chcu, aby behem první iterace p_base tečiček jistě dopadlo do buňky
107 # nis_base = int((sample_box.nvar+1)/p_base)
108 # nis = int(max(budget/nsim, nis_base / stats.binom.sf(int(sample_box.nvar+1), nis_base, p_base)))
109 200
110 201 #č já vím, že sample box pokážde failsi přepočítavá #č já vím, že sample box pokážde failsi přepočítavá
111 202 self.failsi = self.sample_box.failsi self.failsi = self.sample_box.failsi
112 203
113 204 self.PDF = self.sample_box.pdf(self.model_space) self.PDF = self.sample_box.pdf(self.model_space)
114 205
115 #č zde provadím rozdělení na prostor, ve kterém vzorkujem
116 #č a prostor "modelu", vô ktôrom, v podstatě, měříme vzdaleností
117 sampled_plan_model = getattr(self.sample_box, model_space)
118 self.tree = cKDTree(sampled_plan_model)
119
206 self.sampled_plan_model = getattr(self.sample_box, self.model_space)
207 self.tree = KDTree(sampled_plan_model)
120 208
121 if self.sampling_space is None:
122 sampling_space = model_space
123 # sing like sampling
124 sampled_plan_sing = sampled_plan_model
125 self.tree_sampling = self.tree
126 else:
127 sampled_plan_sing = getattr(self.sample_box, self.sampling_space)
128 # narychlo, moc to nepomůže, neboť asi po 16 vzorcích počítá brut forsem
129 self.tree_sampling = cKDTree(sampled_plan_sing, compact_nodes=False, balanced_tree=False)
130
131 # find distance to the nearest sampling point (from all points)
132 #č pro sampling bych vždy použival p_norm=2
133 dd2, ii2 = tree_sampling.query(sampled_plan_sing, k=[2], p=2)
134 mindist_sing = dd2.flatten()
135 209
136 210
137 211 #č já vím, že sample box je pokážde přepočítavá #č já vím, že sample box je pokážde přepočítavá
 
... ... class ContactVoronoi:
194 268 def onboard_couple(self, couple_indices): def onboard_couple(self, couple_indices):
195 269 #č (i, j)? poprvé ta čísla vidíme #č (i, j)? poprvé ta čísla vidíme
196 270 i, j = couple_indices i, j = couple_indices
197 if i in self.failure_points:
198 if j in self.failure_points:
199 #č červený kontakt
200 self.integrate_couple(i)
201 else:
202 #č žlutý kontakt
203 self.integrate_couple(i)
204 else:
205
271
272 contact_node_model = np.sum(self.sampled_plan_model[[i, j]], axis=0)
273 np.divide(contact_node_model, 2, out=contact_node_model)
274
275
206 276 self.direct_contacts[(i, j)] = None self.direct_contacts[(i, j)] = None
207 277 self.nodes[(i, j)] = None self.nodes[(i, j)] = None
208 278
209 279
280 dd, ii = tree.query(h_plan_model_part, k=1, p=p_norm)
281
282 # find distance to the nearest sampling point (from all points)
283 dd2, ii2 = tree_sampling.query(sampled_plan_sing, k=[2], p=2)
284 mindist_sing = dd2.flatten()
285
210 286
211 287
212 288
 
... ... class ContactVoronoi:
220 296 self.onboard_couple((i, j)) self.onboard_couple((i, j))
221 297
222 298
299 #č i-té indexy jsou ty čerstvé, přes ně iterujeme
300 #č j-té - ty bežné, protí ním rozhodujeme
301 if j < self._nsim:
302 self._indices_to_update.add(j)
303
304
223 305
224 306 def integrate_couple(self, couple_indices): def integrate_couple(self, couple_indices):
225 307 """č máme nový manželský páreček """č máme nový manželský páreček
 
... ... class ContactVoronoi:
246 328 h_plan_model = getattr(h_plan, model_space) h_plan_model = getattr(h_plan, model_space)
247 329 dd, ii = tree.query(h_plan_model, k=1, p=p_norm) dd, ii = tree.query(h_plan_model, k=1, p=p_norm)
248 330
331
249 332 # nechám s velkým písmenkem # nechám s velkým písmenkem
250 333 Vor_mask = ii==i Vor_mask = ii==i
251 334 h_plan_model_ma = h_plan_model[Vor_mask] h_plan_model_ma = h_plan_model[Vor_mask]
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