lazily compute early termination boundary conditions
This commit is contained in:
parent
da669f088d
commit
5970c77cb9
1 changed files with 2 additions and 6 deletions
8
synth.py
8
synth.py
|
|
@ -5,14 +5,10 @@ from lenses import lens
|
||||||
|
|
||||||
def binsearch(stleval, *, tol=1e-3, lo, hi, polarity):
|
def binsearch(stleval, *, tol=1e-3, lo, hi, polarity):
|
||||||
"""Only run search if tightest robustness was positive."""
|
"""Only run search if tightest robustness was positive."""
|
||||||
# Only check low since hi taken care of by precondition.
|
|
||||||
# TODO: allow for different polarities
|
|
||||||
rL, rH = stleval(lo), stleval(hi)
|
|
||||||
# Early termination via bounds checks
|
# Early termination via bounds checks
|
||||||
posL, posH = rL > 0, rH > 0
|
if polarity and stleval(lo) > 0:
|
||||||
if polarity and posL:
|
|
||||||
return lo
|
return lo
|
||||||
elif not polarity and posH:
|
elif not polarity and stleval(hi) > 0:
|
||||||
return hi
|
return hi
|
||||||
|
|
||||||
while hi - lo > tol:
|
while hi - lo > tol:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue