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

Skip to content

Commit 72efcf2

Browse files
committed
1 parent 8fb3d0b commit 72efcf2

File tree

3 files changed

+12
-45
lines changed

3 files changed

+12
-45
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ 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"
36+
# version = "4.1.1"
37+
git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
38+
branch = "Refactor/expected_workload_via_dp"
3839
# rev = "a7f7efc10f0a26b14ee348cc7402155685f2a24f"
3940
# path = "../open-spaced-repetition/fsrs-rs"
4041

rslib/src/deckconfig/service.rs

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -103,43 +103,15 @@ 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-
114106
let guard =
115107
self.search_cards_into_table(&input.search, crate::search::SortMode::NoOrder)?;
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-
}
108+
109+
let revlogs = guard
110+
.col
111+
.storage
112+
.get_revlog_entries_for_searched_cards_in_card_order()?;
122113

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-
);
114+
let config = guard.col.get_optimal_retention_parameters(revlogs)?;
143115

144116
let costs = (70u32..=99u32)
145117
.map(|dr| {
@@ -148,12 +120,7 @@ impl crate::services::DeckConfigService for Collection {
148120
fsrs::expected_workload(
149121
&input.w,
150122
dr as f32 / 100.,
151-
LEARN_SPAN,
152-
cost_success,
153-
cost_failure,
154-
cost_learn,
155-
initial_pass_rate,
156-
TERMINATION_PROB,
123+
&config
157124
)?,
158125
))
159126
})

0 commit comments

Comments
 (0)