From 9ef2eb8d9ba4e969b7c68bce2811a9b5f23c5c8b Mon Sep 17 00:00:00 2001 From: Andrea Alfonsi - NuCube Date: Fri, 13 Sep 2024 11:40:55 -0600 Subject: [PATCH] PyDMD based DMD ROMs (#2342) * added dep * initial dmd pydmd * deps * added pydmd DMD * addded some dmd based algo * added some tests * added forward backward * added tests * hodmd * HODMD * added pidmd * added PiDMD * RDMD * SpDMD * BOPDMD * subspace dmd * subspace dmd * reseed * added final tests * docs * documentation * fixed auto documentation * trailing whitespaces * removed old DMD files and moved DMDC in DMD/ folder * dmdc * added some old functionalities of the DynamicModeDecomposition (raven implementation) in the DMDc * removed dmdType * fixed comparison statement * Apply suggestions from code review * Update ravenframework/SupervisedLearning/DMD/DMDBase.py * Apply suggestions from code review * Update tests/framework/ROM/TimeSeries/DMD/test_spdmd_pydmd.xml * Apply suggestions from code review * addressed reviewers comments * almost done * fixed dmd with new default (multiquadratic approximation) * added tests with approximation RBF and GPR * Update tests/framework/ROM/TimeSeries/DMD/test_kernelized_dmd_pydmd.xml * Update ravenframework/SupervisedLearning/DMD/BOPDMD.py * better setting parameters for HODMD rbf * fixed manual * max time --- dependencies.xml | 2 + doc/user_manual/generated/generateRomDoc.py | 677 +- doc/user_manual/generated/internalRom.tex | 5623 ++++++++++++++++- .../SupervisedLearning/DMD/BOPDMD.py | 187 + ravenframework/SupervisedLearning/DMD/CDMD.py | 180 + ravenframework/SupervisedLearning/DMD/DMD.py | 153 + .../SupervisedLearning/DMD/DMDBase.py | 474 ++ .../DynamicModeDecompositionControl.py | 88 +- ravenframework/SupervisedLearning/DMD/EDMD.py | 144 + .../SupervisedLearning/DMD/FbDMD.py | 154 + .../SupervisedLearning/DMD/HAVOK.py | 163 + .../SupervisedLearning/DMD/HODMD.py | 192 + .../SupervisedLearning/DMD/HankelDMD.py | 180 + .../SupervisedLearning/DMD/PiDMD.py | 200 + ravenframework/SupervisedLearning/DMD/RDMD.py | 180 + .../SupervisedLearning/DMD/SpDMD.py | 209 + .../SupervisedLearning/DMD/SubspaceDMD.py | 131 + .../SupervisedLearning/DMD/VarProDMD.py | 163 + .../SupervisedLearning/DMD/__init__.py | 22 + .../DynamicModeDecomposition.py | 400 -- ravenframework/SupervisedLearning/Factory.py | 19 +- ravenframework/SupervisedLearning/__init__.py | 1 + .../gold/data/dmdc_stats_rfe.xml | 1 - .../data/dmdc_stats_rfe_apply_clustering.xml | 1 - .../data/dmdc_stats_rfe_score_only_output.xml | 1 - .../data/dmdc_stats_rfe_score_subgroup.xml | 1 - .../data/dmdc_stats_variance_threshold.xml | 1 - tests/framework/ROM/FeatureSelection/tests | 1 + .../gold/BOPDMD/outputBOPDMD/outputDMD_0.csv | 9 + .../outputCompressedDMD/outputDMD_0.csv | 9 + .../outputForwardBackwardDMD/outputDMD_0.csv | 9 + .../gold/HAVOK/outputHAVOKDMD/outputDMD_0.csv | 9 + .../gold/HODMD/outputHODMD/outputDMD_0.csv | 9 + .../gold/HODMDgpr/outputHODMD/outputDMD_0.csv | 9 + .../gold/HODMDrbf/outputHODMD/outputDMD_0.csv | 9 + .../HankelDMD/outputHankelDMD/outputDMD_0.csv | 9 + .../outputDMD/outputDMDHighOrder_0.csv | 9 - .../outputKernalizedDMD/outputDMD_0.csv | 9 + .../gold/PiDMD/outputPiDMD/outputDMD_0.csv | 9 + .../outputDMD/outputDMDHighOrder_0.csv | 16 +- .../DMD/gold/RDMD/outputRDMD/outputDMD_0.csv | 9 + .../gold/SpDMD/outputSpDMD/outputDMD_0.csv | 9 + .../outputSubspaceDMD/outputDMD_0.csv | 9 + .../TraditionalDMD/outputDMD/outputDMD_0.csv | 9 + .../outputDMD/outputDMDtraditional_0.csv | 9 - .../VarProDMD/outputVarProDMD/outputDMD_0.csv | 9 + .../ROM/TimeSeries/DMD/test_bopdmd_pydmd.xml | 140 + .../DMD/test_compressed_dmd_pydmd.xml | 140 + .../DMD/test_forward_backward_dmd_pydmd.xml | 137 + .../TimeSeries/DMD/test_hankel_dmd_pydmd.xml | 140 + .../TimeSeries/DMD/test_havok_dmd_pydmd.xml | 140 + .../ROM/TimeSeries/DMD/test_hodmd_pydmd.xml | 139 + .../test_hodmd_pydmd_with_gpr_settings.xml | 145 + .../test_hodmd_pydmd_with_rbf_settings.xml | 145 + .../DMD/test_kernelized_dmd_pydmd.xml | 136 + .../ROM/TimeSeries/DMD/test_pickle_dmd.xml | 7 +- .../ROM/TimeSeries/DMD/test_pidmd_pydmd.xml | 139 + ...high_order_dmd.xml => test_rdmd_pydmd.xml} | 31 +- .../ROM/TimeSeries/DMD/test_spdmd_pydmd.xml | 136 + .../TimeSeries/DMD/test_subspacedmd_pydmd.xml | 137 + ...dmd.xml => test_traditional_dmd_pydmd.xml} | 16 +- .../TimeSeries/DMD/test_varprodmd_pydmd.xml | 134 + tests/framework/ROM/TimeSeries/DMD/tests | 123 +- 63 files changed, 11160 insertions(+), 542 deletions(-) create mode 100644 ravenframework/SupervisedLearning/DMD/BOPDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/CDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/DMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/DMDBase.py rename ravenframework/SupervisedLearning/{ => DMD}/DynamicModeDecompositionControl.py (83%) create mode 100644 ravenframework/SupervisedLearning/DMD/EDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/FbDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/HAVOK.py create mode 100644 ravenframework/SupervisedLearning/DMD/HODMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/HankelDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/PiDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/RDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/SpDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/SubspaceDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/VarProDMD.py create mode 100644 ravenframework/SupervisedLearning/DMD/__init__.py delete mode 100644 ravenframework/SupervisedLearning/DynamicModeDecomposition.py create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/BOPDMD/outputBOPDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/CompressedDMD/outputCompressedDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/ForwardBackwardDMD/outputForwardBackwardDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/HAVOK/outputHAVOKDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/HODMD/outputHODMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/HODMDgpr/outputHODMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/HODMDrbf/outputHODMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/HankelDMD/outputHankelDMD/outputDMD_0.csv delete mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/HighOrderDMD/outputDMD/outputDMDHighOrder_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/KernalizedDMD/outputKernalizedDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/PiDMD/outputPiDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/RDMD/outputRDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/SpDMD/outputSpDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/SubspaceDMD/outputSubspaceDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMD_0.csv delete mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMDtraditional_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/gold/VarProDMD/outputVarProDMD/outputDMD_0.csv create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_bopdmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_compressed_dmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_forward_backward_dmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_hankel_dmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_havok_dmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_gpr_settings.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_rbf_settings.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_kernelized_dmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_pidmd_pydmd.xml rename tests/framework/ROM/TimeSeries/DMD/{test_high_order_dmd.xml => test_rdmd_pydmd.xml} (83%) create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_spdmd_pydmd.xml create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_subspacedmd_pydmd.xml rename tests/framework/ROM/TimeSeries/DMD/{test_traditional_dmd.xml => test_traditional_dmd_pydmd.xml} (90%) create mode 100644 tests/framework/ROM/TimeSeries/DMD/test_varprodmd_pydmd.xml diff --git a/dependencies.xml b/dependencies.xml index ad59b23c2c..a4b3064790 100644 --- a/dependencies.xml +++ b/dependencies.xml @@ -89,6 +89,8 @@ Note all install methods after "main" take + + remove diff --git a/doc/user_manual/generated/generateRomDoc.py b/doc/user_manual/generated/generateRomDoc.py index eb4957f5f9..0ccf2db01a 100644 --- a/doc/user_manual/generated/generateRomDoc.py +++ b/doc/user_manual/generated/generateRomDoc.py @@ -321,16 +321,644 @@ ... ... - - time,totals_watts, xe135_dens - enrichment,bu - dmd - time - 0 - 5 - False - True - + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +BOPDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + False + True + 0 + 0.6 + auto + stable + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +CDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + sample + 20201986 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +FbDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + True + True + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +HankelDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + False + 1 + False + first + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +HAVOK = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 3 + 1 + 1 + False + True + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +HODMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + False + 1 + False + mean + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +EDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 3 + 7 + linear + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +PiDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + False + BCCB + 1,9 + True + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +RDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + 20021986 + 5 + 2 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +SpDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +SubspaceDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + -1 + None + False + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} +""" + +VarProDMD = r""" +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + ... ... @@ -638,6 +1266,18 @@ 'ARMA': armaExp, 'PolyExponential': poly, 'DMD': dmd, + 'BOPDMD': BOPDMD, + 'CDMD': CDMD, + 'FbDMD': FbDMD, + 'HankelDMD': HankelDMD, + 'HAVOK': HAVOK, + 'HODMD': HODMD, + 'EDMD': EDMD, + 'PiDMD': PiDMD, + 'RDMD': RDMD, + 'SpDMD': SpDMD, + 'SubspaceDMD': SubspaceDMD, + 'VarProDMD': VarProDMD, 'DMDC': dmdc, 'KerasMLPClassifier': kmlpc, 'KerasConvNetClassifier': kconv, @@ -767,9 +1407,24 @@ 'PolyExponential', 'DMD', 'DMDC'] + +vaildInternalDMDRom = ['DMD', + 'HODMD', + 'BOPDMD', + 'CDMD', + 'EDMD', + 'FbDMD', + 'HankelDMD', + 'HAVOK', + 'PiDMD', + 'RDMD', + 'SpDMD', + 'SubspaceDMD', + 'VarProDMD', + 'DMDC'] validRom = list(SupervisedLearning.factory.knownTypes()) orderedValidRom = [] -for rom in validInternalRom + validRom: +for rom in validInternalRom + vaildInternalDMDRom + validRom: if rom not in orderedValidRom: orderedValidRom.append(rom) ### Internal ROM file generation diff --git a/doc/user_manual/generated/internalRom.tex b/doc/user_manual/generated/internalRom.tex index 98eb933b9d..4109bcd699 100644 --- a/doc/user_manual/generated/internalRom.tex +++ b/doc/user_manual/generated/internalRom.tex @@ -2114,17 +2114,28 @@ \subsubsection{SyntheticHistory} Note: New models wishing to apply this transformation should use a \xmlNode{gaussianize} node preceding the \xmlNode{arma} node instead of this option. \default{False} + \item \xmlAttr{auto\_select}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0], optional}, + if set to True, the ARMA algorithm will use P and Q, the signal and + noise lag respectively, determined by the `autoarma` TSA algorithm. + The `autoarma` algorithm must be selected in the TSA input sequence before + the `ARMA` algorithm. \default{False} \end{itemize} The \xmlNode{arma} node recognizes the following subnodes: \begin{itemize} - \item \xmlNode{SignalLag}: \xmlDesc{integer}, - the number of terms in the AutoRegressive term to retain in the - regression; typically represented as $P$ in literature. - - \item \xmlNode{NoiseLag}: \xmlDesc{integer}, - the number of terms in the Moving Average term to retain in the - regression; typically represented as $Q$ in literature. + \item \xmlNode{P}: \xmlDesc{comma-separated integers}, + the number of terms in the AutoRegressive (AR) term to retain in the + regression; typically represented as $P$ or Signal Lag in literature. + Accepted as list or single value. If list, should be the same length as + number of target signals. Otherwise, the singular value is used for all + all signals. + + \item \xmlNode{Q}: \xmlDesc{comma-separated integers}, + the number of terms in the Moving Average (MA) term to retain in the + regression; typically represented as $Q$ or Noise Lag in literature. + Accepted as list or single value. If list, should be the same length as + number of target signals. Otherwise, the singular value is used for all + all signals. \end{itemize} \item \xmlNode{varma}: @@ -2314,6 +2325,60 @@ \subsubsection{SyntheticHistory} Specifies the degree polynomial to fit the data with. \end{itemize} + \item \xmlNode{autoarma}: + characterizes the signal \textit{before} using Auto-Regressive and Moving Average + coefficients to stochastically fit the training signal. AutoARMA automatically + determines the number of coefficients to use in the regression. The ARMA + representation has the following form: \begin{equation*} A\_t = \sum_{i=1}^P + \phi\_i A_{t-i} + \epsilon\_t + \sum_{j=1}^Q \theta\_j \epsilon_{t-j}, \end{equation*} + where $t$ indicates a discrete time step, $\phi$ are the signal lag (or auto-regressive) + coefficients, $P$ is the number of signal lag terms to consider, $\epsilon$ is a random noise + term, $\theta$ are the noise lag (or moving average) coefficients, and $Q$ is the number of + noise lag terms to consider. The AutoARMA algorithm determines the optimal value of $P$ + and $Q$ for the each signal. The AutoARMA algorithms are developed in RAVEN using the + \texttt{statsforecast} Python library. + The \xmlNode{autoarma} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{target}: \xmlDesc{comma-separated strings, required}, + indicates the variables for which this algorithm will be used for characterization. + \item \xmlAttr{seed}: \xmlDesc{integer, optional}, + sets a seed for the underlying random number generator, if present. + \item \xmlAttr{global}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0], optional}, + designates this algorithm to be used on full signal instead of per + segment. NOTE: because this is intended to be used when some algorithms are + applied segment-wise and others are applied globally, this is meant to be an + advanced feature and it is important to be mindful of the segments lengths. + E.g., some Fourier periods may be longer than the intended segment length, in + which case the this 'global' parameter should be set to True for better + fitting. \default{False} + \end{itemize} + + The \xmlNode{autoarma} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{P\_upper}: \xmlDesc{integer}, + upper bound for the number of terms in the AutoRegressive term to retain + in the regression; typically represented as $P$ or Signal Lag in + literature. + + \item \xmlNode{Q\_upper}: \xmlDesc{integer}, + upper bound for the number of terms in the Moving Average term to retain + in the regression; typically represented as $Q$ in Noise Lag + literature. + + \item \xmlNode{criterion}: \xmlDesc{[aic, aicc, bic]}, + information criterion used to determine optimal ARMA parameters. The + options are `aic` for Akaike Information Criterion, `aicc` for corrected AIC which + is used when number of observations is small, and `bic` for Bayesian Information + Criterion. Default is `aicc`. + + \item \xmlNode{use\_approximation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + if True, this uses the default version of the AutoARIMA algorithm within + `statsforecast` which uses heuristics to find an approximate solution in + much faster time. This previously led to different answers between Linux and + Windows, but may be a good option if the alternative is taking too long. + Default is False. + \end{itemize} + \item \xmlNode{rwd}: TimeSeriesAnalysis algorithm for sliding window snapshots to generate features The \xmlNode{rwd} node recognizes the following parameters: @@ -2649,8 +2714,8 @@ \subsubsection{SyntheticHistory} 12, 24 - 2 - 3 +

2

+ 3
... @@ -3545,28 +3610,27 @@ \subsubsection{PolyExponential} \subsubsection{DMD} - The \xmlString{DMD} ROM aimed to construct a time-dependent (or any other monotonic - variable) surrogate model based on Dynamic Mode Decomposition This surrogate is aimed to - perform a ``dimensionality reduction regression'', where, given time series (or any - monotonic-dependent variable) of data, a set of modes each of which is associated with a - fixed oscillation frequency and decay/growth rate is computed in order to represent the - data-set. In order to use this Reduced Order Model, the \xmlNode{ROM} attribute - \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ Once the ROM is - trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an - XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following - variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of - type \xmlAttr{Print}): \begin{itemize} \item \xmlNode{rankSVD}, see XML input - specifications below \item \xmlNode{energyRankSVD}, see XML input specifications below - \item \xmlNode{rankTLSQ}, see XML input specifications below \item \xmlNode{exactModes}, - see XML input specifications below \item \xmlNode{optimized}, see XML input - specifications below \item \xmlNode{features}, see XML input specifications below + The \xmlString{DynamicModeDecomposition} ROM aimed to construct a time-dependent (or any other + monotonic variable) surrogate model based on Dynamic Mode Decomposition This surrogate is + aimed to perform a ``dimensionality reduction regression'', where, given time series (or any + monotonic-dependent variable) of data, a set of modes each of which is associated with a fixed + oscillation frequency and decay/growth rate is computed in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute \xmlAttr{subType} needs + to be set equal to \xmlString{DMD}. \\ Once the ROM is trained (\textbf{Step} + \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file via an + \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported + (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type \xmlAttr{Print}): \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below \item \xmlNode{tlsq\_rank}, + see XML input specifications below \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below \item \xmlNode{forward\_backward}, + see XML input specifications below \item \xmlNode{tikhonov\_regularization}, see XML input + specifications below \item \xmlNode{features}, see XML input specifications below \item \xmlNode{timeScale}, XML node containing the array of the training time steps values \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be - used as mapping between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) - \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) - \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) - \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) - \end{itemize} + used as mapping between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item + \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) \item + \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) \item + \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) \end{itemize} The \xmlNode{DMD} node recognizes the following parameters: \begin{itemize} @@ -3776,45 +3840,138 @@ \subsubsection{DMD} either ``input'' or ``output''. \end{itemize} - \item \xmlNode{dmdType}: \xmlDesc{[dmd, hodmd]}, - the type of Dynamic Mode Decomposition to apply.Available are: - \begin{itemize} \item \textit{dmd}, for - classical DMD \item \textit{hodmd}, for - high order DMD. \end{itemize} - \default{dmd} + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} \item \xmlNode{pivotParameter}: \xmlDesc{string}, defines the pivot variable (e.g., time) that represents the independent monotonic variable \default{time} - \item \xmlNode{rankSVD}: \xmlDesc{integer}, - defines the truncation rank to be used for the SVD. + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. Available options are: \begin{itemize} \item \textit{-1}, no truncation is performed \item \textit{0}, optimal rank is internally computed - \item \textit{>1}, this rank is going to be used for the truncation + \item \textit{$>1$}, this rank is going to be used for the truncation \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space \default{None} - \item \xmlNode{energyRankSVD}: \xmlDesc{float}, - energy level ($0.0 < float < 1.0$) used to compute the rank such - as computed rank is the number of the biggest singular values needed to reach the energy - identified by \xmlNode{energyRankSVD}. This - node has always priority over \xmlNode{rankSVD} + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. \default{None} - \item \xmlNode{rankTLSQ}: \xmlDesc{integer}, + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{optimization\_restart}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $optimization\_restart == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, + this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, $int > 0$ that defines the truncation rank to be used for the total least square problem. If not inputted, no truncation is applied \default{None} - \item \xmlNode{exactModes}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + \item \xmlNode{exact}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, True if the exact modes need to be computed (eigenvalues and eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD). \default{True} - \item \xmlNode{optimized}: \xmlDesc{float}, + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). Default is + False. + \default{False} + + \item \xmlNode{tikhonov\_regularization}: \xmlDesc{float or integer}, + Tikhonov parameter for the regularization. If + `None`, no regularization is applied, if `float`, it is used as the + $`\lambda`$ tikhonov parameter. + \default{None} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, True if the amplitudes need to be computed minimizing the error between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered @@ -3829,16 +3986,15 @@ \subsubsection{DMD} ... ... - - time,totals_watts, xe135_dens - enrichment,bu - dmd - time - 0 - 5 - False - True - + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + ... ... @@ -4114,17 +4270,149 @@ \subsubsection{DMDC} either ``input'' or ``output''. \end{itemize} + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + \item \xmlNode{pivotParameter}: \xmlDesc{string}, defines the pivot variable (e.g., time) that represents the independent monotonic variable \default{time} + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, + this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{None} + + \item \xmlNode{exact}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD). + \default{True} + + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). Default is + False. + \default{False} + + \item \xmlNode{tikhonov\_regularization}: \xmlDesc{float or integer}, + Tikhonov parameter for the regularization. If + `None`, no regularization is applied, if `float`, it is used as the + $`\lambda`$ tikhonov parameter. + \default{None} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + \item \xmlNode{rankSVD}: \xmlDesc{integer}, defines the truncation rank to be used for the SVD. Available options are: \begin{itemize} \item \textit{-1}, no truncation is performed \item \textit{0}, optimal rank is internally computed - \item \textit{>1}, this rank is going to be used for the truncation + \item \textit{$>1$}, this rank is going to be used for the truncation \end{itemize} \default{None} @@ -4245,3 +4533,5224 @@ \subsubsection{DMDC} ...
\end{lstlisting} + + +\subsubsection{HODMD} + The \xmlString{HODMD} ROM aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on the High Order Dynamic Mode Decomposition This surrogate is + aimed to perform a ``dimensionality reduction regression'', where, given time series (or any + monotonic-dependent variable) of data, a set of modes each of which is associated with a fixed + oscillation frequency and decay/growth rate is computed in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute \xmlAttr{subType} needs + to be set equal to \xmlString{DMD}. \\ Once the ROM is trained (\textbf{Step} + \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file via an + \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported + (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type \xmlAttr{Print}): \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below \item \xmlNode{tlsq\_rank}, + see XML input specifications below \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below \item \xmlNode{rescale\_mode}, see + XML input specifications below \item \xmlNode{forward\_backward}, see XML input + specifications below \item \xmlNode{d}, see XML input specifications below \item + \xmlNode{sorted\_eigs}, see XML input specifications below \item + \xmlNode{reconstruction\_method}, see XML input specifications below \item + \xmlNode{svd\_rank\_extra}, see XML input specifications below \item \xmlNode{features}, see + XML input specifications below \item \xmlNode{timeScale}, XML node containing the array of + the training time steps values \item \xmlNode{dmdTimeScale}, XML node containing the array + of time scale in the DMD space (can be used as mapping between the \xmlNode{timeScale} and + \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary + and real part) \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and + real part) \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real + part) \end{itemize} + + The \xmlNode{HODMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{HODMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, + this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{None} + + \item \xmlNode{exact}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD). + \default{True} + + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). Default is + False. + \default{False} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in \url{10.1016/j.jneumeth.2015.10.010} (section 2.4) before computing its + eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular + values. + \default{None} + + \item \xmlNode{svd\_rank\_extra}: \xmlDesc{float or integer}, + the rank for the initial reduction of the input data, performed before the rearrangement + of the input data to the (pseudo) Hankel matrix format + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, + this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank\_extra}. + \default{0} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{d}: \xmlDesc{integer}, + The new order for spatial dimension of the input snapshots. + \default{1} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + + \item \xmlNode{reconstruction\_method}: \xmlDesc{[first, mean]}, + Method used to reconstruct the snapshots of the dynamical system from the multiple versions + available due to how HankelDMD is conceived. + If ``first'' (default) the first version available is selected + (i.e. the nearest to the 0-th row in the augmented matrix). If ``mean'' we compute the + element-wise mean. + \default{first} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + False + 1 + False + mean + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{BOPDMD} + The \xmlString{BOPDMD} ROM (Optimized DMD and Bagging, Optimized DMD) aimed to construct a time- + dependent (or any other monotonic variable) surrogate model based on FOptimized DMD and + Bagging, Optimized DMD. This surrogate is aimed to perform a ``dimensionality reduction + regression'', where, given time series (or any monotonic-dependent variable) of data, a set of + modes each of which is associated with a fixed oscillation frequency and decay/growth rate is + computed in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below \item \xmlNode{exact}, see XML input + specifications below \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below \item \xmlNode{d}, see + XML input specifications below \item \xmlNode{eig\_sort}, see XML input specifications below + \item \xmlNode{reconstruction\_method}, see XML input specifications below \item + \xmlNode{features}, see XML input specifications below \item \xmlNode{timeScale}, XML node + containing the array of the training time steps values \item \xmlNode{dmdTimeScale}, XML + node containing the array of time scale in the DMD space (can be used as mapping between the + \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing + the eigenvalues (imaginary and real part) \item \xmlNode{amplitudes}, XML node containing + the amplitudes (imaginary and real part) \item \xmlNode{modes}, XML node containing the + dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{BOPDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{BOPDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{compute\_A}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Flag that determines whether or not to compute the full Koopman operator A. + Default is False, do not compute the full operator. Note that the full operator + is potentially prohibitively expensive to compute. + \default{False} + + \item \xmlNode{use\_proj}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Flag that determines the type of computation to perform. If True, fit input + data projected onto the first svd\_rank POD modes or columns of proj\_basis if provided. + If False, fit the full input data. Default is True, fit projected data. + \default{True} + + \item \xmlNode{num\_trials}: \xmlDesc{integer}, + Number of BOP-DMD trials to perform. If num\_trials is a positive integer, + num\_trials BOP-DMD trials are performed. Otherwise, standard optimized dmd is performed + \default{0} + + \item \xmlNode{trial\_size}: \xmlDesc{float or integer}, + Size of the randomly selected subset of observations to use for each trial of bagged optimized + dmd (BOP-DMD). Available options are: + \begin{itemize} \item \textit{$>1$}, + trial\_size many observations will be used per trial. + \item $0.0 < trial\_size < 1.0$, $int(trial\_size * m)$ many observations will be used per + trial, where $m$ denotes the total + number of data points observed. \end{itemize} + \default{0.6} + + \item \xmlNode{eig\_sort}: \xmlDesc{[real, abs, imag, auto]}, + Method used to sort eigenvalues (and modes accordingly) when performing BOP-DMD. Available + options are: \begin{itemize} + \item \textit{real}, eigenvalues will be sorted by real part and then by imaginary part to + break ties. \item \textit{imag}, + eigenvalues will be sorted by imaginary part and then by real part to break ties. + \item \textit{abs}, eigenvalues will be sorted by magnitude. + \item \textit{auto}, one of the previously-mentioned sorting methods is chosen depending on + eigenvalue variance. \end{itemize} + \default{auto} + + \item \xmlNode{eig\_constraints}: \xmlDesc{[stable, imag, conjugate\_pairs, None]}, + Set containing desired DMD operator eigenvalue constraints.. Available options are: + \begin{itemize} \item \textit{stable}, + constrains eigenvalues to the left half of the complex plane. + \item \textit{imag}, constrains eigenvalues to the imaginary axis. + \item \textit{conjugate\_pairs}, enforces that eigenvalues are always present with their + complex conjugate. \end{itemize} + \default{None} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + False + True + 0 + 0.6 + auto + stable + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{CDMD} + The \xmlString{CDMD} ROM (Compressed Dynamic Mode Decomposition) aimed to construct a time- + dependent (or any other monotonic variable) surrogate model based on Compressed Dynamic Mode + Decomposition This surrogate is aimed to perform a ``dimensionality reduction regression'', + where, given time series (or any monotonic-dependent variable) of data, a set of modes each of + which is associated with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{compression\_matrix}, see XML input specifications below \item \xmlNode{opt}, + see XML input specifications below \item \xmlNode{rescale\_mode}, see XML input + specifications below \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below \item + \xmlNode{tikhonov\_regularization}, see XML input specifications below \item + \xmlNode{features}, see XML input specifications below \item \xmlNode{timeScale}, XML node + containing the array of the training time steps values \item \xmlNode{dmdTimeScale}, XML + node containing the array of time scale in the DMD space (can be used as mapping between the + \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing + the eigenvalues (imaginary and real part) \item \xmlNode{amplitudes}, XML node containing + the amplitudes (imaginary and real part) \item \xmlNode{modes}, XML node containing the + dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{CDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{CDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{energyRankSVD}. This + node has always priority over \xmlNode{rankSVD} + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{None} + + \item \xmlNode{compression\_matrix}: \xmlDesc{[linear, sparse, uniform, sample]}, + The matrix method that pre-multiplies the snapshots matrix in order to compress it. Available + are: \begin{itemize} + \item \textit{linear}, linearized matrix + \item \textit{sparse}, sparse matrix \item + \textit{uniform}, uniform \item + \textit{sample}, sampled matrix. + \end{itemize} + \default{uniform} + + \item \xmlNode{opt}: \xmlDesc{float}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). Default is + False. + \default{False} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its + eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular + values. + \default{None} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + + \item \xmlNode{tikhonov\_regularization}: \xmlDesc{float}, + Tikhonov parameter for the regularization. If + `None`, no regularization is applied, if `float`, it is used as the + $`\lambda`$ tikhonov parameter. + \default{None} + + \item \xmlNode{seed}: \xmlDesc{integer}, + Seed of the random number generator + \default{None} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + sample + 20201986 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{EDMD} + The \xmlString{EDMD} ROM (Kernelized Extended Dynamic Mode Decomposition) aimed to construct a + time-dependent (or any other monotonic variable) surrogate model based on Compressed Dynamic + Mode Decomposition This surrogate is aimed to perform a ``dimensionality reduction + regression'', where, given time series (or any monotonic-dependent variable) of data, a set of + modes each of which is associated with a fixed oscillation frequency and decay/growth rate is + computed in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below \item \xmlNode{kernel\_metric}, see + XML input specifications below \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be + used as mapping between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item + \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) \item + \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) \item + \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{EDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{EDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, + this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{-1} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{0} + + \item \xmlNode{kernel\_metric}: \xmlDesc{[additive\_chi2, chi2, linear, poly, rbf, laplacian, sigmoid, cosine]}, + The kernel function to apply (for more details, see ``sklearn.metrics.pairwise\_kernels''). + Available are: \begin{itemize} + \item \textit{additive\_chi2}, additive\_chi2 kernel + \item \textit{chi2}, chi2 kernel \item + \textit{linear}, linear kernel \item + \textit{poly}, polynomial kernel \item + \textit{rbf}, radial basis function \item + \textit{laplacian}, laplacian kernel \item + \textit{sigmoid}, sigmoid kernel \item + \textit{cosine}, cosine kernel \end{itemize} + \default{linear} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 3 + 7 + linear + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{FbDMD} + The \xmlString{FbDMD} ROM (Forward/Backward Dynamic Mode Decomposition) aimed to construct a time- + dependent (or any other monotonic variable) surrogate model based on Forward-Backward Dynamic + Mode Decomposition This surrogate is aimed to perform a ``dimensionality reduction + regression'', where, given time series (or any monotonic-dependent variable) of data, a set of + modes each of which is associated with a fixed oscillation frequency and decay/growth rate is + computed in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below \item \xmlNode{exact}, see XML input + specifications below \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below \item \xmlNode{features}, + see XML input specifications below \item \xmlNode{timeScale}, XML node containing the array + of the training time steps values \item \xmlNode{dmdTimeScale}, XML node containing the + array of time scale in the DMD space (can be used as mapping between the + \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing + the eigenvalues (imaginary and real part) \item \xmlNode{amplitudes}, XML node containing + the amplitudes (imaginary and real part) \item \xmlNode{modes}, XML node containing the + dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{FbDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{FbDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{0} + + \item \xmlNode{exact}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD). + \default{False} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its + eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular + values. + \default{None} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + True + True + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{HankelDMD} + The \xmlString{FbDMD} ROM (Forward/Backward Dynamic Mode Decomposition) aimed to construct a time- + dependent (or any other monotonic variable) surrogate model based on Forward-Backward Dynamic + Mode Decomposition This surrogate is aimed to perform a ``dimensionality reduction + regression'', where, given time series (or any monotonic-dependent variable) of data, a set of + modes each of which is associated with a fixed oscillation frequency and decay/growth rate is + computed in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below \item \xmlNode{exact}, see XML input + specifications below \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below \item \xmlNode{d}, see + XML input specifications below \item \xmlNode{sorted\_eigs}, see XML input specifications + below \item \xmlNode{reconstruction\_method}, see XML input specifications below \item + \xmlNode{features}, see XML input specifications below \item \xmlNode{timeScale}, XML node + containing the array of the training time steps values \item \xmlNode{dmdTimeScale}, XML + node containing the array of time scale in the DMD space (can be used as mapping between the + \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing + the eigenvalues (imaginary and real part) \item \xmlNode{amplitudes}, XML node containing + the amplitudes (imaginary and real part) \item \xmlNode{modes}, XML node containing the + dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{HankelDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{HankelDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{0} + + \item \xmlNode{exact}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD). + \default{False} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its + eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular + values. + \default{None} + + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). + \default{False} + + \item \xmlNode{d}: \xmlDesc{integer}, + The new order for spatial dimension of the input snapshots. + \default{1} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + + \item \xmlNode{reconstruction\_method}: \xmlDesc{[first, mean]}, + Method used to reconstruct the snapshots of the dynamical system from the multiple versions + available due to how HankelDMD is conceived. + If ``first'' (default) the first version available is selected + (i.e. the nearest to the 0-th row in the augmented matrix). If ``mean'' we compute the + element-wise mean. + \default{first} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + False + 1 + False + first + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{HAVOK} + The \xmlString{HAVOK} ROM (Hankel Alternative View of Koopman - HAVOK) aimed to construct a time- + dependent (or any other monotonic variable) surrogate model based on Hankel Alternative View + of Koopman model This surrogate is aimed to perform a ``dimensionality reduction regression'', + where, given time series (or any monotonic-dependent variable) of data, a set of modes each of + which is associated with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{delays}, see XML input specifications below \item + \xmlNode{lag}, see XML input specifications below \item \xmlNode{num\_chaos}, see XML input + specifications below \item \xmlNode{structured}, see XML input specifications below + \item \xmlNode{lstsq}, see XML input specifications below \item \xmlNode{features}, see XML + input specifications below \item \xmlNode{timeScale}, XML node containing the array of the + training time steps values \item \xmlNode{dmdTimeScale}, XML node containing the array of + time scale in the DMD space (can be used as mapping between the \xmlNode{timeScale} and + \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary + and real part) \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and + real part) \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real + part) \end{itemize} + + The \xmlNode{HAVOK} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{HAVOK} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{delays}: \xmlDesc{integer}, + The number of consecutive time-shifted copies of the data to use when building Hankel + matrices. Note that if examining an + n-dimensional data set, this means that the resulting Hankel matrix + will contain $n * delays$ rows + \default{10} + + \item \xmlNode{lag}: \xmlDesc{integer}, + The number of time steps between each time-shifted copy of data in the Hankel matrix. + This means that each row of the Hankel matrix will be separated by a time-step of $dt * lag$. + \default{1} + + \item \xmlNode{num\_chaos}: \xmlDesc{integer}, + The number of forcing terms to use in the HAVOK model. + \default{1} + + \item \xmlNode{structured}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether to perform standard HAVOK or structured HAVOK (sHAVOK). + If True, sHAVOK is performed, otherwise HAVOK is performed. + \default{False} + + \item \xmlNode{lstsq}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Method used for computing the HAVOK operator. + If True, least-squares is used, otherwise the pseudo- inverse is used. + \default{True} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 3 + 1 + 1 + False + True + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{PiDMD} + The \xmlString{PiDMD} ROM aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on the Physics Informed Dynamic Mode Decomposition This + surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed in order to represent the + data-set. In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ Once the ROM is trained + (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be + exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} \item \xmlNode{svd\_rank}, see XML input specifications below \item + \xmlNode{tlsq\_rank}, see XML input specifications below \item \xmlNode{opt}, see XML input + specifications below \item \xmlNode{manifold}, see XML input specifications below + \item \xmlNode{compute\_A}, see XML input specifications below \item \xmlNode{features}, see + XML input specifications below \item \xmlNode{timeScale}, XML node containing the array of + the training time steps values \item \xmlNode{dmdTimeScale}, XML node containing the array + of time scale in the DMD space (can be used as mapping between the \xmlNode{timeScale} and + \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary + and real part) \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and + real part) \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real + part) \end{itemize} + + The \xmlNode{PiDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{PiDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, + this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{None} + + \item \xmlNode{opt}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{manifold}: \xmlDesc{[unitary, uppertriangular, lowertriangular, diagonal, symmetric, skewsymmetric, toeplitz, hankel, circulant, circulant\_unitary, circulant\_symmetric, circulant\_skewsymmetric, symmetric\_tridiagonal, BC, BCTB, BCCB, BCCBunitary, BCCBsymmetric, BCCBskewsymmetric]}, + the matrix manifold to restrict the full operator A to. Available options are: + \begin{itemize} \item \textit{unitary}, + \item \textit{uppertriangular}, \item + \textit{lowertriangular}, \item + \textit{diagonal}, \item \textit{symmetric}, + \item \textit{skewsymmetric}, \item + \textit{toeplitz}, \item \textit{hankel}, + \item \textit{circulant}, \item + \textit{circulant\_unitary}, \item + \textit{circulant\_symmetric}, \item + \textit{circulant\_skewsymmetric}, \item + \textit{symmetric\_tridiagonal}, \item + \textit{BC} (block circulant), \item + \textit{BCTB} (BC with tridiagonal blocks), + \item \textit{BCCB} (BC with circulant blocks), + \item \textit{BCCBunitary} (BCCB and unitary), + \item \textit{BCCBsymmetric} (BCCB and symmetric), + \item \textit{BCCBskewsymmetric} (BCCB and skewsymmetric). + \end{itemize} + \default{None} + + \item \xmlNode{compute\_A}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Flag that determines whether or not to compute the full Koopman operator A + \default{False} + + \item \xmlNode{manifold\_opt}: \xmlDesc{comma-separated strings}, + Option used to specify certain manifolds: + \begin{itemize} \item If manifold $==$ + \textit{diagonal}, \textit{manifold\_opt} may be used to specify the width of the diagonal of + A: \begin{itemize} + \item If manifold\_opt is an integer $k$, A is banded, with a lower and upper bandwidth of + $k-1$. \item If manifold\_opt is a tuple + containing two integers $k1$ and $k2$, A is banded with + a lower bandwidth of $k1-1$ and an upper bandwidth of $k2-1$ + . \end{itemize} \item If manifold $==$ + \textit{BC},\textit{BCTB},\textit{BCCB},\textit{BCCBunitary},\textit{BCCBsymmetric}, + \textit{BCCBskewsymmetric}, \textit{manifold\_opt} must be a 2D tuple that specifies the + desired dimensions of the blocks of A. + \end{itemize} Note that all other manifolds + do not use \textit{manifold\_opt}. + \default{None} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + False + BCCB + 1,9 + True + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{RDMD} + The \xmlString{RDMD} ROM (Randomized Dynamic Mode Decomposition) aimed to construct a time- + dependent (or any other monotonic variable) surrogate model based on Randomized Dynamic Mode + Decomposition This surrogate is aimed to perform a ``dimensionality reduction regression'', + where, given time series (or any monotonic-dependent variable) of data, a set of modes each of + which is associated with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. In order to use this Reduced Order Model, the + \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be + exported into an XML file via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following + variable/parameters can be exported (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type + \xmlAttr{Print}): \begin{itemize} \item \xmlNode{svd\_rank}, see XML input + specifications below \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{compression\_matrix}, see XML input specifications below \item \xmlNode{opt}, + see XML input specifications below \item \xmlNode{rescale\_mode}, see XML input + specifications below \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below \item + \xmlNode{tikhonov\_regularization}, see XML input specifications below \item \xmlNode{seed}, + see XML input specifications below \item \xmlNode{oversampling}, see XML input + specifications below \item \xmlNode{power\_iters}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below \item \xmlNode{timeScale}, XML + node containing the array of the training time steps values \item \xmlNode{dmdTimeScale}, + XML node containing the array of time scale in the DMD space (can be used as mapping between + the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node + containing the eigenvalues (imaginary and real part) \item \xmlNode{amplitudes}, XML node + containing the amplitudes (imaginary and real part) \item \xmlNode{modes}, XML node + containing the dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{RDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{RDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{energyRankSVD}. This + node has always priority over \xmlNode{rankSVD} + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{None} + + \item \xmlNode{opt}: \xmlDesc{float}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). Default is + False. + \default{False} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its + eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular + values. + \default{None} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + + \item \xmlNode{tikhonov\_regularization}: \xmlDesc{float}, + Tikhonov parameter for the regularization. + If ``None'', no regularization is applied, if ``float'', it is used as the + ``$\lambda''$ tikhonov parameter. + \default{None} + + \item \xmlNode{seed}: \xmlDesc{integer}, + Seed used to initialize the random generator when computing random test matrices. + \default{None} + + \item \xmlNode{oversampling}: \xmlDesc{integer}, + Number of additional samples (beyond the target rank) to use when computing the + random test matrix. Note that values in the range $[5, 10]$ tend to be sufficient. + \default{10} + + \item \xmlNode{power\_iters}: \xmlDesc{integer}, + Number of power iterations to perform when executing the Randomized QB Decomposition. + Note that as many as 1 to 2 power iterations often lead to considerable improvements. + \default{2} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + 20021986 + 5 + 2 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{SpDMD} + The \xmlString{SpDMD} ROM (Sparsity-Promoting Dynamic Mode Decomposition) aimed to construct a + time-dependent (or any other monotonic variable) surrogate model based on Sparsity-Promoting + Dynamic Mode Decomposition, which promotes solutions having an high number of amplitudes set + to zero (i.e. sparse solutions). Reference: 10.1063/1.4863670. This surrogate is aimed to + perform a ``dimensionality reduction regression'', where, given time series (or any monotonic- + dependent variable) of data, a set of modes each of which is associated with a fixed + oscillation frequency and decay/growth rate is computed in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute \xmlAttr{subType} needs + to be set equal to \xmlString{DMD}. \\ Once the ROM is trained (\textbf{Step} + \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file via an + \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported + (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type \xmlAttr{Print}): \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below \item \xmlNode{tlsq\_rank}, + see XML input specifications below \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below \item \xmlNode{rescale\_mode}, see + XML input specifications below \item \xmlNode{forward\_backward}, see XML input + specifications below \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{abs\_tolerance}, see XML input specifications below \item + \xmlNode{rel\_tolerance}, see XML input specifications below \item + \xmlNode{max\_iterations}, see XML input specifications below \item \xmlNode{rho}, see XML + input specifications below \item \xmlNode{gamma}, see XML input specifications below + \item \xmlNode{verbose}, see XML input specifications below \item \xmlNode{enforce\_zero}, + see XML input specifications below \item \xmlNode{release\_memory}, see XML input + specifications below \item \xmlNode{zero\_absolute\_tolerance}, see XML input specifications + below \item \xmlNode{features}, see XML input specifications below \item + \xmlNode{timeScale}, XML node containing the array of the training time steps values \item + \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used + as mapping between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item + \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) \item + \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) \item + \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{SpDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{SpDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{energyRankSVD}. This + node has always priority over \xmlNode{rankSVD} + \default{0} + + \item \xmlNode{tlsq\_rank}: \xmlDesc{integer}, + $int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied + \default{None} + + \item \xmlNode{opt}: \xmlDesc{float}, + True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be + considered + \default{False} + + \item \xmlNode{forward\_backward}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True, the low-rank operator is computed like in fbDMD (reference: + https://arxiv.org/abs/1507.02264). Default is + False. + \default{False} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its + eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular + values. + \default{None} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + + \item \xmlNode{abs\_tolerance}: \xmlDesc{float}, + Controls the convergence of ADMM. Absolute tolerance from iteration $k$ and $k-1$. + \default{1e-06} + + \item \xmlNode{rel\_tolerance}: \xmlDesc{float}, + Controls the convergence of ADMM. Relative tolerance from iteration $k$ and $k-1$. + \default{0.0001} + + \item \xmlNode{max\_iterations}: \xmlDesc{integer}, + The maximum number of iterations performed by ADMM, after that the algorithm is stopped. + \default{10000} + + \item \xmlNode{rho}: \xmlDesc{float}, + Controls the convergence of ADMM. For a reference on the optimal value for rho see + 10.1109/TAC.2014.2354892 or 10.3182/20120914-2-US-4030.00038. + \default{1} + + \item \xmlNode{gamma}: \xmlDesc{float}, + Controls the level of “promotion” assigned to sparse solution. Increasing gamma will + result in an higher number of zero-amplitudes. + \default{10} + + \item \xmlNode{verbose}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If False, the information provided by SpDMD (like the number of iterations performed + by ADMM) are not shown. + \default{False} + + \item \xmlNode{enforce\_zero}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True the DMD amplitudes which should be set to zero + according to the solution of ADMM are manually set to 0 (since we + solve a sparse linear system to find the optimal vector of DMD amplitudes + very small terms may survive in some cases). + \default{True} + + \item \xmlNode{release\_memory}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If True the intermediate matrices computed by the algorithm are deleted + after the termination of a call to train. + \default{True} + + \item \xmlNode{zero\_absolute\_tolerance}: \xmlDesc{float}, + Zero absolute tolerance. + \default{1e-12} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{SubspaceDMD} + The \xmlString{SubspaceDMD} ROM (Subspace DMD) aimed to construct a time-dependent (or any other + monotonic variable) surrogate model based on Subspace DMD This surrogate is aimed to + perform a ``dimensionality reduction regression'', where, given time series (or any monotonic- + dependent variable) of data, a set of modes each of which is associated with a fixed + oscillation frequency and decay/growth rate is computed in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute \xmlAttr{subType} needs + to be set equal to \xmlString{DMD}. \\ Once the ROM is trained (\textbf{Step} + \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file via an + \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported + (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type \xmlAttr{Print}): \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below \item \xmlNode{rescale\_mode}, + see XML input specifications below \item \xmlNode{sorted\_eigs}, see XML input + specifications below \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be + used as mapping between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item + \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) \item + \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) \item + \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{SubspaceDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{SubspaceDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{integer}, + defines the truncation rank to be used for the SVD. + the rank for the truncation; if -1 all the columns of $U\_q$ are used, + if svd\_rank is an integer grater than zero it is used as the number + of columns retained from U\_q. $svd\_rank=0$ or float values are not supported + \default{-1} + + \item \xmlNode{rescale\_mode}: \xmlDesc{[auto, None]}, + Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before + computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic + rescaling using singular values. + \default{None} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, False]}, + Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted\_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted\_eigs=``real''. + \default{False} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + -1 + None + False + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + +\subsubsection{VarProDMD} + The \xmlString{VarProDMD} ROM (Variable Projection for DMD) aimed to construct a time-dependent + (or any other monotonic variable) surrogate model based on Variable Projection for DMD + (https://epubs.siam.org/doi/abs/10.1137/M1124176). This surrogate is aimed to perform a + ``dimensionality reduction regression'', where, given time series (or any monotonic-dependent + variable) of data, a set of modes each of which is associated with a fixed oscillation + frequency and decay/growth rate is computed in order to represent the data-set. In order + to use this Reduced Order Model, the \xmlNode{ROM} attribute \xmlAttr{subType} needs to be set + equal to \xmlString{DMD}. \\ Once the ROM is trained (\textbf{Step} + \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file via an + \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported + (i.e. \xmlNode{what} node in \xmlNode{OutStream} of type \xmlAttr{Print}): \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below \item \xmlNode{exact}, see XML + input specifications below \item \xmlNode{compression}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below \item \xmlNode{features}, + see XML input specifications below \item \xmlNode{timeScale}, XML node containing the array + of the training time steps values \item \xmlNode{dmdTimeScale}, XML node containing the + array of time scale in the DMD space (can be used as mapping between the + \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) \item \xmlNode{eigs}, XML node containing + the eigenvalues (imaginary and real part) \item \xmlNode{amplitudes}, XML node containing + the amplitudes (imaginary and real part) \item \xmlNode{modes}, XML node containing the + dynamic modes (imaginary and real part) \end{itemize} + + The \xmlNode{VarProDMD} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \item \xmlAttr{subType}: \xmlDesc{string, required}, + specify the type of ROM that will be used + \end{itemize} + + The \xmlNode{VarProDMD} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{Features}: \xmlDesc{comma-separated strings}, + specifies the names of the features of this ROM. \nb These parameters are going to be + requested for the training of this object (see Section~\ref{subsec:stepRomTrainer}) + + \item \xmlNode{Target}: \xmlDesc{comma-separated strings}, + contains a comma separated list of the targets of this ROM. These parameters are the + Figures of Merit (FOMs) this ROM is supposed to predict. \nb These parameters are + going to be requested for the training of this object (see Section + \ref{subsec:stepRomTrainer}). + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + If a time-dependent ROM is requested, please specifies the pivot variable (e.g. time, + etc) used in the input HistorySet. + \default{time} + + \item \xmlNode{featureSelection}: + Apply feature selection algorithm + + The \xmlNode{featureSelection} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{RFE}: + The \xmlString{RFE} (Recursive Feature Elimination) is a feature selection algorithm. + Feature selection refers to techniques that select a subset of the most relevant features + for a model (ROM). Fewer features can allow ROMs to run more efficiently (less + space or time complexity) and be more effective. Indeed, some ROMs (machine + learning algorithms) can be misled by irrelevant input features, resulting in worse + predictive performance. RFE is a wrapper-type feature selection algorithm. This + means that a different ROM is given and used in the core of the method, is + wrapped by RFE, and used to help select features. \\RFE works by searching for a + subset of features by starting with all features in the training dataset and successfully + removing features until the desired number remains. This is achieved by + fitting the given ROM used in the core of the model, ranking features by importance, + discarding the least important features, and re-fitting the model. This process is + repeated until a specified number of features remains. When the full model + is created, a measure of variable importance is computed that ranks the predictors from + most important to least. At each stage of the search, the least important + predictors are iteratively eliminated prior to rebuilding the model. Features are + scored either using the ROM model (if the model provides a mean to compute feature + importances) or by using a statistical method. \\In RAVEN the + \xmlString{RFE} class refers to an augmentation of the basic algorithm, since it allows, + optionally, to perform the search on multiple groups of targets (separately) and + then combine the results of the search in a single set. In addition, when the RFE + search is concluded, the user can request to identify the set of features that + bring to a minimization of the score (i.e. maximimization of the accuracy). In + addition, using the ``applyClusteringFiltering'' option, the algorithm can, using an + hierarchal clustering algorithm, identify highly correlated features to speed up + the subsequential search. + The \xmlNode{RFE} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{RFE} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{nFeaturesToSelect}: \xmlDesc{integer}, + Exact Number of features to select. If not inputted, ``nFeaturesToSelect'' will be set + to $1/2$ of the features in the training dataset. + \default{None} + + \item \xmlNode{maxNumberFeatures}: \xmlDesc{integer}, + Maximum Number of features to select, the algorithm will automatically determine the + feature list to minimize a total score. + \default{None} + + \item \xmlNode{onlyOutputScore}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + If maxNumberFeatures is on, only output score should beconsidered? Or, in case of + particular models (e.g. DMDC), state variable space score should be considered as + well. + \default{False} + + \item \xmlNode{applyClusteringFiltering}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Applying clustering correlation before RFE search? If true, an hierarchal clustering + is applied on the feature space aimed to remove features that are correlated + before the actual RFE search is performed. This approach can stabilize and + accelerate the process in case of large feature spaces (e.g > 500 features). + \default{False} + + \item \xmlNode{applyCrossCorrelation}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + In case of subgroupping, should a cross correleation analysis should be performed + cross sub-groups? If it is activated, a cross correleation analysis is used to + additionally filter the features selected for each sub-groupping search. + \default{False} + + \item \xmlNode{step}: \xmlDesc{float}, + If greater than or equal to 1, then step corresponds to the (integer) number + of features to remove at each iteration. If within (0.0, 1.0), then step + corresponds to the percentage (rounded down) of features to remove at each + iteration. + \default{1} + + \item \xmlNode{subGroup}: \xmlDesc{comma-separated strings, integers, and floats}, + Subgroup of output variables on which to perform the search. Multiple nodes of this + type can be inputted. The RFE search will be then performed in each ``subgroup'' + separately and then the the union of the different feature sets are used for the final + ROM. + \end{itemize} + + \item \xmlNode{VarianceThreshold}: + The \xmlString{VarianceThreshold} is a feature selector that removes all low-variance + features. This feature selection algorithm looks only at the features and not the + desired outputs. The variance threshold can be set by the user. + The \xmlNode{VarianceThreshold} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{name}: \xmlDesc{string, required}, + User-defined name to designate this entity in the RAVEN input file. + \item \xmlAttr{verbosity}: \xmlDesc{[silent, quiet, all, debug], optional}, + Desired verbosity of messages coming from this entity + \end{itemize} + + The \xmlNode{VarianceThreshold} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the search. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature (this is temporary till DataSet training is + implemented) + \default{feature} + + \item \xmlNode{threshold}: \xmlDesc{float}, + Features with a training-set variance lower than this threshold will + be removed. The default is to keep all features with non-zero + variance, i.e. remove the features that have the same value in all + samples. + \default{0.0} + \end{itemize} + \end{itemize} + + \item \xmlNode{featureSpaceTransformation}: + Use dimensionality reduction technique to perform a trasformation of the training dataset + into an uncorrelated one. The dimensionality of the problem will not be reduced but + the data will be transformed in the transformed space. E.g if the number of features + are 5, the method projects such features into a new uncorrelated space (still 5-dimensional). + In case of time-dependent ROMs, all the samples are concatenated in a global 2D matrix + (n\_samples*n\_timesteps,n\_features) before applying the transformation and then reconstructed + back into the original shape (before fitting the model). + + The \xmlNode{featureSpaceTransformation} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{transformationMethod}: \xmlDesc{[PCA, KernelLinearPCA, KernelPolyPCA, KernelRbfPCA, KernelSigmoidPCA, KernelCosinePCA, ICA]}, + Transformation method to use. Eight options (5 Kernel PCAs) are available: + \begin{itemize} \item \textit{PCA}, Principal Component Analysis; + \item \textit{KernelLinearPCA}, Kernel (Linear) Principal component analysis; + \item \textit{KernelPolyPCA}, Kernel (Poly) Principal component analysis; + \item \textit{KernelRbfPCA}, Kernel(Rbf) Principal component analysis; + \item \textit{KernelSigmoidPCA}, Kernel (Sigmoid) Principal component analysis; + \item \textit{KernelCosinePCA}, Kernel (Cosine) Principal component analysis; + \item \textit{ICA}, Independent component analysis; \end{itemize} + \default{PCA} + + \item \xmlNode{parametersToInclude}: \xmlDesc{comma-separated strings}, + List of IDs of features/variables to include in the transformation process. + \default{None} + + \item \xmlNode{whichSpace}: \xmlDesc{[Feature, feature, Target, target]}, + Which space to search? Target or Feature? + \default{Feature} + \end{itemize} + + \item \xmlNode{CV}: \xmlDesc{string}, + The text portion of this node needs to contain the name of the \xmlNode{PostProcessor} with + \xmlAttr{subType} ``CrossValidation``. + The \xmlNode{CV} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{class}: \xmlDesc{string, optional}, + should be set to \xmlString{Model} + \item \xmlAttr{type}: \xmlDesc{string, optional}, + should be set to \xmlString{PostProcessor} + \end{itemize} + + \item \xmlNode{alias}: \xmlDesc{string}, + specifies alias for any variable of interest in the input or output space. These + aliases can be used anywhere in the RAVEN input to refer to the variables. In the body + of this node the user specifies the name of the variable that the model is going to use + (during its execution). + The \xmlNode{alias} node recognizes the following parameters: + \begin{itemize} + \item \xmlAttr{variable}: \xmlDesc{string, required}, + define the actual alias, usable throughout the RAVEN input + \item \xmlAttr{type}: \xmlDesc{[input, output], required}, + either ``input'' or ``output''. + \end{itemize} + + \item \xmlNode{light}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources. + \default{False} + + \item \xmlNode{pivotParameter}: \xmlDesc{string}, + defines the pivot variable (e.g., time) that represents the + independent monotonic variable + \default{time} + + \item \xmlNode{reductionMethod}: \xmlDesc{[svd, correlation\_matrix, randomized\_svd]}, + the type of method used for the dimensionality reduction.Available are: + \begin{itemize} \item \textit{svd}, single + value decomposition \item \textit{svd}, + randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize} + \default{svd} + + \item \xmlNode{reductionRank}: \xmlDesc{integer}, + defines the truncation rank to be used for the reduction method. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + \default{0} + + \item \xmlNode{approximationMethod}: \xmlDesc{[RBF, GPR]}, + the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} \item \textit{RBF}, + Radial-basis functions \item \textit{GPR}, + Gaussian Process Regression \end{itemize} + \default{RBF} + + \item \xmlNode{approximationSettings}: \xmlDesc{[RBF, GPR]}, + the settings available depending on the different type of method used for the interpolation of + the parameter space + \default{None} + + The \xmlNode{approximationSettings} node recognizes the following subnodes: + \begin{itemize} + \item \xmlNode{kernel}: \xmlDesc{[cubic, quintic, linear, gaussian, inverse, multiquadric, thin\_plate\_spline]}, + RBF kernel. Available options are: + \begin{itemize} \item + \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize} + \default{multiquadric} + + \item \xmlNode{smooth}: \xmlDesc{float}, + RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in + this case. + \default{0.0} + + \item \xmlNode{neighbors}: \xmlDesc{integer}, + RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default. + \default{None} + + \item \xmlNode{epsilon}: \xmlDesc{float}, + RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin\_plate\_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified. + \default{1.0} + + \item \xmlNode{degree}: \xmlDesc{integer}, + RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree. + \default{None} + + \item \xmlNode{n\_restarts\_optimizer}: \xmlDesc{integer}, + GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the + optimizer is performed from the kernel’s + initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is + performed. + \default{0} + + \item \xmlNode{normalize\_y}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + GPR normalization. Whether or not to normalize the target values y by removing the mean + and scaling to unit-variance. This is + recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions + are reported. + \default{True} + \end{itemize} + + \item \xmlNode{svd\_rank}: \xmlDesc{float or integer}, + defines the truncation rank to be used for the SVD. + Available options are: \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} If $0.0 < svd\_rank < 1.0$, this + parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy + identified by \xmlNode{svd\_rank}. + \default{0} + + \item \xmlNode{exact}: \xmlDesc{[True, Yes, 1, False, No, 0, t, y, 1, f, n, 0]}, + True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD). + \default{False} + + \item \xmlNode{compression}: \xmlDesc{float}, + If libary compression $c = 0$, all samples are used. If $0 < c < 1$, the best fitting + $\lfloor \left(1 - c\right)m\rfloor$ samples are selected + \default{False} + + \item \xmlNode{sorted\_eigs}: \xmlDesc{[real, abs, True, False, imag]}, + Sort eigenvalues (and modes/dynamics accordingly) method. Available options are: + \begin{itemize} \item \textit{True}, the + variance of the absolute values of the complex eigenvalues + $\left(\sqrt{\omega\_i \cdot \bar{\omega}\_i}\right)$, the variance absolute values + of the real parts $\left|\Re\{{\omega\_i}\}\right|$ and the variance of the absolute + values of the imaginary parts $\left|\Im\{{\omega\_i}\}\right|$ is computed. The + eigenvalues are then sorted according to the highest variance (from highest to lowest). + \item \textit{False}, no sorting is performed + \item \textit{real}, the eigenvalues are sorted w.r.t. the absolute values of the real + parts of the eigenvalues (from highest to lowest). + \item \textit{imag}, the eigenvalues are sorted w.r.t. the absolute values of the imaginary + parts of the eigenvalues (from highest to lowest). + \item \textit{abs}, the eigenvalues are sorted w.r.t. the magnitude of the eigenvalues + $\left(\sqrt{\omega\_i \cdot \bar{\omega}\_i}\right)$ (from highest to lowest) + \end{itemize} + \default{False} + \end{itemize} + +\hspace{24pt} +Example: +\textbf{Example:} +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + + ... + + ... + +\end{lstlisting} + +Example to export the coefficients of trained DMD ROM: +\begin{lstlisting}[style=XML,morekeywords={name,subType}] + + ... + + ... + + xml + DMD + + + + xml + DMD + eigs,amplitudes,modes + + ... + + ... + +\end{lstlisting} + + diff --git a/ravenframework/SupervisedLearning/DMD/BOPDMD.py b/ravenframework/SupervisedLearning/DMD/BOPDMD.py new file mode 100644 index 0000000000..118c8c57eb --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/BOPDMD.py @@ -0,0 +1,187 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Optimized DMD and Bagging, Optimized DMD + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import utils +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class BOPDMD(DMDBase): + """ + Optimized DMD and Bagging, Optimized DMD (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + # local model + self.fitArguments = {'t': 1} + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(BOPDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{BOPDMD} ROM (Optimized DMD and Bagging, Optimized DMD) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on FOptimized DMD and Bagging, Optimized DMD. + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{d}, see XML input specifications below + \item \xmlNode{eig\_sort}, see XML input specifications below + \item \xmlNode{reconstruction\_method}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("compute_A", contentType=InputTypes.BoolType, + descr=r"""Flag that determines whether or not to compute the full Koopman operator A. + Default is False, do not compute the full operator. Note that the full operator + is potentially prohibitively expensive to compute.""", default=False)) + specs.addSub(InputData.parameterInputFactory("use_proj", contentType=InputTypes.BoolType, + descr=r"""Flag that determines the type of computation to perform. If True, fit input + data projected onto the first svd_rank POD modes or columns of proj_basis if provided. + If False, fit the full input data. Default is True, fit projected data.""", default=True)) + + specs.addSub(InputData.parameterInputFactory("num_trials", contentType=InputTypes.IntegerType, + descr=r"""Number of BOP-DMD trials to perform. If num_trials is a positive integer, + num\_trials BOP-DMD trials are performed. Otherwise, standard optimized dmd is performed""", default=0)) + specs.addSub(InputData.parameterInputFactory("trial_size", contentType=InputTypes.FloatOrIntType, + descr=r"""Size of the randomly selected subset of observations to use for each trial of bagged optimized dmd (BOP-DMD). + Available options are: + \begin{itemize} + \item \textit{$>1$}, trial\_size many observations will be used per trial. + \item $0.0 < trial\_size < 1.0$, $int(trial\_size * m)$ many observations will be used per trial, + where $m$ denotes the total number of data points observed. + \end{itemize} + """, default=0.6)) + specs.addSub(InputData.parameterInputFactory("eig_sort", contentType=InputTypes.makeEnumType("eig_sort", "SortedType", + ["real", "abs", "imag", "auto"]), + descr=r"""Method used to sort eigenvalues (and modes accordingly) when performing BOP-DMD. Available options are: + \begin{itemize} + \item \textit{real}, eigenvalues will be sorted by real part and then by imaginary part to break ties. + \item \textit{imag}, eigenvalues will be sorted by imaginary part and then by real part to break ties. + \item \textit{abs}, eigenvalues will be sorted by magnitude. + \item \textit{auto}, one of the previously-mentioned sorting methods is chosen depending on eigenvalue variance. + \end{itemize} + """, default="auto")) + specs.addSub(InputData.parameterInputFactory("eig_constraints", contentType=InputTypes.makeEnumType("eig_constraints", "EigenConstraintType", + ["stable", "imag", "conjugate_pairs", "None"]), + descr=r"""Set containing desired DMD operator eigenvalue constraints.. Available options are: + \begin{itemize} + \item \textit{stable}, constrains eigenvalues to the left half of the complex plane. + \item \textit{imag}, constrains eigenvalues to the imaginary axis. + \item \textit{conjugate_pairs}, enforces that eigenvalues are always present with their complex conjugate. + \end{itemize} + """, default=None)) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import BOPDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'compute_A', 'use_proj', 'num_trials', 'trial_size', + 'eig_sort', 'eig_constraints']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # compute full A matrix + self.dmdParams['compute_A'] = settings.get('compute_A') + # Type of projection to perform + self.dmdParams['use_proj'] = settings.get('use_proj') + # Number of trials + self.dmdParams['num_trials'] = settings.get('num_trials') + # Trial size + self.dmdParams['trial_size'] = settings.get('trial_size') + # Eigen value constraints to apply + self.dmdParams['eig_constraints'] = set([settings.get('eig_constraints'), ]) + if self.dmdParams["eig_constraints"] == 'None': + self.dmdParams["eig_constraints"] = None + # Sorted eigs + self.dmdParams['eig_sort'] = settings.get('eig_sort') + self._dmdBase = BOPDMD + # intialize the model + self.initializeModel(self.dmdParams) + + def _preFitModifications(self): + """ + Method to modify parameters and populate fit argument before fitting + @ In, None + @ Out, None + """ + self.fitArguments['t'] = self.pivotValues.flatten() diff --git a/ravenframework/SupervisedLearning/DMD/CDMD.py b/ravenframework/SupervisedLearning/DMD/CDMD.py new file mode 100644 index 0000000000..f1fd0eab1f --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/CDMD.py @@ -0,0 +1,180 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 22, 2024 + + @author: Andrea Alfonsi + Compressed Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +np = importModuleLazy("numpy") +pydmd = importModuleLazy("pydmd") +ezyrb = importModuleLazy("ezyrb") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import utils +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class CDMD(DMDBase): + """ + Compressed Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(CDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{CDMD} ROM (Compressed Dynamic Mode Decomposition) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Compressed Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{compression\_matrix}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward_backward}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{tikhonov\_regularization}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{energyRankSVD}. This node has always priority over \xmlNode{rankSVD} + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("compression_matrix", contentType=InputTypes.makeEnumType("compression_matrix", "compressionMatrixType", + ["linear", "sparse", "uniform", "sample"]), + descr=r"""The matrix method that pre-multiplies the snapshots matrix in order to compress it. Available are: + \begin{itemize} + \item \textit{linear}, linearized matrix + \item \textit{sparse}, sparse matrix + \item \textit{uniform}, uniform + \item \textit{sample}, sampled matrix. + \end{itemize}""", default="uniform")) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.FloatType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) + specs.addSub(InputData.parameterInputFactory("forward_backward", contentType=InputTypes.BoolType, + descr=r"""If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + Default is False.""", default=False)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleType", + ["auto", 'None']), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular values. + """, default=None)) + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'False']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default=False)) + specs.addSub(InputData.parameterInputFactory("tikhonov_regularization", contentType=InputTypes.FloatType, + descr=r"""Tikhonov parameter for the regularization. + If `None`, no regularization is applied, if `float`, it is used as the + $`\lambda`$ tikhonov parameter.""", default=None)) + specs.addSub(InputData.parameterInputFactory("seed", contentType=InputTypes.IntegerType, + descr=r"""Seed of the random number generator""", default=None)) + + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import CDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','rescale_mode', 'sorted_eigs','seed', + 'compression_matrix','forward_backward','tikhonov_regularization', 'opt']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank' ] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + self.dmdParams['forward_backward'] = settings.get('forward_backward') + # Compression matrix + self.dmdParams['compression_matrix'] = settings.get('compression_matrix') + # Rescale mode + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams["rescale_mode"] == 'None': + self.dmdParams["rescale_mode"] = None + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams["sorted_eigs"] == 'False': + self.dmdParams["sorted_eigs"] = False + # Tikhonov parameter for the regularization. + self.dmdParams['tikhonov_regularization'] = settings.get('tikhonov_regularization') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # seed + import numpy as np + np.random.seed(settings.get('seed')) + self._dmdBase = CDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/DMD.py b/ravenframework/SupervisedLearning/DMD/DMD.py new file mode 100644 index 0000000000..38bc76fef3 --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/DMD.py @@ -0,0 +1,153 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Traditional Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class DMD(DMDBase): + """ + Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + # local model + self._dmdBase = None #{} # DMD + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(DMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{DynamicModeDecomposition} ROM aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{tikhonov_regularization}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd\_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd\_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("exact", contentType=InputTypes.BoolType, + descr=r"""True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=True)) + specs.addSub(InputData.parameterInputFactory("forward_backward", contentType=InputTypes.BoolType, + descr=r"""If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + Default is False.""", default=False)) + specs.addSub(InputData.parameterInputFactory("tikhonov_regularization", contentType=InputTypes.FloatOrIntType, + descr=r"""Tikhonov parameter for the regularization. + If `None`, no regularization is applied, if `float`, it is used as the + $`\lambda`$ tikhonov parameter.""", default=None)) + + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.BoolType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import DMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank', + 'exact','forward_backward','tikhonov_regularization', 'opt']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) + self.dmdParams['exact'] = settings.get('exact') + # If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + self.dmdParams['forward_backward'] = settings.get('forward_backward') + # Tikhonov parameter for the regularization. + self.dmdParams['tikhonov_regularization'] = settings.get('tikhonov_regularization') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # for target + #for target in set(self.target) - set(self.pivotID): + # self._dmdBase[target] = DMD + self._dmdBase = DMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/DMDBase.py b/ravenframework/SupervisedLearning/DMD/DMDBase.py new file mode 100644 index 0000000000..4d544fe3dd --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/DMDBase.py @@ -0,0 +1,474 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Dynamic Mode Decomposition base class + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +np = importModuleLazy("numpy") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ..SupervisedLearning import SupervisedLearning +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + + +approximationDefaults = {'GPR': {},'RBF': {}} +# RBF +approximationDefaults['RBF']['kernel'] = 'multiquadric' +approximationDefaults['RBF']['smooth'] = 0. +approximationDefaults['RBF']['neighbors'] = None +approximationDefaults['RBF']['epsilon'] = 1. +approximationDefaults['RBF']['degree'] = None +# GPR +approximationDefaults['GPR']['optimization_restart'] = 0 +approximationDefaults['GPR']['normalize_y'] = True + +class DMDBase(SupervisedLearning): + """ + Base Class for DMD-based surrogate models + """ + info = {'problemtype':None, 'normalize':None} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + # handling time series? + self._dynamicHandling = True + # initial settings for the ROM (coming from input) + self.settings = {} + # dmd-based model parameters (used in the initialization of the DMD models) + self.dmdParams = {} + # parametric model + self.model = None # ParametericDMD + # local models + ## POD + self._dimReductionRom = None + ## RBF + self._interpolator = None + ## base specific DMD estimator/model (Set by derived classes) + self._dmdBase = None + ## DMD fit arguments (overloaded by derived classes (if needed)) + self.fitArguments = {} + # flag to indicate that the model has a single target (in addition to the pivot parameter) + # This flag is needed because the DMD based model has an issue with single target (space dimension == 1) and + # a counter mesurament (concatenation of snapshots) is required + self.singleTarget = False + # target indeces (positions in self.target list) + self.targetIndices = None + + @property + def featureImportances_(self): + """ + This property is in charge of extracting from the estimators + the importance of the features used in the training process + @ In, None + @ Out, importances, dict, {featName:float or array(nTargets)} importances of the features + """ + # store importances + importances = {} + return importances + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super().getInputSpecification() + specs.addSub(InputData.parameterInputFactory("light", contentType=InputTypes.BoolType, + descr=r"""Whether this instance should be light or not. A light instance uses + less memory since it caches a smaller number of resources.""", default=False)) + specs.addSub(InputData.parameterInputFactory("pivotParameter", contentType=InputTypes.StringType, + descr=r"""defines the pivot variable (e.g., time) that represents the + independent monotonic variable""", default="time")) + specs.addSub(InputData.parameterInputFactory("reductionMethod", contentType=InputTypes.makeEnumType("reductionMethod", "reductionMethodType", + ["svd", "correlation_matrix", "randomized_svd"]), + descr=r"""the type of method used for the dimensionality reduction.Available are: + \begin{itemize} + \item \textit{svd}, single value decomposition + \item \textit{svd}, randomized single value decomposition + \item \textit{correlation\_matrix}, correlation-based reduction. + \end{itemize}""", default="svd")) + specs.addSub(InputData.parameterInputFactory("reductionRank", contentType=InputTypes.IntegerType, + descr=r"""defines the truncation rank to be used for the reduction method. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize}""", default=0)) + specs.addSub(InputData.parameterInputFactory("approximationMethod", contentType=InputTypes.makeEnumType("approximationMethod", "approximationMethodType", + ["RBF", "GPR"]), + descr=r"""the type of method used for the interpolation of the parameter space.Available are: + \begin{itemize} + \item \textit{RBF}, Radial-basis functions + \item \textit{GPR}, Gaussian Process Regression + \end{itemize}""", default="RBF")) + + approximationSettings = InputData.parameterInputFactory("approximationSettings", + descr=r"""the settings available depending on the different type of method used for the interpolation of the parameter space""") + #RBF + approximationSettings.addSub(InputData.parameterInputFactory("kernel", contentType=InputTypes.makeEnumType("kernelRBF", "kernelRBFType", + ["cubic", "quintic", "linear", + "gaussian", "inverse", "multiquadric", "thin_plate_spline"]), + descr=r"""RBF kernel. + Available options are: + \begin{itemize} + \item \textit{thin\_plate\_spline}, thin-plate spline ($r**2 * log(r)$) + \item \textit{cubic}, cubic kernel ($r**3$) + \item \textit{quintic}, quintic kernel ($r**5$) + \item \textit{linear}, linear kernel ($r$) + \item \textit{gaussian}, gaussian kernel ($exp(-(r/self.epsilon)**2)$) + \item \textit{inverse}, inverse kernel ($1.0/sqrt((r/self.epsilon)**2 + 1)$) + \item \textit{multiquadric}, multiquadric kernel ($sqrt((r/self.epsilon)**2 + 1)$) + \end{itemize}""", default=approximationDefaults['RBF']['kernel'])) + approximationSettings.addSub(InputData.parameterInputFactory("smooth", contentType=InputTypes.FloatType, + descr=r"""RBF smooth factor. Values greater than zero increase the smoothness of the approximation. + 0 is for interpolation (default), the function will always go through the nodal points in this case. + """, default=approximationDefaults['RBF']['smooth'])) + approximationSettings.addSub(InputData.parameterInputFactory("neighbors", contentType=InputTypes.IntegerType, + descr=r"""RBF number of neighbors. If specified, the value of the interpolant at each + evaluation point will be computed using only the nearest data points. + If None (default), all the data points are used by default.""", + default=approximationDefaults['RBF']['neighbors'])) + approximationSettings.addSub(InputData.parameterInputFactory("epsilon", contentType=InputTypes.FloatType, + descr=r"""RBF Shape parameter that scales the input to the RBF. + If kernel is ``linear'', ‘thin_plate_spline'', ``cubic'', or ``quintic'', this + defaults to 1 and can be ignored. Otherwise, this must be specified.""", + default=approximationDefaults['RBF']['epsilon'])) + approximationSettings.addSub(InputData.parameterInputFactory("degree", contentType=InputTypes.IntegerType, + descr=r"""RBF Degree of the added polynomial. The default value is + the minimum degree for kernel or 0 if there is no minimum degree.""", + default=approximationDefaults['RBF']['degree'])) + #GPR + approximationSettings.addSub(InputData.parameterInputFactory("optimization_restart", contentType=InputTypes.IntegerType, + descr=r"""GPR restart parameter. The number of restarts of the optimizer for finding the + kernel parameters which maximize the log-marginal likelihood. The first run of the optimizer + is performed from the kernel’s initial parameters, the remaining ones (if any) from thetas + sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, + all bounds must be finite. Note that $n\_restarts\_optimizer == 0$ implies that one run is performed.""", + default=approximationDefaults['GPR']['optimization_restart'])) + approximationSettings.addSub(InputData.parameterInputFactory("normalize_y", contentType=InputTypes.BoolType, + descr=r"""GPR normalization. Whether or not to normalize the target values y by removing the mean and scaling + to unit-variance. This is recommended for cases where zero-mean, unit-variance priors are used. + Note that, in this implementation, the normalisation is reversed before the GP predictions are reported.""", + default=approximationDefaults['GPR']['normalize_y'])) + + specs.addSub(approximationSettings) + return specs + + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the model parameter input. + @ In, paramInput, InputData.ParameterInput, the already parsed input. + @ Out, None + """ + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['pivotParameter','light', 'reductionRank', 'reductionMethod', 'approximationMethod']) + # notFound must be empty + assert(not notFound) + self.settings = {} + self.pivotParameterID = settings.get("pivotParameter") # pivot parameter + self.settings['light'] = settings.get('light') + self.settings['reductionMethod'] = settings.get('reductionMethod') + self.settings['reductionRank'] = settings.get('reductionRank') + self.settings['approximationMethod'] = settings.get('approximationMethod') + approximationSettings = paramInput.findFirst("approximationSettings") + self.settings['approximationSettings'] = {} + if self.settings['approximationMethod'] == 'RBF': + if approximationSettings is not None: + RBFsettings, RBFnotFound = approximationSettings.findNodesAndExtractValues(['kernel','smooth', 'neighbors', 'epsilon', 'degree']) + # RBFnotFound must be empty + assert(not RBFnotFound) + else: + RBFsettings = approximationDefaults['RBF'] + self.settings['approximationSettings']['kernel'] = RBFsettings.get('kernel') + self.settings['approximationSettings']['smooth'] = RBFsettings.get('smooth') + self.settings['approximationSettings']['neighbors'] = RBFsettings.get('neighbors') + self.settings['approximationSettings']['epsilon'] = RBFsettings.get('epsilon') + self.settings['approximationSettings']['degree'] = RBFsettings.get('degree') + elif self.settings['approximationMethod'] == 'GPR': + if approximationSettings is not None: + GPRsettings, GPRnotFound = approximationSettings.findNodesAndExtractValues(['optimization_restart','normalize_y']) + # GPRnotFound must be empty + assert(not GPRnotFound) + else: + GPRsettings = approximationDefaults['GPR'] + self.settings['approximationSettings']['optimization_restart'] = GPRsettings.get('optimization_restart') + self.settings['approximationSettings']['normalize_y'] = GPRsettings.get('normalize_y') + if self.pivotParameterID not in self.target: + self.raiseAnError(IOError,f"The pivotParameter {self.pivotParameterID} must be part of the Target space!") + if len(self.target) < 2: + self.raiseAnError(IOError,f"At least one Target in addition to the pivotParameter {self.pivotParameterID} must be part of the Target space!") + + def initializeModel(self, dmdParams): + """ + Method to initialize the surrogate model with a dmdParams dictionary + @ In, dmdParams, dict, the dictionary containin the parameters/settings to instanciate the model + @ Out, None + """ + from pydmd import ParametricDMD + from ezyrb import POD, RBF, GPR + + assert(self._dmdBase is not None) + self.dmdParams = dmdParams + print(self.dmdParams) + + # intialize dimensionality reduction + self._dimReductionRom = POD(self.settings['reductionMethod'], rank=self.settings['reductionRank']) + # initialize coefficient interpolator + if self.settings['approximationMethod'] == 'RBF': + self._interpolator = RBF(kernel=self.settings['approximationSettings']['kernel'], smooth=self.settings['approximationSettings']['smooth'], + neighbors=self.settings['approximationSettings']['neighbors'], epsilon=self.settings['approximationSettings']['epsilon'], + degree=self.settings['approximationSettings']['degree']) + elif self.settings['approximationMethod'] == 'GPR': + self._interpolator = GPR(optimization_restart=self.settings['approximationSettings']['optimization_restart'], + normalizer=self.settings['approximationSettings']['normalize_y']) + # initialize the base model + self._dmdBase = self._dmdBase(**self.dmdParams) + self.model = ParametricDMD(self._dmdBase, self._dimReductionRom, self._interpolator, light=self.settings['light'], dmd_fit_kwargs=self.fitArguments) + # set type of dmd class + self.dmdType = self.__class__.__name__ + # check if single target + self.singleTarget = len(self.target) == 2 + self.targetIndices = tuple([i for i,x in enumerate(self.target) if x != self.pivotID]) + + def _localNormalizeData(self,values,names,feat): + """ + Overwrites default normalization procedure. + @ In, values, unused + @ In, names, unused + @ In, feat, feature to normalize + @ Out, None + """ + self.muAndSigmaFeatures[feat] = (0.0,1.0) + + ####### + def _getTimeScale(self): + """ + Get the ts of the dmd (if dmd = True) or training (if dmd = False) reconstructed time scale. + @ In, None + @ Out, timeScale, numpy.array, the dmd or training reconstructed time scale + """ + try: + timeScaleInfo = self.model.dmd_time + if isinstance(timeScaleInfo, dict): + timeScale = np.arange(timeScaleInfo['t0'], (timeScaleInfo['tend']+1)*timeScaleInfo['dt'], timeScaleInfo['dt']) + else: + timeScale = timeScaleInfo + except AttributeError: + if 'time' in dir(self.model._reference_dmd): + timeScale = self.model._reference_dmd.time + else: + timeScale = self.pivotValues.flatten() + return timeScale + + def _preFitModifications(self): + """ + Method to modify parameters and populate fit argument before fitting + @ In, None + @ Out, None + """ + pass + + def _train(self,featureVals,targetVals): + """ + Perform training on input database stored in featureVals. + @ In, featureVals, numpy.ndarray, shape=[n_samples, n_features], an array of input data # Not use for ARMA training + @ In, targetVals, numpy.ndarray, shape = [n_samples, n_timeStep, n_targets], an array of time series data + """ + + # - 0: Training parameters; + # - 1: Space; + # - 2: Training time instants. + self.featureVals = featureVals + pivotParamIndex = self.target.index(self.pivotParameterID) + self.pivotValues = targetVals[0,:,pivotParamIndex] + + snapshots = np.swapaxes(targetVals, 1, 2) + if self.singleTarget: + targetSnaps = snapshots[:, self.targetIndices, :].reshape((snapshots.shape[0], 1, snapshots.shape[-1])) + targetSnaps = np.concatenate((targetSnaps, targetSnaps), axis=1) + else: + targetSnaps = snapshots[:, self.targetIndices, :] + # populate fit arguments and allow for modifications (if needed) + self._preFitModifications() + # fit model + self.model.fit(targetSnaps, training_parameters=featureVals) + self.model.parameters = featureVals + + def __evaluateLocal__(self,featureVals): + """ + This method is used to inquire the DMD to evaluate (after normalization that in + this case is not performed) a set of points contained in featureVals. + a KDTree algorithm is used to construct a weighting function for the reconstructed space + @ In, featureVals, numpy.ndarray, shape= (n_requests, n_dimensions), an array of input data + @ Out, returnEvaluation , dict, dictionary of values for each target (and pivot parameter) + """ + returnEvaluation = dict.fromkeys(self.target) + returnEvaluation[self.pivotID] = self.pivotValues + self.model.parameters = featureVals + data = self.model.reconstructed_data + for didx, tidx in enumerate(self.targetIndices): + target = self.target[tidx] + returnEvaluation[target] = data[:, didx, :].flatten().real + + return returnEvaluation + + def writeXMLPreamble(self, writeTo, targets = None): + """ + Specific local method for printing anything desired to xml file at the begin of the print. + @ In, writeTo, xmlUtils.StaticXmlElement instance, element to write to + @ In, targets, list, list of targets for whom information should be written. + @ Out, None + """ + # add description + super().writeXMLPreamble(writeTo, targets) + description = ' This XML file contains the main information of the DMD-based ROM .' + description += ' If "modes" (dynamic modes), "eigs" (eigenvalues), "amplitudes" (mode amplitudes)' + description += ' and "dmdTimeScale" (internal dmd time scale) are dumped, the basic method' + description += ' is explained in P.J. Schmid, Dynamic mode decomposition' + description += ' of numerical and experimental data, Journal of Fluid Mechanics 656.1 (2010), 5-28' + writeTo.addScalar('ROM',"description",description) + + def writeXML(self, writeTo, targets = None, skip = None): + """ + Adds requested entries to XML node. + @ In, writeTo, xmlTuils.StaticXmlElement, element to write to + @ In, targets, list, optional, list of targets for whom information should be written + @ In, skip, list, optional, list of targets to skip + @ Out, None + """ + if not self.amITrained: + self.raiseAnError(RuntimeError,'ROM is not yet trained!') + if skip is None: + skip = [] + + # check what + + what = ['features','timeScale','eigs','amplitudes','modes','dmdTimeScale'] + list(self.dmdParams.keys()) + if targets is None: + readWhat = what + else: + readWhat = targets + for s in skip: + if s in readWhat: + readWhat.remove(s) + if not set(readWhat) <= set(what): + self.raiseAnError(IOError, "The following variables specified in node are not recognized: "+ ",".join(np.setdiff1d(readWhat, what).tolist()) ) + else: + what = readWhat + + target = self.name + toAdd = list(self.dmdParams.keys()) + + for add in toAdd: + if add in what : + writeTo.addScalar(target,add,self.dmdParams[add]) + targNode = writeTo._findTarget(writeTo.getRoot(), target) + if "features" in what: + writeTo.addScalar(target,"features",' '.join(self.features)) + if "timeScale" in what: + writeTo.addScalar(target,"timeScale",' '.join(['%.6e' % elm for elm in self.pivotValues.ravel()])) + if "dmdTimeScale" in what: + writeTo.addScalar(target,"dmdTimeScale",' '.join(['%.6e' % elm for elm in self._getTimeScale()])) + if "eigs" in what: + eigsReal = " ".join(['%.6e' % self.model._reference_dmd.eigs[indx].real for indx in + range(len(self.model._reference_dmd.eigs))]) + writeTo.addScalar("eigs","real", eigsReal, root=targNode) + eigsImag = " ".join(['%.6e' % self.model._reference_dmd.eigs.imag[indx] for indx in + range(len(self.model._reference_dmd.eigs))]) + writeTo.addScalar("eigs","imaginary", eigsImag, root=targNode) + if "amplitudes" in what and 'amplitudes' in dir(self.model._reference_dmd) and self.model._reference_dmd.amplitudes is not None: + ampsReal = " ".join(['%.6e' % self.model._reference_dmd.amplitudes.real[indx] for indx in + range(len(self.model._reference_dmd.amplitudes))]) + writeTo.addScalar("amplitudes","real", ampsReal, root=targNode) + ampsImag = " ".join(['%.6e' % self.model._reference_dmd.amplitudes.imag[indx] for indx in + range(len(self.model._reference_dmd.amplitudes))]) + writeTo.addScalar("amplitudes","imaginary", ampsImag, root=targNode) + if "modes" in what: + nSamples = self.featureVals.shape[0] + delays = max(1, int(self.model._reference_dmd.modes.shape[0] / nSamples)) + loopCnt = 0 + noSampled = False + if nSamples * delays != self.model._reference_dmd.modes.shape[0]: + nSamples = self.model._reference_dmd.modes.shape[0] + noSampled = True + for smp in range(nSamples): + valDict = {'real':'', 'imaginary': ''} + for _ in range(delays): + valDict['real'] += ' '.join([ '%.6e' % elm for elm in self.model._reference_dmd.modes[loopCnt,:].real]) + ' ' + valDict['imaginary'] += ' '.join([ '%.6e' % elm for elm in self.model._reference_dmd.modes[loopCnt,:].imag]) +' ' + loopCnt += 1 + if noSampled: + attributeDict = {"index":f'{loopCnt}'} + else: + attributeDict = {self.features[index]:'%.6e' % self.featureVals[smp,index] for index in range(len(self.features))} + if delays > 1: + attributeDict['shape'] = f"({self.model._reference_dmd.modes.shape[1]},{delays})" + writeTo.addVector("modes","realization" if not noSampled else "element",valDict, root=targNode, attrs=attributeDict) + + def __confidenceLocal__(self,featureVals): + """ + The confidence associate with a set of requested evaluations + @ In, featureVals, numpy.ndarray, shape= (n_requests, n_dimensions), an array of input data + @ Out, None + """ + pass + + def __resetLocal__(self,featureVals): + """ + After this method the ROM should be described only by the initial parameter settings + @ In, featureVals, numpy.ndarray, shape= (n_samples, n_dimensions), an array of input data (training data) + @ Out, None + """ + self.amITrained = False + self.model = {} + self.pivotValues = None + self.featureVals = None + + def __returnInitialParametersLocal__(self): + """ + This method returns the initial parameters of the SM + @ In, None + @ Out, params, dict, the dict of the SM settings + """ + params = self.dmdParams + params.update(self.settings) + return params + + def __returnCurrentSettingLocal__(self): + """ + This method is used to pass the set of parameters of the ROM that can change during simulation + @ In, None + @ Out, params, dict, the dict of the SM settings + """ + return self.__returnInitialParametersLocal__() diff --git a/ravenframework/SupervisedLearning/DynamicModeDecompositionControl.py b/ravenframework/SupervisedLearning/DMD/DynamicModeDecompositionControl.py similarity index 83% rename from ravenframework/SupervisedLearning/DynamicModeDecompositionControl.py rename to ravenframework/SupervisedLearning/DMD/DynamicModeDecompositionControl.py index 732966fcb7..0db2febfb5 100644 --- a/ravenframework/SupervisedLearning/DynamicModeDecompositionControl.py +++ b/ravenframework/SupervisedLearning/DMD/DynamicModeDecompositionControl.py @@ -26,9 +26,9 @@ #External Modules End-------------------------------------------------------------------------------- #Internal Modules------------------------------------------------------------------------------------ -from ..utils import mathUtils -from ..utils import InputData, InputTypes -from .DynamicModeDecomposition import DMD +from ...utils import mathUtils +from ...utils import InputData, InputTypes +from .DMD import DMD #Internal Modules End-------------------------------------------------------------------------------- class DMDC(DMD): @@ -101,7 +101,27 @@ class cls. \item \xmlNode{Ctilde}, XML node containing the C matrix in discrete time domain (imaginary part, matrix shape, and real part) \end{itemize}""" - specs.popSub("dmdType") + specs.addSub(InputData.parameterInputFactory("rankSVD", contentType=InputTypes.IntegerType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize}""", default=None)) + specs.addSub(InputData.parameterInputFactory("energyRankSVD", contentType=InputTypes.FloatType, + descr=r"""energy level ($0.0 < float < 1.0$) used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{energyRankSVD}. This node has always priority over \xmlNode{rankSVD}""", default=None)) + specs.addSub(InputData.parameterInputFactory("rankTLSQ", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("exactModes", contentType=InputTypes.BoolType, + descr=r"""True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=True)) + specs.addSub(InputData.parameterInputFactory("optimized", contentType=InputTypes.FloatType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) specs.addSub(InputData.parameterInputFactory("actuators", contentType=InputTypes.StringListType, descr=r"""defines the actuators (i.e. system input parameters) of this model. Each actuator variable (u1, u2, etc.) needs to @@ -145,6 +165,10 @@ def __init__(self): self.parametersIDs = None # Parameter Names self.neigh = None # neighbors # variables filled up in the training stages + self._amplitudes = {} # {'target1': vector of amplitudes,'target2':vector of amplitudes, etc.} + self._eigs = {} # {'target1': vector of eigenvalues,'target2':vector of eigenvalues, etc.} + self._modes = {} # {'target1': matrix of dynamic modes,'target2':matrix of dynamic modes, etc.} + self.__Atilde = {} # {'target1': matrix of lowrank operator from the SVD,'target2':matrix of lowrank operator from the SVD, etc.} self.__Btilde = {} # B matrix self.__Ctilde = {} # C matrix self.actuatorVals = None # Actuator values (e.g. U), the variable names are in self.ActuatorID @@ -160,10 +184,16 @@ def _handleInput(self, paramInput): @ Out, None """ super()._handleInput(paramInput) - settings, notFound = paramInput.findNodesAndExtractValues(['actuators','stateVariables', 'initStateVariables', + settings, notFound = paramInput.findNodesAndExtractValues(['pivotParameter','rankSVD', 'energyRankSVD', + 'rankTLSQ','exactModes','optimized','actuators','stateVariables', 'initStateVariables', 'subtractNormUXY','singleValuesTruncationTol']) # notFound must be empty assert(not notFound) + self.dmdParams['rankSVD' ] = settings.get('rankSVD',None) # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + self.dmdParams['energyRankSVD' ] = settings.get('energyRankSVD',None) # 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by "energyRankSVD" + self.dmdParams['rankTLSQ' ] = settings.get('rankTLSQ',None) # truncation rank for total least square + self.dmdParams['exactModes' ] = settings.get('exactModes',True) # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) + self.dmdParams['optimized' ] = settings.get('optimized',False) # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) # Truncation threshold to apply to single values self.sTruncationTol = settings.get('singleValuesTruncationTol') # Extract the Actuator Variable Names (u) @@ -184,6 +214,13 @@ def _handleInput(self, paramInput): # whether to subtract the nominal(initial) value from U, X and Y signal for calculation self.dmdParams['centerUXY'] = settings.get('subtractNormUXY') # some checks + if self.dmdParams['rankSVD'] is not None and self.dmdParams['energyRankSVD'] is not None: + self.raiseAWarning('Both "rankSVD" and "energyRankSVD" have been inputted. "energyRankSVD" is predominant and will be used!') + # check if the pivotParameter is among the targetValues + if self.pivotParameterID not in self.target: + self.raiseAnError(IOError,"The pivotParameter "+self.pivotParameterID+" must be part of the Target space!") + if len(self.target) < 2: + self.raiseAnError(IOError,"At least one Target in addition to the pivotParameter "+self.pivotParameterID+" must be part of the Target space!") # check if state ids in target if not (set(self.stateID) <= set(self.target)): self.raiseAnError(IOError,'stateVariables must also be listed among variables!') @@ -199,6 +236,43 @@ def _handleInput(self, paramInput): if str(self.parametersIDs[i]).endswith('_init'): self.parametersIDs.remove(self.parametersIDs[i]) + def initializeModel(self, dmdParams): + """ + Method to initialize the surrogate model with a dmdParams dictionary + @ In, dmdParams, dict, the dictionary containin the parameters/settings to instanciate the model + @ Out, None + """ + pass + + def _getTimeScale(self,dmd=True): + """ + Get the ts of the dmd (if dmd = True) or training (if dmd = False) reconstructed time scale. + @ In, dmd, bool, optional, True if dmd time scale needs to be returned, othewise training one + @ Out, timeScale, numpy.array, the dmd or training reconstructed time scale + """ + timeScaleInfo = self.timeScales['dmd'] if dmd else self.timeScales['training'] + timeScale = np.arange(timeScaleInfo['t0'], (timeScaleInfo['intervals']+1)*timeScaleInfo['dt'], timeScaleInfo['dt']) + return timeScale + + def __getTimeEvolution(self, target): + """ + Get the time evolution of each mode + @ In, target, str, the target for which mode evolution needs to be retrieved for + @ Out, timeEvol, numpy.ndarray, the matrix that contains all the time evolution (by row) + """ + omega = np.log(self._eigs[target]) / self.timeScales['training']['dt'] + van = np.exp(np.multiply(*np.meshgrid(omega, self._getTimeScale()))) + timeEvol = (van * self._amplitudes[target]).T + return timeEvol + + def _reconstructData(self, target): + """ + Retrieve the reconstructed data + @ In, target, str, the target for which the data needs to be reconstructed + @ Out, data, numpy.ndarray, the matrix (nsamples,n_time_steps) containing the reconstructed data + """ + data = self._modes[target].dot(self.__getTimeEvolution(target)) + return data def __setstate__(self,state): """ Initializes the DMD with the data contained in state @@ -403,7 +477,7 @@ def writeXML(self, writeTo, targets = None, skip = None): if skip is None: # skip = None skip = [] - what = ['dmdType','rankSVD','acturators', + what = ['rankSVD','acturators', 'stateVariables','outputs','initStateVariables', 'Atilde','Btilde','Ctilde','UNorm','XNorm','YNorm', 'XLast','dmdTimeScale'] @@ -424,7 +498,7 @@ def writeXML(self, writeTo, targets = None, skip = None): target = 'DMDcModel' - toAdd = ['dmdType','rankSVD'] + toAdd = ['rankSVD'] self.dmdParams['rankSVD'] = self.dmdParams['rankSVD'] if self.dmdParams['rankSVD'] is not None else -1 for add in toAdd: # toAdd = ['dmdType','rankSVD'] diff --git a/ravenframework/SupervisedLearning/DMD/EDMD.py b/ravenframework/SupervisedLearning/DMD/EDMD.py new file mode 100644 index 0000000000..9e6946ce6d --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/EDMD.py @@ -0,0 +1,144 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Kernelized Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class EDMD(DMDBase): + """ + Kernelized Extended Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(EDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{EDMD} ROM (Kernelized Extended Dynamic Mode Decomposition) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Compressed Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{kernel\_metric}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd\_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd\_rank}. + """, default=-1)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=0)) + specs.addSub(InputData.parameterInputFactory("kernel_metric", contentType=InputTypes.makeEnumType("kernel_metric", "kernelMetricType", + ["additive_chi2", "chi2", "linear", "poly", + "rbf", "laplacian", "sigmoid", "cosine"]), + descr=r"""The kernel function to apply (for more details, see ``sklearn.metrics.pairwise_kernels''). Available are: + \begin{itemize} + \item \textit{additive_chi2}, additive_chi2 kernel + \item \textit{chi2}, chi2 kernel + \item \textit{linear}, linear kernel + \item \textit{poly}, polynomial kernel + \item \textit{rbf}, radial basis function + \item \textit{laplacian}, laplacian kernel + \item \textit{sigmoid}, sigmoid kernel + \item \textit{cosine}, cosine kernel + \end{itemize}""", default="linear")) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.BoolType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", + default=False)) + + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import EDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','kernel_metric', 'opt']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank' ] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # Kernel metric + self.dmdParams['kernel_metric'] = settings.get('kernel_metric') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + self._dmdBase = EDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/FbDMD.py b/ravenframework/SupervisedLearning/DMD/FbDMD.py new file mode 100644 index 0000000000..dad2631b7e --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/FbDMD.py @@ -0,0 +1,154 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Forward/Backward Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class FbDMD(DMDBase): + """ + Forward/Backward Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(FbDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{FbDMD} ROM (Forward/Backward Dynamic Mode Decomposition) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Forward-Backward Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=0)) + specs.addSub(InputData.parameterInputFactory("exact", contentType=InputTypes.BoolType, + descr=r"""True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=False)) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.BoolType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", + default=False)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleType", + ["auto", 'None']), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular values. + """, default=None)) + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'False']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default=False)) + + + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import FbDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','exact', 'opt', 'rescale_mode', 'sorted_eigs']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) + self.dmdParams['exact' ] = settings.get('exact') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # Rescale mode + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams["rescale_mode"] == 'None': + self.dmdParams["rescale_mode"] = None + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams["sorted_eigs"] == 'False': + self.dmdParams["sorted_eigs"] = False + + self._dmdBase = FbDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/HAVOK.py b/ravenframework/SupervisedLearning/DMD/HAVOK.py new file mode 100644 index 0000000000..02ebac1e22 --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/HAVOK.py @@ -0,0 +1,163 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Hankel Alternative View of Koopman (HAVOK) model + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class HAVOK(DMDBase): + """ + Hankel Alternative View of Koopman (HAVOK) (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + # local model + self.fitArguments = {'t': 1} + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(HAVOK, cls).getInputSpecification() + + specs.description = r"""The \xmlString{HAVOK} ROM (Hankel Alternative View of Koopman - HAVOK) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Hankel Alternative View of Koopman model + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{delays}, see XML input specifications below + \item \xmlNode{lag}, see XML input specifications below + \item \xmlNode{num\_chaos}, see XML input specifications below + \item \xmlNode{structured}, see XML input specifications below + \item \xmlNode{lstsq}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("delays", contentType=InputTypes.IntegerType, + descr=r"""The number of consecutive time-shifted copies of the data to use when building Hankel matrices. + Note that if examining an n-dimensional data set, this means that the resulting Hankel matrix + will contain $n * delays$ rows""", default=10)) + specs.addSub(InputData.parameterInputFactory("lag", contentType=InputTypes.IntegerType, + descr=r"""The number of time steps between each time-shifted copy of data in the Hankel matrix. + This means that each row of the Hankel matrix will be separated by a time-step of $dt * lag$.""", default=1)) + specs.addSub(InputData.parameterInputFactory("num_chaos", contentType=InputTypes.IntegerType, + descr=r"""The number of forcing terms to use in the HAVOK model.""", default=1)) + specs.addSub(InputData.parameterInputFactory("structured", contentType=InputTypes.BoolType, + descr=r"""Whether to perform standard HAVOK or structured HAVOK (sHAVOK). + If True, sHAVOK is performed, otherwise HAVOK is performed.""", default=False)) + specs.addSub(InputData.parameterInputFactory("lstsq", contentType=InputTypes.BoolType, + descr=r"""Method used for computing the HAVOK operator. + If True, least-squares is used, otherwise the pseudo- inverse is used.""", + default=True)) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import HAVOK + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'delays','lag', 'num_chaos', 'structured', 'lstsq']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # The number of consecutive time-shifted copies of the data to use when building Hankel matrices. + self.dmdParams['delays'] = settings.get('delays') + # the number of time steps between each time-shifted copy of data in the Hankel matrix + self.dmdParams['lag' ] = settings.get('lag') + # The number of forcing terms to use in the HAVOK model. + self.dmdParams['num_chaos'] = settings.get('num_chaos') + # Whether to perform standard HAVOK or structured HAVOK (sHAVOK) + self.dmdParams['structured'] = settings.get('structured') + # Method used for computing the HAVOK operator. + self.dmdParams['lstsq'] = settings.get('lstsq') + + # for target + #for target in set(self.target) - set(self.pivotID): + # self._dmdBase[target] = HankelDMD + self._dmdBase = HAVOK + # intialize the model + self.initializeModel(self.dmdParams) + + def _preFitModifications(self): + """ + Method to modify parameters and populate fit argument before fitting + @ In, None + @ Out, None + """ + self.fitArguments['t'] = self.pivotValues.flatten() + if len(self.fitArguments['t']) < self.dmdParams['delays']: + self.raiseAWarning(f'In ROM {self.name} "delays" argument is set to {delays} but the # ts is {len(self.fitArguments["t"])}. ' + 'Modifying parameter accordingly!') + self.dmdParams['delays'] = min(self.dmdParams['delays'], len(self.fitArguments['t'])) diff --git a/ravenframework/SupervisedLearning/DMD/HODMD.py b/ravenframework/SupervisedLearning/DMD/HODMD.py new file mode 100644 index 0000000000..69fcd3d40f --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/HODMD.py @@ -0,0 +1,192 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Higher Order Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class HODMD(DMDBase): + """ + Higher Order Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(HODMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{HODMD} ROM aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on the High Order Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{d}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{reconstruction\_method}, see XML input specifications below + \item \xmlNode{svd\_rank\_extra}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd\_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd\_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("exact", contentType=InputTypes.BoolType, + descr=r"""True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=True)) + specs.addSub(InputData.parameterInputFactory("forward_backward", contentType=InputTypes.BoolType, + descr=r"""If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + Default is False.""", default=False)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleType", + ["auto", 'None']), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular values. + """, default=None)) + specs.addSub(InputData.parameterInputFactory("svd_rank_extra", contentType=InputTypes.FloatOrIntType, + descr=r"""the rank for the initial reduction of the input data, performed before the rearrangement + of the input data to the (pseudo) Hankel matrix format + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd\_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd\_rank\_extra}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.BoolType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) + specs.addSub(InputData.parameterInputFactory("d", contentType=InputTypes.IntegerType, + descr=r"""The new order for spatial dimension of the input snapshots. + """, default=1)) + + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'False']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default=False)) + specs.addSub(InputData.parameterInputFactory("reconstruction_method", contentType=InputTypes.makeEnumType("reconstruction_method", "ReconstructionMethodType", + ["first", "mean"]), + descr=r"""Method used to reconstruct the snapshots of the dynamical system from the multiple versions available + due to how HankelDMD is conceived. If ``first'' (default) the first version available is selected + (i.e. the nearest to the 0-th row in the augmented matrix). If ``mean'' we compute the element-wise mean. + """, default='first')) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import HODMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','exact', 'opt', 'rescale_mode','svd_rank_extra', + 'forward_backward', 'd', 'sorted_eigs', 'reconstruction_method']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) + self.dmdParams['exact' ] = settings.get('exact') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # Rescale mode + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams["rescale_mode"] == 'None': + self.dmdParams["rescale_mode"] = None + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams["sorted_eigs"] == 'False': + self.dmdParams["sorted_eigs"] = False + # Forward Backward method (see FbDMD) + self.dmdParams['forward_backward'] = settings.get('forward_backward') + # Sorted eigs + self.dmdParams['d'] = settings.get('d') + # Reconstruction method + self.dmdParams['reconstruction_method'] = settings.get('reconstruction_method') + # svd_rank_extra + self.dmdParams['svd_rank_extra'] = settings.get('svd_rank_extra') + + self._dmdBase = HODMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/HankelDMD.py b/ravenframework/SupervisedLearning/DMD/HankelDMD.py new file mode 100644 index 0000000000..33696fd8de --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/HankelDMD.py @@ -0,0 +1,180 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Hankel Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import utils +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class HankelDMD(DMDBase): + """ + Hankel Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(HankelDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{FbDMD} ROM (Forward/Backward Dynamic Mode Decomposition) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Forward-Backward Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{d}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{reconstruction\_method}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=0)) + specs.addSub(InputData.parameterInputFactory("exact", contentType=InputTypes.BoolType, + descr=r"""True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=False)) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.BoolType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", + default=False)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleType", + ["auto", 'None']), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular values. + """, default=None)) + specs.addSub(InputData.parameterInputFactory("forward_backward", contentType=InputTypes.BoolType, + descr=r"""If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + """, default=False)) + specs.addSub(InputData.parameterInputFactory("d", contentType=InputTypes.IntegerType, + descr=r"""The new order for spatial dimension of the input snapshots. + """, default=1)) + + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'False']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default=False)) + specs.addSub(InputData.parameterInputFactory("reconstruction_method", contentType=InputTypes.makeEnumType("reconstruction_method", "ReconstructionMethodType", + ["first", "mean"]), + descr=r"""Method used to reconstruct the snapshots of the dynamical system from the multiple versions available + due to how HankelDMD is conceived. If ``first'' (default) the first version available is selected + (i.e. the nearest to the 0-th row in the augmented matrix). If ``mean'' we compute the element-wise mean. + """, default='first')) + + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import HankelDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','exact', 'opt', 'rescale_mode', + 'forward_backward', 'd', 'sorted_eigs', 'reconstruction_method']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) + self.dmdParams['exact' ] = settings.get('exact') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # Rescale mode + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams["rescale_mode"] == 'None': + self.dmdParams["rescale_mode"] = None + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams["sorted_eigs"] == 'False': + self.dmdParams["sorted_eigs"] = False + # Forward Backward method (see FbDMD) + self.dmdParams['forward_backward'] = settings.get('forward_backward') + # Sorted eigs + self.dmdParams['d'] = settings.get('d') + # Reconstruction method + self.dmdParams['reconstruction_method'] = settings.get('reconstruction_method') + + # for target + #for target in set(self.target) - set(self.pivotID): + # self._dmdBase[target] = HankelDMD + self._dmdBase = HankelDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/PiDMD.py b/ravenframework/SupervisedLearning/DMD/PiDMD.py new file mode 100644 index 0000000000..a6236c0218 --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/PiDMD.py @@ -0,0 +1,200 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Physics-Informed Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class PiDMD(DMDBase): + """ + Physics-Informed Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(PiDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{PiDMD} ROM aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on the Physics Informed Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{manifold}, see XML input specifications below + \item \xmlNode{compute\_A}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd\_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd\_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.BoolType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", + default=False)) + specs.addSub(InputData.parameterInputFactory("manifold", contentType=InputTypes.makeEnumType("factorization", "FactorizationType", + ["unitary", "uppertriangular", + "lowertriangular", "diagonal", + "symmetric", "skewsymmetric", + "toeplitz", "hankel", "circulant", + "circulant_unitary", "circulant_symmetric", + "circulant_skewsymmetric", "symmetric_tridiagonal", + "BC", "BCTB", "BCCB", "BCCBunitary", "BCCBsymmetric", + "BCCBskewsymmetric"]), + descr=r""" the matrix manifold to restrict the full operator A to. Available options are: + \begin{itemize} + \item \textit{unitary}, + \item \textit{uppertriangular}, + \item \textit{lowertriangular}, + \item \textit{diagonal}, + \item \textit{symmetric}, + \item \textit{skewsymmetric}, + \item \textit{toeplitz}, + \item \textit{hankel}, + \item \textit{circulant}, + \item \textit{circulant\_unitary}, + \item \textit{circulant\_symmetric}, + \item \textit{circulant\_skewsymmetric}, + \item \textit{symmetric\_tridiagonal}, + \item \textit{BC} (block circulant), + \item \textit{BCTB} (BC with tridiagonal blocks), + \item \textit{BCCB} (BC with circulant blocks), + \item \textit{BCCBunitary} (BCCB and unitary), + \item \textit{BCCBsymmetric} (BCCB and symmetric), + \item \textit{BCCBskewsymmetric} (BCCB and skewsymmetric). + \end{itemize} + """, default=None)) + specs.addSub(InputData.parameterInputFactory("compute_A", contentType=InputTypes.BoolType, + descr=r"""Flag that determines whether or not to compute the full Koopman operator A""", + default=False)) + specs.addSub(InputData.parameterInputFactory("manifold_opt", contentType=InputTypes.StringListType, + descr=r"""Option used to specify certain manifolds: + \begin{itemize} + \item If manifold $==$ \textit{diagonal}, \textit{manifold\_opt} may be used to specify the width of the diagonal of A: + \begin{itemize} + \item If manifold_opt is an integer $k$, A is banded, with a lower and upper bandwidth of $k-1$. + \item If manifold_opt is a tuple containing two integers $k1$ and $k2$, A is banded with + a lower bandwidth of $k1-1$ and an upper bandwidth of $k2-1$ + . \end{itemize} + \item If manifold $==$ \textit{BC},\textit{BCTB},\textit{BCCB},\textit{BCCBunitary},\textit{BCCBsymmetric}, + \textit{BCCBskewsymmetric}, \textit{manifold\_opt} must be a 2D tuple that specifies the desired dimensions + of the blocks of A. + \end{itemize} + + Note that all other manifolds do not use \textit{manifold\_opt}.""", + default=None)) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import PiDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','compute_A', 'opt', 'manifold', 'manifold_opt']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # Compute full A operator? + self.dmdParams['compute_A'] = settings.get('compute_A') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # Manifold + self.dmdParams['manifold'] = settings.get('manifold') + if self.dmdParams['manifold'] is None: + self.raiseAnError(IOError, f"XML node must be inputted for ROM type 'PiDMD' named {self.name}") + # Manifold opt + self.dmdParams['manifold_opt'] = settings.get('manifold_opt') + + if self.dmdParams['manifold'].startswith("BC") or self.dmdParams['manifold'] == 'diagonal': + if self.dmdParams['manifold_opt'] is None: + self.raiseAnError(IOError, f"XML node must be inputted for ROM type 'PiDMD' named {self.name} if" + f" choosen is {self.dmdParams['manifold']}") + if len(self.dmdParams['manifold_opt']) == 1: + # this is an integer + self.dmdParams['manifold_opt'] = int(self.dmdParams['manifold_opt'][0]) + else: + # tuple + self.dmdParams['manifold_opt'] = tuple([int(el) for el in self.dmdParams['manifold_opt']]) + + self._dmdBase = PiDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/RDMD.py b/ravenframework/SupervisedLearning/DMD/RDMD.py new file mode 100644 index 0000000000..9ba91b6f7a --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/RDMD.py @@ -0,0 +1,180 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 22, 2024 + + @author: Andrea Alfonsi + Randomized Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class RDMD(DMDBase): + """ + Randomized Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(RDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{RDMD} ROM (Randomized Dynamic Mode Decomposition) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Randomized Dynamic Mode Decomposition + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{compression\_matrix}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{sorted_eigs}, see XML input specifications below + \item \xmlNode{tikhonov_regularization}, see XML input specifications below + \item \xmlNode{seed}, see XML input specifications below + \item \xmlNode{oversampling}, see XML input specifications below + \item \xmlNode{power\_iters}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{energyRankSVD}. This node has always priority over \xmlNode{rankSVD} + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.FloatType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) + specs.addSub(InputData.parameterInputFactory("forward_backward", contentType=InputTypes.BoolType, + descr=r"""If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + Default is False.""", default=False)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleType", + ["auto", 'None']), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular values. + """, default=None)) + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'False']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default=False)) + specs.addSub(InputData.parameterInputFactory("tikhonov_regularization", contentType=InputTypes.FloatType, + descr=r"""Tikhonov parameter for the regularization. + If ``None'', no regularization is applied, if ``float'', it is used as the + ``$\lambda''$ tikhonov parameter.""", default=None)) + specs.addSub(InputData.parameterInputFactory("seed", contentType=InputTypes.IntegerType, + descr=r"""Seed used to initialize the random generator when computing random test matrices.""", default=None)) + specs.addSub(InputData.parameterInputFactory("oversampling", contentType=InputTypes.IntegerType, + descr=r"""Number of additional samples (beyond the target rank) to use when computing the + random test matrix. Note that values in the range $[5, 10]$ tend to be sufficient.""", default=10)) + specs.addSub(InputData.parameterInputFactory("power_iters", contentType=InputTypes.IntegerType, + descr=r"""Number of power iterations to perform when executing the Randomized QB Decomposition. + Note that as many as 1 to 2 power iterations often lead to considerable improvements.""", default=2)) + + + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import RDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','rescale_mode', 'sorted_eigs', + 'forward_backward','tikhonov_regularization', 'opt', 'seed', 'oversampling', 'power_iters']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank' ] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + self.dmdParams['forward_backward'] = settings.get('forward_backward') + # Rescale mode + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams["rescale_mode"] == 'None': + self.dmdParams["rescale_mode"] = None + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams["sorted_eigs"] == 'False': + self.dmdParams["sorted_eigs"] = False + # Tikhonov parameter for the regularization. + self.dmdParams['tikhonov_regularization'] = settings.get('tikhonov_regularization') + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + # seed + self.dmdParams['seed'] = settings.get('seed') + # Number of additional samples (beyond the target rank) to use when computing the random test matrix + self.dmdParams['oversampling'] = settings.get('oversampling') + # Number of power iterations + self.dmdParams['power_iters'] = settings.get('power_iters') + + self._dmdBase = RDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/SpDMD.py b/ravenframework/SupervisedLearning/DMD/SpDMD.py new file mode 100644 index 0000000000..2a8ead8702 --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/SpDMD.py @@ -0,0 +1,209 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 22, 2024 + + @author: Andrea Alfonsi + Sparsity-Promoting Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class SpDMD(DMDBase): + """ + Sparsity-Promoting Dynamic Mode Decomposition (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(SpDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{SpDMD} ROM (Sparsity-Promoting Dynamic Mode Decomposition) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Sparsity-Promoting Dynamic Mode Decomposition, which promotes solutions having an high number of + amplitudes set to zero (i.e. sparse solutions). Reference: 10.1063/1.4863670. + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{tlsq\_rank}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{opt}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{forward\_backward}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{abs\_tolerance}, see XML input specifications below + \item \xmlNode{rel\_tolerance}, see XML input specifications below + \item \xmlNode{max\_iterations}, see XML input specifications below + \item \xmlNode{rho}, see XML input specifications below + \item \xmlNode{gamma}, see XML input specifications below + \item \xmlNode{verbose}, see XML input specifications below + \item \xmlNode{enforce\_zero}, see XML input specifications below + \item \xmlNode{release\_memory}, see XML input specifications below + \item \xmlNode{zero\_absolute\_tolerance}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{energyRankSVD}. This node has always priority over \xmlNode{rankSVD} + """, default=0)) + specs.addSub(InputData.parameterInputFactory("tlsq_rank", contentType=InputTypes.IntegerType, + descr=r"""$int > 0$ that defines the truncation rank to be used for the total + least square problem. If not inputted, no truncation is applied""", default=None)) + specs.addSub(InputData.parameterInputFactory("opt", contentType=InputTypes.FloatType, + descr=r"""True if the amplitudes need to be computed minimizing the error + between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) + specs.addSub(InputData.parameterInputFactory("forward_backward", contentType=InputTypes.BoolType, + descr=r"""If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + Default is False.""", default=False)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleType", + ["auto", 'None']), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic rescaling using singular values. + """, default=None)) + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'False']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default=False)) + specs.addSub(InputData.parameterInputFactory("abs_tolerance", contentType=InputTypes.FloatType, + descr=r"""Controls the convergence of ADMM. Absolute tolerance from iteration $k$ and $k-1$.""", default=1e-06)) + specs.addSub(InputData.parameterInputFactory("rel_tolerance", contentType=InputTypes.FloatType, + descr=r"""Controls the convergence of ADMM. Relative tolerance from iteration $k$ and $k-1$.""", default=0.0001)) + specs.addSub(InputData.parameterInputFactory("max_iterations", contentType=InputTypes.IntegerType, + descr=r"""The maximum number of iterations performed by ADMM, after that the algorithm is stopped.""", default=10000)) + specs.addSub(InputData.parameterInputFactory("rho", contentType=InputTypes.FloatType, + descr=r"""Controls the convergence of ADMM. For a reference on the optimal value for rho see + 10.1109/TAC.2014.2354892 or 10.3182/20120914-2-US-4030.00038.""", default=1)) + specs.addSub(InputData.parameterInputFactory("gamma", contentType=InputTypes.FloatType, + descr=r"""Controls the level of “promotion” assigned to sparse solution. Increasing gamma will + result in an higher number of zero-amplitudes.""", default=10)) + specs.addSub(InputData.parameterInputFactory("verbose", contentType=InputTypes.BoolType, + descr=r"""If False, the information provided by SpDMD (like the number of iterations performed + by ADMM) are not shown.""", default=False)) + specs.addSub(InputData.parameterInputFactory("enforce_zero", contentType=InputTypes.BoolType, + descr=r"""If True the DMD amplitudes which should be set to zero + according to the solution of ADMM are manually set to 0 (since we + solve a sparse linear system to find the optimal vector of DMD amplitudes + very small terms may survive in some cases).""", default=True)) + specs.addSub(InputData.parameterInputFactory("release_memory", contentType=InputTypes.BoolType, + descr=r"""If True the intermediate matrices computed by the algorithm are deleted + after the termination of a call to train.""", default=True)) + specs.addSub(InputData.parameterInputFactory("zero_absolute_tolerance", contentType=InputTypes.FloatType, + descr=r"""Zero absolute tolerance.""", default=1e-12)) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import SpDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'tlsq_rank','rescale_mode', 'sorted_eigs', + 'forward_backward', 'opt', + 'abs_tolerance', 'rel_tolerance','max_iterations', 'rho', 'gamma', + 'verbose', 'enforce_zero', 'release_memory', 'zero_absolute_tolerance']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank' ] = settings.get('svd_rank') + # truncation rank for total least square + self.dmdParams['tlsq_rank'] = settings.get('tlsq_rank') + # If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). + self.dmdParams['forward_backward'] = settings.get('forward_backward') + # abs tolerance + self.dmdParams['abs_tolerance'] = settings.get('abs_tolerance') + # rel tolerance + self.dmdParams['rel_tolerance'] = settings.get('rel_tolerance') + # max num of iterations + self.dmdParams['max_iterations'] = settings.get('max_iterations') + # rho + self.dmdParams['rho'] = settings.get('rho') + # gamma + self.dmdParams['gamma'] = settings.get('gamma') + # verbose? + self.dmdParams['verbose'] = settings.get('verbose') + # enforce_zero? + self.dmdParams['enforce_zero'] = settings.get('enforce_zero') + # release_memory? + self.dmdParams['release_memory'] = settings.get('release_memory') + # zero_absolute_tolerance + self.dmdParams['zero_absolute_tolerance'] = settings.get('zero_absolute_tolerance') + # Rescale mode + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams["rescale_mode"] == 'None': + self.dmdParams["rescale_mode"] = None + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams["sorted_eigs"] == 'False': + self.dmdParams["sorted_eigs"] = False + # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) + self.dmdParams['opt'] = settings.get('opt') + + self._dmdBase = SpDMD + # intialize the model + self.initializeModel(self.dmdParams) diff --git a/ravenframework/SupervisedLearning/DMD/SubspaceDMD.py b/ravenframework/SupervisedLearning/DMD/SubspaceDMD.py new file mode 100644 index 0000000000..6592c196ec --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/SubspaceDMD.py @@ -0,0 +1,131 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Subspace DMD model + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class SubspaceDMD(DMDBase): + """ + Subspace DMD (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(SubspaceDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{SubspaceDMD} ROM (Subspace DMD) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Subspace DMD + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{rescale\_mode}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.IntegerType, + descr=r"""defines the truncation rank to be used for the SVD. + the rank for the truncation; if -1 all the columns of $U_q$ are used, + if svd\_rank is an integer grater than zero it is used as the number + of columns retained from U_q. $svd\_rank=0$ or float values are not supported + """, default=-1)) + specs.addSub(InputData.parameterInputFactory("rescale_mode", contentType=InputTypes.makeEnumType("rescale_mode", "RescaleModeType", + ["auto", "None"]), + descr=r"""Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before + computing its eigendecomposition. None means no rescaling, ‘auto’ means automatic + rescaling using singular values. + """, default="None")) + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", "False"]), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) by magnitude if sorted_eigs=``abs'', + by real part (and then by imaginary part to break ties) if sorted_eigs=``real''. + """, default="False")) + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import SubspaceDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'rescale_mode','sorted_eigs']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # how to rescale + self.dmdParams['rescale_mode'] = settings.get('rescale_mode') + if self.dmdParams['rescale_mode'] == 'None': + self.dmdParams['rescale_mode'] = None + # sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams['sorted_eigs'] == 'False': + self.dmdParams['sorted_eigs'] = False + + self._dmdBase = SubspaceDMD + # intialize the model + self.initializeModel(self.dmdParams) + + diff --git a/ravenframework/SupervisedLearning/DMD/VarProDMD.py b/ravenframework/SupervisedLearning/DMD/VarProDMD.py new file mode 100644 index 0000000000..ec6f540099 --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/VarProDMD.py @@ -0,0 +1,163 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + Created on July 21, 2024 + + @author: Andrea Alfonsi + Forward/Backward Dynamic Mode Decomposition + +""" +#Internal Modules (Lazy Importer)-------------------------------------------------------------------- +from ...utils.importerUtils import importModuleLazy +#Internal Modules (Lazy Importer) End---------------------------------------------------------------- + +#External Modules------------------------------------------------------------------------------------ +pydmd = importModuleLazy("pydmd") +#External Modules End-------------------------------------------------------------------------------- + +#Internal Modules------------------------------------------------------------------------------------ +from ...SupervisedLearning.DMD import DMDBase +from ...utils import InputData, InputTypes +#Internal Modules End-------------------------------------------------------------------------------- + +class VarProDMD(DMDBase): + """ + Variable Projection for DMD. (Parametric) + """ + info = {'problemtype':'regression', 'normalize':False} + + def __init__(self): + """ + Constructor that will appropriately initialize a supervised learning object + @ In, None + @ Out, None + """ + super().__init__() + # local model + self.fitArguments = {'time': None} + + @classmethod + def getInputSpecification(cls): + """ + Method to get a reference to a class that specifies the input data for + class cls. + @ In, cls, the class for which we are retrieving the specification + @ Out, inputSpecification, InputData.ParameterInput, class to use for + specifying input of cls. + """ + specs = super(VarProDMD, cls).getInputSpecification() + + specs.description = r"""The \xmlString{VarProDMD} ROM (Variable Projection for DMD) aimed to construct a time-dependent (or any other monotonic + variable) surrogate model based on Variable Projection for DMD (https://epubs.siam.org/doi/abs/10.1137/M1124176). + This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time + series (or any monotonic-dependent variable) of data, a set of modes each of which is associated + with a fixed oscillation frequency and decay/growth rate is computed + in order to represent the data-set. + In order to use this Reduced Order Model, the \xmlNode{ROM} attribute + \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. + \\ + Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file + via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node + in \xmlNode{OutStream} of type \xmlAttr{Print}): + \begin{itemize} + \item \xmlNode{svd\_rank}, see XML input specifications below + \item \xmlNode{exact}, see XML input specifications below + \item \xmlNode{compression}, see XML input specifications below + \item \xmlNode{sorted\_eigs}, see XML input specifications below + \item \xmlNode{features}, see XML input specifications below + \item \xmlNode{timeScale}, XML node containing the array of the training time steps values + \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping + between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) + \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) + \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) + \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) + \end{itemize}""" + + specs.addSub(InputData.parameterInputFactory("svd_rank", contentType=InputTypes.FloatOrIntType, + descr=r"""defines the truncation rank to be used for the SVD. + Available options are: + \begin{itemize} + \item \textit{-1}, no truncation is performed + \item \textit{0}, optimal rank is internally computed + \item \textit{$>1$}, this rank is going to be used for the truncation + \end{itemize} + If $0.0 < svd_rank < 1.0$, this parameter represents the energy level.The value is used to compute the rank such + as computed rank is the number of the biggest singular values needed to reach the energy identified by + \xmlNode{svd_rank}. + """, default=0)) + specs.addSub(InputData.parameterInputFactory("exact", contentType=InputTypes.BoolType, + descr=r"""True if the exact modes need to be computed (eigenvalues and + eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=False)) + specs.addSub(InputData.parameterInputFactory("compression", contentType=InputTypes.FloatType, + descr=r"""If libary compression $c = 0$, all samples are used. If $0 < c < 1$, the best fitting + $\lfloor \left(1 - c\right)m\rfloor$ samples are selected""", default=False)) + specs.addSub(InputData.parameterInputFactory("sorted_eigs", contentType=InputTypes.makeEnumType("sorted_eigs", "SortedType", + ["real", "abs", 'True', 'False', 'imag']), + descr=r"""Sort eigenvalues (and modes/dynamics accordingly) method. Available options are: + \begin{itemize} + \item \textit{True}, the variance of the absolute values of the complex eigenvalues + $\left(\sqrt{\omega_i \cdot \bar{\omega}_i}\right)$, the variance absolute values + of the real parts $\left|\Re\{{\omega_i}\}\right|$ and the variance of the absolute + values of the imaginary parts $\left|\Im\{{\omega_i}\}\right|$ is computed. The + eigenvalues are then sorted according to the highest variance (from highest to lowest). + \item \textit{False}, no sorting is performed + \item \textit{real}, the eigenvalues are sorted w.r.t. the absolute values of the real + parts of the eigenvalues (from highest to lowest). + \item \textit{imag}, the eigenvalues are sorted w.r.t. the absolute values of the imaginary + parts of the eigenvalues (from highest to lowest). + \item \textit{abs}, the eigenvalues are sorted w.r.t. the magnitude of the eigenvalues + $\left(\sqrt{\omega_i \cdot \bar{\omega}_i}\right)$ (from highest to lowest) + \end{itemize} + """, default='False')) + + + return specs + + def _handleInput(self, paramInput): + """ + Function to handle the common parts of the distribution parameter input. + @ In, paramInput, ParameterInput, the already parsed input. + @ Out, None + """ + import pydmd + from pydmd import VarProDMD + super()._handleInput(paramInput) + settings, notFound = paramInput.findNodesAndExtractValues(['svd_rank', 'exact','compression', 'sorted_eigs']) + # notFound must be empty + assert(not notFound) + # -1 no truncation, 0 optimal rank is computed, >1 truncation rank + # if 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by this float value + self.dmdParams['svd_rank'] = settings.get('svd_rank') + # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) + self.dmdParams['exact' ] = settings.get('exact') + # compression + self.dmdParams['compression'] = settings.get('compression') + # Sorted eigs + self.dmdParams['sorted_eigs'] = settings.get('sorted_eigs') + if self.dmdParams['sorted_eigs'] == 'False': + self.dmdParams['sorted_eigs'] = False + if self.dmdParams['sorted_eigs'] == 'True': + self.dmdParams['sorted_eigs'] = True + + self._dmdBase = VarProDMD + # intialize the model + self.initializeModel(self.dmdParams) + + def _preFitModifications(self): + """ + Method to modify parameters and populate fit argument before fitting + @ In, None + @ Out, None + """ + self.fitArguments['time'] = self.pivotValues.flatten() diff --git a/ravenframework/SupervisedLearning/DMD/__init__.py b/ravenframework/SupervisedLearning/DMD/__init__.py new file mode 100644 index 0000000000..c9f9abd263 --- /dev/null +++ b/ravenframework/SupervisedLearning/DMD/__init__.py @@ -0,0 +1,22 @@ +# Copyright 2017 Battelle Energy Alliance, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + The DMD folder includes different types of DMD based ROMs + that are available via RAVEN + + Created on July 21, 2024 + @author: Andrea Alfonsi +""" +# These lines ensure that we do not have to do something like: +from .DMDBase import DMDBase diff --git a/ravenframework/SupervisedLearning/DynamicModeDecomposition.py b/ravenframework/SupervisedLearning/DynamicModeDecomposition.py deleted file mode 100644 index 3353e10b22..0000000000 --- a/ravenframework/SupervisedLearning/DynamicModeDecomposition.py +++ /dev/null @@ -1,400 +0,0 @@ - -# Copyright 2017 Battelle Energy Alliance, LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" - Created on May 8, 2018 - - @author: alfoa, talbpaul, wangc - Originally from SupervisedLearning.py, split in PR #650 in July 2018 - Base subclass definition for DynamicModeDecomposition ROM (transferred from alfoa in SupervisedLearning) -""" - -#External Modules------------------------------------------------------------------------------------ -import sys -import numpy as np -from scipy import spatial -#External Modules End-------------------------------------------------------------------------------- - -#Internal Modules------------------------------------------------------------------------------------ -from ..utils import mathUtils -from ..utils import InputData, InputTypes -from ..SupervisedLearning import SupervisedLearning -#Internal Modules End-------------------------------------------------------------------------------- - - -class DMD(SupervisedLearning): - """ - This surrogate is aimed to construct a "time-dep" surrogate based on - Dynamic Mode Decomposition method. - Ref. Kutz, Brunton, Brunton, Proctor. Dynamic Mode Decomposition: - Data-Driven Modeling of Complex Systems. SIAM Other Titles in - Applied Mathematics, 2016 - """ - info = {'problemtype':'regression', 'normalize':True} - - @classmethod - def getInputSpecification(cls): - """ - Method to get a reference to a class that specifies the input data for - class cls. - @ In, cls, the class for which we are retrieving the specification - @ Out, inputSpecification, InputData.ParameterInput, class to use for - specifying input of cls. - """ - specs = super().getInputSpecification() - specs.description = r"""The \xmlString{DMD} ROM aimed to construct a time-dependent (or any other monotonic - variable) surrogate model based on Dynamic Mode Decomposition - This surrogate is aimed to perform a ``dimensionality reduction regression'', where, given time - series (or any monotonic-dependent variable) of data, a set of modes each of which is associated - with a fixed oscillation frequency and decay/growth rate is computed - in order to represent the data-set. - In order to use this Reduced Order Model, the \xmlNode{ROM} attribute - \xmlAttr{subType} needs to be set equal to \xmlString{DMD}. - \\ - Once the ROM is trained (\textbf{Step} \xmlNode{RomTrainer}), its parameters/coefficients can be exported into an XML file - via an \xmlNode{OutStream} of type \xmlAttr{Print}. The following variable/parameters can be exported (i.e. \xmlNode{what} node - in \xmlNode{OutStream} of type \xmlAttr{Print}): - \begin{itemize} - \item \xmlNode{rankSVD}, see XML input specifications below - \item \xmlNode{energyRankSVD}, see XML input specifications below - \item \xmlNode{rankTLSQ}, see XML input specifications below - \item \xmlNode{exactModes}, see XML input specifications below - \item \xmlNode{optimized}, see XML input specifications below - \item \xmlNode{features}, see XML input specifications below - \item \xmlNode{timeScale}, XML node containing the array of the training time steps values - \item \xmlNode{dmdTimeScale}, XML node containing the array of time scale in the DMD space (can be used as mapping - between the \xmlNode{timeScale} and \xmlNode{dmdTimeScale}) - \item \xmlNode{eigs}, XML node containing the eigenvalues (imaginary and real part) - \item \xmlNode{amplitudes}, XML node containing the amplitudes (imaginary and real part) - \item \xmlNode{modes}, XML node containing the dynamic modes (imaginary and real part) - \end{itemize}""" - specs.addSub(InputData.parameterInputFactory("dmdType", contentType=InputTypes.makeEnumType("dmd", "dmdType", ["dmd", "hodmd"]), - descr=r"""the type of Dynamic Mode Decomposition to apply.Available are: - \begin{itemize} - \item \textit{dmd}, for classical DMD - \item \textit{hodmd}, for high order DMD. - \end{itemize}""", default="dmd")) - specs.addSub(InputData.parameterInputFactory("pivotParameter", contentType=InputTypes.StringType, - descr=r"""defines the pivot variable (e.g., time) that represents the - independent monotonic variable""", default="time")) - specs.addSub(InputData.parameterInputFactory("rankSVD", contentType=InputTypes.IntegerType, - descr=r"""defines the truncation rank to be used for the SVD. - Available options are: - \begin{itemize} - \item \textit{-1}, no truncation is performed - \item \textit{0}, optimal rank is internally computed - \item \textit{>1}, this rank is going to be used for the truncation - \end{itemize}""", default=None)) - specs.addSub(InputData.parameterInputFactory("energyRankSVD", contentType=InputTypes.FloatType, - descr=r"""energy level ($0.0 < float < 1.0$) used to compute the rank such - as computed rank is the number of the biggest singular values needed to reach the energy identified by - \xmlNode{energyRankSVD}. This node has always priority over \xmlNode{rankSVD}""", default=None)) - specs.addSub(InputData.parameterInputFactory("rankTLSQ", contentType=InputTypes.IntegerType, - descr=r"""$int > 0$ that defines the truncation rank to be used for the total - least square problem. If not inputted, no truncation is applied""", default=None)) - specs.addSub(InputData.parameterInputFactory("exactModes", contentType=InputTypes.BoolType, - descr=r"""True if the exact modes need to be computed (eigenvalues and - eigenvectors), otherwise the projected ones (using the left-singular matrix after SVD).""", default=True)) - specs.addSub(InputData.parameterInputFactory("optimized", contentType=InputTypes.FloatType, - descr=r"""True if the amplitudes need to be computed minimizing the error - between the modes and all the time-steps or False, if only the 1st timestep only needs to be considered""", default=False)) - return specs - - def __init__(self): - """ - DMD constructor - @ In, None - @ Out, None - """ - super().__init__() - self.dmdParams = {} # dmd settings container - self.printTag = 'DMD' # print tag - self._dynamicHandling = True # This ROM is able to manage the time-series on its own. No need for special treatment outside - self.pivotParameterID = None # pivot parameter - # variables filled up in the training stages - self._amplitudes = {} # {'target1': vector of amplitudes,'target2':vector of amplitudes, etc.} - self._eigs = {} # {'target1': vector of eigenvalues,'target2':vector of eigenvalues, etc.} - self._modes = {} # {'target1': matrix of dynamic modes,'target2':matrix of dynamic modes, etc.} - self.__Atilde = {} # {'target1': matrix of lowrank operator from the SVD,'target2':matrix of lowrank operator from the SVD, etc.} - self.pivotValues = None # pivot values (e.g. time) - self.KDTreeFinder = None # kdtree weighting model - self.timeScales = {} # time-scales (training and dmd). {'training' and 'dmd':{t0:float,'dt':float,'intervals':int}} - self.featureVals = None # feature values - - def _handleInput(self, paramInput): - """ - Function to handle the common parts of the model parameter input. - @ In, paramInput, InputData.ParameterInput, the already parsed input. - @ Out, None - """ - super()._handleInput(paramInput) - settings, notFound = paramInput.findNodesAndExtractValues(['pivotParameter','rankSVD', 'energyRankSVD', - 'rankTLSQ','exactModes','optimized', 'dmdType']) - # notFound must be empty - assert(not notFound) - self.pivotParameterID = settings.get("pivotParameter","time") # pivot parameter - self.dmdParams['rankSVD' ] = settings.get('rankSVD',None) # -1 no truncation, 0 optimal rank is computed, >1 truncation rank - self.dmdParams['energyRankSVD' ] = settings.get('energyRankSVD',None) # 0.0 < float < 1.0, computed rank is the number of the biggest sv needed to reach the energy identified by "energyRankSVD" - self.dmdParams['rankTLSQ' ] = settings.get('rankTLSQ',None) # truncation rank for total least square - self.dmdParams['exactModes' ] = settings.get('exactModes',True) # True if the exact modes need to be computed (eigs and eigvs), otherwise the projected ones (using the left-singular matrix) - self.dmdParams['optimized' ] = settings.get('optimized',False) # amplitudes computed minimizing the error between the mods and all the timesteps (True) or 1st timestep only (False) - self.dmdParams['dmdType' ] = settings.get('dmdType','dmd') # the dmd type to be applied. Currently we support dmd and hdmd (high order dmd) - - # some checks - if self.dmdParams['rankSVD'] is not None and self.dmdParams['energyRankSVD'] is not None: - self.raiseAWarning('Both "rankSVD" and "energyRankSVD" have been inputted. "energyRankSVD" is predominant and will be used!') - # check if the pivotParameter is among the targetValues - if self.pivotParameterID not in self.target: - self.raiseAnError(IOError,"The pivotParameter "+self.pivotParameterID+" must be part of the Target space!") - if len(self.target) < 2: - self.raiseAnError(IOError,"At least one Target in addition to the pivotParameter "+self.pivotParameterID+" must be part of the Target space!") - - def __setstate__(self,state): - """ - Initializes the DMD with the data contained in state - @ In, state, dict, it contains all the information needed by the ROM to be initialized - @ Out, None - """ - self.__dict__.update(state) - self.KDTreeFinder = spatial.KDTree(self.featureVals) - - def _localNormalizeData(self,values,names,feat): - """ - Overwrites default normalization procedure. - @ In, values, unused - @ In, names, unused - @ In, feat, feature to normalize - @ Out, None - """ - self.muAndSigmaFeatures[feat] = (0.0,1.0) - - ####### - def _getTimeScale(self,dmd=True): - """ - Get the ts of the dmd (if dmd = True) or training (if dmd = False) reconstructed time scale. - @ In, dmd, bool, optional, True if dmd time scale needs to be returned, othewise training one - @ Out, timeScale, numpy.array, the dmd or training reconstructed time scale - """ - timeScaleInfo = self.timeScales['dmd'] if dmd else self.timeScales['training'] - timeScale = np.arange(timeScaleInfo['t0'], (timeScaleInfo['intervals']+1)*timeScaleInfo['dt'], timeScaleInfo['dt']) - return timeScale - - def __getTimeEvolution(self, target): - """ - Get the time evolution of each mode - @ In, target, str, the target for which mode evolution needs to be retrieved for - @ Out, timeEvol, numpy.ndarray, the matrix that contains all the time evolution (by row) - """ - omega = np.log(self._eigs[target]) / self.timeScales['training']['dt'] - van = np.exp(np.multiply(*np.meshgrid(omega, self._getTimeScale()))) - timeEvol = (van * self._amplitudes[target]).T - return timeEvol - - def _reconstructData(self, target): - """ - Retrieve the reconstructed data - @ In, target, str, the target for which the data needs to be reconstructed - @ Out, data, numpy.ndarray, the matrix (nsamples,n_time_steps) containing the reconstructed data - """ - data = self._modes[target].dot(self.__getTimeEvolution(target)) - return data - - def _train(self,featureVals,targetVals): - """ - Perform training on input database stored in featureVals. - @ In, featureVals, numpy.ndarray, shape=[n_timeStep, n_dimensions], an array of input data # Not use for ARMA training - @ In, targetVals, numpy.ndarray, shape = [n_timeStep, n_dimensions], an array of time series data - """ - self.featureVals = featureVals - self.KDTreeFinder = spatial.KDTree(featureVals) - pivotParamIndex = self.target.index(self.pivotParameterID) - self.pivotValues = targetVals[0,:,pivotParamIndex] - ts = len(self.pivotValues) - for target in list(set(self.target) - set([self.pivotParameterID])): - targetParamIndex = self.target.index(target) - snaps = targetVals[:,:,targetParamIndex] - # if number of features (i.e. samples) > number of snapshots, we apply the high order DMD or HODMD has been requested - imposedHODMD = False - if self.dmdParams['dmdType'] == 'hodmd' or snaps.shape[0] < snaps.shape[1]: - v = max(snaps.shape[1] - snaps.shape[0],2) - imposedHODMD = True - snaps = np.concatenate([snaps[:, i:snaps.shape[1] - v + i + 1] for i in range(v) ], axis=0) - # overlap snaps - X, Y = snaps[:, :-1], snaps[:, 1:] - if self.dmdParams['rankTLSQ'] is not None: - X, Y = mathUtils.computeTruncatedTotalLeastSquare(X, Y, self.dmdParams['rankTLSQ']) - rank = self.dmdParams['energyRankSVD'] if self.dmdParams['energyRankSVD'] is not None else (self.dmdParams['rankSVD'] if self.dmdParams['rankSVD'] is not None else -1) - U, s, V = mathUtils.computeTruncatedSingularValueDecomposition(X, rank) - # lowrank operator from the SVD of matrices X and Y - self.__Atilde[target] = U.T.conj().dot(Y).dot(V) * np.reciprocal(s) - self._eigs[target], self._modes[target] = mathUtils.computeEigenvaluesAndVectorsFromLowRankOperator(self.__Atilde[target], - Y, U, s, V, - self.dmdParams['exactModes']) - if imposedHODMD: - self._modes[target] = self._modes[target][:targetVals[:,:,targetParamIndex].shape[0],:] - self._amplitudes[target] = mathUtils.computeAmplitudeCoefficients(self._modes[target], - targetVals[:,:,targetParamIndex], - self._eigs[target], - self.dmdParams['optimized']) - # Default timesteps (even if the time history is not equally spaced in time, we "trick" the dmd to think it). - self.timeScales = dict.fromkeys( ['training','dmd'],{'t0': 0, 'intervals': ts - 1, 'dt': 1}) - - def __evaluateLocal__(self,featureVals): - """ - This method is used to inquire the DMD to evaluate (after normalization that in - this case is not performed) a set of points contained in featureVals. - a KDTree algorithm is used to construct a weighting function for the reconstructed space - @ In, featureVals, numpy.ndarray, shape= (n_requests, n_dimensions), an array of input data - @ Out, returnEvaluation , dict, dictionary of values for each target (and pivot parameter) - """ - returnEvaluation = {self.pivotParameterID:self.pivotValues} - for target in list(set(self.target) - set([self.pivotParameterID])): - reconstructData = self._reconstructData(target).real - # find the nearest data and compute weights - if len(reconstructData) > 1: - weights, indexes = self.KDTreeFinder.query(featureVals, k=min(2**len(self.features),len(reconstructData))) - # if 0 (perfect match), assign minimum possible distance - weights[weights == 0] = sys.float_info.min - weights =1./weights - # normalize to 1 - weights = weights/weights.sum() - for point in range(len(weights)): - returnEvaluation[target] = np.sum ((weights[point,:]*reconstructData[indexes[point,:]].T) , axis=1) - else: - returnEvaluation[target] = reconstructData[0] - - return returnEvaluation - - def writeXMLPreamble(self, writeTo, targets = None): - """ - Specific local method for printing anything desired to xml file at the begin of the print. - @ In, writeTo, xmlUtils.StaticXmlElement instance, element to write to - @ In, targets, list, list of targets for whom information should be written. - @ Out, None - """ - # add description - super().writeXMLPreamble(writeTo, targets) - description = ' This XML file contains the main information of the DMD ROM.' - description += ' If "modes" (dynamic modes), "eigs" (eigenvalues), "amplitudes" (mode amplitudes)' - description += ' and "dmdTimeScale" (internal dmd time scale) are dumped, the method' - description += ' is explained in P.J. Schmid, Dynamic mode decomposition' - description += ' of numerical and experimental data, Journal of Fluid Mechanics 656.1 (2010), 5-28' - writeTo.addScalar('ROM',"description",description) - - def writeXML(self, writeTo, targets = None, skip = None): - """ - Adds requested entries to XML node. - @ In, writeTo, xmlTuils.StaticXmlElement, element to write to - @ In, targets, list, optional, list of targets for whom information should be written - @ In, skip, list, optional, list of targets to skip - @ Out, None - """ - if not self.amITrained: - self.raiseAnError(RuntimeError,'ROM is not yet trained!') - if skip is None: - skip = [] - - # check what - what = ['exactModes','optimized','dmdType','features','timeScale','eigs','amplitudes','modes','dmdTimeScale'] - if self.dmdParams['rankTLSQ'] is not None: - what.append('rankTLSQ') - what.append('energyRankSVD' if self.dmdParams['energyRankSVD'] is not None else 'rankSVD') - if targets is None: - readWhat = what - else: - readWhat = targets - for s in skip: - if s in readWhat: - readWhat.remove(s) - if not set(readWhat) <= set(what): - self.raiseAnError(IOError, "The following variables specified in node are not recognized: "+ ",".join(np.setdiff1d(readWhat, what).tolist()) ) - else: - what = readWhat - - target = self.target[-1] - toAdd = ['exactModes','optimized','dmdType'] - if self.dmdParams['rankTLSQ'] is not None: - toAdd.append('rankTLSQ') - toAdd.append('energyRankSVD' if self.dmdParams['energyRankSVD'] is not None else 'rankSVD') - self.dmdParams['rankSVD'] = self.dmdParams['rankSVD'] if self.dmdParams['rankSVD'] is not None else -1 - - for add in toAdd: - if add in what : - writeTo.addScalar(target,add,self.dmdParams[add]) - targNode = writeTo._findTarget(writeTo.getRoot(), target) - if "features" in what: - writeTo.addScalar(target,"features",' '.join(self.features)) - if "timeScale" in what: - writeTo.addScalar(target,"timeScale",' '.join(['%.6e' % elm for elm in self.pivotValues.ravel()])) - if "dmdTimeScale" in what: - writeTo.addScalar(target,"dmdTimeScale",' '.join(['%.6e' % elm for elm in self._getTimeScale()])) - if "eigs" in what: - eigsReal = " ".join(['%.6e' % self._eigs[target][indx].real for indx in - range(len(self._eigs[target]))]) - writeTo.addScalar("eigs","real", eigsReal, root=targNode) - eigsImag = " ".join(['%.6e' % self._eigs[target][indx].imag for indx in - range(len(self._eigs[target]))]) - writeTo.addScalar("eigs","imaginary", eigsImag, root=targNode) - if "amplitudes" in what: - ampsReal = " ".join(['%.6e' % self._amplitudes[target][indx].real for indx in - range(len(self._amplitudes[target]))]) - writeTo.addScalar("amplitudes","real", ampsReal, root=targNode) - ampsImag = " ".join(['%.6e' % self._amplitudes[target][indx].imag for indx in - range(len(self._amplitudes[target]))]) - writeTo.addScalar("amplitudes","imaginary", ampsImag, root=targNode) - if "modes" in what: - for smp in range(len(self._modes[target])): - valDict = {'real': ' '.join([ '%.6e' % elm for elm in self._modes[target][smp,:].real]), - 'imaginary':' '.join([ '%.6e' % elm for elm in self._modes[target][smp,:].imag])} - attributeDict = {self.features[index]:'%.6e' % self.featureVals[smp,index] for index in range(len(self.features))} - writeTo.addVector("modes","realization",valDict, root=targNode, attrs=attributeDict) - - def __confidenceLocal__(self,featureVals): - """ - The confidence associate with a set of requested evaluations - @ In, featureVals, numpy.ndarray, shape= (n_requests, n_dimensions), an array of input data - @ Out, None - """ - pass - - def __resetLocal__(self,featureVals): - """ - After this method the ROM should be described only by the initial parameter settings - @ In, featureVals, numpy.ndarray, shape= (n_samples, n_dimensions), an array of input data (training data) - @ Out, None - """ - self.amITrained = False - self._amplitudes = {} - self._eigs = {} - self._modes = {} - self.__Atilde = {} - self.pivotValues = None - self.KDTreeFinder = None - self.featureVals = None - - def __returnInitialParametersLocal__(self): - """ - This method returns the initial parameters of the SM - @ In, None - @ Out, self.dmdParams, dict, the dict of the SM settings - """ - return self.dmdParams - - def __returnCurrentSettingLocal__(self): - """ - This method is used to pass the set of parameters of the ROM that can change during simulation - @ In, None - @ Out, self.dmdParams, dict, the dict of the SM settings - """ - return self.dmdParams diff --git a/ravenframework/SupervisedLearning/Factory.py b/ravenframework/SupervisedLearning/Factory.py index 04f217610c..ec08ab3439 100644 --- a/ravenframework/SupervisedLearning/Factory.py +++ b/ravenframework/SupervisedLearning/Factory.py @@ -30,8 +30,23 @@ from .SyntheticHistory import SyntheticHistory from .pickledROM import pickledROM from .PolyExponential import PolyExponential -from .DynamicModeDecomposition import DMD -from .DynamicModeDecompositionControl import DMDC + +## Dynamic Mode Decomposition-based methods +from .DMD.DynamicModeDecompositionControl import DMDC +from .DMD.DMD import DMD +from .DMD.CDMD import CDMD +from .DMD.EDMD import EDMD +from .DMD.FbDMD import FbDMD +from .DMD.HankelDMD import HankelDMD +from .DMD.HAVOK import HAVOK +from .DMD.HODMD import HODMD +from .DMD.PiDMD import PiDMD +from .DMD.RDMD import RDMD +from .DMD.SpDMD import SpDMD +from .DMD.BOPDMD import BOPDMD +from .DMD.SubspaceDMD import SubspaceDMD +from .DMD.VarProDMD import VarProDMD + from .ARMA import ARMA from .ROMCollection import Segments, Clusters, Interpolated diff --git a/ravenframework/SupervisedLearning/__init__.py b/ravenframework/SupervisedLearning/__init__.py index 2bf71e38de..31a1d61b9f 100644 --- a/ravenframework/SupervisedLearning/__init__.py +++ b/ravenframework/SupervisedLearning/__init__.py @@ -17,6 +17,7 @@ from .SupervisedLearning import SupervisedLearning from .ScikitLearn.ScikitLearnBase import ScikitLearnBase +from .DMD.DMDBase import DMDBase from .KerasBase import KerasBase from .KerasRegression import KerasRegression from .KerasClassifier import KerasClassifier diff --git a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe.xml b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe.xml index fe4f3f25a7..141e00b379 100644 --- a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe.xml +++ b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe.xml @@ -7,7 +7,6 @@ This XML file contains the main information of the DMDC ROM. The method is explained in: Proctor, Joshua L., Steven L. Brunton, and J. Nathan Kutz. "Dynamic mode decomposition with control." SIAM Journal on Applied Dynamical Systems 15, no. 1 (2016): 142-161. - None -1 pulse_SES.y pulse_BOP.y pulse_TES.y BOP.HPT.state_a.d TES.hot_tank.der(V) diff --git a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_apply_clustering.xml b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_apply_clustering.xml index b89e4fbf26..d2282f9dde 100644 --- a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_apply_clustering.xml +++ b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_apply_clustering.xml @@ -7,7 +7,6 @@ This XML file contains the main information of the DMDC ROM. The method is explained in: Proctor, Joshua L., Steven L. Brunton, and J. Nathan Kutz. "Dynamic mode decomposition with control." SIAM Journal on Applied Dynamical Systems 15, no. 1 (2016): 142-161. - None -1 pulse_SES.y pulse_BOP.y pulse_TES.y SES.fuelCtrl.VCE TES.hot_tank.der(V) diff --git a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_only_output.xml b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_only_output.xml index 54e25cd153..ff11c233fc 100644 --- a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_only_output.xml +++ b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_only_output.xml @@ -7,7 +7,6 @@ This XML file contains the main information of the DMDC ROM. The method is explained in: Proctor, Joshua L., Steven L. Brunton, and J. Nathan Kutz. "Dynamic mode decomposition with control." SIAM Journal on Applied Dynamical Systems 15, no. 1 (2016): 142-161. - None -1 pulse_SES.y pulse_BOP.y pulse_TES.y BOP.HPT.dew_out.d TES.hot_tank.der(V) diff --git a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_subgroup.xml b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_subgroup.xml index ec60ee2694..83fb9dc3d8 100644 --- a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_subgroup.xml +++ b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_rfe_score_subgroup.xml @@ -7,7 +7,6 @@ This XML file contains the main information of the DMDC ROM. The method is explained in: Proctor, Joshua L., Steven L. Brunton, and J. Nathan Kutz. "Dynamic mode decomposition with control." SIAM Journal on Applied Dynamical Systems 15, no. 1 (2016): 142-161. - None -1 pulse_SES.y pulse_BOP.y pulse_TES.y BOP.sensor_T1.y BOP.HPT.state_a.d BOP.HPT.dew_out.d TES.hot_tank.der(V) diff --git a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_variance_threshold.xml b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_variance_threshold.xml index c14bc4a04d..c8b56c18f3 100644 --- a/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_variance_threshold.xml +++ b/tests/framework/ROM/FeatureSelection/gold/data/dmdc_stats_variance_threshold.xml @@ -7,7 +7,6 @@ This XML file contains the main information of the DMDC ROM. The method is explained in: Proctor, Joshua L., Steven L. Brunton, and J. Nathan Kutz. "Dynamic mode decomposition with control." SIAM Journal on Applied Dynamical Systems 15, no. 1 (2016): 142-161. - None -1 pulse_SES.y pulse_BOP.y pulse_TES.y BOP.sensor_T1.y BOP.HPT.state_a.d BOP.HPT.sat_in.Tsat BOP.HPT.dew_out.d BOP.tee.medium.T_degC SES.fuelCtrl.VCE TES.cold_tank.V TES.discharge_pump.medium.u diff --git a/tests/framework/ROM/FeatureSelection/tests b/tests/framework/ROM/FeatureSelection/tests index f7992f95f0..252a4b6a9f 100644 --- a/tests/framework/ROM/FeatureSelection/tests +++ b/tests/framework/ROM/FeatureSelection/tests @@ -45,6 +45,7 @@ type = 'RavenFramework' input = 'dmdc_rfe_and_score_cross_corr.xml' output = 'data/dmdc_stats_rfe_score_subgroup_cross_correlation.xml' + max_time = 400 [../] [./StaticSklearnVarianceThreshold] type = 'RavenFramework' diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/BOPDMD/outputBOPDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/BOPDMD/outputBOPDMD/outputDMD_0.csv new file mode 100644 index 0000000000..4efbeee883 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/BOPDMD/outputBOPDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1595.20210768,0.00531734025657 +0.01,524.596977306,0.00174865655736 +0.02,397.38580103,0.00132461931127 +0.05,313.647721022,0.00104549238328 +0.075,285.926098128,0.000953086975412 +0.1,267.061378317,0.000890204577253 +0.2,210.699615639,0.000702332038612 +0.3,166.892296882,0.000556307645564 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/CompressedDMD/outputCompressedDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/CompressedDMD/outputCompressedDMD/outputDMD_0.csv new file mode 100644 index 0000000000..862ee6d651 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/CompressedDMD/outputCompressedDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1595.0621246,0.00531687364633 +0.01,515.872369107,0.00171957453059 +0.02,399.840746658,0.0013328024632 +0.05,331.25782585,0.00110419273158 +0.075,286.1451816,0.00095381725364 +0.1,252.0737606,0.000840245852493 +0.2,224.032179004,0.000746773915637 +0.3,199.889322705,0.000666297729525 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/ForwardBackwardDMD/outputForwardBackwardDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/ForwardBackwardDMD/outputForwardBackwardDMD/outputDMD_0.csv new file mode 100644 index 0000000000..0eb4c724cb --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/ForwardBackwardDMD/outputForwardBackwardDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1593.74161646,0.00531247195261 +0.01,619.855248192,0.00206618412087 +0.02,398.578266171,0.00132859419499 +0.05,257.614856597,0.000858716172127 +0.075,164.651696387,0.000548838977392 +0.1,97.6756066032,0.000325585349077 +0.2,77.3330268285,0.000257776751133 +0.3,164.599805109,0.000548666006469 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/HAVOK/outputHAVOKDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/HAVOK/outputHAVOKDMD/outputDMD_0.csv new file mode 100644 index 0000000000..21e5b6f241 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/HAVOK/outputHAVOKDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1596.24219871,0.00532080722661 +0.01,508.409439139,0.00169469809784 +0.02,421.964047214,0.00140654679697 +0.05,338.173180971,0.00112724391487 +0.075,279.436776363,0.00093145590328 +0.1,179.553008904,0.000598510018158 +0.2,120.230297173,0.000400767649528 +0.3,81.1463727778,0.000270487904052 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/HODMD/outputHODMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/HODMD/outputHODMD/outputDMD_0.csv new file mode 100644 index 0000000000..535288109f --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/HODMD/outputHODMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1596.32698236,0.00532108983878 +0.01,687.552621129,0.00229184202631 +0.02,296.135197892,0.000987117307304 +0.05,127.548136296,0.000425160446135 +0.075,54.9361480444,0.000183120489956 +0.1,23.6615010583,7.88716686762e-05 +0.2,10.191224763,3.39707485561e-05 +0.3,4.38945364937,1.46315118829e-05 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/HODMDgpr/outputHODMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/HODMDgpr/outputHODMD/outputDMD_0.csv new file mode 100644 index 0000000000..f082c8cf06 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/HODMDgpr/outputHODMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1692.41091034,0.00564136959253 +0.01,728.936847079,0.00242978944349 +0.02,313.959762244,0.00104653252067 +0.05,135.225339072,0.000450751121564 +0.075,58.2427894469,0.000194142627752 +0.1,25.0857017319,8.36190041633e-05 +0.2,10.8046410098,3.60154693392e-05 +0.3,4.65365763324,1.55121918122e-05 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/HODMDrbf/outputHODMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/HODMDrbf/outputHODMD/outputDMD_0.csv new file mode 100644 index 0000000000..86dc4fbe08 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/HODMDrbf/outputHODMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1604.32629598,0.00534775421699 +0.01,690.997998614,0.00230332661771 +0.02,297.619153464,0.000992063825782 +0.05,128.187289523,0.000427290956853 +0.075,55.2114371811,0.000184038120394 +0.1,23.7800706056,7.92669004928e-05 +0.2,10.2422937507,3.41409785118e-05 +0.3,4.41144952912,1.47048314807e-05 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/HankelDMD/outputHankelDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/HankelDMD/outputHankelDMD/outputDMD_0.csv new file mode 100644 index 0000000000..99f23826a8 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/HankelDMD/outputHankelDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1596.26653186,0.00532088833709 +0.01,510.106676319,0.001700355555 +0.02,397.903665514,0.00132634552618 +0.05,330.687040882,0.00110229011506 +0.075,286.124092766,0.000953746957527 +0.1,252.273862329,0.000840912858241 +0.2,224.3207074,0.000747735676939 +0.3,200.211355594,0.000667371172466 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/HighOrderDMD/outputDMD/outputDMDHighOrder_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/HighOrderDMD/outputDMD/outputDMDHighOrder_0.csv deleted file mode 100644 index a8191bbc3b..0000000000 --- a/tests/framework/ROM/TimeSeries/DMD/gold/HighOrderDMD/outputDMD/outputDMDHighOrder_0.csv +++ /dev/null @@ -1,9 +0,0 @@ -t,decay_heat,decay_heat_pu -0.0,1650.98615875,0.00550328467491 -0.01,1393.28669109,0.00464430436646 -0.02,1150.66523793,0.00383556347978 -0.05,950.382107433,0.00316795086465 -0.075,784.959646371,0.00261654085535 -0.1,648.330437541,0.0021611086638 -0.2,535.48275785,0.00178494849304 -0.3,442.277220612,0.00147426234329 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/KernalizedDMD/outputKernalizedDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/KernalizedDMD/outputKernalizedDMD/outputDMD_0.csv new file mode 100644 index 0000000000..9c78b5d570 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/KernalizedDMD/outputKernalizedDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1596.26653186,0.00532088833709 +0.01,510.106676319,0.001700355555 +0.02,397.903665512,0.00132634552617 +0.05,330.687040894,0.0011022901151 +0.075,286.124092787,0.000953746957596 +0.1,252.273862357,0.000840912858338 +0.2,224.320707436,0.000747735677059 +0.3,200.211355636,0.000667371172606 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/PiDMD/outputPiDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/PiDMD/outputPiDMD/outputDMD_0.csv new file mode 100644 index 0000000000..555014cd50 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/PiDMD/outputPiDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1596.26899389,0.00532089654387 +0.01,687.419849634,0.00229139945467 +0.02,297.571119712,0.000991903713281 +0.05,128.800199708,0.000429333990761 +0.075,55.7443059041,0.000185814349437 +0.1,24.1236955527,8.04123169613e-05 +0.2,10.4387287024,3.47957616716e-05 +0.3,4.51661305059,1.50553765455e-05 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/PickledHighOrderDMD/outputDMD/outputDMDHighOrder_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/PickledHighOrderDMD/outputDMD/outputDMDHighOrder_0.csv index a8191bbc3b..535288109f 100644 --- a/tests/framework/ROM/TimeSeries/DMD/gold/PickledHighOrderDMD/outputDMD/outputDMDHighOrder_0.csv +++ b/tests/framework/ROM/TimeSeries/DMD/gold/PickledHighOrderDMD/outputDMD/outputDMDHighOrder_0.csv @@ -1,9 +1,9 @@ t,decay_heat,decay_heat_pu -0.0,1650.98615875,0.00550328467491 -0.01,1393.28669109,0.00464430436646 -0.02,1150.66523793,0.00383556347978 -0.05,950.382107433,0.00316795086465 -0.075,784.959646371,0.00261654085535 -0.1,648.330437541,0.0021611086638 -0.2,535.48275785,0.00178494849304 -0.3,442.277220612,0.00147426234329 +0.0,1596.32698236,0.00532108983878 +0.01,687.552621129,0.00229184202631 +0.02,296.135197892,0.000987117307304 +0.05,127.548136296,0.000425160446135 +0.075,54.9361480444,0.000183120489956 +0.1,23.6615010583,7.88716686762e-05 +0.2,10.191224763,3.39707485561e-05 +0.3,4.38945364937,1.46315118829e-05 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/RDMD/outputRDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/RDMD/outputRDMD/outputDMD_0.csv new file mode 100644 index 0000000000..93496965c6 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/RDMD/outputRDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1595.08197565,0.0053169398165 +0.01,515.142647701,0.00171714212595 +0.02,399.075570083,0.00133025187467 +0.05,330.491021868,0.00110163671835 +0.075,285.464439897,0.000951548114674 +0.1,251.495276096,0.000838317570849 +0.2,223.550694727,0.000745168968079 +0.3,199.493712068,0.000664979027426 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/SpDMD/outputSpDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/SpDMD/outputSpDMD/outputDMD_0.csv new file mode 100644 index 0000000000..9af3b395d3 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/SpDMD/outputSpDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1595.00925792,0.00531669742407 +0.01,516.887532175,0.00172295840742 +0.02,395.104368347,0.00131701453581 +0.05,324.842421611,0.00108280805119 +0.075,279.594250945,0.000931980818543 +0.1,245.924530002,0.000819748417561 +0.2,218.441389978,0.000728137952578 +0.3,194.87259382,0.00064957530023 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/SubspaceDMD/outputSubspaceDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/SubspaceDMD/outputSubspaceDMD/outputDMD_0.csv new file mode 100644 index 0000000000..34c30110f6 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/SubspaceDMD/outputSubspaceDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1595.3134217,0.00531771130329 +0.01,5003.21913326,0.0166773967898 +0.02,3400.57138601,0.0113352377352 +0.05,2986.33382228,0.00995444588264 +0.075,4854.73770634,0.0161824587096 +0.1,3611.20293001,0.0120373428683 +0.2,3909.16732748,0.0130305575074 +0.3,3930.9483816,0.0131031610198 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMD_0.csv new file mode 100644 index 0000000000..763b111d9a --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1595.08197565,0.0053169398165 +0.01,515.142647701,0.00171714212595 +0.02,399.075570082,0.00133025187467 +0.05,330.491021867,0.00110163671835 +0.075,285.464439897,0.000951548114672 +0.1,251.495276095,0.000838317570847 +0.2,223.550694727,0.000745168968078 +0.3,199.493712067,0.000664979027424 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMDtraditional_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMDtraditional_0.csv deleted file mode 100644 index f996e591d0..0000000000 --- a/tests/framework/ROM/TimeSeries/DMD/gold/TraditionalDMD/outputDMD/outputDMDtraditional_0.csv +++ /dev/null @@ -1,9 +0,0 @@ -t,decay_heat,decay_heat_pu -0.0,1653.93746097,0.00551311433678 -0.01,534.182033659,0.00178068468374 -0.02,413.778684873,0.00137931439747 -0.05,342.646822779,0.00114220092104 -0.075,295.955522812,0.000986555753721 -0.1,260.734500481,0.000869145465481 -0.2,231.761948328,0.000772564221071 -0.3,206.820792777,0.000689421800673 diff --git a/tests/framework/ROM/TimeSeries/DMD/gold/VarProDMD/outputVarProDMD/outputDMD_0.csv b/tests/framework/ROM/TimeSeries/DMD/gold/VarProDMD/outputVarProDMD/outputDMD_0.csv new file mode 100644 index 0000000000..eb4ca56264 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/gold/VarProDMD/outputVarProDMD/outputDMD_0.csv @@ -0,0 +1,9 @@ +t,decay_heat,decay_heat_pu +0.0,1596.25763338,0.00532085867552 +0.01,508.241356382,0.00169413782199 +0.02,421.930727526,0.00140643573135 +0.05,318.06313461,0.00106021042829 +0.075,276.177771132,0.000920592552721 +0.1,252.292712716,0.000840975692864 +0.2,209.495249534,0.000698317485004 +0.3,183.262271361,0.000610874226112 diff --git a/tests/framework/ROM/TimeSeries/DMD/test_bopdmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_bopdmd_pydmd.xml new file mode 100644 index 0000000000..ef24a238bf --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_bopdmd_pydmd.xml @@ -0,0 +1,140 @@ + + + + framework/ROM/TimeSeries/DMD.BOPDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.BOPDMD + + This test is aimed to check the mechanics of the DMD ROM using the BOPDMD. + + + + + BOPDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + False + True + 0 + 0.6 + auto + stable + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_compressed_dmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_compressed_dmd_pydmd.xml new file mode 100644 index 0000000000..d55d84a76f --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_compressed_dmd_pydmd.xml @@ -0,0 +1,140 @@ + + + + framework/ROM/TimeSeries/DMD.compressedDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.CDMD + + This test is aimed to check the mechanics of the DMD ROM using the compressed SVD-based + algorithm. + In addition, it tests the capability for the user to export the ROM info in an XML output + file. + + + + + CompressedDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + sample + 20201986 + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_forward_backward_dmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_forward_backward_dmd_pydmd.xml new file mode 100644 index 0000000000..3cba4a130e --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_forward_backward_dmd_pydmd.xml @@ -0,0 +1,137 @@ + + + + framework/ROM/TimeSeries/DMD.forwardBackwardDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.FbDMD + + This test is aimed to check the mechanics of the DMD ROM using the forward backward DMD algorithm. + + + + + ForwardBackwardDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + True + True + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_hankel_dmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_hankel_dmd_pydmd.xml new file mode 100644 index 0000000000..46b1ea70cd --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_hankel_dmd_pydmd.xml @@ -0,0 +1,140 @@ + + + + framework/ROM/TimeSeries/DMD.hankelDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.HenkelDMD + + This test is aimed to check the mechanics of the DMD ROM using the HANKEL variation of the DMD. + + + + + + HankelDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + False + 1 + False + first + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_havok_dmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_havok_dmd_pydmd.xml new file mode 100644 index 0000000000..fa6f90ddb5 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_havok_dmd_pydmd.xml @@ -0,0 +1,140 @@ + + + + framework/ROM/TimeSeries/DMD.havokDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.HAVOK + + This test is aimed to check the mechanics of the DMD ROM using the HAVOK variation of the DMD. + + + + + + HAVOK + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 3 + 1 + 1 + False + True + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd.xml new file mode 100644 index 0000000000..424e0b895b --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd.xml @@ -0,0 +1,139 @@ + + + + framework/ROM/TimeSeries/DMD.HODMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.HODMD + + This test is aimed to check the mechanics of the DMD ROM using the High Order DMD. + + + + + HODMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + False + 1 + False + mean + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_gpr_settings.xml b/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_gpr_settings.xml new file mode 100644 index 0000000000..e3ae10fb47 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_gpr_settings.xml @@ -0,0 +1,145 @@ + + + + framework/ROM/TimeSeries/DMD.HODMDgpr + alfoa + 2024-09-02 + SupervisedLearning.DMD.HODMD + + This test is aimed to check the mechanics of the DMD ROM using the High Order DMD and GPR approximation + with input settings. + + + + + HODMDgpr + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + False + 1 + False + mean + GPR + + 1 + True + + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_rbf_settings.xml b/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_rbf_settings.xml new file mode 100644 index 0000000000..d1ba013982 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_hodmd_pydmd_with_rbf_settings.xml @@ -0,0 +1,145 @@ + + + + framework/ROM/TimeSeries/DMD.HODMDrbf + alfoa + 2024-09-02 + SupervisedLearning.DMD.HODMD + + This test is aimed to check the mechanics of the DMD ROM using the High Order DMD and RBF approximation + with input settings. + + + + + HODMDrbf + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 0 + False + 1 + False + mean + RBF + + thin_plate_spline + 0 + + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_kernelized_dmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_kernelized_dmd_pydmd.xml new file mode 100644 index 0000000000..b4bd967a88 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_kernelized_dmd_pydmd.xml @@ -0,0 +1,136 @@ + + + + framework/ROM/TimeSeries/DMD.kernalizedDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.EDMD + + This test is aimed to check the mechanics of the DMD ROM using the Kernalized DMD approach. + + + + + KernalizedDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 3 + 7 + linear + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_pickle_dmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_pickle_dmd.xml index 44249fb73f..c24289f240 100644 --- a/tests/framework/ROM/TimeSeries/DMD/test_pickle_dmd.xml +++ b/tests/framework/ROM/TimeSeries/DMD/test_pickle_dmd.xml @@ -4,14 +4,15 @@ framework/ROM/TimeSeries/DMD.PickleDMD alfoa - 2018-06-04 - SupervisedLearning.DynamicModeDecomposition + 2024-07-26 + SupervisedLearning.DMD.HODMD This test is aimed to check that the DMD-based surrogate models can be serialized and used in a working calculation flow. Adding this test description. + Modified test to link to new implementation of DMD. @@ -26,7 +27,7 @@ ../../PolyExponential/data/decay_heat.csv - ../HighOrderDMD/ROMpk + ../HODMD/ROMpk diff --git a/tests/framework/ROM/TimeSeries/DMD/test_pidmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_pidmd_pydmd.xml new file mode 100644 index 0000000000..f32abd51e6 --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_pidmd_pydmd.xml @@ -0,0 +1,139 @@ + + + + framework/ROM/TimeSeries/DMD.PiDMD + alfoa + 2024-07-26 + SupervisedLearning.PiDMD + + This test is aimed to check the mechanics of the DMD ROM using the Physics-based DMD approach. + + + + + PiDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + False + BCCB + 1,9 + True + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_high_order_dmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_rdmd_pydmd.xml similarity index 83% rename from tests/framework/ROM/TimeSeries/DMD/test_high_order_dmd.xml rename to tests/framework/ROM/TimeSeries/DMD/test_rdmd_pydmd.xml index ff08967b68..f8f3d69aae 100644 --- a/tests/framework/ROM/TimeSeries/DMD/test_high_order_dmd.xml +++ b/tests/framework/ROM/TimeSeries/DMD/test_rdmd_pydmd.xml @@ -1,22 +1,18 @@ - framework/ROM/TimeSeries/DMD.HighOrderDMD + framework/ROM/TimeSeries/DMD.randomizedDMD alfoa - 2018-04-25 + 2024-07-26 SupervisedLearning.DynamicModeDecomposition - This test is aimed to check the mechanics of the High Order DMD ROM using the standard SVD-based - algorithm + This test is aimed to check the mechanics of the DMD ROM using the Randomized DMD approach. - - moving from ROM-file to ROM-dataobject - Adding this test description. - + - HighOrderDMD + RDMD readIn, DMDTrain, @@ -61,13 +57,17 @@ - + t,decay_heat,decay_heat_pu enrichment,burnup t - 0 - 7 - hodmd + svd + 0 + 0 + 7 + 20021986 + 5 + 2 @@ -97,13 +97,13 @@ synDataDMD rom_stats - outputDMDHighOrder + outputDMD ROMCoefficientsXML - + csv synDataDMD @@ -134,5 +134,6 @@ + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_spdmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_spdmd_pydmd.xml new file mode 100644 index 0000000000..eae823ed0c --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_spdmd_pydmd.xml @@ -0,0 +1,136 @@ + + + + framework/ROM/TimeSeries/DMD.SpDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.SpDMD + + This test is aimed to check the mechanics of the DMD ROM using Sparsity-Promoting Dynamic Mode Decomposition. + Promotes solutions having an high number of amplitudes set to zero (i.e. sparse solutions). + + + + + SpDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + 7 + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_subspacedmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_subspacedmd_pydmd.xml new file mode 100644 index 0000000000..62e9ec503a --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_subspacedmd_pydmd.xml @@ -0,0 +1,137 @@ + + + + framework/ROM/TimeSeries/DMD.SubspaceDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.SubspaceDMD + + This test is aimed to check the mechanics of the DMD ROM using the Subspace + dynamic mode decomposition for stochastic Koopman analysis. + + + + + SubspaceDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + -1 + None + False + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/test_traditional_dmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_traditional_dmd_pydmd.xml similarity index 90% rename from tests/framework/ROM/TimeSeries/DMD/test_traditional_dmd.xml rename to tests/framework/ROM/TimeSeries/DMD/test_traditional_dmd_pydmd.xml index 0abfec4e22..c1ce162e44 100644 --- a/tests/framework/ROM/TimeSeries/DMD/test_traditional_dmd.xml +++ b/tests/framework/ROM/TimeSeries/DMD/test_traditional_dmd_pydmd.xml @@ -3,8 +3,8 @@ framework/ROM/TimeSeries/DMD.traditionalDMD alfoa - 2018-04-25 - SupervisedLearning.DynamicModeDecomposition + 2024-07-26 + SupervisedLearning.DMD.DMD This test is aimed to check the mechanics of the DMD ROM using the standard SVD-based algorithm. @@ -15,6 +15,7 @@ Adding this test description. This test is a requirement test now. moving from ROM-files to ROM-dataobjects + Modified test to point to new pydmd-based DMD model R-F-5 @@ -69,9 +70,10 @@ t,decay_heat,decay_heat_pu enrichment,burnup t - 0 - 7 - dmd + svd + 0 + 0 + 7 @@ -101,13 +103,13 @@ synDataDMD rom_stats - outputDMDtraditional + outputDMD ROMCoefficientsXML - + csv synDataDMD diff --git a/tests/framework/ROM/TimeSeries/DMD/test_varprodmd_pydmd.xml b/tests/framework/ROM/TimeSeries/DMD/test_varprodmd_pydmd.xml new file mode 100644 index 0000000000..68685a723f --- /dev/null +++ b/tests/framework/ROM/TimeSeries/DMD/test_varprodmd_pydmd.xml @@ -0,0 +1,134 @@ + + + + framework/ROM/TimeSeries/DMD.VarProDMD + alfoa + 2024-07-26 + SupervisedLearning.DMD.VarProdDMD + + This test is aimed to check the mechanics of the DMD ROM using the Variable Projection for DMD. + + + + + VarProDMD + + readIn, + DMDTrain, + pickleRom, + stats, + runDMD, + writeOut + + 1 + + + + + ../../PolyExponential/data/decay_heat.csv + ROMpk + + + + + 3.4 + 9.9 + + + 16.501 + 26.402 + + + + + + + 4 + 20021986 + + + enrichmentDist + + + burnupDist + + + + + + + t,decay_heat,decay_heat_pu + enrichment,burnup + t + svd + 0 + 0 + + + + + + rawDataFile + rawData + + + rawData + DMDrom + + + DMDrom + ROMpk + + + DMDrom + rom_stats + + + dataIn + DMDrom + mcSampler + synDataDMD + + + synDataDMD + rom_stats + outputDMD + ROMCoefficientsXML + + + + + + csv + synDataDMD + + + csv + rom_stats + + + + + + enrichment,burnup + OutputPlaceHolder + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + enrichment,burnup + decay_heat,decay_heat_pu + + t + + + + + + + diff --git a/tests/framework/ROM/TimeSeries/DMD/tests b/tests/framework/ROM/TimeSeries/DMD/tests index 805ea0ce67..a5e92b118e 100644 --- a/tests/framework/ROM/TimeSeries/DMD/tests +++ b/tests/framework/ROM/TimeSeries/DMD/tests @@ -1,17 +1,105 @@ [Tests] - [./TraditionalDMD] + [./traditionalDMD] type = 'RavenFramework' - input = 'test_traditional_dmd.xml' - output = 'TraditionalDMD/ROMpk TraditionalDMD/outputDMD/outputDMDtraditional.xml TraditionalDMD/ROMCoefficientsXML.xml' - csv = 'TraditionalDMD/outputDMD/outputDMDtraditional_0.csv' + input = 'test_traditional_dmd_pydmd.xml' + output = 'TraditionalDMD/ROMpk TraditionalDMD/outputDMD/outputDMD.xml TraditionalDMD/ROMCoefficientsXML.xml' + csv = 'TraditionalDMD/outputDMD/outputDMD_0.csv' rel_err = 0.0001 [../] - [./HighOrderDMD] + [./BOPDMD] type = 'RavenFramework' - input = 'test_high_order_dmd.xml' - output = 'HighOrderDMD/ROMpk HighOrderDMD/outputDMD/outputDMDHighOrder.xml HighOrderDMD/ROMCoefficientsXML.xml' - csv = 'HighOrderDMD/outputDMD/outputDMDHighOrder_0.csv' + input = 'test_bopdmd_pydmd.xml' + output = 'BOPDMD/ROMpk BOPDMD/outputBOPDMD/outputDMD.xml BOPDMD/ROMCoefficientsXML.xml' + csv = 'BOPDMD/outputBOPDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./compressedDMD] + type = 'RavenFramework' + input = 'test_compressed_dmd_pydmd.xml' + output = 'CompressedDMD/ROMpk CompressedDMD/outputCompressedDMD/outputDMD.xml CompressedDMD/ROMCoefficientsXML.xml' + csv = 'CompressedDMD/outputCompressedDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./forwardBackwardDMD] + type = 'RavenFramework' + input = 'test_forward_backward_dmd_pydmd.xml' + output = 'ForwardBackwardDMD/ROMpk ForwardBackwardDMD/outputForwardBackwardDMD/outputDMD.xml ForwardBackwardDMD/ROMCoefficientsXML.xml' + csv = 'ForwardBackwardDMD/outputForwardBackwardDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./hankelDMD] + type = 'RavenFramework' + input = 'test_hankel_dmd_pydmd.xml' + output = 'HankelDMD/ROMpk HankelDMD/outputHankelDMD/outputDMD.xml HankelDMD/ROMCoefficientsXML.xml' + csv = 'HankelDMD/outputHankelDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./havokDMD] + type = 'RavenFramework' + input = 'test_havok_dmd_pydmd.xml' + output = 'HAVOK/ROMpk HAVOK/outputHAVOKDMD/outputDMD.xml HAVOK/ROMCoefficientsXML.xml' + csv = 'HAVOK/outputHAVOKDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./HODMD] + type = 'RavenFramework' + input = 'test_hodmd_pydmd.xml' + output = 'HODMD/ROMpk HODMD/outputHODMD/outputDMD.xml HODMD/ROMCoefficientsXML.xml' + csv = 'HODMD/outputHODMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./kernalizedDMD] + type = 'RavenFramework' + input = 'test_kernelized_dmd_pydmd.xml' + output = 'KernalizedDMD/ROMpk KernalizedDMD/outputKernalizedDMD/outputDMD.xml KernalizedDMD/ROMCoefficientsXML.xml' + csv = 'KernalizedDMD/outputKernalizedDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./PiDMD] + type = 'RavenFramework' + input = 'test_pidmd_pydmd.xml' + output = 'PiDMD/ROMpk PiDMD/outputPiDMD/outputDMD.xml PiDMD/ROMCoefficientsXML.xml' + csv = 'PiDMD/outputPiDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./randomizedDMD] + type = 'RavenFramework' + input = 'test_rdmd_pydmd.xml' + output = 'RDMD/ROMpk RDMD/outputRDMD/outputDMD.xml RDMD/ROMCoefficientsXML.xml' + csv = 'RDMD/outputRDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./SpDMD] + type = 'RavenFramework' + input = 'test_spdmd_pydmd.xml' + output = 'SpDMD/ROMpk SpDMD/outputSpDMD/outputDMD.xml SpDMD/ROMCoefficientsXML.xml' + csv = 'SpDMD/outputSpDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./SubspaceDMD] + type = 'RavenFramework' + input = 'test_subspacedmd_pydmd.xml' + output = 'SubspaceDMD/ROMpk SubspaceDMD/outputSubspaceDMD/outputDMD.xml SubspaceDMD/ROMCoefficientsXML.xml' + csv = 'SubspaceDMD/outputSubspaceDMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./VarProDMD] + type = 'RavenFramework' + input = 'test_varprodmd_pydmd.xml' + output = 'VarProDMD/ROMpk VarProDMD/outputVarProDMD/outputDMD.xml VarProDMD/ROMCoefficientsXML.xml' + csv = 'VarProDMD/outputVarProDMD/outputDMD_0.csv' rel_err = 0.0001 [../] @@ -21,7 +109,7 @@ output = 'PickledHighOrderDMD/outputDMD/outputDMDHighOrder.xml' csv = 'PickledHighOrderDMD/outputDMD/outputDMDHighOrder_0.csv' rel_err = 0.0001 - prereq = HighOrderDMD + prereq = HODMD [../] [./ParameterizedDMDC] @@ -48,4 +136,21 @@ rel_err = 0.001 [../] + [./HODMDrbf] + type = 'RavenFramework' + input = 'test_hodmd_pydmd_with_rbf_settings.xml' + output = 'HODMDrbf/ROMpk HODMDrbf/outputHODMD/outputDMD.xml HODMDrbf/ROMCoefficientsXML.xml' + csv = 'HODMDrbf/outputHODMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + [./HODMDgpr] + type = 'RavenFramework' + input = 'test_hodmd_pydmd_with_gpr_settings.xml' + output = 'HODMDgpr/ROMpk HODMDgpr/outputHODMD/outputDMD.xml HODMDgpr/ROMCoefficientsXML.xml' + csv = 'HODMDgpr/outputHODMD/outputDMD_0.csv' + rel_err = 0.0001 + [../] + + []