summaryrefslogtreecommitdiff
path: root/lib/model.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-11-02 13:28:40 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-11-02 13:28:40 +0100
commitc7a7b48c6739e193ba24eec4d41082271df164ce (patch)
treeca01ada66ac02395999310f84bf8f4a61d1aa049 /lib/model.py
parentc179546f74807882f4dff47c8a969741f2dba1a7 (diff)
Simplify PELT usage. remove kneedle, refactor code
Diffstat (limited to 'lib/model.py')
-rw-r--r--lib/model.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/model.py b/lib/model.py
index 57507e7..192cea3 100644
--- a/lib/model.py
+++ b/lib/model.py
@@ -938,18 +938,26 @@ class PTAModel:
def get_substates(self):
states = self.states()
for k in self.by_param.keys():
- if k[0] == "TX":
+ if k[0] in states:
if self.pelt.needs_refinement(self.by_param[k]["power_traces"]):
- print(f"PELT: {k} needs refinement")
- penalty = self.pelt.get_penalty_value(
- self.by_param[k]["power_traces"]
- )
- print(
- f" we found {penalty[1]} changepoints with penalty {penalty[0]}"
- )
- self.pelt.calc_raw_states(
- self.by_param[k]["power_traces"], penalty[0]
+ logger.debug(f"PELT: {k} needs refinement")
+ # Assumption: All power traces for this parameter setting
+ # are similar, so determining the penalty for the first one
+ # is sufficient.
+ penalty, changepoints = self.pelt.get_penalty_and_changepoints(
+ self.by_param[k]["power_traces"][0]
)
+ if len(changepoints):
+ logger.debug(
+ f" we found {len(changepoints)} changepoints with penalty {penalty}"
+ )
+ self.pelt.calc_raw_states(
+ self.by_param[k]["power_traces"], penalty
+ )
+ else:
+ logger.debug(
+ f" we found no changepoints with penalty {penalty}"
+ )
return None, None