From 813c1508c200c6fc64a671b521af2eec522e9487 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 5 Mar 2021 15:35:44 +0100 Subject: promote sub-state models to a first-class modeling citizen get_fitted_sub is no longer present, sub-state models are part of get_fitted now --- bin/analyze-archive.py | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'bin') diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index d7e6a59..a9ee5cf 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -47,6 +47,7 @@ from dfatool.functions import ( gplearn_to_function, SplitFunction, AnalyticFunction, + SubstateFunction, StaticFunction, ) from dfatool.model import PTAModel @@ -866,15 +867,6 @@ if __name__ == "__main__": safe_functions_enabled=safe_functions_enabled ) - if args.with_substates: - sub_model, sub_info = model.get_fitted_sub( - safe_functions_enabled=safe_functions_enabled, - state_duration=raw_data.setup_by_fileno[0]["state_duration"] * 1e3, - ) - - # substate_model = model.get_substates() - # print(model.assess(substate_model, ref=model.sc_by_name)) - if "paramdetection" in show_models or "all" in show_models: for state in model.states_and_transitions: for attribute in model.attributes(state): @@ -931,6 +923,8 @@ if __name__ == "__main__": print_splitinfo( model.parameters, info, f"{state:10s} {attribute:15s}" ) + elif type(info) is SubstateFunction: + print(f"{state:10s} {attribute:15s}: Substate (TODO)") for trans in model.transitions: for attribute in model.attributes(trans): info = param_info(trans, attribute) @@ -940,6 +934,8 @@ if __name__ == "__main__": print_splitinfo( model.parameters, info, f"{trans:10s} {attribute:15s}" ) + elif type(info) is SubstateFunction: + print(f"{state:10s} {attribute:15s}: Substate (TODO)") if args.with_substates: for submodel in model.submodel_by_name.values(): sub_param_model, sub_param_info = submodel.get_fitted() @@ -949,14 +945,21 @@ if __name__ == "__main__": if type(info) is AnalyticFunction: print( "{:10s} {:15s}: {}".format( - substate, subattribute, info.function.model_function - ) - ) - print( - "{:10s} {:15s} {}".format( - "", "", info.function.model_args + substate, subattribute, info.model_function ) ) + print("{:10s} {:15s} {}".format("", "", info.model_args)) + + if args.with_substates: + for state in model.states: + if ( + type(model.attr_by_name[state]["power"].model_function) + is SubstateFunction + ): + # sub-state models need to know the duration of the state / transition. only needed for eval. + model.attr_by_name[state]["power"].model_function.static_duration = ( + raw_data.setup_by_fileno[0]["state_duration"] * 1e3 + ) if xv_method == "montecarlo": analytic_quality = xv.montecarlo(lambda m: m.get_fitted()[0], xv_count) @@ -965,9 +968,6 @@ if __name__ == "__main__": else: analytic_quality = model.assess(param_model) - if args.with_substates: - sub_quality = model.assess(sub_model) - if "tex" in show_models or "tex" in show_quality: print_text_model_data( model, @@ -1013,13 +1013,6 @@ if __name__ == "__main__": [None, sub_param_info, None], ) - if ("table" in show_quality or "all" in show_quality) and args.with_substates: - model_quality_table( - ["parameterized", "sub-states", "LUT"], - [analytic_quality, sub_quality, lut_quality], - [param_info, sub_info, None], - ) - if "overall" in show_quality or "all" in show_quality: print("overall state static/param/lut MAE assuming equal state distribution:") print( -- cgit v1.2.3