def AnalyseStatePath(state): answer = [] NextStateIds = DiagnoserFunctions.GetNextStatesInID(state) status = False while status != True: for each in NextStateIds: NextStateNames = str( DiagnoserFunctions.GetNextStatesInNames(str(each))) if DiagnoserFunctions.IsCertain(NextStateNames) == True: status = True answer.append(1) else: if DiagnoserFunctions.IsOnlySelfloop(each) == 1: status = True answer.append(0) else: state_id = DiagnoserFunctions.GetNextStatesInID(each) for cada in state_id: if NextStateIds.__contains__(cada) == False: NextStateIds.append(cada) if answer.__contains__(0) == True: resposta_final = 0 else: resposta_final = 1 return (resposta_final)
def GetFC_s_IDs(string): # gets the FC(s) for a given string number FU_s_StateNames = FU_s.Get_FU_s() # for this string only, getting the FU(s): FU_s_StateIDs = [] FU_s_StateIDs.append(DiagnoserFunctions.GetStateId(FU_s_StateNames[string])) # and getting the reachable states for this string in ID string_states_IDs = DefineStrings.GetDiagReachable(FU_s_StateIDs[0]) # getting the names string_states_names = [] for each in string_states_IDs: string_states_names.append(DiagnoserFunctions.GetStateName(each)) # ignoring the non-certain ones the_certain_IDs = [] i = 0 while i < len(string_states_names): if DiagnoserFunctions.IsCertain(string_states_names[i]): the_certain_IDs.append(string_states_IDs[i]) i += 1 # getting the names the_certain_names = [] for each in the_certain_IDs: the_certain_names.append(DiagnoserFunctions.GetStateName(each)) previus_states_uncertain = list() for each in the_certain_IDs: a = DiagnoserFunctions.GetPrevisousStatesInID(each) for k in a: b = DiagnoserFunctions.GetStateName(k) if DiagnoserFunctions.IsUncertain(b): if FU_s_StateNames[string] == b: previus_states_uncertain.append(DiagnoserFunctions.GetStateName(each)) elif FU_s_StateNames[string] != b and b not in FU_s_StateNames: previus_states_uncertain.append(DiagnoserFunctions.GetStateName(each)) FC_s = [] for each in previus_states_uncertain: FC_s.append(DiagnoserFunctions.GetStateId(each)) return (FC_s)
def Build(state): aux = [] aux.append(state) for cada in aux: FS = Step1(state) aux = [] for each in FS: eachname = DiagnoserFunctions.GetNextStatesInNames(str(each)) if DiagnoserFunctions.IsNormal(eachname) == True: if DiagnoserFunctions.IsOnlySelfloop(each) == 0: x = Step1(each) for cada in x: FS.append(str(cada)) elif DiagnoserFunctions.IsCertain(eachname) == True: FCs.append(str(each)) elif DiagnoserFunctions.IsUncertain(eachname) == True: FUax.append(str(each))