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
Added a paragraph on golden section search #1119
base: master
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (for commit f1a01b7): https://cp-algorithms--preview-1119-onu0hmd3.web.app (expires 2023-07-18T16:36:20.301594370Z) |
Thanks for the pull request! Do you think you can also provide some implementation and benchmarks for this method? I'd really like to know how much it improves on practice. Also when we say that "only once at each iteration" we should as well note that the number of iterations increases to, I assume So, we reduce the number of function computations per iteration by a factor of Also, maybe we should highlight more that it is especially important in nested search, as the improvement multiplies in this case. |
I'll try to design some benchmarks, I think finding largest inscribed circle will be a good one. I definitely encountered some problems which I couldn't pass with ordinary ternary search and passed after choosing points with golden section, but they mostly appeared on Petrozavodsk contests, so I doubt I can find them now. |
Also could you elaborate on choosing |
I don't write ternary search that often... Perhaps, using |
@SYury hi, do you have any updates on this? Do you plan to move forward with benchmarks? |
Visit the preview URL for this PR (for commit 49a3759): https://cp-algorithms--preview-1119-ciidekzq.web.app (expires 2023-12-27T01:56:42.672782340Z) |
Another important point is, I would really appreciate it if the change also included the implementation for this approach. |
Can you confirm this
Originally posted by @jxu in #1159 (comment) |
I think there is a significant practical benefit in terms of constant term optimization if function computation is costly. Especially in the case of nested search, the constants multiply which makes it even more important. |
@SYury hi, do you plan any further work on this? |
Currently I'm very busy, so probably not. Maybe in a couple of months, if someone doesn't pick this work up |
I did some simple tests with f(x) = x^2 + 1, L = -4e6, R = 4e6 and eps = 1e-9 just to get a feel.
As said in the comment section of the blog linked, this is more useful for interactive problems, there are even some examples. Anyways, the implementation from kactl is neat and I can make a more clever benchmark if you give me some ideas on how. |
No description provided.