argmin-rs / argmin

Numerical optimization in pure Rust
http://argmin-rs.org
Apache License 2.0
972 stars 76 forks source link

How to inject custom termination criteria to existing solvers? #370

Closed millardjn closed 11 months ago

millardjn commented 11 months ago

Is it possible to terminate one of the crates solvers after evaluating a custom problem specific criteria based on gradient magnitude and cost? I looked at doing it via an observer, but they cannot call terminate_with via a non-mutable borrow. What is the correct way to do this?

stefan-k commented 11 months ago

Unfortunately this currently is not possible, but it is planned (#91). For now, a not so convenient workaround is to write your own Executor (basically copy paste the existing one and add your criteria).

millardjn commented 11 months ago

Thanks for the quick reply, and apologies for not seeing that issue, I only searched for "termination" and similar.