summaryrefslogtreecommitdiff
path: root/lib/automata.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-09-25 15:27:59 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-09-25 15:27:59 +0200
commitcd38fd1a31526f6667aaf0b4060601a433df9ff1 (patch)
tree656b324cd0a17cb83534b28d6b66f16ac28be6b1 /lib/automata.py
parent0d4dac662b89bac9624337f851f448516a14f6fc (diff)
PTA: Add shrink_argument_values function
Diffstat (limited to 'lib/automata.py')
-rwxr-xr-xlib/automata.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/automata.py b/lib/automata.py
index 3bba65c..0cc7143 100755
--- a/lib/automata.py
+++ b/lib/automata.py
@@ -1,6 +1,7 @@
"""Classes and helper functions for PTA and other automata."""
from functions import AnalyticFunction, NormalizationFunction
+from utils import is_numeric
import itertools
import numpy as np
@@ -604,6 +605,31 @@ class PTA:
for transition in self.transitions:
transition.set_random_energy_model(static_model)
+ def shrink_argument_values(self):
+ """
+ Throw away all but two values for each numeric argument of each transition.
+
+ This is meant to speed up an initial PTA-based benchmark by
+ reducing the parameter space while still gaining insights in the
+ effect (or nop) or individual parameters on hardware behaviour.
+
+ Parameters with non-numeric values (anything containing neither
+ numbers nor enums) are left as-is, as they may be distinct
+ toggles whose effect cannot be estimated when they are left out.
+ """
+ for transition in self.transitions:
+ for i, argument in enumerate(transition.arguments):
+ if len(transition.argument_values[i]) <= 2:
+ continue
+ if transition.argument_combination == 'zip':
+ continue
+ values_are_numeric = True
+ for value in transition.argument_values[i]:
+ if not is_numeric(self.normalize_parameter(transition.arg_to_param_map[i], value)):
+ values_are_numeric = False
+ if values_are_numeric and len(transition.argument_values[i]) > 2:
+ transition.argument_values[i] = [transition.argument_values[i][0], transition.argument_values[i][-1]]
+
def _dfs_with_param(self, generator, param_dict):
for trace in generator:
param = param_dict.copy()