-
Notifications
You must be signed in to change notification settings - Fork 1
Separate State and StoppingCriterionState initialization
#9
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
Closed
Changes from all commits
Commits
Show all changes
4 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
Oops, something went wrong.
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.
It's a small change, but in practice what I've been doing is writing the definition of
initialize_statemore like this:Maybe I was being dense, but it took me some time to realize that was a "valid" way to define it and still have control over the parts of the state initialization that I wanted to control, since that allows running
solveas:I think seeing the example written that way would have helped me understand how I should define
initialize_state.However, I realized a slightly awkward thing about defining
initialize_statein that way and then calling solve assolve(SqrtProblem(16.0), HeronAlgorithm(StopAfterIteration(10)); x0 = 1.0)is that thenx0gets passed to bothinitialize_stateandinitialize_state!. Maybe that's not a problem in practice but I found it to be a bit strange (i.e. shouldinitialize_state!usex0or not?), and also made me confused about the roles ofintialize_statevs.initialize_state!. I think the suggestion in this PR of just havinginitialize_state!resetiterationhelps clarify that issue a bit.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 comment about the kwargs is a really good one, I was looking at this a bit before and it's somewhat difficult to come up with a way to split arbitrary keywords generically, but it could even make sense to just not pass the keyword arguments to
initialize_state!anymore if they have already been passed toinitialize_state?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 was thinking about that, indeed maybe it makes sense to not pass the keyword arguments to
initialize_state!. That could make the distinction betweeninitialize_stateandinitialize_state!clearer, since theninitialize_statehandles external inputs (i.e. initial guesses for the iterate) whileinitialize_state!just handles resetting the "internal" state, such as the iteration number and stopping criterion state. Callingsolve!means that you made thestatealready, so it seems like anything handled through keyword arguments toinitialize_state!could instead be handled by just modifying thestatedirectly (i.e. before callingsolve!/initialize_state!).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.
Hm, I disagree here, for me functions of same name should do the same and accept the same keywords. Or to be more precise
initialize_stateshould create astatefrom new memory but alsoinitialize_state!applied to the same memorystateshould set it to the same situation as well.