-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use a reference of problem for set_problem() #4
Conversation
During simulation it may be necessary to update the state, which also requires the problem. Previously `set_problem()` consumed `problem`, but this change instead calls for a reference. The problem itself is small, and as such the clone should not be especially expensive.
Use a reference of problem for set_problem
Alternatively a different solution focused on updating the state without requiring a new call to |
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.
thanks @mhovd, few minor changes below to reduce some lines of unnessessary code:
As I see it, the old solver method needs to know if the state has been altered, so it can reset its own internal state. You could either:
|
I understand that sometimes it is necessary to update the state (and if we're planning to support events this will be happening all the time). But I'm not sure about the approach. Wouldn't it be better if we have a sort of higher level orchestrator that sub divides the time vector to stop the solver at the event's time, and then modifies the state by changing the initial condition of the next simulation? I know there is some overhead to this approach, namely the need to interpolate for every event time, but this approach (I think) can be more easily extrapolated when new solvers are implemented. |
Agreed, I think this PR is to sort out the api on the solver methods that this orchestrator could use to implement this. |
Co-authored-by: Martin Robinson <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
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.
looks great, thanks @mhovd
During simulation it may be necessary to update the state, which also requires the problem. Previously
set_problem()
consumedproblem
, but this change instead calls for a reference. The problem itself is small, and as such the clone should not be especially expensive.