def emitClauses(self, writer): self.left.emitClauses(writer) self.right.emitClauses(writer) A = self.left.output B = self.right.output C = self.output writer.doComment("Xor(%d, %d) --> %d" % (A, B, C)) self.clauseIds.append(writer.doClause([-A, -B, -C])) self.clauseIds.append(writer.doClause([-A, B, C])) self.clauseIds.append(writer.doClause([A, -B, C])) self.clauseIds.append(writer.doClause([A, B, -C]))
def doClauses(self, writer): clist = [] writer.doComment("AtMost1 constraint for hole %d, pigeon %d" % (self.h, self.p)) if self.S is not None: clist.append(writer.doClause([-self.M, self.S])) if self.Sprev is not None: clist.append(writer.doClause([-self.Sprev, -self.M])) if self.S is not None: clist.append(writer.doClause([-self.Sprev, self.S])) return clist
def doClauses(self, writer): allVars = [self.top, self.right, self.bottom, self.left] vars = [v for v in allVars if v is not None] clist = [] if len(vars) > 1: # Not chopped corner writer.doComment( "Exactly one constraints for square %d,%d (%d variables)" % (self.row, self.col, len(vars))) clauses = exactlyOne(vars) for clause in clauses: clist.append(writer.doClause(clause)) return clist
def doClauses(self, writer): clist = [] writer.doComment("AtMost1 constraint for hole %d, pigeons %d-%d" % (self.h, self.p, self.p+self.width-1)) if self.S is not None: clist.append(writer.doClause([-self.Sprev, self.S])) clist.append(writer.doClause([-self.M0, self.S])) if self.width > 1: clist.append(writer.doClause([-self.M1, self.S])) clist.append(writer.doClause([-self.Sprev, -self.M0])) if self.width > 1: clist.append(writer.doClause([-self.Sprev, -self.M1])) clist.append(writer.doClause([-self.M0, -self.M1])) return clist