コード例 #1
0
 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]))
コード例 #2
0
ファイル: pigeon-sinz.py プロジェクト: rebryant/pgbdd
 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
コード例 #3
0
 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
コード例 #4
0
ファイル: pigeon-sinz2.py プロジェクト: rebryant/pgbdd
 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