File dicebox.py changed (mode: 100644) (index 8bcf826..fb33661) |
... |
... |
class Chrt(DiceBox): |
308 |
308 |
#č už mě to dědění nebaví |
#č už mě to dědění nebaví |
309 |
309 |
#ё без поллитры было не разобраться, что этот слоёный пирог делал |
#ё без поллитры было не разобраться, что этот слоёный пирог делал |
310 |
310 |
def __init__(bx, sample_object, tri_space='Rn', tree_space=None,\ |
def __init__(bx, sample_object, tri_space='Rn', tree_space=None,\ |
311 |
|
sampling_space=None, kechato_space='U', potencial='psee',\ |
|
|
311 |
|
sampling_space=None, kechato_space='U', potential='psee',\ |
312 |
312 |
p_norm=2, budget=1000, simplex_budget=100, \ |
p_norm=2, budget=1000, simplex_budget=100, \ |
313 |
313 |
LHS_correction=False, design=None): |
LHS_correction=False, design=None): |
314 |
314 |
|
|
|
... |
... |
class Chrt(DiceBox): |
329 |
329 |
bx.budget = budget |
bx.budget = budget |
330 |
330 |
bx.simplex_budget = simplex_budget |
bx.simplex_budget = simplex_budget |
331 |
331 |
bx.p_norm = p_norm |
bx.p_norm = p_norm |
332 |
|
bx.potencial = potencial |
|
|
332 |
|
bx.potential = potential |
333 |
333 |
bx.LHS_correction = LHS_correction |
bx.LHS_correction = LHS_correction |
334 |
334 |
bx.design = design |
bx.design = design |
335 |
335 |
|
|
|
... |
... |
class Chrt(DiceBox): |
351 |
351 |
return {'sample_object':bx.sample_box, \ |
return {'sample_object':bx.sample_box, \ |
352 |
352 |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
353 |
353 |
'sampling_space':bx.sampling_space, 'kechato_space':bx.kechato_space,\ |
'sampling_space':bx.sampling_space, 'kechato_space':bx.kechato_space,\ |
354 |
|
'potencial':bx.potencial, 'p_norm':bx.p_norm, 'budget':bx.budget,\ |
|
|
354 |
|
'potential':bx.potential, 'p_norm':bx.p_norm, 'budget':bx.budget,\ |
355 |
355 |
'simplex_budget':bx.simplex_budget, \ |
'simplex_budget':bx.simplex_budget, \ |
356 |
356 |
'LHS_correction':bx.LHS_correction, 'design':str(bx.design)} |
'LHS_correction':bx.LHS_correction, 'design':str(bx.design)} |
357 |
357 |
|
|
|
... |
... |
class Chrt(DiceBox): |
392 |
392 |
bx.candidates_index = dict() |
bx.candidates_index = dict() |
393 |
393 |
|
|
394 |
394 |
if bx.nsim > 0: |
if bx.nsim > 0: |
395 |
|
# needed for potencial calculation |
|
|
395 |
|
# needed for potential calculation |
396 |
396 |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
397 |
397 |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
398 |
398 |
bx.highest_bid = 0 |
bx.highest_bid = 0 |
|
... |
... |
class Chrt(DiceBox): |
480 |
480 |
bx._LHS_increment(input_sample) |
bx._LHS_increment(input_sample) |
481 |
481 |
|
|
482 |
482 |
#č strom posuneme sem |
#č strom posuneme sem |
483 |
|
# cKDTree is used for potencial calculation |
|
|
483 |
|
# cKDTree is used for potential calculation |
484 |
484 |
# we need everytime regenerate it |
# we need everytime regenerate it |
485 |
485 |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
486 |
486 |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
|
... |
... |
class Chrt(DiceBox): |
588 |
588 |
#č A ještě... AUKCE, AUCTION |
#č A ještě... AUKCE, AUCTION |
589 |
589 |
# Election - selection |
# Election - selection |
590 |
590 |
for candidates in bx.candidates_index.values(): |
for candidates in bx.candidates_index.values(): |
591 |
|
bids = getattr(candidates, bx.potencial) |
|
|
591 |
|
bids = getattr(candidates, bx.potential) |
592 |
592 |
if len(bids): |
if len(bids): |
593 |
593 |
bid = np.nanmax(bids) |
bid = np.nanmax(bids) |
594 |
594 |
# side effect |
# side effect |
|
... |
... |
class Chrt(DiceBox): |
608 |
608 |
""" |
""" |
609 |
609 |
function should be only runned by .assess_candidates() |
function should be only runned by .assess_candidates() |
610 |
610 |
""" |
""" |
611 |
|
bids = getattr(candidates, bx.potencial) |
|
|
611 |
|
bids = getattr(candidates, bx.potential) |
612 |
612 |
# -1 = 'out', 0=success, 1=failure, 2=mix |
# -1 = 'out', 0=success, 1=failure, 2=mix |
613 |
613 |
#č -1 a 2 jsou samozrejmě disjunktní |
#č -1 a 2 jsou samozrejmě disjunktní |
614 |
614 |
bids *= (candidates.event_id == -1) + (candidates.event_id == 2) |
bids *= (candidates.event_id == -1) + (candidates.event_id == 2) |
|
... |
... |
class Chrt(DiceBox): |
699 |
699 |
candidates.ii = ii |
candidates.ii = ii |
700 |
700 |
|
|
701 |
701 |
|
|
702 |
|
if bx.potencial in ('psee', 'fee', 'fee2'): |
|
|
702 |
|
if bx.potential in ('psee', 'fee', 'fee2'): |
703 |
703 |
#оӵ кучапи |
#оӵ кучапи |
704 |
704 |
#č pejskovej potenciál |
#č pejskovej potenciál |
705 |
705 |
#č psí-kučapí není invariántní vůči lineárním transformácím |
#č psí-kučapí není invariántní vůči lineárním transformácím |
|
... |
... |
class Chrt(DiceBox): |
725 |
725 |
candidates.fee = candidates.tree_Pdf_mean * candidates.volume * np.power(pdf/PDF, 1/(bx.nvar+1)) |
candidates.fee = candidates.tree_Pdf_mean * candidates.volume * np.power(pdf/PDF, 1/(bx.nvar+1)) |
726 |
726 |
candidates.fee2 = candidates.tree_Pdf_mean * candidates.volume * np.power(pdf/PDF, 1/(bx.nvar*2)) |
candidates.fee2 = candidates.tree_Pdf_mean * candidates.volume * np.power(pdf/PDF, 1/(bx.nvar*2)) |
727 |
727 |
|
|
728 |
|
elif bx.potencial == 'ksee': # ksee |
|
|
728 |
|
elif bx.potential == 'ksee': # ksee |
729 |
729 |
#оӵ кечато |
#оӵ кечато |
730 |
730 |
#č koťatko-káčátkovej potenciál |
#č koťatko-káčátkovej potenciál |
731 |
731 |
#č ksí-kěčató není invariántní vůčí rotacím |
#č ksí-kěčató není invariántní vůčí rotacím |
|
... |
... |
class Chrt(DiceBox): |
752 |
752 |
#č vyhodnotíme |
#č vyhodnotíme |
753 |
753 |
bx.assess_candidates(candidates) |
bx.assess_candidates(candidates) |
754 |
754 |
#č půlku prýč |
#č půlku prýč |
755 |
|
bids = getattr(candidates, bx.potencial) |
|
|
755 |
|
bids = getattr(candidates, bx.potential) |
756 |
756 |
mask = np.isfinite(bids) |
mask = np.isfinite(bids) |
757 |
757 |
if np.any(mask): #č hmm... |
if np.any(mask): #č hmm... |
758 |
758 |
candidates = candidates[mask] |
candidates = candidates[mask] |
|
... |
... |
class Erjee(Chrt): |
952 |
952 |
bx._LHS_increment(input_sample) |
bx._LHS_increment(input_sample) |
953 |
953 |
|
|
954 |
954 |
#č strom posuneme sem |
#č strom posuneme sem |
955 |
|
# cKDTree is used for potencial calculation |
|
|
955 |
|
# cKDTree is used for potential calculation |
956 |
956 |
# we need everytime regenerate it |
# we need everytime regenerate it |
957 |
957 |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
958 |
958 |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
|
... |
... |
class Razitko(Erjee): |
993 |
993 |
#č už mě to dědění nebaví |
#č už mě to dědění nebaví |
994 |
994 |
#ё без поллитры было не разобраться, что этот слоёный пирог делал |
#ё без поллитры было не разобраться, что этот слоёный пирог делал |
995 |
995 |
def __init__(bx, sample_object, scheme, tri_space='Rn', tree_space=None,\ |
def __init__(bx, sample_object, scheme, tri_space='Rn', tree_space=None,\ |
996 |
|
sampling_space=None, kechato_space='U', potencial='psee',\ |
|
|
996 |
|
sampling_space=None, kechato_space='U', potential='psee',\ |
997 |
997 |
p_norm=2, budget=1000, \ |
p_norm=2, budget=1000, \ |
998 |
998 |
LHS_correction=False, design=None): |
LHS_correction=False, design=None): |
999 |
999 |
|
|
|
... |
... |
class Razitko(Erjee): |
1013 |
1013 |
bx.kechato_space = kechato_space |
bx.kechato_space = kechato_space |
1014 |
1014 |
bx.budget = budget |
bx.budget = budget |
1015 |
1015 |
bx.p_norm = p_norm |
bx.p_norm = p_norm |
1016 |
|
bx.potencial = potencial |
|
|
1016 |
|
bx.potential = potential |
1017 |
1017 |
bx.LHS_correction = LHS_correction |
bx.LHS_correction = LHS_correction |
1018 |
1018 |
bx.design = design |
bx.design = design |
1019 |
1019 |
|
|
|
... |
... |
class Razitko(Erjee): |
1042 |
1042 |
return {'sample_object':bx.sample_box, 'scheme':bx.scheme.name,\ |
return {'sample_object':bx.sample_box, 'scheme':bx.scheme.name,\ |
1043 |
1043 |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
1044 |
1044 |
'sampling_space':bx.sampling_space, 'kechato_space':bx.kechato_space,\ |
'sampling_space':bx.sampling_space, 'kechato_space':bx.kechato_space,\ |
1045 |
|
'potencial':bx.potencial, 'p_norm':bx.p_norm, 'budget':bx.budget,\ |
|
|
1045 |
|
'potential':bx.potential, 'p_norm':bx.p_norm, 'budget':bx.budget,\ |
1046 |
1046 |
'LHS_correction':bx.LHS_correction, 'design':str(bx.design)} |
'LHS_correction':bx.LHS_correction, 'design':str(bx.design)} |
1047 |
1047 |
|
|
1048 |
1048 |
def _regen_inside(bx): |
def _regen_inside(bx): |
|
... |
... |
class Goal(DiceBox): |
1235 |
1235 |
#č míží nám sampling_space: Ghull umí vzorkovat outside pouze v G prostoru |
#č míží nám sampling_space: Ghull umí vzorkovat outside pouze v G prostoru |
1236 |
1236 |
#č quadpy umístí integráční bodíky v prostoru triangulace. |
#č quadpy umístí integráční bodíky v prostoru triangulace. |
1237 |
1237 |
def __init__(bx, sample_object, scheme, tri_space='G', tree_space=None,\ |
def __init__(bx, sample_object, scheme, tri_space='G', tree_space=None,\ |
1238 |
|
kechato_space='U', potencial='psee',\ |
|
|
1238 |
|
kechato_space='U', potential='psee',\ |
1239 |
1239 |
p_norm=2, shell_budget=1000, outer_budget=100,\ |
p_norm=2, shell_budget=1000, outer_budget=100,\ |
1240 |
1240 |
LHS_correction=False, stm_filename=None): |
LHS_correction=False, stm_filename=None): |
1241 |
1241 |
|
|
|
... |
... |
class Goal(DiceBox): |
1251 |
1251 |
bx.shell_budget = shell_budget |
bx.shell_budget = shell_budget |
1252 |
1252 |
bx.outer_budget = outer_budget |
bx.outer_budget = outer_budget |
1253 |
1253 |
bx.p_norm = p_norm |
bx.p_norm = p_norm |
1254 |
|
bx.potencial = potencial |
|
|
1254 |
|
bx.potential = potential |
1255 |
1255 |
bx.LHS_correction = LHS_correction |
bx.LHS_correction = LHS_correction |
1256 |
1256 |
|
|
1257 |
1257 |
bx.stm_filename = stm_filename |
bx.stm_filename = stm_filename |
|
... |
... |
class Goal(DiceBox): |
1265 |
1265 |
""" |
""" |
1266 |
1266 |
return {'sample_object':bx.sample_box, 'scheme':bx.scheme.name,\ |
return {'sample_object':bx.sample_box, 'scheme':bx.scheme.name,\ |
1267 |
1267 |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
1268 |
|
'kechato_space':bx.kechato_space, 'potencial':bx.potencial,\ |
|
|
1268 |
|
'kechato_space':bx.kechato_space, 'potential':bx.potential,\ |
1269 |
1269 |
'p_norm':bx.p_norm, 'shell_budget':bx.shell_budget,\ |
'p_norm':bx.p_norm, 'shell_budget':bx.shell_budget,\ |
1270 |
1270 |
'outer_budget':bx.outer_budget, 'LHS_correction':bx.LHS_correction} |
'outer_budget':bx.outer_budget, 'LHS_correction':bx.LHS_correction} |
1271 |
1271 |
|
|
|
... |
... |
class Goal(DiceBox): |
1332 |
1332 |
bx._LHS_increment(input_sample) |
bx._LHS_increment(input_sample) |
1333 |
1333 |
|
|
1334 |
1334 |
#č strom posuneme sem |
#č strom posuneme sem |
1335 |
|
# cKDTree is used for potencial calculation |
|
|
1335 |
|
# cKDTree is used for potential calculation |
1336 |
1336 |
# we need everytime regenerate it |
# we need everytime regenerate it |
1337 |
1337 |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
sampled_plan_tree = getattr(bx.sample_box, bx.tree_space) |
1338 |
1338 |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
bx.tree = spatial.cKDTree(sampled_plan_tree) |
|
... |
... |
class Goal(DiceBox): |
1389 |
1389 |
#č A ještě... AUKCE, AUCTION |
#č A ještě... AUKCE, AUCTION |
1390 |
1390 |
# Election - selection |
# Election - selection |
1391 |
1391 |
for candidates in bx.candidates_index.values(): |
for candidates in bx.candidates_index.values(): |
1392 |
|
bids = getattr(candidates, bx.potencial) |
|
|
1392 |
|
bids = getattr(candidates, bx.potential) |
1393 |
1393 |
if len(bids): |
if len(bids): |
1394 |
1394 |
bid = np.nanmax(bids) |
bid = np.nanmax(bids) |
1395 |
1395 |
# side effect |
# side effect |
|
... |
... |
class DiceSimpleX: |
1807 |
1807 |
# |
# |
1808 |
1808 |
highest_bid = 0 |
highest_bid = 0 |
1809 |
1809 |
for i, candidates in bx.candidates_index.items(): |
for i, candidates in bx.candidates_index.items(): |
1810 |
|
bids = getattr(candidates, bx.potencial) |
|
|
1810 |
|
bids = getattr(candidates, bx.potential) |
1811 |
1811 |
bid = np.max(bids) |
bid = np.max(bids) |
1812 |
1812 |
# side effect |
# side effect |
1813 |
1813 |
if bid > highest_bid: |
if bid > highest_bid: |
|
... |
... |
class DiceSimpleX: |
1819 |
1819 |
candidates = bx.candidates_index[i] |
candidates = bx.candidates_index[i] |
1820 |
1820 |
|
|
1821 |
1821 |
#š a eště ráz |
#š a eště ráz |
1822 |
|
bids = getattr(candidates, bx.potencial) |
|
|
1822 |
|
bids = getattr(candidates, bx.potential) |
1823 |
1823 |
bid = np.max(bids) |
bid = np.max(bids) |
1824 |
1824 |
if bid > highest_bid: |
if bid > highest_bid: |
1825 |
1825 |
highest_bid = bid |
highest_bid = bid |
|
... |
... |
class DiceSimpleX: |
1893 |
1893 |
Objective function for optimalization |
Objective function for optimalization |
1894 |
1894 |
""" |
""" |
1895 |
1895 |
|
|
1896 |
|
if (bx.tri_space == bx.tree_space) and (bx.potencial == 'psee'): |
|
|
1896 |
|
if (bx.tri_space == bx.tree_space) and (bx.potential == 'psee'): |
1897 |
1897 |
x_tree = x |
x_tree = x |
1898 |
1898 |
pdf = float(bx.f_model.sample_pdf(x, bx.tree_space)) |
pdf = float(bx.f_model.sample_pdf(x, bx.tree_space)) |
1899 |
1899 |
else:#č máme smulu |
else:#č máme smulu |
|
... |
... |
class DiceSimpleX: |
1908 |
1908 |
# teď máme hustoty kandidatů a prislušejicích jím vzorků |
# teď máme hustoty kandidatů a prislušejicích jím vzorků |
1909 |
1909 |
PDF = PDFs[ii] |
PDF = PDFs[ii] |
1910 |
1910 |
|
|
1911 |
|
if bx.potencial == 'psee': |
|
|
1911 |
|
if bx.potential == 'psee': |
1912 |
1912 |
#оӵ кучапи |
#оӵ кучапи |
1913 |
1913 |
#č pejskovej potenciál |
#č pejskovej potenciál |
1914 |
1914 |
#č psí-kučapí není invariántní vůči lineárním transformácím |
#č psí-kučapí není invariántní vůči lineárním transformácím |