Subject | Hash | Author | Date (UTC) |
---|---|---|---|
testcases: clean up a little bit | 979a70e10cda4786ef17d03217f5a57cd86a6ae9 | I am | 2023-05-31 16:57:49 |
g_models: fix quartic name, add parabola | b80e98134d7a5c91ad9e44ad9b58e76ac0a3bb64 | I am | 2023-05-31 16:54:39 |
qt_gui.qt_gui: little tweaks | 73c027858135753f99d2eabb3f080e936c4ff18d | I am | 2023-05-30 16:53:59 |
reader forgets Udmurt, learns English instead :'( | 640ac860613b0d93fc037490c3a02da251eb8aca | I am | 2023-05-30 15:23:31 |
testcases: add __init__ file | 0b942cd9028c3c5baea43aff61526b75c2f3ee43 | I am | 2023-05-28 14:04:55 |
mplot: add quiver plots | a32b3d850fef99d6798b778140867416e17c16db | I am | 2023-03-30 13:21:30 |
mplot.mart: add simplex_vectors() function | 7a90003e40bd459d2a3ef45a4867dfa392bd3fc8 | I am | 2023-03-30 13:20:10 |
simplex: use shares instead of probabilities in sinsitivity analysis | 75ff4258b95fd568d1b4d163cdc04d40952e0029 | I am | 2023-03-16 18:46:44 |
whitebox.get_sensitivities: mask nans and infinities | 1a754c51b3a1ef535e86b5b4cb6b75fe9e90840f | I am | 2023-03-14 22:33:52 |
simplex.SeparationAxis: fix previous commit | 61abd70e69d2fecd74535738c96e74a634af0ad1 | I am | 2023-03-12 16:49:22 |
simplex.SeparationAxis: print linprog solution in case of an unexpected status | af1aaac1dce3fbc51dc48418685d948a27cf72c6 | I am | 2023-03-12 15:18:07 |
g_models: add hyperbola LSF | 5f6df35b4280a11c0df1d3cd110250305805ce66 | I am | 2023-03-12 15:07:20 |
simplex._Sense: implement piece of postprocessing to get unique vectors | 4088852e703947643a8388b2ba8839a694211566 | I am | 2023-03-10 17:22:29 |
simplex.SeparationAxis: in case of an unexpected linprog status print result message too | 1c9346233693533afb07022c78308b3be6ea9ec7 | I am | 2023-03-10 15:40:06 |
whitebox: implement method to .get_sensitivities() from 2D boundary | 5729723cfe5c93658c3739fbfec384e135b44073 | I am | 2023-03-09 22:14:27 |
simplex.SeparationAxis: make an perfectionism-driven change | 8278c48915c326e7731f1934732550c5b9c18e64 | I am | 2023-03-09 21:51:18 |
simplex.SeparationAxis: little fix for an hypotetical issue | 838e476387c31f9c6847cf7ae8a2a01514038a03 | I am | 2023-03-09 15:19:48 |
simplex._Sense: bugfix | 3ae53e8b178107b8beb6ad960ec683c8d38a3b3c | I am | 2023-03-07 23:23:36 |
simplex._Sense: totally rework, finalized vectors are introduced | 829ba58a93481541a58cd4a9f6dae0ba9fb611c6 | I am | 2023-03-07 13:33:38 |
simplex: preliminary commit of an _Sense's auxiliary class - brand new SeparationAxis | c0bbb714400df48abf7a398e018c5626803bf024 | I am | 2023-03-04 10:17:12 |
File | Lines added | Lines deleted |
---|---|---|
wellmet/testcases/gaussian_2D.py | 14 | 91 |
wellmet/testcases/testcases_2D.py | 60 | 0 |
wellmet/testcases/testcases_2D_papers.py | 10 | 58 |
File wellmet/testcases/gaussian_2D.py changed (mode: 100644) (index 99940ff..752410b) | |||
2 | 2 | # coding: utf-8 | # coding: utf-8 |
3 | 3 | ||
4 | 4 | """ | """ |
5 | We will prepare here WhiteBox instances | ||
5 | WhiteBox instances | ||
6 | 6 | of different Gaussian 2D problems | of different Gaussian 2D problems |
7 | 7 | """ | """ |
8 | 8 | ||
... | ... | def hyperbola_2(): | |
108 | 108 | return Gaussian_Hyperbola_2D(const=2) | return Gaussian_Hyperbola_2D(const=2) |
109 | 109 | ||
110 | 110 | ||
111 | class ProxyProd: | ||
112 | def __init__(self, const=0): | ||
113 | self.const = const | ||
114 | #assert (const * sign) > 0 | ||
115 | #self.sign = sign | ||
116 | self.true_gm = gm.Z_prod(const=const, sign=np.sign(self.const)) | ||
117 | # wrap | ||
118 | self.get_2D_R_boundary = self.true_gm.get_2D_R_boundary | ||
119 | |||
120 | # sign | ||
121 | def __repr__(self): | ||
122 | return 'ProxyProd(const=%s)' % repr(self.const) | ||
123 | |||
124 | def __call__(self, input_sample): | ||
125 | #č očekávam, že get_R_coordinates mně vrátí 2D pole | ||
126 | sample = gm.get_R_coordinates(input_sample, 2) | ||
127 | x, y = sample.T | ||
128 | |||
129 | #č osudná podmínka | ||
130 | mask = np.atleast_1d(np.sign(x)==(np.sign(y)*np.sign(self.const))) | ||
131 | #č mrdáme na kontrolu. současný startup candybox vytvoří vždycky | ||
132 | input_sample.candybox.proxy = mask | ||
133 | sweet_sample = input_sample | ||
134 | #sweet_sample = CandyBox(input_sample, proxy=mask) | ||
135 | |||
136 | #č zatím, pro jednoduchost, předpokladáme, | ||
137 | #č že dostaváme vzorky po jednom | ||
138 | if np.all(mask): | ||
139 | #č nevíme vůbec, co to je za funkci | ||
140 | #č ale veříme, že víme co tam bude | ||
141 | g = np.full(len(sweet_sample), 1) | ||
142 | #č s praznejm podpísem odmítá | ||
143 | return samplebox.SampleBox(sweet_sample, g, repr(self)) | ||
144 | |||
145 | else: #č deme počítat, bez b | ||
146 | true_sample = self.true_gm(sweet_sample) | ||
147 | #č padelame pospís | ||
148 | true_sample.gm_signature = repr(self) | ||
149 | return true_sample | ||
150 | |||
151 | |||
152 | def _proxy_prod(const): | ||
153 | wt = Gaussian_Z_prod_2D(const=const) | ||
154 | wt.gm = ProxyProd(const) | ||
155 | #č padelame pospís | ||
156 | wt.samplebox.gm_signature = repr(wt.gm) | ||
157 | return wt | ||
158 | |||
159 | add('proxy_prod_1') | ||
160 | def proxy_prod_1(): | ||
161 | return _proxy_prod(1) | ||
162 | 111 | ||
163 | add('proxy_prod_5') | ||
164 | def proxy_prod_5(): | ||
165 | return _proxy_prod(-5) | ||
166 | 112 | ||
167 | 113 | ||
168 | 114 | """ | """ |
... | ... | def circle(): | |
195 | 141 | return WhiteBox(f, gm.ConicSection(l=1.4, e=0, teta=0, c=(1.3, 0.6), sign=1)) | return WhiteBox(f, gm.ConicSection(l=1.4, e=0, teta=0, c=(1.3, 0.6), sign=1)) |
196 | 142 | ||
197 | 143 | ||
198 | # parabola | ||
199 | #č nemá dostatečnou pro g_models uroveň | ||
200 | #č proto ji celou dáme tady | ||
201 | def Z(X, Y): | ||
202 | '''Rezerva spolehlivosti Z=Y+1-X**2''' | ||
203 | return - Y + 2.5 + 10.1*(X-1)**2 | ||
204 | 144 | ||
205 | def get_bound_y(x): | ||
206 | '''Hranice poruchy Z=0''' | ||
207 | return 10.1*(x-1)**2 + 2.5 | ||
208 | |||
209 | def parabola_2D(input_sample): | ||
210 | # očekávam, že get_R_coordinates mně vrátí 2D pole | ||
211 | sample = gm.get_R_coordinates(input_sample) | ||
212 | x, y, *__ = (*sample.T,) | ||
213 | g = Z(x, y) | ||
214 | return samplebox.SampleBox(input_sample, g, 'parabola_2D') | ||
215 | |||
216 | def parabola_boundary(nrod=100, xlim=(-5,5), *args): | ||
217 | """ | ||
218 | Fence off! | ||
219 | nrod - number of rods in fencing | ||
220 | """ | ||
221 | |||
222 | xbound = np.linspace(xlim[0], xlim[1], nrod, endpoint=True) | ||
223 | |||
224 | bound_y = get_bound_y(xbound) | ||
225 | |||
226 | # sample compatible | ||
227 | # малы транспонировать кароно? Озьы кулэ! | ||
228 | bound_R = np.array((xbound, bound_y)).T | ||
229 | # tuple of samples | ||
230 | return (f_models.Ingot(bound_R),) | ||
231 | |||
232 | |||
233 | parabola_2D.get_2D_R_boundary = parabola_boundary | ||
234 | 145 | ||
235 | 146 | add('parabola') | add('parabola') |
236 | 147 | def parabola(): | def parabola(): |
237 | return WhiteBox(f, parabola_2D) | ||
148 | return WhiteBox(f, gm.parabola_2D) | ||
238 | 149 | ||
239 | 150 | ||
240 | 151 | # Sin2D | # Sin2D |
... | ... | add('sumexp') | |
315 | 226 | def sumexp(): | def sumexp(): |
316 | 227 | return Gaussian_Z_sumexp_2D(-0.003) | return Gaussian_Z_sumexp_2D(-0.003) |
317 | 228 | ||
229 | add('modified_rastrigin') | ||
230 | def modified_rastrigin(): | ||
231 | wt = WhiteBox(f, gm.modified_rastrigin) | ||
232 | wt.description = "Modified Rastrigin" | ||
233 | wt.pf_exact = 7.34e-02 | ||
234 | wt.pf_exact_method = 'known value' | ||
235 | return wt | ||
236 | |||
237 | add('quartic') | ||
238 | def quartic(): | ||
239 | wt = WhiteBox(f, gm.quartic) | ||
240 | return wt | ||
318 | 241 | ||
319 | 242 | ||
320 | 243 | add('max') | add('max') |
File wellmet/testcases/testcases_2D.py changed (mode: 100644) (index 54c5bd1..52d8dd8) | |||
... | ... | def add(str): | |
31 | 31 | __all__.append(str) | __all__.append(str) |
32 | 32 | ||
33 | 33 | ||
34 | |||
35 | |||
36 | class ProxyProd: | ||
37 | def __init__(self, const=0): | ||
38 | self.const = const | ||
39 | #assert (const * sign) > 0 | ||
40 | #self.sign = sign | ||
41 | self.true_gm = gm.Z_prod(const=const, sign=np.sign(self.const)) | ||
42 | # wrap | ||
43 | self.get_2D_R_boundary = self.true_gm.get_2D_R_boundary | ||
44 | |||
45 | # sign | ||
46 | def __repr__(self): | ||
47 | return 'ProxyProd(const=%s)' % repr(self.const) | ||
48 | |||
49 | def __call__(self, input_sample): | ||
50 | #č očekávam, že get_R_coordinates mně vrátí 2D pole | ||
51 | sample = gm.get_R_coordinates(input_sample, 2) | ||
52 | x, y = sample.T | ||
53 | |||
54 | #č osudná podmínka | ||
55 | mask = np.atleast_1d(np.sign(x)==(np.sign(y)*np.sign(self.const))) | ||
56 | #č mrdáme na kontrolu. současný startup candybox vytvoří vždycky | ||
57 | input_sample.candybox.proxy = mask | ||
58 | sweet_sample = input_sample | ||
59 | #sweet_sample = CandyBox(input_sample, proxy=mask) | ||
60 | |||
61 | #č zatím, pro jednoduchost, předpokladáme, | ||
62 | #č že dostaváme vzorky po jednom | ||
63 | if np.all(mask): | ||
64 | #č nevíme vůbec, co to je za funkci | ||
65 | #č ale veříme, že víme co tam bude | ||
66 | g = np.full(len(sweet_sample), 1) | ||
67 | #č s praznejm podpísem odmítá | ||
68 | return samplebox.SampleBox(sweet_sample, g, repr(self)) | ||
69 | |||
70 | else: #č deme počítat, bez b | ||
71 | true_sample = self.true_gm(sweet_sample) | ||
72 | #č padelame pospís | ||
73 | true_sample.gm_signature = repr(self) | ||
74 | return true_sample | ||
75 | |||
76 | |||
77 | def _proxy_prod(const): | ||
78 | wt = Gaussian_Z_prod_2D(const=const) | ||
79 | wt.gm = ProxyProd(const) | ||
80 | #č padelame pospís | ||
81 | wt.samplebox.gm_signature = repr(wt.gm) | ||
82 | return wt | ||
83 | |||
84 | add('proxy_prod_1') | ||
85 | def proxy_prod_1(): | ||
86 | return _proxy_prod(1) | ||
87 | |||
88 | add('proxy_prod_5') | ||
89 | def proxy_prod_5(): | ||
90 | return _proxy_prod(-5) | ||
91 | |||
92 | |||
93 | |||
34 | 94 | # HyperRovina, куда ж без неё? | # HyperRovina, куда ж без неё? |
35 | 95 | ############# | ############# |
36 | 96 | # g= a*X1 + b*X2 + c | # g= a*X1 + b*X2 + c |
File wellmet/testcases/testcases_2D_papers.py changed (mode: 100644) (index c00c746..57f8b67) | |||
2 | 2 | # coding: utf-8 | # coding: utf-8 |
3 | 3 | ||
4 | 4 | """ | """ |
5 | We will prepare here WhiteBox instances | ||
6 | of different well-known 2D problems | ||
5 | WhiteBox instances | ||
6 | of different non-Gaussian 2D problems | ||
7 | 7 | """ | """ |
8 | 8 | ||
9 | 9 | import numpy as np | import numpy as np |
... | ... | from scipy import integrate # for Pareto tail | |
15 | 15 | ||
16 | 16 | __all__ = [ | __all__ = [ |
17 | 17 | 'uniform_branin_2D', | 'uniform_branin_2D', |
18 | 'snorm_four_branch_2D', | ||
19 | 'snorm_four_branch_2D_2', | ||
20 | 'snorm_piecewise_2D_linear', | ||
21 | 18 | 'piecewise_pareto_tail', | 'piecewise_pareto_tail', |
22 | 'snorm_min_2D_linear', | ||
23 | 'snorm_min_2D_logistic', | ||
24 | 'modified_rastrigin', | ||
25 | 'quadratic' | ||
19 | 'natafm_plane_2D', | ||
26 | 20 | ] | ] |
27 | 21 | ||
28 | f = f_models.SNorm(2) | ||
22 | |||
29 | 23 | # Uniform-uniform | # Uniform-uniform |
30 | 24 | # 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]." |
31 | 25 | u = f_models.UnCorD((stats.uniform, stats.uniform)) | u = f_models.UnCorD((stats.uniform, stats.uniform)) |
32 | 26 | ||
27 | gewm = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,-0.8], [-0.8,1]]) | ||
33 | 28 | ||
34 | 29 | ||
35 | 30 | """ | """ |
... | ... | def uniform_branin_2D(): | |
44 | 39 | wt.description = "Rescaled Branin function" | wt.description = "Rescaled Branin function" |
45 | 40 | return wt | return wt |
46 | 41 | ||
47 | # Four branch system | ||
48 | def snorm_four_branch_2D(): | ||
49 | wt = WhiteBox(f, gm.FourBranch2D(k1=3, k2=7)) | ||
50 | wt.pf_exact = 2.34e-03 | ||
51 | wt.pf_exact_method = 'known value' #"some guys said me that" | ||
52 | wt.description = "Four branch system from some paper" | ||
53 | return wt | ||
54 | |||
55 | |||
56 | def snorm_four_branch_2D_2(): | ||
57 | wt = WhiteBox(f, gm.FourBranch2D(k1=5.5, k2=11)) | ||
58 | # TODO calculate | ||
59 | #wt.pf_exact = 0.257 | ||
60 | #wt.pf_exact_method = 'known value' #"some guys said me that" it's 0.256 | ||
61 | wt.description = "Four branch system from another paper" | ||
62 | return wt | ||
63 | |||
64 | |||
65 | |||
66 | |||
67 | |||
68 | # Breitung | ||
69 | # Piecewise linear function | ||
70 | def snorm_piecewise_2D_linear(): | ||
71 | wt = WhiteBox(f, gm.piecewise_2D_linear) | ||
72 | wt.description = "Breitung. Piecewise linear function" | ||
73 | return wt | ||
74 | |||
75 | 42 | ||
76 | 43 | ||
77 | 44 | # Pareto tail | # Pareto tail |
... | ... | def piecewise_pareto_tail(): | |
109 | 76 | ||
110 | 77 | ||
111 | 78 | ||
112 | # Logistic 2D function | ||
113 | def snorm_min_2D_linear(): | ||
114 | wt = WhiteBox(f, gm.Logistic2D()) | ||
115 | wt.description = "Breitung. 2D linear (easy version for SuS)" | ||
116 | return wt | ||
117 | |||
118 | def snorm_min_2D_logistic(): | ||
119 | wt = WhiteBox(f, gm.Logistic2D(easy_version=False)) | ||
120 | wt.description = "Breitung. Logistic 2D function (hard version for SuS)" | ||
121 | return wt | ||
122 | |||
123 | def modified_rastrigin(): | ||
124 | wt = WhiteBox(f, gm.modified_rastrigin) | ||
125 | wt.description = "Modified Rastrigin" | ||
126 | wt.pf_exact = 7.34e-02 | ||
127 | wt.pf_exact_method = 'known value' | ||
128 | return wt | ||
129 | |||
130 | def quadratic(): | ||
131 | wt = WhiteBox(f, gm.quadratic) | ||
79 | def natafm_plane_2D(): | ||
80 | wt = whitebox.WhiteBox(gewm, gm.Linear_nD((-1, -2, 7))) | ||
81 | wt.pf_exact = 0.00114 | ||
82 | wt.Nsim = int(10e8) | ||
83 | wt.pf_exact_method = 'MC' | ||
132 | 84 | return wt | return wt |
133 | 85 | ||
134 | 86 |