Skip to content

Commit

Permalink
Fix/update FSRS-4.5 param into FSRS-5 properly
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Oct 4, 2024
1 parent 165b29b commit 726183c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ pub(crate) fn check_and_fill_parameters(parameters: &Parameters) -> Result<Vec<f
0 => DEFAULT_PARAMETERS.to_vec(),
17 => {
let mut parameters = parameters.to_vec();
parameters[4] = parameters[5].mul_add(2.0, parameters[4]);
parameters[5] = parameters[5].mul_add(3.0, 1.0).ln() / 3.0;
parameters.extend_from_slice(&[0.0, 0.0]);
parameters
}
Expand All @@ -274,6 +276,22 @@ mod tests {
assert_eq!(model.w.val().to_data(), Data::from(DEFAULT_PARAMETERS))
}

#[test]
fn convert_parameters() {
let fsrs4dot5_param = vec![
0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05, 0.34, 1.26,
0.29, 2.61,
];
let fsrs5_param = check_and_fill_parameters(&fsrs4dot5_param).unwrap();
assert_eq!(
fsrs5_param,
vec![
0.4, 0.6, 2.4, 5.8, 6.81, 0.44675013, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05,
0.34, 1.26, 0.29, 2.61, 0.0, 0.0,
]
)
}

#[test]
fn power_forgetting_curve() {
let device = NdArrayDevice::Cpu;
Expand Down

0 comments on commit 726183c

Please sign in to comment.