From c9517e8f3248c3340a951bb395108fffeb27d5da Mon Sep 17 00:00:00 2001 From: user1823 <92206575+user1823@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:01:40 +0530 Subject: [PATCH] Update fsrs_optimizer.py --- src/fsrs_optimizer/fsrs_optimizer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_optimizer.py b/src/fsrs_optimizer/fsrs_optimizer.py index 3ac9e51..fd4216d 100644 --- a/src/fsrs_optimizer/fsrs_optimizer.py +++ b/src/fsrs_optimizer/fsrs_optimizer.py @@ -107,7 +107,10 @@ def init_d(self, rating: Tensor) -> Tensor: def next_d(self, state: Tensor, rating: Tensor) -> Tensor: delta_d = - self.w[6] * (rating - 3) - new_d = state[:, 1] + delta_d * (1 - (state[:, 1]/10)) # linear dampening + if delta_d > 0: + new_d = state[:, 1] + delta_d * (1 - (state[:, 1]/10)) + if delta_d < 0: + new_d = state[:, 1] + delta_d * (1 - ((11 - state[:, 1])/10)) new_d = self.mean_reversion(self.init_d(4), new_d) return new_d