def standardSuppression(): print("===========================================================") print("================STANDARD SUPPRESSION========================") print("===========================================================") basePoint_el = createBasePoint_el() basePoint_elo = createBasePoint_elo() statePoints = [basePoint_el, basePoint_elo] s_i = statePoints f = f_suppression_studyLate #The desired output of the external evaluation function gamma = { 'el': 'She will study late in the library', 'elo': 'We are uncertain if she will study late in the library' } #test ctm c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(WC) c.appendm(SEMANTIC) predictions = f(c) print('predictions: ', predictions) print("Lenient Interp") print( StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)) print("Strict Interp") print( StatePointOperations.predictionsModelsGamma_strict(predictions, gamma)) print("f(pi) models gamma_Sup? : ", (StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)))
def abducibleSuppression(): print("===========================================================") print("=================ABDUCIBLE SUPPRESSION=====================") print("===========================================================") basePoint1 = epistemicState.epistemicState('el') delta1 = ["( l | e )"] S1 = ["( e <- T )"] delta1AsLogic = scpNotationParser.stringListToBasicLogic(delta1) S1AsLogic = scpNotationParser.stringListToBasicLogic(S1) basePoint1['S'] = S1AsLogic basePoint1['Delta'] = delta1AsLogic basePoint1['V'] = [e, l] #The elo case expressed as the addition of information to the el case basePoint2 = copy.deepcopy(basePoint1) basePoint2.setName('elo') #The possible starting states for the SCP extraConditional = ["( l | o )"] extraConditionalAsLogic = scpNotationParser.stringListToBasicLogic( extraConditional) basePoint2['Delta'] = basePoint2['Delta'] + extraConditionalAsLogic basePoint2['V'] = basePoint2['V'] + [o] #abducibs = [ '( l <- T )', '( l <- F )','( o <- T )', '( o <- F )'] abducibs = ['( o <- T )', '( o <- F )'] logAbducibs = scpNotationParser.stringListToBasicLogic(abducibs) basePoint1['R'] = {'abducibles': logAbducibs} basePoint2['R'] = {'abducibles': logAbducibs} #Create the first state point statePoints = [basePoint1, basePoint2] s_i = statePoints f = f_suppression_studyLate #The desired output of the external evaluation function gamma = { 'el': 'She will study late in the library', 'elo': 'We are uncertain if she will study late in the library' } #test ctm c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(ABDUCIBLES) c.appendm(WC) c.appendm(SEMANTIC) predictions = f(c) print('predictions: ', predictions) print("Lenient Interp") print( StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)) print("Strict Interp") print( StatePointOperations.predictionsModelsGamma_strict(predictions, gamma)) print("f(pi) models gamma_noSup? : ", (StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)))
def abducibleSuppression(): print("===========================================================") print("=================ABDUCIBLE SUPPRESSION=====================") print("===========================================================") basePoint_el = createBasePoint_el() basePoint_elo = createBasePoint_elo() statePoints = [basePoint_el, basePoint_elo] #abducibs = [ '( l <- T )', '( l <- F )','( o <- T )', '( o <- F )'] abducibs = ['( o <- T )', '( o <- F )'] logAbducibs = scpNotationParser.stringListToBasicLogic(abducibs) basePoint_el['R'] = {'abducibles': logAbducibs} basePoint_elo['R'] = {'abducibles': logAbducibs} #Create the first state point statePoints = [basePoint_el, basePoint_elo] s_i = statePoints f = f_suppression_studyLate #The desired output of the external evaluation function gamma = { 'el': 'She will study late in the library', 'elo': 'We are uncertain if she will study late in the library' } #test ctm c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(ABDUCIBLES) c.appendm(WC) c.appendm(SEMANTIC) predictions = f(c) print('predictions: ', predictions) print("Lenient Interp") print( StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)) print("Strict Interp") print( StatePointOperations.predictionsModelsGamma_strict(predictions, gamma)) print("f(pi) models gamma_noSup? : ", (StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)))
def s_satisfying(self, results): satisfyingResults = [] for result in results: #print ("result is ",result) #print (self.f(result)) predModelsGamma = StatePointOperations.predictionsModelsGamma_lenient( self.f(result), self.gamma) if predModelsGamma: satisfyingResults.append(result) return StatePointOperations.CTMtoSCP(satisfyingResults, self.f)
def mu_D7_example(): print("\n>>Example for SCP that turns the cards: D, 7...") #create initial base point which has only a single epistemic state in it s_i = create_si_contra() #The final state dependent external evaluation function f = f_turnFunction_prefDoNoTurn #the turn responses which would we would like to achieve gamma_D7 = { 'D': 'Turn Card', 'K': 'Do Not Turn', '3': 'Do Not Turn', '7': 'Turn Card' } #This is a test SCP mu=(c,f()) which is known to work c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(ABDUCIBLES) c.appendm(WC) c.appendm(SEMANTIC) #the set of possible observations which might need to be explained to see if we should # turn a card observations = ['D', 'K', '3', '7'] #use the turn function to evaluate the ctm and see if the card should be turned # we prefer the 'Do Not Turn' response in this case predictions = f(c, observations) print("First state point is ", s_i) print("Example SCP is ", c.__repr__()) #to print all final states uncomment the next line #print("Final State point is : ", c.evaluate()) #the decisions made by f() for the SCP (c,f()) print("Responses: ", predictions) #print True if mu|=gamma_D3 print( "Lenient: mu|=gamma_D7 :", StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma_D7)) print( "Strict: mu|=gamma_D7 :", StatePointOperations.predictionsModelsGamma_strict( predictions, gamma_D7))
def deletionSuppression(): print("===========================================================") print("================DELETION SUPPRESSION=======================") print("===========================================================") print("===========================================================") basePoint_el = createBasePoint_el() basePoint_elo = createBasePoint_elo() statePoints = [basePoint_el, basePoint_elo] basePoint_el['R'] = {'delete': ["o", "e"]} basePoint_elo['R'] = {'delete': ["o", "e"]} #Create the first state point statePoints = [basePoint_el, basePoint_elo] s_i = statePoints #The external evaluation function f = f_suppression_studyLate #The desired output of the external evaluation function gamma = { 'el': 'She will study late in the library', 'elo': 'We are uncertain if she will study late in the library' } #test ctm c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(DELETE) c.appendm(WC) c.appendm(SEMANTIC) predictions = f(c) print('predictions: ', predictions) print("Lenient Interp") print( StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)) print("Strict Interp") print( StatePointOperations.predictionsModelsGamma_strict(predictions, gamma))
def mu_D_example(): #create initial base point which has only a single epistemic state in it s_i = create_si_noContra() #The final state dependent external evaluation function f = f_turnFunction_prefDoNoTurn #the turn responses which would we would like to achieve gamma_D = { 'D': 'Turn Card', 'K': 'Do Not Turn', '3': 'Do Not Turn', '7': 'Do Not Turn' } #This is a test SCP mu=(c,f()) which is known to work c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(ABDUCIBLES) c.appendm(WC) c.appendm(SEMANTIC) #the set of possible observations which might need to be explained to see if we should # turn a card observations = ['D', 'K', '3', '7'] #use the turn function to evaluate the ctm and see if the card should be turned # we prefer the 'Do Not Turn' response in this case predictions = f(c, observations) #print True if mu|=gamma_D3 print("Responses: ", predictions) print( "Lenient: mu|=gamma_D :", StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma_D)) print( "Strict: mu|=gamma_D :", StatePointOperations.predictionsModelsGamma_strict( predictions, gamma_D))
#print (deletionSuppression()) #test ctm c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) #c.appendm(ABDUCIBLES) c.appendm(DELETE) c.appendm(WC) c.appendm(SEMANTIC) predictions = f(c) print('predictions: ', predictions) print("Lenient Interp") print(StatePointOperations.predictionsModelsGamma_lenient(predictions, gamma)) print("Strict Interp") print(StatePointOperations.predictionsModelsGamma_strict(predictions, gamma)) #print (c.evaluate()) searchResult = task.deNoveSearch() print("\nSEARCH RESULTS:") print(searchResult) print("\n") result1 = searchResult[0] print("RESULT 1: IS\n", result1)