diff --git a/pysindy/optimizers/ssr.py b/pysindy/optimizers/ssr.py index 2270b07a..9308298f 100644 --- a/pysindy/optimizers/ssr.py +++ b/pysindy/optimizers/ssr.py @@ -194,8 +194,10 @@ def _reduce(self, x, y): " ... {: >10} ... {: >10}".format(*row) ) - self.history_ = [] - self.err_history_ = [] + self.history_ = [coef] + self.err_history_ = [ + np.sum((y - x @ coef.T) ** 2) + l0_penalty * np.count_nonzero(coef) + ] for k in range(self.max_iter): for i in range(n_targets): if self.criteria == "coefficient_value": diff --git a/test/test_optimizers/test_optimizers.py b/test/test_optimizers/test_optimizers.py index 0145f988..94746ba7 100644 --- a/test/test_optimizers/test_optimizers.py +++ b/test/test_optimizers/test_optimizers.py @@ -79,6 +79,8 @@ def _align_optimizer_and_1dfeatures( if isinstance(opt, TrappingSR3): opt = TrappingSR3(_n_tgts=1, _include_bias=False) features = np.hstack([features, features]) + elif isinstance(opt, SSR): + features = np.hstack([features, features]) else: features = features return opt, features