File dicebox.py changed (mode: 100644) (index 36d7255..5d2342f) |
... |
... |
class Chrt(DiceBox): |
249 |
249 |
#ё без поллитры было не разобраться, что этот слоёный пирог делал |
#ё без поллитры было не разобраться, что этот слоёный пирог делал |
250 |
250 |
def __init__(bx, sample_object, tri_space='Rn', tree_space=None,\ |
def __init__(bx, sample_object, tri_space='Rn', tree_space=None,\ |
251 |
251 |
sampling_space=None, kechato_space='U', potencial='psee',\ |
sampling_space=None, kechato_space='U', potencial='psee',\ |
252 |
|
p_norm=2, budget=1000, simplex_budget=100, LHS_correction=False): |
|
|
252 |
|
p_norm=2, budget=1000, simplex_budget=100, \ |
|
253 |
|
LHS_correction=False, design=None): |
253 |
254 |
|
|
254 |
255 |
|
|
255 |
256 |
bx.tri_space = tri_space |
bx.tri_space = tri_space |
|
... |
... |
class Chrt(DiceBox): |
270 |
271 |
bx.p_norm = p_norm |
bx.p_norm = p_norm |
271 |
272 |
bx.potencial = potencial |
bx.potencial = potencial |
272 |
273 |
bx.LHS_correction = LHS_correction |
bx.LHS_correction = LHS_correction |
|
274 |
|
bx.design = design |
273 |
275 |
|
|
274 |
276 |
# for current candidates |
# for current candidates |
275 |
277 |
# kandidaty musí být 'judged' a 'assessed' |
# kandidaty musí být 'judged' a 'assessed' |
|
... |
... |
class Chrt(DiceBox): |
290 |
292 |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
'tri_space':bx.tri_space, 'tree_space':bx.tree_space,\ |
291 |
293 |
'sampling_space':bx.sampling_space, 'kechato_space':bx.kechato_space,\ |
'sampling_space':bx.sampling_space, 'kechato_space':bx.kechato_space,\ |
292 |
294 |
'potencial':bx.potencial, 'p_norm':bx.p_norm, 'budget':bx.budget,\ |
'potencial':bx.potencial, 'p_norm':bx.p_norm, 'budget':bx.budget,\ |
293 |
|
'simplex_budget':bx.simplex_budget, 'LHS_correction':bx.LHS_correction} |
|
|
295 |
|
'simplex_budget':bx.simplex_budget, \ |
|
296 |
|
'LHS_correction':bx.LHS_correction, 'design':str(bx.design)} |
294 |
297 |
|
|
295 |
298 |
|
|
296 |
299 |
def __repr__(bx): |
def __repr__(bx): |
|
... |
... |
class Chrt(DiceBox): |
342 |
345 |
def _regen_outside(bx): |
def _regen_outside(bx): |
343 |
346 |
if bx.nsim >= bx.nvar + 1: |
if bx.nsim >= bx.nvar + 1: |
344 |
347 |
try: |
try: |
345 |
|
bx.shull = sx.Shull(bx.f_model, bx.tri_space, bx.sampling_space, powerset_correction=True) |
|
|
348 |
|
bx.shull = sx.Shull(bx.f_model, bx.tri_space, bx.sampling_space,\ |
|
349 |
|
powerset_correction=True, design=bx.design) |
346 |
350 |
bx.siss = bx.shull.oiss |
bx.siss = bx.shull.oiss |
347 |
351 |
bx.convex_hull = bx.shull.convex_hull # for gl_plot |
bx.convex_hull = bx.shull.convex_hull # for gl_plot |
348 |
352 |
bx.estimate_outside() |
bx.estimate_outside() |
|
... |
... |
class Chrt(DiceBox): |
359 |
363 |
# nothing happened? We are still here? |
# nothing happened? We are still here? |
360 |
364 |
# we need to generate at least something |
# we need to generate at least something |
361 |
365 |
if bx.nsim > 0: #č požaduji, aby nějaké těčíčky byly vždy pritomné |
if bx.nsim > 0: #č požaduji, aby nějaké těčíčky byly vždy pritomné |
|
366 |
|
if bx.design is None: |
|
367 |
|
nodes = bx.f_model(bx.budget) |
|
368 |
|
else: |
|
369 |
|
nodes = bx.f_model.new_sample(bx.design(bx.budget, bx.nvar), 'U') |
362 |
370 |
#č současný CandyBox odmítne vytvořit neprazdný object bez atributů |
#č současný CandyBox odmítne vytvořit neprazdný object bez atributů |
363 |
|
candidates = CandyBox(bx.f_model(bx.budget), event_id=np.full(bx.budget, -1, dtype=np.int8)) |
|
|
371 |
|
candidates = CandyBox(nodes, event_id=np.full(bx.budget, -1, dtype=np.int8)) |
364 |
372 |
bx.assess_candidates(candidates) |
bx.assess_candidates(candidates) |
365 |
373 |
#č uložíme |
#č uložíme |
366 |
374 |
bx.candidates_index[-1] = candidates |
bx.candidates_index[-1] = candidates |
|
... |
... |
class Chrt(DiceBox): |
374 |
382 |
try: |
try: |
375 |
383 |
|
|
376 |
384 |
#č tri - Deloneho triangulace |
#č tri - Deloneho triangulace |
377 |
|
bx.tri = spatial.Delaunay(getattr(bx.sampled_plan, bx.tri_space), incremental=True) |
|
|
385 |
|
tri_plan = getattr(bx.sampled_plan, bx.tri_space) |
|
386 |
|
bx.tri = spatial.Delaunay(tri_plan, incremental=True) |
378 |
387 |
if len(bx.tri.coplanar): |
if len(bx.tri.coplanar): |
379 |
388 |
#print('triangulace v pořádku není') |
#print('triangulace v pořádku není') |
380 |
389 |
bx._logger(msg='triangulation is coplanar') |
bx._logger(msg='triangulation is coplanar') |
|
... |
... |
class Chrt(DiceBox): |
390 |
399 |
# zde jen počítame |
# zde jen počítame |
391 |
400 |
bx.estimate_simplex(simplex) |
bx.estimate_simplex(simplex) |
392 |
401 |
except BaseException as e: |
except BaseException as e: |
393 |
|
#č chcu zachytit spadnuti QHull na začatku, kdy ještě není dostatek teček. |
|
|
402 |
|
#č chcu zachytit spadnuti QHull na začatku, |
|
403 |
|
#č kdy ještě není dostatek teček. |
394 |
404 |
#č Jinak je třeba nechat QHull spadnout |
#č Jinak je třeba nechat QHull spadnout |
395 |
405 |
if bx.nsim > 2*bx.nvar + 3: |
if bx.nsim > 2*bx.nvar + 3: |
396 |
406 |
#č no to teda ne! |
#č no to teda ne! |
|
... |
... |
class Chrt(DiceBox): |
770 |
780 |
vertices = bx.f_model[indices] |
vertices = bx.f_model[indices] |
771 |
781 |
print("estimate", indices) |
print("estimate", indices) |
772 |
782 |
h_plan, convex_hull, simplex_measure = sx.sample_simplex(vertices,\ |
h_plan, convex_hull, simplex_measure = sx.sample_simplex(vertices,\ |
773 |
|
model_space=bx.tri_space, sampling_space=bx.sampling_space, nis=bx.simplex_budget) |
|
|
783 |
|
model_space=bx.tri_space, design=bx.design,\ |
|
784 |
|
sampling_space=bx.sampling_space, nis=bx.simplex_budget) |
774 |
785 |
|
|
775 |
786 |
|
|
776 |
787 |
fm = simplex_measure * fr |
fm = simplex_measure * fr |
|
... |
... |
class Chrt(DiceBox): |
784 |
795 |
|
|
785 |
796 |
candidates = h_plan[mask] |
candidates = h_plan[mask] |
786 |
797 |
#bx._former_candidates_recovering(candidates, convex_hull, bx.unjudged_candidates) |
#bx._former_candidates_recovering(candidates, convex_hull, bx.unjudged_candidates) |
787 |
|
bx._former_candidates_recovering(candidates, convex_hull, bx.former_candidates) |
|
|
798 |
|
bx._former_candidates_recovering(candidates, convex_hull, \ |
|
799 |
|
bx.former_candidates) |
788 |
800 |
|
|
789 |
801 |
candidates.event_id = np.full(len(candidates), event_id, dtype=np.int8) |
candidates.event_id = np.full(len(candidates), event_id, dtype=np.int8) |
790 |
802 |
#candidates.simplex = np.full((len(candidates), bx.nvar+1), indices) |
#candidates.simplex = np.full((len(candidates), bx.nvar+1), indices) |