Skip to content

Improved Symbolic Indexing - #342

Merged
ChrisRackauckas merged 12 commits into
SciML:masterfrom
AayushSabharwal:sys_indexing
Jan 26, 2023
Merged

ChrisRackauckas merged 12 commits into
SciML:masterfrom
AayushSabharwal:sys_indexing

Conversation

@AayushSabharwal

Copy link
Copy Markdown
Member

Uses SymbolicIndexingInterface.jl
Refer to SciML/ModelingToolkit.jl#1988

@codecov

codecov Bot commented Dec 12, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #342 (acdb611) into master (c6a038e) will increase coverage by 1.15%.
The diff coverage is 91.30%.

@@            Coverage Diff             @@
##           master     #342      +/-   ##
==========================================
+ Coverage   57.75%   58.90%   +1.15%     
==========================================
  Files          43       44       +1     
  Lines        3290     3487     +197     
==========================================
+ Hits         1900     2054     +154     
- Misses       1390     1433      +43     
Impacted Files Coverage Δ
src/SciMLBase.jl 75.00% <ø> (-6.82%) ⬇️
src/solutions/ode_solutions.jl 95.32% <85.71%> (-1.65%) ⬇️
src/integrator_interface.jl 47.38% <91.66%> (+0.20%) ⬆️
src/solutions/solution_interface.jl 59.72% <94.73%> (+<0.01%) ⬆️
src/scimlfunctions.jl 58.74% <100.00%> (+0.08%) ⬆️
src/debug.jl 0.00% <0.00%> (ø)
src/problems/basic_problems.jl 87.50% <0.00%> (+0.54%) ⬆️
... and 9 more

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

@AayushSabharwal

Copy link
Copy Markdown
Member Author

I'm fairly certain the rest of the tests will only pass once MTK gets bumped and this can depend on the new version

@AayushSabharwal

Copy link
Copy Markdown
Member Author

If paramsyms/indepsym is passed to the SciMLFunction, then I guess there isn't a reason to not fallback to it

@AayushSabharwal

Copy link
Copy Markdown
Member Author

This needs RecursiveArrayTools for tests to pass as well

@ChrisRackauckas

Copy link
Copy Markdown
Member

Looks like it's still failing?

@AayushSabharwal

Copy link
Copy Markdown
Member Author

Yeah, I just realised that it needs the latest MTK, which is a bit backward and can be fixed by a small patch to the SymbolicIndexingInterface

@AayushSabharwal

AayushSabharwal commented Dec 12, 2022 •

Copy link
Copy Markdown
Member Author

I didn't realise that some functions contain the sys but may not use it for indexing, so it complains that they don't implement the interface. There's no way (as of now) to check if the interface is implemented, so it looks like defaulting is_state_sym(::Any, _) = false should do the trick

The compat change I just added should fix tests, but someone installing an old MTK would retain compat for the version containing this PR, and things would break.

- `sym_to_index` checks if the system has the specified symbol before
  falling back to `getsyms`. This takes advantage of the change in
  SymbolicIndexingInterface v0.2.0
@AayushSabharwal

Copy link
Copy Markdown
Member Author

Now this should be compatible with previous MTK versions as well

@AayushSabharwal

Copy link
Copy Markdown
Member Author

🤦🏻 I forgot 0.1 - 0.2 is a breaking transition in semver, kept thinking it's just a minor version change

@AayushSabharwal

AayushSabharwal commented Dec 13, 2022 •

Copy link
Copy Markdown
Member Author

Rerunning CI here should make everything pass 🤞🏻

@ChrisRackauckas

Copy link
Copy Markdown
Member

Sounds suspicious.

@AayushSabharwal

AayushSabharwal commented Dec 13, 2022 •

Copy link
Copy Markdown
Member Author

Is the new MTK not tagged?

Edit: Ah, it isn't. Then it'll run into this dependency conflict

@AayushSabharwal

Copy link
Copy Markdown
Member Author

Should I close this to not waste CI then reopen once its tagged?

@ChrisRackauckas

Copy link
Copy Markdown
Member

Told you, sus.

@ChrisRackauckas

Copy link
Copy Markdown
Member

Just gotta wait a bit haha JuliaRegistries/General#74053

@AayushSabharwal

Copy link
Copy Markdown
Member Author

Dunno what is up with me today 😅 a bit all over the place

@AayushSabharwal

AayushSabharwal commented Dec 15, 2022 •

Copy link
Copy Markdown
Member Author

Finally merged the new version of MTK

@AayushSabharwal

Copy link
Copy Markdown
Member Author

Apparently reopening doesn't rerun CI

@ChrisRackauckas

Copy link
Copy Markdown
Member

Still failing

@AayushSabharwal

Copy link
Copy Markdown
Member Author

That failure confuses me. In the system at MTK/test/components.jl:99, why does states(sys) say that there are two states (capacitor.v and capacitor.i) but the solution is Nx1 (timeseries of one element)

@AayushSabharwal

Copy link
Copy Markdown
Member Author

Interestingly sol2.prob.f.syms has only capacitor.v. Must be some ODAEProblem thing I'm unaware of

@ChrisRackauckas

Copy link
Copy Markdown
Member

The other must be an observed variable. How are those treated?

@AayushSabharwal

AayushSabharwal commented Dec 15, 2022 •

Copy link
Copy Markdown
Member Author

If a symbol doesn't match a state variable, it falls back to using observed as it did before. However, the system says its a state variable, so it never falls back.

It seems ODAEProblem does some additional simplification, which seems backward to me. Why would a problem modify the system? In any case, it makes the information that the system has invalid, which causes problems

EDIT: Indeed, capacitor.i is turned into an observed variable, but the system does not know this

@ChrisRackauckas

Copy link
Copy Markdown
Member

Might need to wait until @YingboMa is back

@xtalax

xtalax commented Jan 26, 2023 •

Copy link
Copy Markdown
Member

How is this going - this being merged seems like a prerequisite for symbolic save_idxs which I am working on.
SymbolicIndexingInterface seems to solve a lot of the same problems

@oscardssmith

Copy link
Copy Markdown
Member

it looks like this just needs a format

@ChrisRackauckas
ChrisRackauckas merged commit 4f0fa68 into SciML:master Jan 26, 2023
@ChrisRackauckas

Copy link
Copy Markdown
Member

Boom

@AayushSabharwal

Copy link
Copy Markdown
Member Author

Is the ODAEProblem stuff fixed?

@YingboMa

Copy link
Copy Markdown
Member

Yes

@oscardssmith

Copy link
Copy Markdown
Member

See #379 which makes this also work for DAESolution.

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.

5 participants