-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
symbolic save idxs, new observed #392
base: master
Are you sure you want to change the base?
Changes from 7 commits
70e387d
875658b
4e1611e
659a3e4
c432843
406dcd4
82df76c
bb17abc
1d20e97
92d307a
59dd393
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/ | |
exited due to an error. For more details, see | ||
[the return code documentation](https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes). | ||
""" | ||
struct DAESolution{T, N, uType, duType, uType2, DType, tType, P, A, ID, DE} <: | ||
struct DAESolution{T, N, uType, duType, uType2, DType, tType, P, A, ID, DE, MType} <: | ||
AbstractDAESolution{T, N, uType} | ||
u::uType | ||
du::duType | ||
|
@@ -39,6 +39,7 @@ struct DAESolution{T, N, uType, duType, uType2, DType, tType, P, A, ID, DE} <: | |
interp::ID | ||
dense::Bool | ||
tslocation::Int | ||
sym_map::MType | ||
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. Can this be done using 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. no, because save_idxs isn't known at sys construction stage, only at solve 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. checking out the OrdinaryDiffEq part of this makes this all make a lot more sense to me. |
||
destats::DE | ||
retcode::ReturnCode.T | ||
end | ||
|
@@ -74,6 +75,7 @@ function build_solution(prob::AbstractDAEProblem, alg, t, u, du = nothing; | |
HermiteInterpolation(t, u, du), | ||
retcode = ReturnCode.Default, | ||
destats = nothing, | ||
sym_map = nothing, | ||
kwargs...) | ||
T = eltype(eltype(u)) | ||
|
||
|
@@ -88,34 +90,28 @@ function build_solution(prob::AbstractDAEProblem, alg, t, u, du = nothing; | |
errors = Dict{Symbol, real(eltype(prob.u0))}() | ||
|
||
sol = DAESolution{T, N, typeof(u), typeof(du), typeof(u_analytic), typeof(errors), | ||
typeof(t), | ||
typeof(prob), typeof(alg), typeof(interp), typeof(destats)}(u, du, | ||
u_analytic, | ||
errors, | ||
t, | ||
prob, | ||
alg, | ||
interp, | ||
dense, | ||
0, | ||
destats, | ||
retcode) | ||
typeof(t), typeof(prob), typeof(alg), typeof(interp), | ||
typeof(destats), typeof(sym_map)}(u, du, u_analytic, errors, t, | ||
prob, alg, interp, dense, 0, | ||
sym_map, destats, retcode) | ||
|
||
if calculate_error | ||
calculate_solution_errors!(sol; timeseries_errors = timeseries_errors, | ||
dense_errors = dense_errors) | ||
end | ||
sol | ||
else | ||
DAESolution{T, N, typeof(u), typeof(du), Nothing, Nothing, typeof(t), | ||
typeof(prob), typeof(alg), typeof(interp), typeof(destats)}(u, du, | ||
nothing, | ||
nothing, t, | ||
prob, alg, | ||
interp, | ||
dense, 0, | ||
destats, | ||
retcode) | ||
DAESolution{T, N, typeof(u), typeof(du), Nothing, Nothing, typeof(t), typeof(prob), | ||
typeof(alg), typeof(interp), typeof(destats), typeof(sym_map)}(u, du, | ||
nothing, | ||
nothing, | ||
t, prob, | ||
alg, | ||
interp, | ||
dense, 0, | ||
sym_map, | ||
destats, | ||
retcode) | ||
end | ||
end | ||
|
||
|
@@ -160,70 +156,78 @@ end | |
function build_solution(sol::AbstractDAESolution{T, N}, u_analytic, errors) where {T, N} | ||
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(u_analytic), typeof(errors), | ||
typeof(sol.t), | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats)}(sol.u, | ||
sol.du, | ||
u_analytic, | ||
errors, | ||
sol.t, | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
sol.dense, | ||
sol.tslocation, | ||
sol.destats, | ||
sol.retcode) | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats), | ||
typeof(sol.sym_map)}(sol.u, | ||
sol.du, | ||
u_analytic, | ||
errors, | ||
sol.t, | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
sol.dense, | ||
sol.tslocation, | ||
sol.sym_map, | ||
sol.destats, | ||
sol.retcode) | ||
end | ||
|
||
function solution_new_retcode(sol::AbstractDAESolution{T, N}, retcode) where {T, N} | ||
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(sol.u_analytic), | ||
typeof(sol.errors), typeof(sol.t), | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats)}(sol.u, | ||
sol.du, | ||
sol.u_analytic, | ||
sol.errors, | ||
sol.t, | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
sol.dense, | ||
sol.tslocation, | ||
sol.destats, | ||
retcode) | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats), | ||
typeof(sol.sym_map)}(sol.u, | ||
sol.du, | ||
sol.u_analytic, | ||
sol.errors, | ||
sol.t, | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
sol.dense, | ||
sol.tslocation, | ||
sol.sym_map, | ||
sol.destats, | ||
retcode) | ||
end | ||
|
||
function solution_new_tslocation(sol::AbstractDAESolution{T, N}, tslocation) where {T, N} | ||
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(sol.u_analytic), | ||
typeof(sol.errors), typeof(sol.t), | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats)}(sol.u, | ||
sol.du, | ||
sol.u_analytic, | ||
sol.errors, | ||
sol.t, | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
sol.dense, | ||
tslocation, | ||
sol.destats, | ||
sol.retcode) | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats), | ||
typeof(sol.sym_map)}(sol.u, | ||
sol.du, | ||
sol.u_analytic, | ||
sol.errors, | ||
sol.t, | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
sol.dense, | ||
tslocation, | ||
sol.sym_map, | ||
sol.destats, | ||
sol.retcode) | ||
end | ||
|
||
function solution_slice(sol::AbstractDAESolution{T, N}, I) where {T, N} | ||
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(sol.u_analytic), | ||
typeof(sol.errors), typeof(sol.t), | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats)}(sol.u[I], | ||
sol.du[I], | ||
sol.u_analytic === | ||
nothing ? | ||
nothing : | ||
sol.u_analytic[I], | ||
sol.errors, | ||
sol.t[I], | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
false, | ||
sol.tslocation, | ||
sol.destats, | ||
sol.retcode) | ||
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.destats), | ||
typeof(sol.sym_map)}(sol.u[I], | ||
sol.du[I], | ||
sol.u_analytic === | ||
nothing ? | ||
nothing : | ||
sol.u_analytic[I], | ||
sol.errors, | ||
sol.t[I], | ||
sol.prob, | ||
sol.alg, | ||
sol.interp, | ||
false, | ||
sol.tslocation, | ||
sol.sym_map, | ||
sol.destats, | ||
sol.retcode) | ||
end |
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.
Why do we need this?
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.
otherwise it breaks observed for odae and others
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.
Why would it break that?
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.
Not ODAE sorry, but things like
sol[x[1]^2+x[2]+norm(x)]
. Since you don't know which states you won't have later at solve time it was impossible to get both to work so I needed a flag. I would need some kind of signal from problem construction time to post solve, to signal what to call the observed functions withThere 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.
What signal do you need other than save_idxs?
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.
we don't have save_idxs at problem construction time, only at solve time, look at the ODE PR
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.
Yeah, but maybe we should.
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.
@ChrisRackauckas thoughts on the above?