From de7f0af1797c067792fb7a04163f37085104b5fd Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:31:52 +0300 Subject: [PATCH 01/14] Fine-tune sample size for CMRR.py So here's the idea: the amount of time it takes to run CMRR for small values of days_to_simulate is very small. Which means that we can increase the sample size without having to worry about CMRR taking too long to annoy the user. Instead of writing a whole bunch of else-if statements, I made a function that calculates the "best" sample size. Specifically, it calculates what sample size would make CMRR run roughly as long as it owuld with sample_size=4 and days_to_simulate=365. sample_size=4 and days_to_simulate=365 is used as the default, and then if days_to_simulate is lower, sample size is increased to make the total run time approximately constant. --- src/fsrs_optimizer/fsrs_simulator.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index b0b754d..48f4e35 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -262,12 +262,18 @@ def sample( loss_aversion=2.5, ): memorization = [] - if learn_span < 100: - SAMPLE_SIZE = 16 - elif learn_span < 365: - SAMPLE_SIZE = 8 - else: - SAMPLE_SIZE = 4 + + def best_sample_size(days_to_simulate): + if days_to_simulate <= 30: + return 36 + elif days_to_simulate >= 365: + return 4 + else: + factor = 0.00000358 * np.power(days_to_simulate, 2) + 0.00113 * days_to_simulate +0.0733 + default_sample_size = 4 + return int(default_sample_size/factor) + + SAMPLE_SIZE = best_sample_size(learn_span) for i in range(SAMPLE_SIZE): _, _, _, memorized_cnt_per_day, cost_per_day = simulate( From fa87edb7c89c6e95922eb813515254d51b3b6219 Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:32:59 +0300 Subject: [PATCH 02/14] Update fsrs_simulator.py --- src/fsrs_optimizer/fsrs_simulator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 48f4e35..f83429b 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -263,13 +263,13 @@ def sample( ): memorization = [] - def best_sample_size(days_to_simulate): + def _sample_size(days_to_simulate): if days_to_simulate <= 30: return 36 elif days_to_simulate >= 365: return 4 else: - factor = 0.00000358 * np.power(days_to_simulate, 2) + 0.00113 * days_to_simulate +0.0733 + factor = 0.00000358 * np.power(days_to_simulate, 2) + 0.00113 * days_to_simulate + 0.0733 default_sample_size = 4 return int(default_sample_size/factor) From 6a73234088e2766caf6f24e2030e57101cc397d5 Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:33:23 +0300 Subject: [PATCH 03/14] Update fsrs_simulator.py --- src/fsrs_optimizer/fsrs_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index f83429b..2ed5267 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -263,7 +263,7 @@ def sample( ): memorization = [] - def _sample_size(days_to_simulate): + def best_sample_size(days_to_simulate): if days_to_simulate <= 30: return 36 elif days_to_simulate >= 365: From 0e0795f1802dfd8309544ce99cc45803ab8dd894 Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 20:17:14 +0300 Subject: [PATCH 04/14] Change the coefficients.py --- src/fsrs_optimizer/fsrs_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index f50762c..78d3e59 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -270,7 +270,7 @@ def best_sample_size(days_to_simulate): elif days_to_simulate >= 365: return 4 else: - factor = 0.00000358 * np.power(days_to_simulate, 2) + 0.00113 * days_to_simulate + 0.0733 + factor = 8.54864e-07 * np.power(days_to_simulate, 2) + 2.57563e-03 * days_to_simulate + 1.38928e-02 default_sample_size = 4 return int(default_sample_size/factor) From 146ea804e4db921f7028cd642e647231c056938a Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:37:02 +0300 Subject: [PATCH 05/14] Fixed a problem where the output was 3 instead of 4.py --- src/fsrs_optimizer/fsrs_simulator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 78d3e59..b6e2849 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -264,13 +264,14 @@ def sample( ): results = [] - def best_sample_size(days_to_simulate): + def _sample_size(days_to_simulate): if days_to_simulate <= 30: return 36 elif days_to_simulate >= 365: return 4 else: - factor = 8.54864e-07 * np.power(days_to_simulate, 2) + 2.57563e-03 * days_to_simulate + 1.38928e-02 + a1, a2, a3 = 8.20e-07, 2.41e-03, 1.30e-02 + factor = a1 * np.power(days_to_simulate, 2) + a2 * days_to_simulate + a3 default_sample_size = 4 return int(default_sample_size/factor) From ed70230628855bd4cf0924f18099c717e8615703 Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:37:37 +0300 Subject: [PATCH 06/14] Update fsrs_simulator.py I don't know how I managed to delete "best" twice today --- src/fsrs_optimizer/fsrs_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index b6e2849..7027285 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -264,7 +264,7 @@ def sample( ): results = [] - def _sample_size(days_to_simulate): + def best_sample_size(days_to_simulate): if days_to_simulate <= 30: return 36 elif days_to_simulate >= 365: From cb1168e894388d987b8205b0ae6248c5dcf85e51 Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Sun, 8 Sep 2024 22:03:05 +0300 Subject: [PATCH 07/14] Update fsrs_simulator.py --- src/fsrs_optimizer/fsrs_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 7027285..9fecb4d 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -266,7 +266,7 @@ def sample( def best_sample_size(days_to_simulate): if days_to_simulate <= 30: - return 36 + return 45 elif days_to_simulate >= 365: return 4 else: From b354b5111bfc396c9f258bd93ed8dd1ef18f69f0 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Mon, 9 Sep 2024 10:15:17 +0800 Subject: [PATCH 08/14] set loss_aversion to 1 when plotting workload --- src/fsrs_optimizer/fsrs_simulator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 9fecb4d..43abacf 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -429,6 +429,7 @@ def workload_graph(default_params, sampling_size=30): default_params["deck_size"] / default_params["learn_span"] ) default_params["review_limit_perday"] = math.inf + default_params["loss_aversion"] = 1 workload = [sample(r=r, workload_only=True, **default_params) for r in R] # this is for testing From 1109fdd940a4980adfc78e7613385fea33c8e48f Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:38:18 +0300 Subject: [PATCH 09/14] Update ylim.py Don't mind me, I'm just trying things --- src/fsrs_optimizer/fsrs_simulator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 3f4438e..431203b 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -523,10 +523,14 @@ def workload_graph(default_params, sampling_size=30): if max_w >= 4.5 * min_w: lim = 4.5 * min_w + elif max_w >= 4 * min_w: + lim = 4 * min_w elif max_w >= 3.5 * min_w: lim = 3.5 * min_w + elif max_w >= 3 * min_w: + lim = 3 * min_w else: - lim = 1.1 * max_w + lim = max(max_w, 2.7 * min_w) ax.set_ylim(0, lim) ax.set_ylabel("Workload (minutes of study per day)", fontsize=20) From 3650ba87e1d1321a614676bb7b5864ba90710b6e Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:39:06 +0300 Subject: [PATCH 10/14] Update fsrs_simulator.py --- src/fsrs_optimizer/fsrs_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 431203b..400811d 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -530,7 +530,7 @@ def workload_graph(default_params, sampling_size=30): elif max_w >= 3 * min_w: lim = 3 * min_w else: - lim = max(max_w, 2.7 * min_w) + lim = 1.1 * max_w ax.set_ylim(0, lim) ax.set_ylabel("Workload (minutes of study per day)", fontsize=20) From d9552333419303609e74014459a64c46de29d690 Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:47:35 +0300 Subject: [PATCH 11/14] min -> minimum.py --- src/fsrs_optimizer/fsrs_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 400811d..0bed769 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -539,7 +539,7 @@ def workload_graph(default_params, sampling_size=30): ax.text( 0.701, min_w, - "min. workload", + "minimum workload", ha="left", va="bottom", color="black", From 1711cf428af912a5e19b5cee30bf79fb70a97ffa Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:00:42 +0300 Subject: [PATCH 12/14] Decrease ylim.py --- src/fsrs_optimizer/fsrs_simulator.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index 0bed769..c3b6380 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -521,14 +521,14 @@ def workload_graph(default_params, sampling_size=30): ax.xaxis.set_tick_params(labelsize=14) ax.set_xlim(0.7, 0.99) - if max_w >= 4.5 * min_w: - lim = 4.5 * min_w - elif max_w >= 4 * min_w: - lim = 4 * min_w - elif max_w >= 3.5 * min_w: + if max_w >= 3.5 * min_w: lim = 3.5 * min_w elif max_w >= 3 * min_w: lim = 3 * min_w + elif max_w >= 2.5 * min_w: + lim = 2.5 * min_w + elif max_w >= 2 * min_w: + lim = 2 * min_w else: lim = 1.1 * max_w From b251ca040a05e3cf05fd948150044dc6ef3e606a Mon Sep 17 00:00:00 2001 From: Expertium <83031600+Expertium@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:25:53 +0300 Subject: [PATCH 13/14] Update fsrs_simulator.py Ensure that nothing is plotted above the box with the graph --- src/fsrs_optimizer/fsrs_simulator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsrs_optimizer/fsrs_simulator.py b/src/fsrs_optimizer/fsrs_simulator.py index c3b6380..611e58d 100644 --- a/src/fsrs_optimizer/fsrs_simulator.py +++ b/src/fsrs_optimizer/fsrs_simulator.py @@ -545,7 +545,7 @@ def workload_graph(default_params, sampling_size=30): color="black", fontsize=12, ) - if max_w >= 1.8 * min_w: + if lim >= 1.8 * min_w: ax.axhline(y=1.5 * min_w, color="black", alpha=0.75, ls="--") ax.text( 0.701, @@ -556,7 +556,7 @@ def workload_graph(default_params, sampling_size=30): color="black", fontsize=12, ) - if max_w >= 2.3 * min_w: + if lim >= 2.3 * min_w: ax.axhline(y=2 * min_w, color="black", alpha=0.75, ls="--") ax.text( 0.701, @@ -567,7 +567,7 @@ def workload_graph(default_params, sampling_size=30): color="black", fontsize=12, ) - if max_w >= 2.8 * min_w: + if lim >= 2.8 * min_w: ax.axhline(y=2.5 * min_w, color="black", alpha=0.75, ls="--") ax.text( 0.701, @@ -578,7 +578,7 @@ def workload_graph(default_params, sampling_size=30): color="black", fontsize=12, ) - if max_w >= 3.3 * min_w: + if lim >= 3.3 * min_w: ax.axhline(y=3 * min_w, color="black", alpha=0.75, ls="--") ax.text( 0.701, From 2491fdb0ef2f8c460ed029f6b90a3b29f059d365 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Mon, 9 Sep 2024 21:27:00 +0800 Subject: [PATCH 14/14] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3833775..911356b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "FSRS-Optimizer" -version = "5.0.7" +version = "5.0.8" readme = "README.md" dependencies = [ "matplotlib>=3.7.0",