argmin-rs / argmin

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

Difference between bfgs.rs and bfgs of optimtool.unconstrain.newton_quasi #498

Closed linjing-lab closed 2 months ago

linjing-lab commented 2 months ago

In compiled languages, using the method of state to prompt whether to initialize the parameter vector is a consideration for developers not to treat it as a dynamic tuning method, but to use it to adapt to compilation logic for embedded code? https://github.com/argmin-rs/argmin/blob/a9e3eb7838e4a68994b452e840a04b7726cfa8e8/crates/argmin/src/solver/quasinewton/bfgs.rs#L157-L161 the above code may be same as the underlined code by given initial point:

gradient = np.array(res.subs(reps)).astype(DataType) # optimtool/unconstrain/newton_quasi.py#L64

https://github.com/argmin-rs/argmin/blob/a9e3eb7838e4a68994b452e840a04b7726cfa8e8/crates/argmin/src/solver/quasinewton/bfgs.rs#L200-L202 I have never occured such issue about not set in state, did function parameters make all the initial operations but stop the iteration because of not set in state? https://github.com/argmin-rs/argmin/blob/a9e3eb7838e4a68994b452e840a04b7726cfa8e8/crates/argmin/src/solver/quasinewton/bfgs.rs#L236-L238 if I understand here, No parameters means bfgs.rs may stop iteration in intensive program because of line search, and when give a complicated function to adapt to an embedded program, a developer need many trials according to the exact problem which to process.

stefan-k commented 2 months ago

These are safety hatches in case a bug is introduced somewhere. Apart from the check in init, these should never lead to an error in normal operation. The one in init is a hint to the user in case they forget to provide a parameter vector. This will likely become unnecessary when state handling is improved (#478).

Does this answer your question?

linjing-lab commented 2 months ago

OK, that's really a considerable choice on handling future state.