Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

xtalax
Copy link
Member

@xtalax xtalax commented Feb 15, 2023

Merge order is:

  1. Add observed variable defaults  SymbolicIndexingInterface.jl#7
  2. symbolic save idxs, new observed #392 (This)
  3. Symbolic save idxs OrdinaryDiffEq.jl#1867
  4. get state dependencies, observed -> SymbolicIndexingInterface ModelingToolkit.jl#2071

Am trying to test each part seperately but a lot of this is very tightly coupled, I will test it composed in the MTK PR locally with all dev'd and notify when that passes

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #392 (bb17abc) into master (c2bb35d) will decrease coverage by 13.03%.
The diff coverage is 12.50%.

❗ Current head bb17abc differs from pull request most recent head 59dd393. Consider uploading reports for the commit 59dd393 to get more accurate results

@@             Coverage Diff             @@
##           master     #392       +/-   ##
===========================================
- Coverage   52.25%   39.22%   -13.03%     
===========================================
  Files          46       46               
  Lines        3554     3602       +48     
===========================================
- Hits         1857     1413      -444     
- Misses       1697     2189      +492     
Impacted Files Coverage Δ
src/SciMLBase.jl 46.66% <ø> (ø)
src/solutions/nonlinear_solutions.jl 38.46% <ø> (-23.08%) ⬇️
src/solutions/optimization_solutions.jl 34.78% <ø> (-19.57%) ⬇️
src/solutions/rode_solutions.jl 66.66% <ø> (ø)
src/solutions/solution_interface.jl 30.80% <0.00%> (-28.10%) ⬇️
src/symbolic_utils.jl 15.38% <0.00%> (-50.19%) ⬇️
src/utils.jl 54.48% <60.00%> (-7.11%) ⬇️
src/solutions/dae_solutions.jl 19.56% <100.00%> (ø)
src/solutions/ode_solutions.jl 72.07% <100.00%> (-22.33%) ⬇️

... and 22 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ChrisRackauckas
Copy link
Member

Isn't this needed in every solution type for the indexing?

@xtalax
Copy link
Member Author

xtalax commented Feb 15, 2023

is build_explicit_observed_function used for every system type? If so then yes, but I think it would require updating every __init__ to feed through the symbol map. I will have a think about this

@YingboMa
Copy link
Member

Are the test failures related?

i = get(A.sym_map, sym, nothing)
else
i = sym_to_index(sym, A)
end
elseif all(issymbollike, sym)
if has_sys(A.prob.f) && all(Base.Fix1(is_param_sym, A.prob.f.sys), sym) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i isn't defined in this branch. Maybe this causes the test failure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that branch always returns

@xtalax
Copy link
Member Author

xtalax commented Feb 27, 2023

Remaining failures look unrelated

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done using prob.f.sys? Requiring explicit maps isn't great.

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

kwargs...) where {iip}
_tspan = promote_tspan(tspan)
new{typeof(u0), typeof(_tspan),
isinplace(f), typeof(p), typeof(f),
typeof(kwargs),
typeof(problem_type)}(f, u0, _tspan, p, kwargs, problem_type)
typeof(problem_type)}(f, u0, _tspan, p, kwargs, problem_type, dense_output)
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

@xtalax xtalax Feb 27, 2023

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 with

Copy link
Member

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?

Copy link
Member Author

@xtalax xtalax Feb 28, 2023

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

Copy link
Member

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.

Copy link
Member Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants