elems.append(e1)
return elems
+def lessThanValue(csolverlb, csolver, elems, m, n):
+ e1 = elems[m]
+ e2 = csolverlb.getElementConst(csolver, c_uint(12), n)
+ equals = csolverlb.createPredicateOperator(csolver, c_uint(ps.CompOp.SATC_LT))
+ inp = [e1,e2]
+ inputs = (c_void_p*len(inp))(*inp)
+ b= csolverlb.applyPredicate(csolver,equals, inputs, c_uint(2))
+ return CSConstraint(csolverlb, csolver, b)
+
def Placement(csolverlb, csolver, elems, m, n):
e1 = elems[m]
e2 = csolverlb.getElementConst(csolver, c_uint(12), n)
b= csolverlb.applyPredicate(csolver,equals, inputs, c_uint(2))
return CSConstraint(csolverlb, csolver, b)
-# def Occupied(csolverlb, csolver, elems, m):
-# e1 = elems[m]
-# e2 = csolverlb.getElementConst(csolver, c_uint(12), 7)
-# equals = csolverlb.createPredicateOperator(csolver, c_uint(ps.CompOp.SATC_EQUALS))
-# inp = [e1,e2]
-# inputs = (c_void_p*len(inp))(*inp)
-# b= csolverlb.applyPredicate(csolver,equals, inputs, c_uint(2))
-# return CSConstraint(csolverlb, csolver, b)
+def emptyValue(csolverlb, csolver, elems, m):
+ e1 = elems[m]
+ e2 = csolverlb.getElementConst(csolver, c_uint(12), 7)
+ equals = csolverlb.createPredicateOperator(csolver, c_uint(ps.CompOp.SATC_EQUALS))
+ inp = [e1,e2]
+ inputs = (c_void_p*len(inp))(*inp)
+ b= csolverlb.applyPredicate(csolver,equals, inputs, c_uint(2))
+ return CSConstraint(csolverlb, csolver, b)
def replaceWithElemConst(csolverlb, solver, elems, m, n):
elems[m] = csolverlb.getElementConst(solver, c_uint(10), n)
Equivalent(csolverlb, csolver, +Placement(csolverlb, csolver, elems,m,n), +NSum(n) )
).getConstraint())
- for n in range(nvs+1, 7):
- csolverlb.addConstraint(csolver, (-Placement(csolverlb, csolver, elems,m,n)).getConstraint() )
-
+# for n in range(nvs+1, 7):
+# csolverlb.addConstraint(csolver, (-Placement(csolverlb, csolver, elems,m,n)).getConstraint() )
+ constr =[lessThanValue(csolverlb, csolver, elems, m, nvs+1), emptyValue(csolverlb, csolver, elems, m)]
+ csolverlb.addConstraint(csolver, Or(csolverlb, csolver, constr).getConstraint())
print 'Creating constraints for the number of empty cell...'
empty_count = len(topology.ps) - sum([c for (_,c) in board_input.counts])