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".

/testcases/testcases_2D.py (dfece1ed00db468a3ee31977fec4a8b90262f811) (7007 bytes) (mode 100644) (type blob)

#!/usr/bin/env python
# coding: utf-8

#оӵ Тӧдьы кабъёс (ящикьёс) эскером

from .. import whitebox
from .. import samplebox #č pro proxy_prod
from .. import g_models as gm
from .. import f_models
import scipy.stats as stats

import numpy as np

f = f_models.SNorm(2)
h = f_models.UnCorD((stats.norm(-12,5), stats.norm(12,5)))
#l = f_models.UnCorD([stats.lognorm(s=1), stats.lognorm(s=1)])
#č pro různorodost
gew = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]])
#gew = f_models.Nataf((stats.norm, stats.norm), [[1,0.8], [0.8,1]])
#gew = f_models.Nataf((stats.gumbel_r, stats.gumbel_l), [[1,0.8], [0.8,1]])
#č uniforma je na [0, 1], takže v cajku
u = f_models.UnCorD((stats.uniform, stats.uniform))

__all__ = []

#č zde ten __all__ těžko dohlídáme
#č budeme přidávat do seznamu postupně
def add(str):
    __all__.append(str)


# HyperRovina, куда ж без неё?
# Gauß
#############
# g= a*X1 + b*X2 + c
# becames
# gm = Linear_nD(betas=(a,b,c))
add('plane_2D')
def plane_2D():
    return whitebox.HyperPlane(betas=(0.7,-1,2.5))



# nobody knows whats going on there
""" parametry pravdepodobnostniho rozdeleni pro Z_min s Weib. velicinami
wb_scales=(1,1) - tuple of Weibull scale parameters, len(wb_scales)==nvar
shape = 5 
je třeba zadat buď pf_exact, nebo konštantu u funkce minima Z_min """
# g= min(X1, X2, X3, X4) + c
add('weibull_min_2D')
def weibull_min_2D():
    return whitebox.Weibull_Z_min(wb_scales=(1.5,0.9), shape=4, const=-2.5)
    #whitebox.Weibull_Z_min(wb_scales=(1.5,0.9), shape=4, pf_exact=1.0e-6)



# neither Gauß knows whats going on there
#whitebox.Gaussian_Z_sumexp(nvar=2, pf_exact=1.0e-6)




# je třeba zadat buď pf_exact, nebo konštantu u funkce Z_sumsq
# g = np.sum(sample**2, axis=1) - self._const
add('sumsq_2D')
def sumsq_2D():
    return whitebox.SNorm_Z_sumsq(nvar=2, const=9.2)
    #whitebox.SNorm_Z_sumsq(nvar=2, pf_exact=1.0e-6)



# libustka
add('ball_2D')
def ball_2D():
    return whitebox.SNorm_S_ball(nvar=2, r=5)




"""suma velicin plus beta*sqrt(Nvar. )
Pro IID Gaussian ma tohle ind. spol. beta = beta
The same as Linear_nD, but defined via 
beta in sense of reliability index"""
# Z_sum s divokým rozdělením
# pro obyčejný norm dist viz. HyperPlane
add('sum_2D')
def sum_2D():
    return whitebox.WhiteBox(gew, gm.Z_sum(nvar=2, beta_exact=2))



# soucin velicin plus nějaká konstanta 
# g= X1 * X2 * X3 * X4 + c
add('prod_2D_1')
add('prod_2D_5')
def prod_2D_1():
    return whitebox.WhiteBox(f, gm.Z_prod(const=1))
def prod_2D_5():
    return whitebox.WhiteBox(f, gm.Z_prod(const=5))

gm_z_prod = gm.Z_prod(const=5)

def proxy_prod(input_sample):
    # očekávam, že get_R_coordinates mně vrátí 2D pole
    sample = gm.get_R_coordinates(input_sample, 2)
    x, y = sample.T
    
    # osudná podmínka
    mask = np.atleast_1d(np.sign(x)==np.sign(y)).astype(bool)
    #č mrdáme na kontrolu. současný startup candybox vytvoří vždycky
    input_sample.candybox.proxy = mask
    sweet_sample = input_sample
    #sweet_sample = CandyBox(input_sample, proxy=mask)
            
    # zatím, pro jednoduchost, předpokladáme,
    # že dostaváme vzorky po jednom
    if np.all(mask):
        # nevíme vůbec, co to je za funkci
        # ale veříme, že víme co tam bude
        g = np.full(len(sweet_sample), 1)
        # s praznejm podpísem odmítá
        return samplebox.SampleBox(sweet_sample, g, 'proxy_prod')
        
    else: # deme počítat, bez b
        true_sample = gm_z_prod(sweet_sample)
        # padelame pospís
        true_sample.gm_signature = 'proxy_prod'
        return true_sample

# wrap
proxy_prod.get_2D_R_boundary = gm_z_prod.get_2D_R_boundary

add('proxy_prod_2D_5')
def proxy_prod_2D_5():
    return whitebox.WhiteBox(f, proxy_prod)


# min velicin plus nějaká konstanta 
# g= min(X1, X2, X3, X4) + c
add('min_2D')
def min_2D():
    return whitebox.Gaussian_Z_min(ndim=2, const=5)



# g = np.sum(np.exp(-(sample**2)), axis=1) + self._const
add('sumexp_2D')
def sumexp_2D():
    return whitebox.WhiteBox(f, gm.Z_sumexp(const=-0.1))
    #whitebox.Gaussian_Z_sumexp(nvar=2, co=-2)



"""
c = 0.5 # wave amplitude in Gaussian space
d = 3.0 # average of sine fiunction in Gaussian space
k = 6   # number of sine waves (design points)
"""
add('sinball_2D')
def sinball_2D():
    return whitebox.WhiteBox(f, gm.S_ballSin2D(c=0.5, d=3.0, k=6))





# g = np.sum(sample**2, axis=1) - self._const
add('nataf_sumsq_2D')
def nataf_sumsq_2D():
    return whitebox.WhiteBox(gew, gm.Z_sumsq(const=9.2))




# obecný S_ball bez výpočtu pf
add('nataf_ball_2D')
def nataf_ball_2D():
    return whitebox.WhiteBox(gew, gm.S_ball(r=5))




# kruznicka
add('circle_2D')
def circle_2D():
    return whitebox.WhiteBox(f, gm.ConicSection(l=2, e=0, teta=-np.pi/4, c=(-3,1), sign=1))


# Fajvka
# člověk se tu bez půllitry nevýzná
# viz. conic_section_boundaries_test.py pro inspiraciju
add('five_2D')
def five_2D():
    return whitebox.WhiteBox(h, gm.ConicSection(l=.1, e=1.1, teta=-np.pi/4, c=(-3,1), sign=1))


# Exp_P
# g = y - 1./np.exp(x)**5
# g = y - self._k/np.exp(x)**self._pow
# k tomuhlenstomu by bylo možně výtvořiť bílou skřiňku (pro výpočet pf)
add('exp_P_2D')
def exp_P_2D():
    return whitebox.WhiteBox(u, gm.Exp_P(k=1., pow=5))




# Sin2D
# g = self._kx * x + self._ky * y + np.sin(self._kxsin*x) + self._const
add('sin_2D')
def sin_2D():
    return whitebox.WhiteBox(f, gm.Sin2D(kx=-1/4., ky=-1, kxsin=5, const=5))





# Prod_FourBetas
# g = beta^2/2 - |x1 * x2|
#whitebox.WhiteBox(f, gm.Prod_FourBetas(beta=2.0))



""" BlackSwan2D
a = 2.0 # boundary for x1
b = 5.0 # boundary for x2
y = np.where(sim[:,0] <= a, sim[:,0], sim[:,1])
# pro x1 <= a   y = x1
# pro x1 >  a   y = x2
g = b - y # failure for b<y"""
#whitebox.WhiteBox(f, gm.BlackSwan2D(a=2.0, b=5.0))



""" Metaballs2D
# sebemenší parametrizace
y1 = 4/9*(x1 + 2  )**2 + 1/25 * (x2    )**2 
y2 = 1/4*(x1 - 2.5)**2 + 1/25 * (x2-0.5)**2 
g = 30.0/( y1**2 + 1.0 ) + 20.0/( y2**2 + 1.0 ) - self._const"""
#whitebox.WhiteBox(f, gm.Metaballs2D(const=5))




""" Logistic2D
# sebemenší parametrizace
y1 = self._c1 - x1
y2 = self._c2 + x2
y3 = 1.0/(1+np.exp(-2.0*y2)) - 0.5

if self.easy_version:
    g = np.minimum(y1,y2)  # easy version for SuS
else:
    g = np.minimum(y1,y3)  # difficult version for SuS"""
#whitebox.WhiteBox(f, gm.Logistic2D(c1=5, c2=4, easy_version=True))




""" CosExp2D
# sebemenší parametrizace
s = self._s
# g = cos((np.exp(-xm-s  ))*xm)   * np.exp(-(x +s  )/3)
g = np.cos( ( np.exp(-sample[:,0] - s ) )*sample[:,0])   * np.exp( -(sample[:,0] + s  )/3 )  """
#whitebox.WhiteBox(f, gm.CosExp2D(s=5))



""" FourBranch2D
g1 = k1 + 0.1*(x1 - x2)**2 - (x1 + x2)/np.sqrt(2)
g2 = k1 + 0.1*(x1 - x2)**2 + (x1 + x2)/np.sqrt(2)
g3 = (x1 - x2) + k2/np.sqrt(2)
g4 = (x2 - x1) + k2/np.sqrt(2) #č byl tu překlep v jednom članku
g = np.min((g1, g2, g3, g4), axis=0)"""
#whitebox.WhiteBox(f, gm.FourBranch2D(k1=3, k2=7))





Mode Type Size Ref File
100644 blob 28117 0907e38499eeca10471c7d104d4b4db30b8b7084 IS_stat.py
100644 blob 6 0916b75b752887809bac2330f3de246c42c245cd __init__.py
100644 blob 72 458b7e2ca46acd9ec0d2caf3cc4d72e515bb73dc __main__.py
100644 blob 73368 3d245b8568158ac63c80fa0847631776a140db0f blackbox.py
100644 blob 11243 10c424c2ce5e8cdd0da97a5aba74c54d1ca71e0d candybox.py
100644 blob 29927 066a2d10ea1d21daa6feb79fa067e87941299ec4 convex_hull.py
100644 blob 102798 059ae717e71c651975673420cd8230fbef171e5e dicebox.py
100644 blob 36930 a775d1114bc205bbd1da0a10879297283cca0d4c estimation.py
100644 blob 34394 3f0ab9294a9352a071de18553aa687c2a9e6917a f_models.py
100644 blob 35721 3daee87ec0bc670207356490e16f200fed0d4fc4 g_models.py
100644 blob 20908 457329fe567f1c0a9950c21c7c494cccf38193cc ghull.py
100644 blob 2718 5d721d117448dbb96c554ea8f0e4651ffe9ac457 gp_plot.py
100644 blob 29393 96162a5d181b8307507ba2f44bafe984aa939163 lukiskon.py
100644 blob 2888 0c4303f8865b4861382119d77147f227958f2aec misc.py
040000 tree - 36886ff71aadb2877d4f3cb739e214355580ec31 mplot
100644 blob 1462 437b0d372b6544c74fea0d2c480bb9fd218e1854 plot.py
100644 blob 2807 1feb1d43e90e027f35bbd0a6730ab18501cef63a plotly_plot.py
040000 tree - bfb2adfd17a5c916d2a132e2607f57f14561559e qt_gui
100644 blob 8566 5c8f8cc2a34798a0f25cb9bf50b5da8e86becf64 reader.py
100644 blob 4284 a0e0b4e593204ff6254f23a67652804db07800a6 samplebox.py
100644 blob 6558 df0e88ea13c95cd1463a8ba1391e27766b95c3a5 sball.py
100644 blob 6739 0b6f1878277910356c460674c04d35abd80acf13 schemes.py
100644 blob 76 11b2fde4aa744a1bc9fa1b419bdfd29a25c4d3e8 shapeshare.py
100644 blob 54884 fbe116dab4fc19bb7568102de21f53f15a8fc6bf simplex.py
100644 blob 13090 2b9681eed730ecfadc6c61b234d2fb19db95d87d spring.py
100644 blob 10953 da8a8aaa8cac328ec0d1320e83cb802b562864e2 stm_df.py
040000 tree - 257d3de26ca92fafda012c78bccbd1e3ae01824c testcases
100644 blob 2465 d829bff1dd721bdb8bbbed9a53db73efac471dac welford.py
100644 blob 25318 fcdabd880bf7199783cdb9c0c0ec88c9813a5b18 whitebox.py
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