diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-12-19 16:16:15 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-12-19 16:16:15 +0100 |
commit | 8c6f206ab3cd364d3e5e3955f3de5c9b33e3d370 (patch) | |
tree | 71dfbe947b3b1f82ed406ba3637c676b55608018 | |
parent | b69919229b075df69881666a6a152139d3f274b8 (diff) |
SimulationResult: Handle 0 duration and missing MAE values
-rwxr-xr-x | lib/automata.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/automata.py b/lib/automata.py index d977164..8f938bc 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -40,14 +40,25 @@ class SimulationResult: :param parameters: Parameter values after simulation run """ self.duration = duration * 1e-6 - self.duration_mae = duration_mae * 1e-6 - self.duration_mape = self.duration_mae * 100 / self.duration + if duration_mae is None or self.duration == 0: + self.duration_mae = None + self.duration_mape = None + else: + self.duration_mae = duration_mae * 1e-6 + self.duration_mape = self.duration_mae * 100 / self.duration self.energy = energy * 1e-12 - self.energy_mae = energy_mae * 1e-12 - self.energy_mape = self.energy_mae * 100 / self.energy + if energy_mae is None or self.energy == 0: + self.energy_mae = None + self.energy_mape = None + else: + self.energy_mae = energy_mae * 1e-12 + self.energy_mape = self.energy_mae * 100 / self.energy self.end_state = end_state self.parameters = parameters - self.mean_power = self.energy / self.duration + if self.duration > 0: + self.mean_power = self.energy / self.duration + else: + self.mean_power = 0 class PTAAttribute: |