@@ -72,6 +72,9 @@ class BOPDMDOperator(DMDOperator):
7272 function that will be applied to the computed eigenvalues at each step
7373 of the variable projection routine.
7474 :type eig_constraints: set(str) or function
75+ :param mode_prox: Optional proximal operator function to apply to the DMD
76+ modes at every iteration of variable projection routine.
77+ :type mode_prox: function
7578 :param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
7679 at which to terminate the fit. Default is -1, no stopping condition.
7780 :type bag_maxfail: int
@@ -124,6 +127,7 @@ def __init__(
124127 trial_size ,
125128 eig_sort ,
126129 eig_constraints ,
130+ mode_prox ,
127131 bag_maxfail ,
128132 init_lambda = 1.0 ,
129133 maxlam = 52 ,
@@ -143,6 +147,7 @@ def __init__(
143147 self ._trial_size = trial_size
144148 self ._eig_sort = eig_sort
145149 self ._eig_constraints = eig_constraints
150+ self ._mode_prox = mode_prox
146151 self ._bag_maxfail = bag_maxfail
147152 self ._varpro_opts = [
148153 init_lambda ,
@@ -497,9 +502,15 @@ def compute_residual(alpha):
497502 which is used as an error indicator.
498503 """
499504 Phi_matrix = Phi (alpha , t )
505+
506+ # Update B matrix.
500507 B = np .linalg .lstsq (Phi_matrix , H , rcond = None )[0 ]
508+ if self ._mode_prox is not None :
509+ B = self ._mode_prox (B )
510+
501511 residual = H - Phi_matrix .dot (B )
502512 error = 0.5 * np .linalg .norm (residual ) ** 2
513+
503514 return B , residual , error
504515
505516 # Define M, IS, and IA.
@@ -918,6 +929,9 @@ class BOPDMD(DMDBase):
918929 function that will be applied to the computed eigenvalues at each step
919930 of the variable projection routine.
920931 :type eig_constraints: set(str) or function
932+ :param mode_prox: Optional proximal operator function to apply to the DMD
933+ modes at every iteration of variable projection routine.
934+ :type mode_prox: function
921935 :param bag_maxfail: Number of consecutive non-converged trials of BOP-DMD
922936 at which to terminate the fit. Default is -1, no stopping condition.
923937 :type bag_maxfail: int
@@ -942,6 +956,7 @@ def __init__(
942956 trial_size = 0.6 ,
943957 eig_sort = "auto" ,
944958 eig_constraints = None ,
959+ mode_prox = None ,
945960 bag_maxfail = - 1 ,
946961 varpro_opts_dict = None ,
947962 ):
@@ -978,6 +993,7 @@ def __init__(
978993 raise TypeError ("eig_constraints must be a set or a function." )
979994 self ._check_eig_constraints (eig_constraints )
980995 self ._eig_constraints = eig_constraints
996+ self ._mode_prox = mode_prox
981997
982998 self ._snapshots_holder = None
983999 self ._time = None
@@ -1330,6 +1346,7 @@ def fit(self, X, t):
13301346 self ._trial_size ,
13311347 self ._eig_sort ,
13321348 self ._eig_constraints ,
1349+ self ._mode_prox ,
13331350 self ._bag_maxfail ,
13341351 ** self ._varpro_opts_dict ,
13351352 )
0 commit comments