Skip to content
Snippets Groups Projects

Resolve "Score of order depends on remaining time"

Merged Fabian Heinrich requested to merge 128-score-of-order-depends-on-remaining-time into dev
1 file
+ 30
0
Compare changes
  • Side-by-side
  • Inline
@@ -91,6 +91,12 @@ from cooperative_cuisine.hooks import HookCallbackClass
def constant_score(max_score: float, time_percentage: float = 1.0):
"""Returns the constant score. No time dependence.
Args:
max_score: The maximum score to be returned.
time_percentage: The time percentage. Default is 1.0.
"""
return max_score
@@ -100,6 +106,17 @@ def linear_score(
time_percentage: float = 1.0,
round_decimals: int = 0,
):
"""
Returns the linear score based on the time percentage.
Args:
max_score: Maximum possible score.
min_score_ratio: Minimum score ratio. Default is 0.0.
time_percentage: Time percentage of the order. Default is 1.0.
round_decimals: Number of decimals to round the score to. Default is 0.
Returns: Modified score based on the time percentage.
"""
modified_score = float(
np.round(
max(max_score * time_percentage, max_score * min_score_ratio),
@@ -116,6 +133,19 @@ def stepped_score(
round_decimals: int = 0,
time_percentage: float = 1.0,
):
"""
Modifies the score based on a step function based on the time percentage.
Args:
max_score: Maximum possible score.
steps: Steps for the score ratios.
score_ratios: Ratios for the score based on the steps.
round_decimals: Number of decimals to round the score to. Default is 0.
time_percentage: Time percentage of the order. Default is 1.0.
Returns: Modified score based on the time percentage.
"""
if len(steps) != len(score_ratios):
raise ValueError("steps and vals must have the same length")
Loading