Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49eab29

Browse files
committed
This reverts commit 72efcf2.
1 parent 72efcf2 commit 49eab29

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ git = "https://github.com/ankitects/linkcheck.git"
3333
rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca"
3434

3535
[workspace.dependencies.fsrs]
36-
# version = "4.1.1"
37-
git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
38-
branch = "Refactor/expected_workload_via_dp"
36+
version = "4.1.1"
37+
# git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
3938
# rev = "a7f7efc10f0a26b14ee348cc7402155685f2a24f"
4039
# path = "../open-spaced-repetition/fsrs-rs"
4140

rslib/src/deckconfig/service.rs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,43 @@ impl crate::services::DeckConfigService for Collection {
103103
&mut self,
104104
input: anki_proto::deck_config::GetRetentionWorkloadRequest,
105105
) -> Result<anki_proto::deck_config::GetRetentionWorkloadResponse> {
106+
const LEARN_SPAN: usize = 365;
107+
const TERMINATION_PROB: f32 = 1e-5;
108+
// the default values are from https://github.com/open-spaced-repetition/Anki-button-usage/blob/881009015c2a85ac911021d76d0aacb124849937/analysis.ipynb
109+
const DEFAULT_LEARN_COST: f32 = 19.4698;
110+
const DEFAULT_PASS_COST: f32 = 7.8454;
111+
const DEFAULT_FAIL_COST: f32 = 23.185;
112+
const DEFAULT_INITIAL_PASS_RATE: f32 = 0.7645;
113+
106114
let guard =
107115
self.search_cards_into_table(&input.search, crate::search::SortMode::NoOrder)?;
108-
109-
let revlogs = guard
110-
.col
111-
.storage
112-
.get_revlog_entries_for_searched_cards_in_card_order()?;
116+
let costs = guard.col.storage.get_costs_for_retention()?;
117+
118+
fn smoothing(obs: f32, default: f32, count: u32) -> f32 {
119+
let alpha = count as f32 / (50.0 + count as f32);
120+
obs * alpha + default * (1.0 - alpha)
121+
}
113122

114-
let config = guard.col.get_optimal_retention_parameters(revlogs)?;
123+
let cost_success = smoothing(
124+
costs.average_pass_time_ms / 1000.0,
125+
DEFAULT_PASS_COST,
126+
costs.pass_count,
127+
);
128+
let cost_failure = smoothing(
129+
costs.average_fail_time_ms / 1000.0,
130+
DEFAULT_FAIL_COST,
131+
costs.fail_count,
132+
);
133+
let cost_learn = smoothing(
134+
costs.average_learn_time_ms / 1000.0,
135+
DEFAULT_LEARN_COST,
136+
costs.learn_count,
137+
);
138+
let initial_pass_rate = smoothing(
139+
costs.initial_pass_rate,
140+
DEFAULT_INITIAL_PASS_RATE,
141+
costs.pass_count,
142+
);
115143

116144
let costs = (70u32..=99u32)
117145
.map(|dr| {
@@ -120,7 +148,12 @@ impl crate::services::DeckConfigService for Collection {
120148
fsrs::expected_workload(
121149
&input.w,
122150
dr as f32 / 100.,
123-
&config
151+
LEARN_SPAN,
152+
cost_success,
153+
cost_failure,
154+
cost_learn,
155+
initial_pass_rate,
156+
TERMINATION_PROB,
124157
)?,
125158
))
126159
})

0 commit comments

Comments
 (0)