-
-
Couldn't load subscription status.
- Fork 233
Automatic inference of discrete parameters in events #3991
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
base: master
Are you sure you want to change the base?
Conversation
| sol = solve(prob) | ||
| @test SciMLBase.successful_retcode(sol) | ||
| @test sol[x, end]≈1.0 atol=1e-6 | ||
| @test sol[x, end]≈0.75 atol=1e-6 |
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.
There is an error in this test. The discrete_parameters argument was forgotten, so the event is not actually triggered. Unless the intention of the test is to check that everything works as (un)expected when the input is omitted (but the naming and test do not suggest that), this should be changed. With this PR, the event is now triggered, and the correct value 0.75 is achieved.
|
There are test errors, however, they are the same as in: #3989 |
|
I'm not so sure of this. If I understand correctly, this takes all parameters in affect equations that don't occur inside a @parameters p(t)
@variables x(t)
cb = [some_condition] => [x ~ Pre(x) + p]is well-defined, but after the change |
|
Wouldn't |
|
For non time-dependent parameters I could make it optional to use @parameters p # not `(t)` but I was hesitant as I figured it might make more sense to just enforce |
|
For non-time-dependent parameters,
We have 2 unknowns and one equation. |
|
Sounds good, I can discount non-time dependent parameters if that the case.
Sorry, yes, meant underdetermined. But my point is that |
|
Or maybe you meant @parameters p # Not `(t)`
@variables x(t)
cb = [some_condition] => [x ~ Pre(x) + p]that would make sense, I will update the PR to discount non-time-dependent parameters, which should harmonize this case with current behaviours. |
|
Weird. I investigated, and turns out that julia> pasys
Model affectsys:
Equations (1):
1 standard: see equations(affectsys)
Unknowns (1): see unknowns(affectsys)
x(t)
Parameters (2): see parameters(affectsys)
Pre(x(t))
p(t)
julia> equations(pasys)
1-element Vector{Equation}:
x(t) ~ p(t) + Pre(x(t))However, after simplification the equation becomes |
|
It's not generally correct for the user to not be selecting it? What do you do about the case of |
It causes malformed systems to be automatically created rather than requiring the user to give a correct system. That seems like a recipe for trouble. |
|
Right, but doesn't that align with this PR? I agree that |
When creating a symbolic event through
SymbolicContinuousCallbackorSymbolicDiscreteCallbackit is possible to infer which parameters are updated by the event (everything withinPre(...)statements in the affect are protected, but everything outside can be updated). This PR adds a small routine to do this for the user if thediscrete_parametersargument is not provided. This should prevent the possibility of silent errors if they forgets this argument. Furthermore, it enables programmatic use of events without explicitly importingSymbolicContinuousCallback/SymbolicDiscreteCallback(as one can how just use the normal map for in the input, instead of using these functions).I have tried, and it is possible to remove all
discrete_parametersstatements from all events in the test files, and everything passes. Right now I have not done so, as I wanted to provide minimal changes (isntead I added a bunch of additional new tests as well).