/testcases_2D.py (526104441da7029c83ff7c5037ae6b0dbc9a118d) (3411 bytes) (mode 100644) (type blob)
#!/usr/bin/env python
# coding: utf-8
"""
We will prepare here WhiteBox instances
of different well-known 2D problems
"""
import numpy as np
from . import g_models as gm
from . import f_models
from .whitebox import WhiteBox
import scipy.stats as stats
from scipy import integrate # for Pareto tail
f = f_models.SNorm(2)
# Uniform-uniform
# from scipy: "In the standard form, the distribution is uniform on [0, 1]."
u = f_models.UnCorD((stats.uniform, stats.uniform))
testcases = []
"""
I would like to use function definitions to clearly isolate ones testcases
"""
# Rescaled Branin function
def uniform_branin_2D():
wt = WhiteBox(u, gm.branin_2D)
wt.pf_exact = 0.257
wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256
wt.description = "Rescaled Branin function"
return wt
testcases.append(uniform_branin_2D())
# Four branch system
def snorm_four_branch_2D():
wt = WhiteBox(f, gm.FourBranch2D(k1=3, k2=7))
wt.pf_exact = 2.34e-03
wt.pf_exact_method = 'known value' #"some guys said me that"
wt.description = "Four branch system from some paper"
return wt
testcases.append(snorm_four_branch_2D())
def snorm_four_branch_2D_2():
wt = WhiteBox(f, gm.FourBranch2D(k1=5.5, k2=11))
# TODO calculate
#wt.pf_exact = 0.257
#wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256
wt.description = "Four branch system from another paper"
return wt
testcases.append(snorm_four_branch_2D_2())
# Breitung
# Piecewise linear function
def snorm_piecewise_2D_linear():
wt = WhiteBox(f, gm.piecewise_2D_linear)
wt.description = "Breitung. Piecewise linear function"
return wt
testcases.append(snorm_piecewise_2D_linear())
# Pareto tail
class PiecewiseParetoDist:
def __init__(self, a=3.5):
self.ax = a
self.au = stats.norm.cdf(a)
self.c = np.log(stats.norm.cdf(-a))/np.log(a)
self.pareto = stats.pareto(b=-self.c)
# без излишевст
self._p = integrate.quad(lambda x: self.pdf(x), -np.inf, np.inf)[0]
self._mean = integrate.quad(lambda x: x*self.pdf(x), -np.inf, np.inf)[0]
self._var = integrate.quad(lambda x: x**2*self.pdf(x), -np.inf, np.inf)[0]
def cdf(self, x):
return np.where(x < self.ax, stats.norm.cdf(x), self.pareto.cdf(x))
def pdf(self, x):
return np.where(x < self.ax, stats.norm.pdf(x), self.pareto.pdf(x))
def ppf(self, u):
return np.where(u < self.au, stats.norm.ppf(u), self.pareto.ppf(u))
def mean(self): return self._mean
def var(self): return self._var
def std(self): return np.sqrt(self._var)
def piecewise_pareto_tail():
h = f_models.UnCorD((stats.norm, PiecewiseParetoDist()))
wt = WhiteBox(h, gm.non_chi_squares)
wt.pf_exact = 1.84e-06
wt.pf_exact_method = 'IS estimation'
wt.description = "Breitung. Pareto tail"
return wt
testcases.append(piecewise_pareto_tail())
# Logistic 2D function
def snorm_min_2D_linear():
wt = WhiteBox(f, gm.Logistic2D())
wt.description = "Breitung. 2D linear (easy version for SuS)"
return wt
testcases.append(snorm_min_2D_linear())
def snorm_min_2D_logistic():
wt = WhiteBox(f, gm.Logistic2D(easy_version=False))
wt.description = "Breitung. Logistic 2D function (hard version for SuS)"
return wt
testcases.append(snorm_min_2D_logistic())
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
18023 |
dbc921a5ff53594363973972d53c5d572d2826d1 |
IS_stat.py |
100644 |
blob |
6 |
0916b75b752887809bac2330f3de246c42c245cd |
__init__.py |
100644 |
blob |
73368 |
3d245b8568158ac63c80fa0847631776a140db0f |
blackbox.py |
100644 |
blob |
11243 |
10c424c2ce5e8cdd0da97a5aba74c54d1ca71e0d |
candybox.py |
100644 |
blob |
53090 |
36d72557a0b012a8b30888e26a425a507929bfff |
dicebox.py |
100644 |
blob |
47075 |
3ad01c91c9781b03caf9d0365932c12eb1ccec5c |
estimation.py |
100644 |
blob |
34189 |
e2b43f8f1a46cfc950347d6106ff3cba9ffe5f0c |
f_models.py |
100644 |
blob |
31025 |
70bab60405bfe783a2f7a9f2c41b7c1629d3d474 |
g_models.py |
100644 |
blob |
42845 |
e66a644b3f32e3a7b2556eebe581ef7ef6a638d7 |
gl_plot.py |
100644 |
blob |
2718 |
5d721d117448dbb96c554ea8f0e4651ffe9ac457 |
gp_plot.py |
100644 |
blob |
29393 |
96162a5d181b8307507ba2f44bafe984aa939163 |
lukiskon.py |
100644 |
blob |
2004 |
6ea8dc8f50a656c48f786d5a00bd6398276c9741 |
misc.py |
100644 |
blob |
10489 |
1f6dd06a036fdc4ba6a7e6d61ac0b84e8ad3a4c1 |
mplot.py |
100644 |
blob |
1366 |
993a88f239b6304e48eb519c20a640f28055d7c9 |
plot.py |
100644 |
blob |
2807 |
1feb1d43e90e027f35bbd0a6730ab18501cef63a |
plotly_plot.py |
100644 |
blob |
108414 |
0582ff11304f24e05f5f13bf611a17d85cb37254 |
qt_plot.py |
100644 |
blob |
6304 |
7fc6ac75e415df43af5b7aa9d6d1848aa5d0963d |
reader.py |
100644 |
blob |
4284 |
a0e0b4e593204ff6254f23a67652804db07800a6 |
samplebox.py |
100644 |
blob |
5553 |
bac994ae58f1df80c7f8b3f33955af5402f5a4f3 |
sball.py |
100644 |
blob |
21623 |
281aef80556b8d22842b8659f6f0b7dab0ad71af |
shapeshare.py |
100644 |
blob |
19837 |
5517d072307bd4c5a462a20943e3a354f32a9589 |
simplex.py |
100644 |
blob |
10357 |
80c60a409f7b1eb0592d1276dff7aacb065a0f84 |
stm_df.py |
100644 |
blob |
3411 |
526104441da7029c83ff7c5037ae6b0dbc9a118d |
testcases_2D.py |
100644 |
blob |
22048 |
4a6014ca5255aa96059ff9ed5a7e29df98d26ffc |
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