diff options
author | SeongJae Park <sj@kernel.org> | 2023-10-18 18:15:01 +0000 |
---|---|---|
committer | SeongJae Park <sj@kernel.org> | 2023-10-18 18:15:46 +0000 |
commit | baef0174fe39a37be3c47e393dfc2d7a8b5c75eb (patch) | |
tree | 15b86e3dce9dffc5abacdb7a8e36a623a5e4b814 | |
parent | cb6b5d060819e3477a97268cb55fb534cdbcb2cc (diff) | |
download | damon-hack-baef0174fe39a37be3c47e393dfc2d7a8b5c75eb.tar.gz |
ideas: Add autotune idea simulator draft
The code is not complete but still writing. But who cares about the
quality of this crippy repo?
Signed-off-by: SeongJae Park <sj@kernel.org>
-rw-r--r-- | ideas/autotune_sim/autotune_sim.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ideas/autotune_sim/autotune_sim.py b/ideas/autotune_sim/autotune_sim.py new file mode 100644 index 0000000..28ef91c --- /dev/null +++ b/ideas/autotune_sim/autotune_sim.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +class Tuner: + past_quotas = None + past_scores = None + algorithm = None + goal = None + + def __init__(self, algorithm, goal): + self.past_quotas = [] + self.past_scores = [] + algorithm = algorithm + self.goal = goal + + def get_next_quota(self, current_score): + if len(past_quotas) == 0: + self.past_scores.append(current_score) + self.past_quotas.append(1) + return 1 + self.past_scores.append(current_score) + next_quota = algotithm(self.goal, self.past_scores, self.past_quotas) + self.past_quotas.append(next_quota) + return next_quota + +def the_algorithm(goal, past_scores, past_quotas): + return max(past_quotas[-1] * ((goal - past_scores[-1]) / goal + 1), 1) + + +def main(): + return + +if __name__ == '__main__': + main() |