Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scaling-dependence of termination criterion #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mjacobse
Copy link
Contributor

@mjacobse mjacobse commented Dec 6, 2023

The termination criterion for bisecting alpha implicitly assumes the optimal alpha to be in the order of magnitude of 1.0. For larger values of alpha, lower and upper can never get close enough, meaning the bisection never terminates successfully. This happens already with an example like this:

alpha = optimizealpha(
            [(0., 0.), (0., 0.1), (0.1, 0.1), (0.1, 0.),
             (0.05, 0.025), (0.05, 0.075), (0.025, 0.05), (0.075, 0.05)])

For smaller values of alpha, the bisection may terminate much too early, returning a very suboptimal alpha.

This fixes that by checking the relative instead of the absolute difference using numpy.isclose. Also, this adds tests with a large and a tiny optimal alpha that would have failed with the previous termination criterion.

An alternative might be to check np.nextafter(lower, upper) == upper, to ensure finding the exact threshold.

See also #18 . A user-defined tolerance as suggested there might be a good future addition. But for now, this change would at least make the function usable for larger alphas.

@bellockk
Copy link
Owner

Once conflicts are resolved I will re-review.

The termination criterion for bisecting alpha implicitly assumes the
optimal alpha to be in the order of magnitude of 1.0. For larger values
of alpha, lower and upper can never get close enough, meaning the
bisection never terminates successfully. For smaller values of alpha,
the bisection may terminate much too early.

This fixes that by checking the relative instead of the absolute
difference using numpy.isclose. Also, this adds tests with a large and
a tiny optimal alpha that would have failed with the previous
termination criterion (they also wouldve failed for much more moderate
scaling factors like 100).
@mjacobse mjacobse force-pushed the fix_termination_criterion branch from d8256ad to 33bf675 Compare September 27, 2024 16:36
@mjacobse
Copy link
Contributor Author

mjacobse commented Oct 8, 2024

Once conflicts are resolved I will re-review.

conflicts resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants