-
Notifications
You must be signed in to change notification settings - Fork 3
Added OptimResult #10
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the setup of the result object! I left some comments regarding the use of Option wrappers and the exact meaning of RunStatus. It will also be very valuable for other contributors if the meaning of RunStatus is well documented in the code.
/// The number of function evaluations performed. | ||
pub f_evals: Option<usize>, | ||
/// The number of iterations run. | ||
pub iterations: Option<usize>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clear to me why runtime,f_evals
and iterations
are Option
s. Are there cases imaginable where these don't have 'default' values? I would expect every algorithm can return appropriate values for these fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my point of view, two reasons:
- I did not bother considering all usecases for each parameter.
- I want a uniform interface for all of them anyway. I think the additional costs don't matter as much, but it simply adds more flexibility.
|
||
/// Minimizer states at the end of the run | ||
#[derive(Debug, PartialEq)] | ||
pub enum RunStatus { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meaning of RunStatus is not entirely clear to me. I assume this enum should reflect the reason for termination, but then it should differentiate between e.g. ftol convergence, xtol convergence or maxiter exceeded. See also my comment in the Nelder-Mead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will change this. The PR is only a WIP for now anyway. I was thinking of adding more states, such as warmup
, inprogress
, one for various convergences. This can also be kept in the minimizer state (and updated via something like is_finished
in NM). Maybe at some point it can also be potentially used to save the state of an in-progress minimization to restart or continue.
iterations: Some(iterations), | ||
minimum: Some(MinResult::Vector(best.1)), | ||
minimum_value: Some(best.0), | ||
status: RunStatus::Success, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the status be tied to some conditionality? This relates to my other comment about the meaning of this enum.
Regarding the fmt, you can add |
Just for keeping track of thoughts:
|
Implements #9
Also ran
cargo fmt
on the crate... Will attempt to add this as a requirement for every PR@sebasv if you could have a look if you agree with the implementation?