File qt_gui/qt_box_functions.py changed (mode: 100644) (index c0452d6..3e9aa36) |
2 |
2 |
# coding: utf-8 |
# coding: utf-8 |
3 |
3 |
|
|
4 |
4 |
import sys |
import sys |
|
5 |
|
from . import qt_testcases |
|
6 |
|
from .. import reader |
5 |
7 |
import pyqtgraph as pg |
import pyqtgraph as pg |
6 |
8 |
from pyqtgraph.Qt import QtGui, QtCore |
from pyqtgraph.Qt import QtGui, QtCore |
7 |
9 |
|
|
8 |
10 |
|
|
9 |
|
app = pg.mkQApp() |
|
10 |
|
|
|
11 |
|
csv_filter = "CSV files (*.csv)" |
|
12 |
|
|
|
13 |
|
#print(pg.FileDialog.Options.Union.__dict__) |
|
14 |
|
filename, __filter = pg.FileDialog.getSaveFileName( |
|
15 |
|
parent=None, |
|
16 |
|
caption="open/store", |
|
17 |
|
directory="", |
|
18 |
|
filter=csv_filter + ";;All files(*)", |
|
19 |
|
initialFilter=csv_filter, |
|
20 |
|
options=pg.FileDialog.Option.DontConfirmOverwrite |
|
21 |
|
) |
|
22 |
|
|
|
23 |
|
print(filename) |
|
24 |
|
|
|
25 |
|
def export_to_excel(self): |
|
26 |
|
#č já bych nechtěl, aby mně export najednou spadl |
|
27 |
|
#č z jakéhokoliv důvodu |
|
28 |
|
try: |
|
29 |
|
proposal_filename = self.dice_box.guessbox.filename |
|
30 |
|
if proposal_filename: |
|
31 |
|
proposal_filename += '.xlsx' |
|
32 |
|
else: |
|
33 |
|
proposal_filename = self.dice_box.gm_signature + '.xlsx' |
|
34 |
|
filename, *__ = pg.FileDialog.getSaveFileName(self.stream, 'Export to Excel',\ |
|
35 |
|
proposal_filename, initialFilter='*.xlsx') |
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
self.df.to_excel(filename) |
|
40 |
|
except BaseException as e: |
|
41 |
|
print(self.__class__.__name__ + ":", repr(e)) |
|
42 |
|
|
|
|
11 |
|
def select_test_case(): |
|
12 |
|
return qt_testcases.SelectTestCaseWidget().box |
|
13 |
|
|
|
14 |
|
|
|
15 |
|
def read_box(wt): |
|
16 |
|
""" |
|
17 |
|
Funkce read_box() buď vytvoří Reader object |
|
18 |
|
kterým nahradí wt.sample_box, |
|
19 |
|
nebo - je-li uživatel odmitné zvolit nějaký soubor |
|
20 |
|
ponechá původní samplebox |
|
21 |
|
""" |
|
22 |
|
app = pg.mkQApp() |
|
23 |
|
csv_filter = "CSV files (*.csv)" |
|
24 |
|
filename, __filter = pg.FileDialog.getSaveFileName( |
|
25 |
|
parent=None, |
|
26 |
|
caption="open/store", |
|
27 |
|
directory="store", |
|
28 |
|
#filter=csv_filter, |
|
29 |
|
filter=csv_filter + ";;All files(*)", |
|
30 |
|
initialFilter=csv_filter, |
|
31 |
|
options=pg.FileDialog.Option.DontConfirmOverwrite |
|
32 |
|
) |
|
33 |
|
if filename: |
|
34 |
|
#č Reader vždy dopíše '.csv' na konci souboru |
|
35 |
|
#č nechcu to teď měnit |
|
36 |
|
if filename[-4:]=='.csv': |
|
37 |
|
filename = filename[:-4] |
|
38 |
|
#č Reader sám zavolá SampleBox |
|
39 |
|
wt.sample_box = reader.Reader(filename, wt.samplebox.sampled_plan) |
|
40 |
|
|
43 |
41 |
|
|
|
42 |
|
|
File qt_gui/qt_gui.py copied from file qt_plot.py (similarity 99%) (mode: 100644) (index 6b8bbfa..8aa7ad5) |
... |
... |
import pandas as pd # required for estimation graph |
16 |
16 |
import quadpy |
import quadpy |
17 |
17 |
|
|
18 |
18 |
|
|
19 |
|
from . import estimation as stm |
|
20 |
|
from . import misc |
|
21 |
|
from . import stm_df |
|
22 |
|
from . import sball |
|
23 |
|
from . import schemes |
|
24 |
|
from . import convex_hull as khull |
|
|
19 |
|
from .. import estimation as stm |
|
20 |
|
from .. import misc |
|
21 |
|
from .. import stm_df |
|
22 |
|
from .. import sball |
|
23 |
|
from .. import schemes |
|
24 |
|
from .. import convex_hull as khull |
25 |
25 |
#č pro mě je zvykem jako ghull označovat objekt třídy Ghull |
#č pro mě je zvykem jako ghull označovat objekt třídy Ghull |
26 |
26 |
#č nikoliv čerstvě oddelený modul |
#č nikoliv čerstvě oddelený modul |
27 |
|
from .ghull import Ghull, Shell_MC, Shell_IS, Shell_1DS |
|
|
27 |
|
from ..ghull import Ghull, Shell_MC, Shell_IS, Shell_1DS |
28 |
28 |
|
|
29 |
29 |
|
|
30 |
|
def qt_gui_plot_2d(sample_box, space='R', *args, **kwargs): |
|
31 |
|
""" |
|
32 |
|
This function will start Qt graph window in event loop |
|
33 |
|
""" |
|
34 |
|
|
|
35 |
|
return QtGuiPlot2D(sample_box, space, *args, **kwargs) |
|
36 |
|
|
|
37 |
30 |
|
|
38 |
31 |
### Define a top-level widget to hold everything |
### Define a top-level widget to hold everything |
39 |
32 |
class QtGuiPlot2D(QtGui.QMainWindow): |
class QtGuiPlot2D(QtGui.QMainWindow): |
|
... |
... |
class QtGuiPlot2D(QtGui.QMainWindow): |
103 |
96 |
# should be INHERITED by gl_plot |
# should be INHERITED by gl_plot |
104 |
97 |
def initialize_matplotlib_menu(self): |
def initialize_matplotlib_menu(self): |
105 |
98 |
try: # entire optional functionality |
try: # entire optional functionality |
106 |
|
from .mplot import show_ax, show_ax3d, show_fig |
|
107 |
|
from .mplot import maxes |
|
108 |
|
from .mplot import maxes3d |
|
109 |
|
from .mplot import mfigs |
|
110 |
|
from .mplot import misc as mmisc |
|
|
99 |
|
from ..mplot import show_ax, show_ax3d, show_fig |
|
100 |
|
from ..mplot import maxes |
|
101 |
|
from ..mplot import maxes3d |
|
102 |
|
from ..mplot import mfigs |
|
103 |
|
from ..mplot import misc as mmisc |
111 |
104 |
self.matplotlib_menu = self.bar.addMenu("Matplotlib") |
self.matplotlib_menu = self.bar.addMenu("Matplotlib") |
112 |
105 |
self.matplotlib_actions = [] |
self.matplotlib_actions = [] |
113 |
106 |
|
|
File qt_gui/qt_testcases.py added (mode: 100644) (index 0000000..038a5ce) |
|
1 |
|
import sys |
|
2 |
|
|
|
3 |
|
from ..testcases import testcases_2D, testcases_2D_papers |
|
4 |
|
import pyqtgraph as pg |
|
5 |
|
from pyqtgraph.Qt import QtGui, QtCore, QtWidgets |
|
6 |
|
|
|
7 |
|
|
|
8 |
|
class TestCasesListWidget(QtGui.QListWidget): |
|
9 |
|
def __init__(self, module, parent=None): |
|
10 |
|
self.module = module |
|
11 |
|
super().__init__(parent) |
|
12 |
|
self.addItems(module.__all__) |
|
13 |
|
|
|
14 |
|
def extract_selected_item(self): |
|
15 |
|
item = self.currentItem() |
|
16 |
|
if item is None: |
|
17 |
|
return getattr(self.module, self.module.__all__[0])() |
|
18 |
|
else: |
|
19 |
|
item_str = self.currentItem().text() |
|
20 |
|
return getattr(self.module, item_str)() |
|
21 |
|
|
|
22 |
|
|
|
23 |
|
class SelectTestCaseWidget(pg.LayoutWidget): |
|
24 |
|
def __init__(self, parent=None): |
|
25 |
|
#č nejdřív vytvořiť apku |
|
26 |
|
self.app = pg.mkQApp("WellMet") |
|
27 |
|
# |
|
28 |
|
super().__init__(parent) |
|
29 |
|
|
|
30 |
|
self.setup() |
|
31 |
|
|
|
32 |
|
#č zobraziť |
|
33 |
|
self.show() |
|
34 |
|
#č a spustit smyčku |
|
35 |
|
self.app.exec_() |
|
36 |
|
|
|
37 |
|
def setup(self): |
|
38 |
|
self.setWindowTitle("Select testcase") |
|
39 |
|
self.box = None |
|
40 |
|
|
|
41 |
|
self.setup_tabs() |
|
42 |
|
self.addWidget(self.tabs, row=0, col=0, rowspan=1, colspan=2) |
|
43 |
|
|
|
44 |
|
self.btn_exit = QtGui.QPushButton('Exit') |
|
45 |
|
self.addWidget(self.btn_exit, row=1, col=0) |
|
46 |
|
self.btn_exit.clicked.connect(self.exit) |
|
47 |
|
|
|
48 |
|
self.btn_choose = QtGui.QPushButton('Next') |
|
49 |
|
self.addWidget(self.btn_choose, row=1, col=1) |
|
50 |
|
self.btn_choose.clicked.connect(self.choose) |
|
51 |
|
|
|
52 |
|
def exit(self): |
|
53 |
|
self.app.quit() |
|
54 |
|
sys.exit() |
|
55 |
|
|
|
56 |
|
def choose(self): |
|
57 |
|
tab_index = self.tabs.currentIndex() |
|
58 |
|
if tab_index == 0: |
|
59 |
|
self.box = self.tab_2d_papers.extract_selected_item() |
|
60 |
|
elif tab_index == 1: |
|
61 |
|
self.box = self.tab_2d.extract_selected_item() |
|
62 |
|
else: |
|
63 |
|
raise |
|
64 |
|
self.app.quit() |
|
65 |
|
|
|
66 |
|
def setup_tabs(self): |
|
67 |
|
# Initialize tab screen |
|
68 |
|
self.tabs = QtWidgets.QTabWidget(self) |
|
69 |
|
|
|
70 |
|
# Add tabs |
|
71 |
|
self.tab_2d_papers = TestCasesListWidget(testcases_2D_papers, self) |
|
72 |
|
self.tabs.addTab(self.tab_2d_papers,"Well-known 2D testcases") |
|
73 |
|
|
|
74 |
|
self.tab_2d = TestCasesListWidget(testcases_2D, self) |
|
75 |
|
self.tabs.addTab(self.tab_2d,"2D testcases") |
|
76 |
|
|
|
77 |
|
|
File testcases/testcases_2D.py added (mode: 100644) (index 0000000..b08cccf) |
|
1 |
|
#!/usr/bin/env python |
|
2 |
|
# coding: utf-8 |
|
3 |
|
|
|
4 |
|
#оӵ Тӧдьы кабъёс (ящикьёс) эскером |
|
5 |
|
|
|
6 |
|
from .. import whitebox |
|
7 |
|
from .. import g_models as gm |
|
8 |
|
from .. import f_models |
|
9 |
|
import scipy.stats as stats |
|
10 |
|
|
|
11 |
|
import numpy as np |
|
12 |
|
|
|
13 |
|
f = f_models.SNorm(2) |
|
14 |
|
h = f_models.UnCorD((stats.norm(-12,5), stats.norm(12,5))) |
|
15 |
|
#č pro různorodost |
|
16 |
|
gew = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]]) |
|
17 |
|
#gew = f_models.Nataf((stats.norm, stats.norm), [[1,0.8], [0.8,1]]) |
|
18 |
|
#gew = f_models.Nataf((stats.gumbel_r, stats.gumbel_l), [[1,0.8], [0.8,1]]) |
|
19 |
|
#č uniforma je na [0, 1], takže v cajku |
|
20 |
|
u = f_models.UnCorD((stats.uniform, stats.uniform)) |
|
21 |
|
|
|
22 |
|
__all__ = [] |
|
23 |
|
|
|
24 |
|
#č zde ten __all__ těžko dohlídáme |
|
25 |
|
#č budeme přidávat do seznamu postupně |
|
26 |
|
def add(str): |
|
27 |
|
__all__.append(str) |
|
28 |
|
|
|
29 |
|
|
|
30 |
|
# HyperRovina, куда ж без неё? |
|
31 |
|
# Gauß |
|
32 |
|
############# |
|
33 |
|
# g= a*X1 + b*X2 + c |
|
34 |
|
# becames |
|
35 |
|
# gm = Linear_nD(betas=(a,b,c)) |
|
36 |
|
add('plane_2D') |
|
37 |
|
def plane_2D(): |
|
38 |
|
return whitebox.HyperPlane(betas=(0.7,-1,2.5)) |
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
# nobody knows whats going on there |
|
43 |
|
""" parametry pravdepodobnostniho rozdeleni pro Z_min s Weib. velicinami |
|
44 |
|
wb_scales=(1,1) - tuple of Weibull scale parameters, len(wb_scales)==nvar |
|
45 |
|
shape = 5 |
|
46 |
|
je třeba zadat buď pf_exact, nebo konštantu u funkce minima Z_min """ |
|
47 |
|
# g= min(X1, X2, X3, X4) + c |
|
48 |
|
add('weibull_min_2D') |
|
49 |
|
def weibull_min_2D(): |
|
50 |
|
return whitebox.Weibull_Z_min(wb_scales=(1.5,0.9), shape=4, const=-2.5) |
|
51 |
|
#whitebox.Weibull_Z_min(wb_scales=(1.5,0.9), shape=4, pf_exact=1.0e-6) |
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
# neither Gauß knows whats going on there |
|
56 |
|
#whitebox.Gaussian_Z_sumexp(nvar=2, pf_exact=1.0e-6) |
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
# je třeba zadat buď pf_exact, nebo konštantu u funkce Z_sumsq |
|
62 |
|
# g = np.sum(sample**2, axis=1) - self._const |
|
63 |
|
add('sumsq_2D') |
|
64 |
|
def sumsq_2D(): |
|
65 |
|
return whitebox.SNorm_Z_sumsq(nvar=2, const=9.2) |
|
66 |
|
#whitebox.SNorm_Z_sumsq(nvar=2, pf_exact=1.0e-6) |
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
# libustka |
|
71 |
|
add('ball_2D') |
|
72 |
|
def ball_2D(): |
|
73 |
|
return whitebox.SNorm_S_ball(nvar=2, r=5) |
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
"""suma velicin plus beta*sqrt(Nvar. ) |
|
79 |
|
Pro IID Gaussian ma tohle ind. spol. beta = beta |
|
80 |
|
The same as Linear_nD, but defined via |
|
81 |
|
beta in sense of reliability index""" |
|
82 |
|
# Z_sum s divokým rozdělením |
|
83 |
|
# pro obyčejný norm dist viz. HyperPlane |
|
84 |
|
add('sum_2D') |
|
85 |
|
def sum_2D(): |
|
86 |
|
return whitebox.WhiteBox(gew, gm.Z_sum(nvar=2, beta_exact=2)) |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
# soucin velicin plus nějaká konstanta |
|
91 |
|
# g= X1 * X2 * X3 * X4 + c |
|
92 |
|
add('prod_2D_1') |
|
93 |
|
add('prod_2D_5') |
|
94 |
|
def prod_2D_1(): |
|
95 |
|
return whitebox.WhiteBox(f, gm.Z_prod(const=1)) |
|
96 |
|
def prod_2D_5(): |
|
97 |
|
return whitebox.WhiteBox(f, gm.Z_prod(const=5)) |
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
# min velicin plus nějaká konstanta |
|
102 |
|
# g= min(X1, X2, X3, X4) + c |
|
103 |
|
add('min_2D') |
|
104 |
|
def min_2D(): |
|
105 |
|
return whitebox.WhiteBox(f, gm.Z_min(const=5)) |
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
# g = np.sum(np.exp(-(sample**2)), axis=1) + self._const |
|
112 |
|
add('sumexp_2D') |
|
113 |
|
def sumexp_2D(): |
|
114 |
|
return whitebox.WhiteBox(f, gm.Z_sumexp(const=5)) |
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
""" |
|
119 |
|
c = 0.5 # wave amplitude in Gaussian space |
|
120 |
|
d = 3.0 # average of sine fiunction in Gaussian space |
|
121 |
|
k = 6 # number of sine waves (design points) |
|
122 |
|
""" |
|
123 |
|
add('sinball_2D') |
|
124 |
|
def sinball_2D(): |
|
125 |
|
return whitebox.WhiteBox(f, gm.S_ballSin2D(c=0.5, d=3.0, k=6)) |
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
# g = np.sum(sample**2, axis=1) - self._const |
|
132 |
|
add('nataf_sumsq_2D') |
|
133 |
|
def nataf_sumsq_2D(): |
|
134 |
|
return whitebox.WhiteBox(gew, gm.Z_sumsq(const=9.2)) |
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
# obecný S_ball bez výpočtu pf |
|
140 |
|
add('nataf_ball_2D') |
|
141 |
|
def nataf_ball_2D(): |
|
142 |
|
return whitebox.WhiteBox(gew, gm.S_ball(r=5)) |
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
# kruznicka |
|
148 |
|
add('circle_2D') |
|
149 |
|
def circle_2D(): |
|
150 |
|
return whitebox.WhiteBox(f, gm.ConicSection(l=2, e=0, teta=-np.pi/4, c=(-3,1), sign=1)) |
|
151 |
|
|
|
152 |
|
|
|
153 |
|
# Fajvka |
|
154 |
|
# člověk se tu bez půllitry nevýzná |
|
155 |
|
# viz. conic_section_boundaries_test.py pro inspiraciju |
|
156 |
|
add('five_2D') |
|
157 |
|
def five_2D(): |
|
158 |
|
return whitebox.WhiteBox(h, gm.ConicSection(l=.1, e=1.1, teta=-np.pi/4, c=(-3,1), sign=1)) |
|
159 |
|
|
|
160 |
|
|
|
161 |
|
# Exp_P |
|
162 |
|
# g = y - 1./np.exp(x)**5 |
|
163 |
|
# g = y - self._k/np.exp(x)**self._pow |
|
164 |
|
# k tomuhlenstomu by bylo možně výtvořiť bílou skřiňku (pro výpočet pf) |
|
165 |
|
add('exp_P_2D') |
|
166 |
|
def exp_P_2D(): |
|
167 |
|
return whitebox.WhiteBox(u, gm.Exp_P(k=1., pow=5)) |
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
# Sin2D |
|
173 |
|
# g = self._kx * x + self._ky * y + np.sin(self._kxsin*x) + self._const |
|
174 |
|
add('sin_2D') |
|
175 |
|
def sin_2D(): |
|
176 |
|
return whitebox.WhiteBox(f, gm.Sin2D(kx=-1/4., ky=-1, kxsin=5, const=5)) |
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
# Prod_FourBetas |
|
183 |
|
# g = beta^2/2 - |x1 * x2| |
|
184 |
|
#whitebox.WhiteBox(f, gm.Prod_FourBetas(beta=2.0)) |
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
""" BlackSwan2D |
|
189 |
|
a = 2.0 # boundary for x1 |
|
190 |
|
b = 5.0 # boundary for x2 |
|
191 |
|
y = np.where(sim[:,0] <= a, sim[:,0], sim[:,1]) |
|
192 |
|
# pro x1 <= a y = x1 |
|
193 |
|
# pro x1 > a y = x2 |
|
194 |
|
g = b - y # failure for b<y""" |
|
195 |
|
#whitebox.WhiteBox(f, gm.BlackSwan2D(a=2.0, b=5.0)) |
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
""" Metaballs2D |
|
200 |
|
# sebemenší parametrizace |
|
201 |
|
y1 = 4/9*(x1 + 2 )**2 + 1/25 * (x2 )**2 |
|
202 |
|
y2 = 1/4*(x1 - 2.5)**2 + 1/25 * (x2-0.5)**2 |
|
203 |
|
g = 30.0/( y1**2 + 1.0 ) + 20.0/( y2**2 + 1.0 ) - self._const""" |
|
204 |
|
#whitebox.WhiteBox(f, gm.Metaballs2D(const=5)) |
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
""" Logistic2D |
|
210 |
|
# sebemenší parametrizace |
|
211 |
|
y1 = self._c1 - x1 |
|
212 |
|
y2 = self._c2 + x2 |
|
213 |
|
y3 = 1.0/(1+np.exp(-2.0*y2)) - 0.5 |
|
214 |
|
|
|
215 |
|
if self.easy_version: |
|
216 |
|
g = np.minimum(y1,y2) # easy version for SuS |
|
217 |
|
else: |
|
218 |
|
g = np.minimum(y1,y3) # difficult version for SuS""" |
|
219 |
|
#whitebox.WhiteBox(f, gm.Logistic2D(c1=5, c2=4, easy_version=True)) |
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
""" CosExp2D |
|
225 |
|
# sebemenší parametrizace |
|
226 |
|
s = self._s |
|
227 |
|
# g = cos((np.exp(-xm-s ))*xm) * np.exp(-(x +s )/3) |
|
228 |
|
g = np.cos( ( np.exp(-sample[:,0] - s ) )*sample[:,0]) * np.exp( -(sample[:,0] + s )/3 ) """ |
|
229 |
|
#whitebox.WhiteBox(f, gm.CosExp2D(s=5)) |
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
""" FourBranch2D |
|
234 |
|
g1 = k1 + 0.1*(x1 - x2)**2 - (x1 + x2)/np.sqrt(2) |
|
235 |
|
g2 = k1 + 0.1*(x1 - x2)**2 + (x1 + x2)/np.sqrt(2) |
|
236 |
|
g3 = (x1 - x2) + k2/np.sqrt(2) |
|
237 |
|
g4 = (x2 - x1) + k2/np.sqrt(2) #č byl tu překlep v jednom članku |
|
238 |
|
g = np.min((g1, g2, g3, g4), axis=0)""" |
|
239 |
|
#whitebox.WhiteBox(f, gm.FourBranch2D(k1=3, k2=7)) |
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
File testcases/testcases_2D_papers.py renamed from testcases_2D.py (similarity 88%) (mode: 100644) (index 3063a1b..eeb3598) |
... |
... |
of different well-known 2D problems |
7 |
7 |
""" |
""" |
8 |
8 |
|
|
9 |
9 |
import numpy as np |
import numpy as np |
10 |
|
from . import g_models as gm |
|
11 |
|
from . import f_models |
|
12 |
|
from .whitebox import WhiteBox |
|
|
10 |
|
from .. import g_models as gm |
|
11 |
|
from .. import f_models |
|
12 |
|
from ..whitebox import WhiteBox |
13 |
13 |
import scipy.stats as stats |
import scipy.stats as stats |
14 |
14 |
from scipy import integrate # for Pareto tail |
from scipy import integrate # for Pareto tail |
15 |
15 |
|
|
|
16 |
|
__all__ = [ |
|
17 |
|
'uniform_branin_2D', |
|
18 |
|
'snorm_four_branch_2D', |
|
19 |
|
'snorm_four_branch_2D_2', |
|
20 |
|
'snorm_piecewise_2D_linear', |
|
21 |
|
'piecewise_pareto_tail', |
|
22 |
|
'snorm_min_2D_linear', |
|
23 |
|
'snorm_min_2D_logistic', |
|
24 |
|
] |
|
25 |
|
|
16 |
26 |
f = f_models.SNorm(2) |
f = f_models.SNorm(2) |
17 |
27 |
# Uniform-uniform |
# Uniform-uniform |
18 |
28 |
# from scipy: "In the standard form, the distribution is uniform on [0, 1]." |
# from scipy: "In the standard form, the distribution is uniform on [0, 1]." |
19 |
29 |
u = f_models.UnCorD((stats.uniform, stats.uniform)) |
u = f_models.UnCorD((stats.uniform, stats.uniform)) |
20 |
30 |
|
|
21 |
|
testcases = [] |
|
|
31 |
|
|
22 |
32 |
|
|
23 |
33 |
""" |
""" |
24 |
34 |
I would like to use function definitions to clearly isolate ones testcases |
I would like to use function definitions to clearly isolate ones testcases |
|
... |
... |
def uniform_branin_2D(): |
31 |
41 |
wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256 |
wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256 |
32 |
42 |
wt.description = "Rescaled Branin function" |
wt.description = "Rescaled Branin function" |
33 |
43 |
return wt |
return wt |
34 |
|
testcases.append(uniform_branin_2D()) |
|
35 |
44 |
|
|
36 |
45 |
# Four branch system |
# Four branch system |
37 |
46 |
def snorm_four_branch_2D(): |
def snorm_four_branch_2D(): |
|
... |
... |
def snorm_four_branch_2D(): |
40 |
49 |
wt.pf_exact_method = 'known value' #"some guys said me that" |
wt.pf_exact_method = 'known value' #"some guys said me that" |
41 |
50 |
wt.description = "Four branch system from some paper" |
wt.description = "Four branch system from some paper" |
42 |
51 |
return wt |
return wt |
43 |
|
testcases.append(snorm_four_branch_2D()) |
|
44 |
52 |
|
|
45 |
53 |
|
|
46 |
54 |
def snorm_four_branch_2D_2(): |
def snorm_four_branch_2D_2(): |
|
... |
... |
def snorm_four_branch_2D_2(): |
50 |
58 |
#wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256 |
#wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256 |
51 |
59 |
wt.description = "Four branch system from another paper" |
wt.description = "Four branch system from another paper" |
52 |
60 |
return wt |
return wt |
53 |
|
testcases.append(snorm_four_branch_2D_2()) |
|
54 |
61 |
|
|
55 |
62 |
|
|
56 |
63 |
|
|
|
... |
... |
def snorm_piecewise_2D_linear(): |
62 |
69 |
wt = WhiteBox(f, gm.piecewise_2D_linear) |
wt = WhiteBox(f, gm.piecewise_2D_linear) |
63 |
70 |
wt.description = "Breitung. Piecewise linear function" |
wt.description = "Breitung. Piecewise linear function" |
64 |
71 |
return wt |
return wt |
65 |
|
testcases.append(snorm_piecewise_2D_linear()) |
|
66 |
72 |
|
|
67 |
73 |
|
|
68 |
74 |
|
|
|
... |
... |
def piecewise_pareto_tail(): |
98 |
104 |
wt.pf_exact_method = 'FORM-type thought-three beta points' |
wt.pf_exact_method = 'FORM-type thought-three beta points' |
99 |
105 |
wt.description = "Breitung. Pareto tail" |
wt.description = "Breitung. Pareto tail" |
100 |
106 |
return wt |
return wt |
101 |
|
testcases.append(piecewise_pareto_tail()) |
|
102 |
107 |
|
|
103 |
108 |
|
|
104 |
109 |
|
|
|
... |
... |
def snorm_min_2D_linear(): |
107 |
112 |
wt = WhiteBox(f, gm.Logistic2D()) |
wt = WhiteBox(f, gm.Logistic2D()) |
108 |
113 |
wt.description = "Breitung. 2D linear (easy version for SuS)" |
wt.description = "Breitung. 2D linear (easy version for SuS)" |
109 |
114 |
return wt |
return wt |
110 |
|
testcases.append(snorm_min_2D_linear()) |
|
111 |
115 |
|
|
112 |
116 |
def snorm_min_2D_logistic(): |
def snorm_min_2D_logistic(): |
113 |
117 |
wt = WhiteBox(f, gm.Logistic2D(easy_version=False)) |
wt = WhiteBox(f, gm.Logistic2D(easy_version=False)) |
114 |
118 |
wt.description = "Breitung. Logistic 2D function (hard version for SuS)" |
wt.description = "Breitung. Logistic 2D function (hard version for SuS)" |
115 |
119 |
return wt |
return wt |
116 |
|
testcases.append(snorm_min_2D_logistic()) |
|
117 |
120 |
|
|
118 |
121 |
|
|
119 |
122 |
|
|