in simulation/decai/simulation/contract/incentive/stakeable.py [0:0]
def get_next_add_data_cost(self, data, classification) -> float:
"""
:param data: A single sample of training data for the model.
:param classification: The label for `data`.
:return: The current cost to update a model with a specific sample of training data.
"""
current_time_s = int(self._time())
# TODO Limit how many times a data point can be added if the model already classifies right for it?
# TODO Add cost to flip all data?
# TODO Add discount if already submitted good data?
# Convert to integers like in Solidity.
time_since_last_update_s = int((current_time_s - self._last_update_time_s))
if time_since_last_update_s <= 0:
raise RejectException("Not enough time has passed since the last update.")
# We really want to think about the time in hours
# (divide by 3600 but this is in the square root of the denominator so we multiply by sqrt(3600)).
# Equivalent to: cost = self.cost_weight / int(math.sqrt(time_since_last_update_s * 3600))
result = self.cost_weight * 60 / int(math.sqrt(time_since_last_update_s))
result = int(result)
# Make sure there is a minimum cost to adding data.
if result < 1:
result = 1
return result