Added: Loss aversion

This commit is contained in:
Luc Mcgrady 2025-06-19 23:56:03 +01:00
parent 4e31a33cce
commit 0e0e3b9238
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 17 additions and 4 deletions

View file

@ -391,7 +391,8 @@ message FsrsReview {
enum CMRRTarget {
memorized = 0;
stability = 1;
loss_aversion = 1;
stability = 2;
};
message SimulateFsrsReviewRequest {

View file

@ -25,7 +25,7 @@ impl Collection {
};
}
let target = req
let target_type = req
.target
.map(TryInto::try_into)
.transpose()
@ -33,8 +33,9 @@ impl Collection {
let days_to_simulate = req.days_to_simulate as f32;
let target = match target {
let target = match target_type {
Some(CmrrTarget::Memorized) => None,
Some(CmrrTarget::LossAversion) => None,
Some(CmrrTarget::Stability) => {
wrap!(move |SimulationResult {
cards,
@ -57,7 +58,14 @@ impl Collection {
if req.days_to_simulate == 0 {
invalid_input!("no days to simulate")
}
let (config, cards) = self.simulate_request_to_config(&req)?;
let (mut config, cards) = self.simulate_request_to_config(&req)?;
if target_type == Some(CmrrTarget::LossAversion) {
config.relearning_step_transitions[0][0] *= 2.;
config.relearning_step_transitions[1][0] *= 2.;
config.relearning_step_transitions[2][0] *= 2.;
}
Ok(fsrs
.optimal_retention(
&config,

View file

@ -206,6 +206,10 @@ export function CMRRTargetChoices(): Choice<CMRRTarget>[] {
label: "Memorized (Default)",
value: CMRRTarget.memorized,
},
{
label: "Memorized (Double cost)",
values: CMRRTarget.loss_aversion,
},
{
label: "Stability (Experimental)",
value: CMRRTarget.stability,