summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-03-05 09:19:59 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-03-05 09:19:59 +0100
commit593f4767829f0aae2e598a09d337da88d169973a (patch)
treeeb000ca01104e1daac91f37b3607696cd6a0f834 /lib
parent6972b984f633cb2c89c67f6fe268a52c8259a3d1 (diff)
eval: remove unused function_args argument
Diffstat (limited to 'lib')
-rwxr-xr-xlib/automata.py11
-rw-r--r--lib/functions.py14
-rw-r--r--lib/parameters.py9
3 files changed, 20 insertions, 14 deletions
diff --git a/lib/automata.py b/lib/automata.py
index 5849daa..c59f47a 100755
--- a/lib/automata.py
+++ b/lib/automata.py
@@ -1108,6 +1108,7 @@ class PTA:
for i in range(len(self.parameters))
]
)
+ param_list = dict_to_list(param_dict)
for function in trace:
if isinstance(function[0], Transition):
function_name = function[0].name
@@ -1120,7 +1121,7 @@ class PTA:
total_energy += state.get_energy(duration, param_dict)
if state.power.value_error is not None:
total_energy_error += (
- duration * state.power.eval_mae(param_dict, function_args)
+ duration * state.power.eval_mae(param_list + function_args)
) ** 2
total_duration += duration
# assumption: sleep is near-exact and does not contribute to the duration error
@@ -1128,17 +1129,15 @@ class PTA:
accounting.sleep(duration)
else:
transition = state.get_transition(function_name)
- total_duration += transition.duration.eval(
- dict_to_list(param_dict) + function_args
- )
+ total_duration += transition.duration.eval(param_list + function_args)
if transition.duration.value_error is not None:
total_duration_mae += (
- transition.duration.eval_mae(param_dict, function_args) ** 2
+ transition.duration.eval_mae(param_list + function_args) ** 2
)
total_energy += transition.get_energy(param_dict, function_args)
if transition.energy.value_error is not None:
total_energy_error += (
- transition.energy.eval_mae(param_dict, function_args) ** 2
+ transition.energy.eval_mae(param_list + function_args) ** 2
)
param_dict = transition.get_params_after_transition(
param_dict, function_args
diff --git a/lib/functions.py b/lib/functions.py
index df74903..da9ad48 100644
--- a/lib/functions.py
+++ b/lib/functions.py
@@ -168,10 +168,10 @@ class ModelFunction:
def is_predictable(self, param_list):
raise NotImplementedError
- def eval(self, param_list, arg_list):
+ def eval(self, param_list):
raise NotImplementedError
- def eval_mae(self, param_list, arg_list):
+ def eval_mae(self, param_list):
if self.is_predictable(param_list):
return self.function_error["mae"]
return self.value_error["mae"]
@@ -231,7 +231,7 @@ class StaticFunction(ModelFunction):
"""
return True
- def eval(self, param_list=None, arg_list=None):
+ def eval(self, param_list=None):
"""
Evaluate model function with specified param/arg values.
@@ -275,9 +275,9 @@ class SplitFunction(ModelFunction):
return False
return self.child[param_value].is_predictable(param_list)
- def eval(self, param_list, arg_list=list()):
+ def eval(self, param_list):
param_value = param_list[self.param_index]
- return self.child[param_value].eval(param_list, arg_list)
+ return self.child[param_value].eval(param_list)
def to_json(self):
ret = super().to_json()
@@ -485,7 +485,7 @@ class AnalyticFunction(ModelFunction):
return False
return True
- def eval(self, param_list, arg_list=[]):
+ def eval(self, param_list):
"""
Evaluate model function with specified param/arg values.
@@ -493,8 +493,6 @@ class AnalyticFunction(ModelFunction):
corresponds to lexically first parameter, etc.
:param arg_list: argument values (list of float), if arguments are used.
"""
- if len(self.model_args) == 0:
- return self._function(param_list, arg_list)
return self._function(self.model_args, param_list)
def to_json(self):
diff --git a/lib/parameters.py b/lib/parameters.py
index aedb6cd..5fd44c3 100644
--- a/lib/parameters.py
+++ b/lib/parameters.py
@@ -567,6 +567,15 @@ class ParamStats:
class ModelAttribute:
+ """
+ A ModelAttribute instance handles a single model attribute, e.g. TX state power or something() function call duration, and corresponding benchmark data.
+
+ It provides three models:
+ - a static model (`mean`, `median`) as lower bound of model accuracy
+ - a LUT model (`by_param`) as upper bound of model accuracy
+ - a fitted model (`model_function`, a `ModelFunction` instance)
+ """
+
def __init__(self, name, attr, data, param_values, param_names, arg_count=0):
# Data for model generation