summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/workload.py4
-rwxr-xr-xlib/automata.py9
2 files changed, 9 insertions, 4 deletions
diff --git a/bin/workload.py b/bin/workload.py
index d2e5b34..c9d4e76 100755
--- a/bin/workload.py
+++ b/bin/workload.py
@@ -22,9 +22,9 @@ prev_param = None
for trace_part in timedword:
print('Trace Part {}'.format(trace_part))
if type(trace_part) is TimedWord:
- result = pta.simulate(trace_part, orig_state=prev_state)
+ result = pta.simulate(trace_part, orig_state=prev_state, orig_param=prev_param)
elif type(trace_part) is Workload:
- result = pta.simulate(trace_part.word, orig_state=prev_state)
+ result = pta.simulate(trace_part.word, orig_state=prev_state, orig_param=prev_param)
if prev_state != result.end_state:
print('Warning: loop starts in state {}, but terminates in {}'.format(prev_state, result.end_state.name))
if prev_param != result.parameters:
diff --git a/lib/automata.py b/lib/automata.py
index 02dbfb6..552b482 100755
--- a/lib/automata.py
+++ b/lib/automata.py
@@ -965,7 +965,7 @@ class PTA:
else:
return generator
- def simulate(self, trace: list, orig_state: str = 'UNINITIALIZED', accounting=None):
+ def simulate(self, trace: list, orig_state: str = 'UNINITIALIZED', orig_param=None, accounting=None):
u"""
Simulate a single run through the PTA and return total energy, duration, final state, and resulting parameters.
@@ -973,6 +973,8 @@ class PTA:
or list of (Transition, argument tuple, parameter) tuples originating from dfs.
The tuple (None, duration) represents a sleep time between states in us
:param orig_state: origin state, default UNINITIALIZED
+ :param orig_param: initial parameters, default: `self.initial_param_values`
+ :param accounting: EnergyAccounting object, default empty
:returns: SimulationResult with duration in s, total energy in J, end state, and final parameters
"""
@@ -984,7 +986,10 @@ class PTA:
state = orig_state
else:
state = self.state[orig_state]
- param_dict = dict([[self.parameters[i], self.initial_param_values[i]] for i in range(len(self.parameters))])
+ if orig_param:
+ param_dict = orig_param.copy()
+ else:
+ param_dict = dict([[self.parameters[i], self.initial_param_values[i]] for i in range(len(self.parameters))])
for function in trace:
if isinstance(function[0], Transition):
function_name = function[0].name