Skip to content

Commit

Permalink
fix issues in fdp converter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy43 committed Nov 28, 2023
1 parent fae0105 commit a88d19e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions autodp/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def fun(x): # the input the RDP's \alpha
return np.log(1 / delta) / (x - 1) + rdp(x)

results = minimize_scalar(fun, method='Brent', bracket=(1,2))#, bounds=[1, alpha_max])
#results = minimize_scalar(fun, method='BBounded', bounds=[1, alpha_max])
if results.success:
return results.fun
else:
Expand Down Expand Up @@ -736,13 +737,16 @@ def normal_equation_loglogx(loglogx):
bound1 = np.log(-tmp - tmp**2 / 2 - tmp**3 / 6)
else:
bound1 = np.log(1-np.exp(fun1(np.log(1-delta))))
#results = minimize_scalar(normal_equation, bracket=[-1,-2])
results = minimize_scalar(normal_equation, method="Bounded", bounds=[bound1,0],
options={'xatol': 1e-10, 'maxiter': 500, 'disp': 0})
results = minimize_scalar(normal_equation, bracket=[-0.5,-2])
#results = minimize_scalar(normal_equation, method="Bounded", bounds=[bound1,0],
# options={'xatol': 1e-10, 'maxiter': 500, 'disp': 0})
if results.success:
if abs(results.fun) > 1e-4 and abs(results.x)>1e-10:

if abs(results.fun) > 1e-3 and abs(results.x)>1e-10:
# This means that we hit xatol (x is close to 0, but
# the function value is not close to 0) In this case let's do an even larger search.

print(f'err is {results.fun}, {results.x}')
raise RuntimeError("'find_logx' fails to find the tangent line.")
else:
return results.x
Expand Down

0 comments on commit a88d19e

Please sign in to comment.