-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
BUG: minimize - COBYQA is very inefficient w.r.t time. #20724
Comments
e.g. A long time is spent in Furthermore, it's not clear why those constraint violations even need to be calculated for a system where there are no constraints or bounds. |
Most of this loop could be vectorised. |
Vectorize this line |
Norm accepts axis keyword. No need to loop there |
Hi, I'm interested in helping out on this issue. Are you interested in PRs from anyone on this topic, or just the original author? |
I've started a branch at https://github.com/andyfaff/cobyqa/tree/efficiency that's looking at various efficiency things. This is based on a jupyter notebook where I was line profiling things, https://gist.github.com/andyfaff/4cfdc554f9f520fb1a6a6f983025996f. I'm yet to find the big prize. It would be good to have the authors on board here, as the originators of the code they're familiar with it, and it's going to be easier for them. You're definitely more than welcome to contribute here, but it might be a slow slog through profiling country.
|
I found it was possible to reduce the time spent in E.g.
Unfortunately, it also increased nfev by 3%, which may not be worth it. I also tried passing |
This looks very helpful, I had a similar impression when I had a glance over COBYQA's source code. For the sake of repo hygiene, could we move the discussion to the COBYQA repo though? It must be fixed there anyway. |
Hello @andyfaff and all, First of all, thank you very much for bringing this issue up and for proposing improvements (see also cobyqa/cobyqa#152). They are extremely important to us. We cherish your suggestions and inputs. Meanwhile, I would like to mention that COBYQA (PRIMA as well) is primarily designed for "derivative-free optimization" (DFO), aka "black-box optimization" or "simulation-based optimization". We assume that function evaluations predominate the cost. In practice, each function evaluation can take seconds, minutes, hours, or days, because it often involves sophisticated simulations. In contrast, the costs incurred inside the solver (e.g., floating point operations, memory allocations) are assumed to be negligible. That is why we commonly use the number of function evaluations to measure the performance of DFO solvers. However, we (Tom @ragonneau and I) always keep in mind that our assumptions can be wrong, and users may use our DFO solvers to solve non-DFO problems. Therefore, we should not ignore the internal costs of our solvers. Prioritization is key: Reducing function evaluations >> enhancing code simplicity & clarity >> economizing solver's internal costs. Any improvement of the code that does not increase the number of function evaluations should be integrated, just like what we have done at cobyqa/cobyqa#152 (credit goes to @andyfaff . Thank you!). If you are interested in this topic, the following notes on DFO may be interesting to you. You are invited to make comments there: https://github.com/orgs/libprima/discussions/145 Many thanks again! Cheers, |
Describe your issue.
CI tests revealed that various COBYQA tests were taking a long time. Local testing reveals that there is a lot of overhead in COBYQA internals compared to the time taken to call the objective function. I believe that there are inefficiencies in the implementation that need to be discovered and reduced.
The example below shows that only 0.2% of time is spent in the objective function for COBYQA, whereas for nelder-mead it's 33%. COBYQA gets to the solution in a smaller number of nfev (nelder-mead doesn't actually get to a good minimum), but it takes two orders of magnitude more time.
@ragonneau
Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: