Skip to content

Commit 5129293

Browse files
authored
Feat/linear damping (#702)
1 parent aee45ca commit 5129293

3 files changed

Lines changed: 398 additions & 369 deletions

File tree

fsrs4anki_optimizer.ipynb

Lines changed: 372 additions & 357 deletions
Large diffs are not rendered by default.

fsrs4anki_scheduler.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// FSRS4Anki v5.0.2 Scheduler Qt6
1+
// FSRS4Anki v5.2.0 Scheduler Qt6
22
set_version();
33
// The latest version will be released on https://github.com/open-spaced-repetition/fsrs4anki/releases/latest
44

@@ -8,7 +8,8 @@ const deckParams = [
88
{
99
// Default parameters of FSRS4Anki for global
1010
"deckName": "global config for FSRS4Anki",
11-
"w": [0.41, 1.18, 3.04, 15.24, 7.14, 0.64, 1.00, 0.06, 1.65, 0.17, 1.11, 2.02, 0.09, 0.30, 2.12, 0.24, 2.94, 0.48, 0.64],
11+
"w": [0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 0.0046, 1.54575, 0.1192, 1.01925,
12+
1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621],
1213
// The above parameters can be optimized via FSRS4Anki optimizer.
1314
// For details about the parameters, please see: https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Algorithm
1415
// User's custom parameters for global
@@ -20,15 +21,17 @@ const deckParams = [
2021
{
2122
// Example 1: User's custom parameters for this deck and its sub-decks.
2223
"deckName": "MainDeck1",
23-
"w": [0.41, 1.18, 3.04, 15.24, 7.14, 0.64, 1.00, 0.06, 1.65, 0.17, 1.11, 2.02, 0.09, 0.30, 2.12, 0.24, 2.94, 0.48, 0.64],
24+
"w": [0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 0.0046, 1.54575, 0.1192, 1.01925,
25+
1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621],
2426
"requestRetention": 0.9,
2527
"maximumInterval": 36500,
2628
},
2729
{
2830
// Example 2: User's custom parameters for this deck and its sub-decks.
2931
// Don't omit any keys.
3032
"deckName": "MainDeck2::SubDeck::SubSubDeck",
31-
"w": [0.41, 1.18, 3.04, 15.24, 7.14, 0.64, 1.00, 0.06, 1.65, 0.17, 1.11, 2.02, 0.09, 0.30, 2.12, 0.24, 2.94, 0.48, 0.64],
33+
"w": [0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 0.0046, 1.54575, 0.1192, 1.01925,
34+
1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621],
3235
"requestRetention": 0.9,
3336
"maximumInterval": 36500,
3437
}
@@ -199,8 +202,12 @@ function next_interval(stability) {
199202
const new_interval = apply_fuzz(stability / FACTOR * (Math.pow(requestRetention, 1 / DECAY) - 1));
200203
return Math.min(Math.max(Math.round(new_interval), 1), maximumInterval);
201204
}
205+
function linear_damping(delta_d, old_d) {
206+
return delta_d * (10 - old_d) / 9
207+
}
202208
function next_difficulty(d, rating) {
203-
let next_d = d - w[6] * (ratings[rating] - 3);
209+
let delta_d = - w[6] * (ratings[rating] - 3);
210+
let next_d = d + linear_damping(delta_d, d);
204211
return constrain_difficulty(mean_reversion(init_difficulty("easy"), next_d));
205212
}
206213
function mean_reversion(init, current) {
@@ -308,7 +315,7 @@ function is_empty() {
308315
return !customData.again.d | !customData.again.s | !customData.hard.d | !customData.hard.s | !customData.good.d | !customData.good.s | !customData.easy.d | !customData.easy.s;
309316
}
310317
function set_version() {
311-
const version = "v5.0.2";
318+
const version = "v5.2.0";
312319
customData.again.v = version;
313320
customData.hard.v = version;
314321
customData.good.v = version;

fsrs4anki_scheduler_qt5.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// FSRS4Anki v5.0.2 Scheduler Qt5
1+
// FSRS4Anki v5.2.0 Scheduler Qt5
22
set_version();
33
// The latest version will be released on https://github.com/open-spaced-repetition/fsrs4anki/releases/latest
44

@@ -8,7 +8,8 @@ const deckParams = [
88
{
99
// Default parameters of FSRS4Anki for global
1010
"deckName": "global config for FSRS4Anki",
11-
"w": [0.41, 1.18, 3.04, 15.24, 7.14, 0.64, 1.00, 0.06, 1.65, 0.17, 1.11, 2.02, 0.09, 0.30, 2.12, 0.24, 2.94, 0.48, 0.64],
11+
"w": [0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 0.0046, 1.54575, 0.1192, 1.01925,
12+
1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621],
1213
// The above parameters can be optimized via FSRS4Anki optimizer.
1314
// For details about the parameters, please see: https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Algorithm
1415
// User's custom parameters for global
@@ -20,15 +21,17 @@ const deckParams = [
2021
{
2122
// Example 1: User's custom parameters for this deck and its sub-decks.
2223
"deckName": "MainDeck1",
23-
"w": [0.41, 1.18, 3.04, 15.24, 7.14, 0.64, 1.00, 0.06, 1.65, 0.17, 1.11, 2.02, 0.09, 0.30, 2.12, 0.24, 2.94, 0.48, 0.64],
24+
"w": [0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 0.0046, 1.54575, 0.1192, 1.01925,
25+
1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621],
2426
"requestRetention": 0.9,
2527
"maximumInterval": 36500,
2628
},
2729
{
2830
// Example 2: User's custom parameters for this deck and its sub-decks.
2931
// Don't omit any keys.
3032
"deckName": "MainDeck2::SubDeck::SubSubDeck",
31-
"w": [0.41, 1.18, 3.04, 15.24, 7.14, 0.64, 1.00, 0.06, 1.65, 0.17, 1.11, 2.02, 0.09, 0.30, 2.12, 0.24, 2.94, 0.48, 0.64],
33+
"w": [0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 0.0046, 1.54575, 0.1192, 1.01925,
34+
1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621],
3235
"requestRetention": 0.9,
3336
"maximumInterval": 36500,
3437
}
@@ -205,8 +208,12 @@ function next_interval(stability) {
205208
const new_interval = apply_fuzz(stability / FACTOR * (Math.pow(requestRetention, 1 / DECAY) - 1));
206209
return Math.min(Math.max(Math.round(new_interval), 1), maximumInterval);
207210
}
211+
function linear_damping(delta_d, old_d) {
212+
return delta_d * (10 - old_d) / 9;
213+
}
208214
function next_difficulty(d, rating) {
209-
let next_d = d - w[6] * (ratings[rating] - 3);
215+
let delta_d = - w[6] * (ratings[rating] - 3);
216+
let next_d = d + linear_damping(delta_d, d);
210217
return constrain_difficulty(mean_reversion(init_difficulty("easy"), next_d));
211218
}
212219
function mean_reversion(init, current) {
@@ -317,7 +324,7 @@ function is_empty() {
317324
return !customData.again.d | !customData.again.s | !customData.hard.d | !customData.hard.s | !customData.good.d | !customData.good.s | !customData.easy.d | !customData.easy.s;
318325
}
319326
function set_version() {
320-
const version = "v5.0.2";
327+
const version = "v5.2.0";
321328
customData.again.v = version;
322329
customData.hard.v = version;
323330
customData.good.v = version;

0 commit comments

Comments
 (0)