This repository was archived by the owner on Dec 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Added OptimResult #10
Open
to266
wants to merge
2
commits into
master
Choose a base branch
from
result
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
|
||
//! This module provides the base framework for all minimizers present in this crate, such as the | ||
//! base trait and return type. | ||
use ndarray::prelude::*; | ||
use std::time::Duration; | ||
|
||
/// Minimizer states at the end of the run | ||
#[derive(Debug, PartialEq)] | ||
pub enum RunStatus { | ||
/// Minimizer finished successfully. | ||
Success, | ||
/// Minimization was not succesful | ||
Failure, | ||
} | ||
|
||
/// Final minimization parameters that result in the smallest found value. | ||
#[derive(Debug, PartialEq)] | ||
pub enum MinResult { | ||
/// Scalar parameter value where the minimum is found | ||
Scalar(f64), | ||
/// Vector of parameters where the minimum if found | ||
Vector(Array1<f64>), | ||
} | ||
|
||
/// A minimization result, storing various details of the run and the final results. | ||
#[derive(Debug, PartialEq)] | ||
pub struct OptimResult { | ||
/// The runtime of the minimization according to the system clock. | ||
pub runtime: Option<Duration>, | ||
/// 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 commentThe reason will be displayed to describe this comment to others. Learn more. It is not clear to me why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my point of view, two reasons:
|
||
/// The final parameter values. | ||
pub minimum: Option<MinResult>, | ||
/// The function value at the found minimum. | ||
pub minimum_value: Option<f64>, | ||
/// The minimizer success or failure status. | ||
pub status: RunStatus, | ||
} | ||
|
||
/// A general minimizer trait. | ||
pub trait Minimizer { | ||
|
@@ -9,5 +46,5 @@ pub trait Minimizer { | |
&self, | ||
func: F, | ||
args: ArrayView1<f64>, | ||
) -> Array1<f64>; | ||
) -> OptimResult; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
//! This module contains algorithms that search for local minima of functions along a single dimension. | ||
//! This module contains algorithms that search for local minima of functions along a single dimension. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ where | |
grad | ||
} | ||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
mod nelder_mead; | ||
|
||
pub use self::nelder_mead::NelderMeadBuilder; | ||
pub use self::nelder_mead::NelderMeadBuilder; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 likeis_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.