|
|
@ -0,0 +1,28 @@ |
|
|
|
#!/usr/bin/python3 |
|
|
|
|
|
|
|
from z3 import * |
|
|
|
|
|
|
|
a,b,c,d,e,f = Ints('a b c d e f') |
|
|
|
s = Solver() |
|
|
|
s.add(215*a + 275*b + 335*c + 355*d + 420*e + 580*f == 1505, a>=0, b>=0, c>=0, d>=0, e>=0, f>=0) |
|
|
|
|
|
|
|
results=[] |
|
|
|
while True: |
|
|
|
if s.check() == sat: # |
|
|
|
m = s.model() # |
|
|
|
print(m) # |
|
|
|
results.append(m) |
|
|
|
block = [a != m[a].as_long(), b != m[b].as_long(), c != m[c].as_long(), d != m[d].as_long(), e != m[e].as_long(), f != m[f].as_long()] |
|
|
|
""" |
|
|
|
#Different approach: Iterate over all entries in the model |
|
|
|
block = [] |
|
|
|
for d in m.decls(): |
|
|
|
print(d, type(d), d(), type(d()), m[d], type(m[d])) |
|
|
|
c = d() |
|
|
|
block.append(c != m[d].as_long()) |
|
|
|
#print(s.sexpr()) |
|
|
|
""" |
|
|
|
s.add(Or(block)) |
|
|
|
else: |
|
|
|
print ("All results enumerated, total=", len(results)) |
|
|
|
break |