-
-
Notifications
You must be signed in to change notification settings - Fork 6
Restructure POD interface #25
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
Conversation
…d reduce! for better modularity
…rgy as well as min and max number of modes.
src/DataReduction/POD.jl
Outdated
function svd(data::Vector{Vector{T}}) where {T} | ||
mat_data = matricize(data) | ||
return svd(mat_data) | ||
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.
Redundant?
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.
absolutely
src/ModelOrderReduction.jl
Outdated
import TSVD.tsvd | ||
import RandomizedLinAlg.rsvd | ||
import LinearAlgebra.svd |
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.
This makes it piracy because it's then adding a function on Base types. It would be safer to just shadow or define a _tsvd
etc. inside of the package for the Vector{Vector} form.
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.
good point. Didn't think about that whatsoever. Should be fixed now.
Codecov Report
@@ Coverage Diff @@
## main #25 +/- ##
==========================================
+ Coverage 72.34% 81.94% +9.60%
==========================================
Files 3 3
Lines 47 72 +25
==========================================
+ Hits 34 59 +25
Misses 13 13
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Other than the shadowing issue, I think this is good. |
Hey,
I revisited some of the POD interface and realized there were a few problems:
First of all, the type specs in the
POD
type are problematic: For example, specifiying integer-valued data will error as the rel. energy and the reduced basis is then constrained to be integer-valued as well (obviously not generally true):Further, the interface did not accommodate a typical workflow for POD. Specifically, one often would like to reduce the dimensionality to capture a specified minimum relative energy (say 95%). Right now we require the dimension to be specified directly. So a user would effectively need to take the SVD of their data, look at the spectrum and decide on the cutoff, just to then take the svd all over again within ModelOrderReduction. I adjusted the POD type to also carry fields
min_renergy
,min_nmodes
,max_nmodes
, referring to the min relative energy captured as well as the minimum and maximum number of modes retained, respectively. I updated the reduction step accordingly to choose the reduction to be inline with these specifications. Moreover, I added a fieldspectrum
that carries the singular spectrum (which is often of interest for a posterior analysis).Lastly, I changed the reduce statement to dispatch directly on the type of the data to be reduced. Consequently, POD can be applied via this interface to any data set which admits computation of a singular value decomposition via the specified routine. That way, everything composes better with the greater ecosystem.
Let me know!
Flemming