From f652361df6154b12a7190f897128f44c1292ea55 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Mon, 16 Dec 2024 20:00:04 +0800 Subject: [PATCH 1/2] Fix/Simulator Failure: min > max --- src/optimal_retention.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/optimal_retention.rs b/src/optimal_retention.rs index 5de3007..55a2cc5 100644 --- a/src/optimal_retention.rs +++ b/src/optimal_retention.rs @@ -82,8 +82,11 @@ fn stability_after_success(w: &[f32], s: f32, r: f32, d: f32, rating: usize) -> } fn stability_after_failure(w: &[f32], s: f32, r: f32, d: f32) -> f32 { - (w[11] * d.powf(-w[12]) * ((s + 1.0).powf(w[13]) - 1.0) * f32::exp((1.0 - r) * w[14])) - .clamp(S_MIN, s / (w[17] * w[18]).exp()) + let new_s_min = s / (w[17] * w[18]).exp(); + let new_s = + (w[11] * d.powf(-w[12]) * ((s + 1.0).powf(w[13]) - 1.0) * f32::exp((1.0 - r) * w[14])) + .min(new_s_min); + new_s.clamp(S_MIN, S_MAX) } fn stability_short_term(w: &[f32], s: f32, rating_offset: f32, session_len: f32) -> f32 { From cfaaaea36d2d808120f4e6f149a84f6e346f70fd Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Mon, 16 Dec 2024 20:02:47 +0800 Subject: [PATCH 2/2] bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00e9c03..7b442c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1077,7 +1077,7 @@ dependencies = [ [[package]] name = "fsrs" -version = "1.4.4" +version = "1.4.5" dependencies = [ "burn", "chrono", diff --git a/Cargo.toml b/Cargo.toml index fcb20e9..f006891 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fsrs" -version = "1.4.4" +version = "1.4.5" authors = ["Open Spaced Repetition"] categories = ["algorithms", "science"] edition = "2021"