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" 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 {