diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2021-03-05 09:10:07 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2021-03-05 09:10:07 +0100 |
commit | 6972b984f633cb2c89c67f6fe268a52c8259a3d1 (patch) | |
tree | 8a8152ae5ca2635bb83d362e6c8b35c9fa42fdac /lib | |
parent | 26d949fb61f874e072f2a495c38ea343e912a02f (diff) |
Restore workload.py
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/automata.py | 10 | ||||
-rw-r--r-- | lib/functions.py | 11 |
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/automata.py b/lib/automata.py index a89155c..5849daa 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -435,11 +435,11 @@ class Transition: "timeout": None, } if self.duration is not None: - ret["duration"] = (self.duration.to_json(),) + ret["duration"] = self.duration.to_json() if self.energy is not None: - ret["energy"] = (self.energy.to_json(),) + ret["energy"] = self.energy.to_json() if self.timeout is not None: - ret["timeout"] = (self.timeout.to_json(),) + ret["timeout"] = self.timeout.to_json() return ret @@ -1111,10 +1111,10 @@ class PTA: for function in trace: if isinstance(function[0], Transition): function_name = function[0].name - function_args = function[1] + function_args = list(function[1]) else: function_name = function[0] - function_args = function[1:] + function_args = list(function[1:]) if function_name is None or function_name == "_": duration = function_args[0] total_energy += state.get_energy(duration, param_dict) diff --git a/lib/functions.py b/lib/functions.py index 48049b5..df74903 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -171,6 +171,11 @@ class ModelFunction: def eval(self, param_list, arg_list): raise NotImplementedError + def eval_mae(self, param_list, arg_list): + if self.is_predictable(param_list): + return self.function_error["mae"] + return self.value_error["mae"] + def to_json(self): ret = { "value": self.value, @@ -201,9 +206,11 @@ class ModelFunction: def from_json_maybe(cls, json_wrapped: dict, attribute: str): # Legacy Code for PTA / tests. Do not use. if type(json_wrapped) is dict and attribute in json_wrapped: - # benchmark data obtained before 2021-03-04 uses {"power": {"static": 0}} - # benchmark data obtained after 2021-03-04 uses {"power": {"type": "static", "value": 0}} + # benchmark data obtained before 2021-03-04 uses {"attr": {"static": 0}} + # benchmark data obtained after 2021-03-04 uses {"attr": {"type": "static", "value": 0}} or {"attr": None} # from_json expects the latter. + if json_wrapped[attribute] is None: + return None if ( "static" in json_wrapped[attribute] and "type" not in json_wrapped[attribute] |