Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.8k
Added a paragraph on golden section search#1119
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Visit the preview URL for this PR (for commitf1a01b7): https://cp-algorithms--preview-1119-onu0hmd3.web.app (expires 2023-07-18T16:36:20.301594370Z) |
adamant-pwn commentedJul 14, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 commit49a3759): 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 fromkactl is neat and I can make a more clever benchmark if you give me some ideas on how. |
Kostero commentedOct 22, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
In BOI 2018, there was a problem that explicitly required to use the golden section search:https://boi18-day1-open.kattis.com/contests/bhptqq/problems/worm |
Okay, there are still some things here in the discussion that I'd prefer added (mention some benchmarks, add implementation, etc), but it doesn't seem like it's going to be implemented, so I will merge in the current state. @NaimSS@SYury if anybody has some more time in the future, I would appreciate new PRs to add benchmarks, implementation, etc. |
82a06ff
intocp-algorithms:mainUh oh!
There was an error while loading.Please reload this page.
* .* Update ternary_search.md---------Co-authored-by: Oleksandr Kulkov <adamant.pwn@gmail.com>
No description provided.