def getValidVariableAssignments(self, conjunction, trueOrFalse, gndAtoms): variableAssignments = [] gndAtomIndices = [] for lit in conjunction.children: assignments = [] atomIndices = [] for gndAtom in gndAtoms: try: if gndAtom.predName != lit.predName: continue assignment = [] for (p1, p2) in zip(lit.params, gndAtom.params): if FOL.isVar(p1): assignment.append((p1, p2)) elif p1 != p2: raise assignments.append(tuple(assignment)) atomIndices.append(gndAtom.idx) except: pass variableAssignments.append(assignments) gndAtomIndices.append(atomIndices) return variableAssignments, gndAtomIndices
def getAdmissibleVarAssignments(self, f, trueGndAtoms): if not type(f) is Conjunction: return None cwPred = False assignments = [] for child in f.children: if not isinstance(child, Lit) and not isinstance(child, GroundLit) and not isinstance(child, GroundAtom): return None if child.predName in self.mrf.mln.closedWorldPreds and not cwPred: cwPred = True for gndAtom in trueGndAtoms: if gndAtom.predName != child.predName: continue assignment = [] try: for (p1, p2) in zip(child.params, gndAtom.params): if FOL.isVar(p1): assignment.append((p1, p2)) elif p1 != p2: raise assignments.append(tuple(assignment)) except: pass return assignments