bitten: update bitten.py
This commit is contained in:
parent
b4442c5734
commit
b655d5c5c7
1 changed files with 8 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
# prepend underscores so these don't leak to __all__.
|
||||
from hashlib import sha256 as _sha256
|
||||
from itertools import chain as _chain
|
||||
from itertools import repeat as _repeat
|
||||
from os import environ as _environ
|
||||
from pathlib import Path as _Path
|
||||
from traceback import print_exception as _print_exception
|
||||
|
@ -161,7 +162,7 @@ def _penalize3(constraints, *x, tol=1e-5, scale=1e10, growth=3.0):
|
|||
penalties = _flatten(cons(*x) for cons in constraints)
|
||||
n_con = len(penalties)
|
||||
growth = growth ** (1.0 / n_con) # "ps"
|
||||
increment = 1.0 / np.sqrt(n_con) # "pnsi"
|
||||
increment = n_con**-0.5 # "pnsi"
|
||||
penalty, nominal = 0.0, 0.0 # "pns", "pnsm"
|
||||
for p in penalties:
|
||||
p = max(p - tol, 0.0)
|
||||
|
@ -622,7 +623,12 @@ def _bite(
|
|||
linear_bounds = []
|
||||
for key, hyper in hypers.items():
|
||||
if isinstance(hyper, BoundArray): # TODO: ArrayMixin or whatever
|
||||
linear_bounds += [hyper.bounds] * hyper.dims
|
||||
lower, upper = hyper.bounds
|
||||
lower = lower if lower.ndim else _repeat(lower)
|
||||
upper = upper if upper.ndim else _repeat(upper)
|
||||
new = [(l, u) for _, l, u in zip(range(hyper.dims), lower, upper)]
|
||||
assert len(new) == hyper.dims, f"length of bounds must equal number of dimensions"
|
||||
linear_bounds += new
|
||||
elif isinstance(hyper, Bound):
|
||||
linear_bounds.append(hyper.bounds)
|
||||
|
||||
|
|
Loading…
Reference in a new issue