Skip to content
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.

Added OptimResult #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Added OptimResult #10

wants to merge 2 commits into from

Conversation

to266
Copy link
Owner

@to266 to266 commented Oct 14, 2018

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?

  • ready for review

Copy link
Contributor

@sebasv sebasv left a 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>,
Copy link
Contributor

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 Options. Are there cases imaginable where these don't have 'default' values? I would expect every algorithm can return appropriate values for these fields.

Copy link
Owner Author

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:

  1. I did not bother considering all usecases for each parameter.
  2. 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 {
Copy link
Contributor

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

Copy link
Owner Author

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,
Copy link
Contributor

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.

@sebasv
Copy link
Contributor

sebasv commented Oct 15, 2018

Regarding the fmt, you can add - cargo fmt --all -- --check to Travis.

@to266
Copy link
Owner Author

to266 commented Nov 28, 2018

Just for keeping track of thoughts:

  • This PR seems to have started leading me towards stateful optimizers that can be paused/resumed in the middle. While this of course sounds excellent, the changes required to adapt master (and also L-BFGS #12 ) are quite substantial.
  • Also, not sure if it's the best implementing the state in a OOP way. I'd like to do this in the data-oriented fashion, but this requires more thinking, since I don't have the experience. Also I'm not sure it's worth it and might result in a better interface / faster / more robust implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants