Skip to content

DEIM #19

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

Merged
merged 101 commits into from
Oct 13, 2022
Merged

DEIM #19

merged 101 commits into from
Oct 13, 2022

Conversation

bowenszhu
Copy link
Member

resolve #12

@codecov
Copy link

codecov bot commented Jul 13, 2022

Codecov Report

Merging #19 (6388cd9) into main (cabc75c) will increase coverage by 11.02%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##             main      #19       +/-   ##
===========================================
+ Coverage   81.94%   92.96%   +11.02%     
===========================================
  Files           3        5        +2     
  Lines          72      199      +127     
===========================================
+ Hits           59      185      +126     
- Misses         13       14        +1     
Impacted Files Coverage Δ
src/DataReduction/POD.jl 74.54% <ø> (-1.39%) ⬇️
src/deim.jl 100.00% <100.00%> (ø)
src/utils.jl 100.00% <100.00%> (ø)

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

@FHoltorf
Copy link
Contributor

Very nice, I like it a lot. We should soon talk a little bit about how to expose these functionalities to a user and create an overarching interface that supports common workflows but also can accommodate generic reduction techniques.

@bowenszhu bowenszhu changed the title WIP: DEIM DEIM Jul 17, 2022
@bowenszhu bowenszhu marked this pull request as draft July 19, 2022 06:33
@bowenszhu
Copy link
Member Author

@ChrisRackauckas @FHoltorf This PR is ready.

Copy link
Contributor

@FHoltorf FHoltorf left a comment

Choose a reason for hiding this comment

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

No further comments. Looks great!

dxs = [x => dx]
order = 2
discretization = MOLFiniteDifference(dxs, t; approx_order = order)
ode_sys, tspan = symbolic_discretize(pde_sys, discretization)
Copy link
Member

Choose a reason for hiding this comment

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

@xtalax this is an interface break.

Copy link
Member

Choose a reason for hiding this comment

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

Note that this might break in a future version, hopefully soon. Not your fault though @bowenszhu , we should make an issue to track it though.

Copy link
Member

Choose a reason for hiding this comment

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

@YingboMa we should add (symbolic) time span to the system types so this can be supported better. It would also make modelingtoolkitize and reconstruction more automatic.


Variables in `vars` must be unique.
"""
function linear_terms(exprs::AbstractVector, vars)
Copy link
Member

Choose a reason for hiding this comment

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

@YingboMa @shashi should this bubble up to being something in MTK itself?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, definitely in Symbolics. There's a function called linear_expansion.

Copy link
Member Author

Choose a reason for hiding this comment

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

This function extracts 1. coefficients of linear terms, 2. constant terms and 3. remaining nonlinear terms to facilitate the DEIM algorithm, which is different from Symbolics.linear_expansion.
For example,

using Symbolics, ModelOrderReduction
@variables x y
exprs = [2x - 4y + 5 + (x + 1)^3 + sin(x)
         8x + 7]
l, c, n = ModelOrderReduction.linear_terms(exprs, [x, y])

gives

julia> l
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64} with 3 stored entries:
 2.0  -4.0
 8.0     

julia> c
2-element Vector{Num}:
 5
 7

julia> n
2-element Vector{Num}:
 (1 + x)^3 + sin(x)
                  0

However, Symbolics.linear_expansion doesn't return what is needed in DEIM:

using Symbolics
@variables x y
exprs = [2x - 4y + 5 + (x + 1)^3 + sin(x)
         8x + 7]
Symbolics.linear_expansion(exprs, [x, y])

result: (Num[#undef #undef; #undef #undef], Num[#undef, #undef], false)

Copy link
Member

Choose a reason for hiding this comment

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

Open an issue on Symbolics.jl about potentially changing linear_expansion to what's needed/used here.

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
Copy link
Member

Awesome work! I left a few comments for something to clean up before merging. Overall this looks really good though.

@bowenszhu bowenszhu mentioned this pull request Oct 11, 2022
@ChrisRackauckas
Copy link
Member

I think I'm basically good here. Try linear_expansion and let's open that issue on the tspan handling, then 👍 from me.

@ChrisRackauckas
Copy link
Member

🎉

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.

DEIM
4 participants