diff options
-rwxr-xr-x | bin/analyze-archive.py | 4 | ||||
-rw-r--r-- | lib/dfatool.py | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index fac8b00..99b3012 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -403,6 +403,10 @@ if __name__ == '__main__': if 'table' in show_quality or 'all' in show_quality: model_quality_table([static_quality, analytic_quality, lut_quality], [None, param_info, None]) + if 'overall' in show_quality or 'all' in show_quality: + print('overall MAE of static model: {} µW'.format(model.assess_states(static_model))) + print('overall MAE of param model: {} µW'.format(model.assess_states(param_model))) + print('overall MAE of LUT model: {} µW'.format(model.assess_states(lut_model))) if 'summary' in show_quality or 'all' in show_quality: model_summary_table([model.assess_on_traces(static_model), model.assess_on_traces(param_model), model.assess_on_traces(lut_model)]) diff --git a/lib/dfatool.py b/lib/dfatool.py index 4ba4911..dd9ed61 100644 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -1719,12 +1719,15 @@ class PTAModel: return self.pta.to_json() def states(self): + """Return sorted list of state names.""" return sorted(list(filter(lambda k: self.by_name[k]['isa'] == 'state', self.by_name.keys()))) def transitions(self): + """Return sorted list of transition names.""" return sorted(list(filter(lambda k: self.by_name[k]['isa'] == 'transition', self.by_name.keys()))) def states_and_transitions(self): + """Return list of states and transition names.""" ret = self.states() ret.extend(self.transitions()) return ret @@ -1760,6 +1763,14 @@ class PTAModel: 'by_name' : detailed_results } + def assess_states(self, model_function, model_attribute = 'power'): + """ + Calculate overall model error assuming equal distribution of states + """ + model_quality = self.assess(model_function) + total_error = np.sqrt(sum(map(lambda x: np.square(model_quality['by_name'][x][model_attribute]['mae']), self.states()))) + return total_error + def assess_on_traces(self, model_function): """ |