summaryrefslogtreecommitdiff
path: root/lib/automata.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-12-19 16:16:15 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2019-12-20 12:58:35 +0100
commit8217e116ddb6e0f1a3095e440e383b8971612416 (patch)
tree71dfbe947b3b1f82ed406ba3637c676b55608018 /lib/automata.py
parentb69919229b075df69881666a6a152139d3f274b8 (diff)
SimulationResult: Handle 0 duration and missing MAE values
Diffstat (limited to 'lib/automata.py')
-rwxr-xr-xlib/automata.py21
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: