-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docstrings to state and stats #657
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4ae646c
Add docstrings to state and stats
Vaibhavdixit02 d026405
Add suggestions from review, fieldnames changed
Vaibhavdixit02 3ea505b
iteration -> iter
Vaibhavdixit02 9b5104e
format to resolve conflicts
Vaibhavdixit02 cac58e1
Merge branch 'master' into statsstatedocs
Vaibhavdixit02 2e6b1f4
constructor changed names
Vaibhavdixit02 325de43
some more iters
Vaibhavdixit02 35b97e5
more updates
Vaibhavdixit02 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 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,4 +1,20 @@ | ||||||||||
""" | ||||||||||
$(TYPEDEF) | ||||||||||
|
||||||||||
Stores the optimization run's statistics that is returned | ||||||||||
in the `stats` field of the `OptimizationResult`. | ||||||||||
|
||||||||||
## Fields | ||||||||||
- `iterations`: number of iterations | ||||||||||
- `time`: time taken to run the solver | ||||||||||
- `fevals`: number of function evaluations | ||||||||||
- `gevals`: number of gradient evaluations | ||||||||||
- `hevals`: number of hessian evaluations | ||||||||||
|
||||||||||
Default values for all the field are set to 0 and hence even when | ||||||||||
you might expect non-zero values due to unavilability of the information | ||||||||||
from the solver it would be 0. | ||||||||||
""" | ||||||||||
struct OptimizationStats | ||||||||||
iterations::Int | ||||||||||
time::Float64 | ||||||||||
|
@@ -7,9 +23,24 @@ | |||||||||
hevals::Int | ||||||||||
end | ||||||||||
|
||||||||||
OptimizationStats(; iterations = 0, time = 0.0, fevals = 0, gevals = 0, hevals = 0) = | ||||||||||
function OptimizationStats(; iterations = 0, time = 0.0, fevals = 0, gevals = 0, hevals = 0) | ||||||||||
OptimizationStats(iterations, time, fevals, gevals, hevals) | ||||||||||
end | ||||||||||
|
||||||||||
""" | ||||||||||
$(TYPEDEF) | ||||||||||
|
||||||||||
Stores the optimization run's state at the current iteration | ||||||||||
and is passed to the callback function as the first argument. | ||||||||||
|
||||||||||
## Fields | ||||||||||
- `iteration`: current iteration | ||||||||||
- `u`: current solution | ||||||||||
- `objective`: current objective value | ||||||||||
- `gradient`: current gradient | ||||||||||
- `hessian`: current hessian | ||||||||||
Comment on lines
+40
to
+41
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.
Suggested change
grad, hes Make the naming match everything else, we can't just have one thing different. |
||||||||||
- `solver_state`: if the solver has its own state object then it is stored here | ||||||||||
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.
Suggested change
for uniformity. |
||||||||||
""" | ||||||||||
struct OptimizationState{X, O, G, H, S} | ||||||||||
iteration::Int | ||||||||||
u::X | ||||||||||
|
@@ -19,6 +50,7 @@ | |||||||||
solver_state::S | ||||||||||
end | ||||||||||
|
||||||||||
OptimizationState(; iteration = 0, u = nothing, objective = nothing, | ||||||||||
gradient = nothing, hessian = nothing, solver_state = nothing) = | ||||||||||
function OptimizationState(; iteration = 0, u = nothing, objective = nothing, | ||||||||||
gradient = nothing, hessian = nothing, solver_state = nothing) | ||||||||||
OptimizationState(iteration, u, objective, gradient, hessian, solver_state) | ||||||||||
end |
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.