This is a summary example of what we have done so far.
It is implemented with inequality constraints. Note that it tries to find two solutions, but only one solution exists, so solution2.txt does not exist.
import sc3
import math
if len(AllDays) !=len(shiftdef) or len(AllDays) !=len(A_Member_in_All):
raise ValueError("AllDays and shiftdef are inconsistent")
blocks=int(math.sqrt(len(AllDays)))
if math.sqrt(len(AllDays)) not in range(2,11,1):
raise ValueError("Illegal sudoku dimmension. Supported sizes are 4x4,9x9...100x100.")
for day in AllDays: #column
for shift in shiftdef.keys():
V=[]
for person in A_Member_in_All:
V.append(sc3.GetShiftVar(person,day,shift))
sc3.AddHard(sc3.SeqLE(1,1,V),'')
for person in A_Member_in_All: #row
for shift in shiftdef.keys():
V=[]
for day in AllDays:
V.append(sc3.GetShiftVar(person,day,shift))
sc3.AddHard(sc3.SeqLE(1,1,V),'')
for person in range(0,len(A_Member_in_All),blocks): #block
for shift in shiftdef.keys():
for day in range(0,len(AllDays),blocks):
V=[]
for i in range(blocks):
for j in range(blocks):
V.append(sc3.GetShiftVar(person+i,day+j,shift))
sc3.AddHard(sc3.SeqLE(1,1,V),'')