#!/usr/bin/python
"""
Test of built in mod (%) in Numberjack.
This model was created by Hakan Kjellerstrand (hakank@bonetmail.com)
See also my Numberjack page http://www.hakank.org/numberjack/
"""
from Numberjack import *
# Notes:
# - We don't have any problems with getNextSolution(), it shows all
# solutions.
# Should we add AllDiff([x,y,z]), then it generates forever
#
# - When y is defined as Variable(1,10,'y')
# the following error occurs:
# Error: Solution does not verify
# c (x2 % x3) = x1
# c 1 x2 = 1
# c 1 x3 = 2
# c 1 x1 = 0
# s NOT SUPPORTED
def model():
x = Variable(0,10,'x')
y = Variable(2,10,'y')
z = Variable(0,10,'z')
model = Model (
z == x % y,
# z == 1
)
for a,b in pair_of([x,y,z]):
model += (a != b)
print model
solver = model.load('Mistral')
solver.solve()
print x,y,z
while solver.getNextSolution():
print x,y,z
model()