summaryrefslogtreecommitdiff
path: root/lib/automata.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-09-06 15:11:41 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-09-06 15:11:41 +0200
commit56fe4ce54cebc8151f784a56ac545795531e6909 (patch)
tree1fc0d041e30a5387a74970f0349d2d860c18ef75 /lib/automata.py
parentbcd014c15b5d9e68f3764a8ae09fa5f20a22dfe8 (diff)
automata: Supprt setting random energy model for benchmarks
Diffstat (limited to 'lib/automata.py')
-rwxr-xr-xlib/automata.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/automata.py b/lib/automata.py
index 4cd694d..30634ab 100755
--- a/lib/automata.py
+++ b/lib/automata.py
@@ -2,6 +2,7 @@
from functions import AnalyticFunction, NormalizationFunction
import itertools
+import numpy as np
def _dict_to_list(input_dict: dict) -> list:
return [input_dict[x] for x in sorted(input_dict.keys())]
@@ -51,6 +52,9 @@ class State:
return self.power_function.eval(_dict_to_list(param_dict)) * duration
return self.power * duration
+ def set_random_energy_model(self, static_model = True):
+ self.power = np.random.sample() * 50000
+
def get_transition(self, transition_name: str) -> object:
"""Return Transition object for outgoing transtion transition_name."""
return self.outgoing_transitions[transition_name]
@@ -213,6 +217,9 @@ class Transition:
return self.energy_function.eval(_dict_to_list(param_dict), args)
return self.energy
+ def set_random_energy_model(self, static_model = True):
+ self.energy = np.random.sample() * 50000
+
def get_timeout(self, param_dict: dict = {}) -> float:
u"""
Return transition timeout in µs.
@@ -533,6 +540,11 @@ class PTA:
def get_initial_param_dict(self):
return dict([[self.parameters[i], self.initial_param_values[i]] for i in range(len(self.parameters))])
+ def set_random_energy_model(self, static_model = True):
+ for state in self.state.values():
+ state.set_random_energy_model(static_model)
+ for transition in self.transitions:
+ transition.set_random_energy_model(static_model)
def _dfs_with_param(self, generator, param_dict):
for trace in generator: