It is the exact specification in Python Tutorial 7 , but soft inequality constraints are used.

import sc3

for person in A_Member_in_All:
    vlist=[]
    s='Python Paid Holiday'+staffdef[person]+'\n'
    for day in Mon:
        v=sc3.GetShiftVar(person,day,'Paid_Holiday')
        vlist.append(v)
    sc3.AddSoft(sc3.SeqError(4,4,4,vlist),s,4) #min max allowable errors listimport sc3



sc3.SeqError(min,max, allowable_errors,list)

is the format for soft inequality constraints. It is always used in conjunction with AddSoft.

The intent of the restriction is to make four of the five Mondays public holidays.
However, the result is not because the schedule entries are entered as hard constraints.



The allowable_errors is how many of these errors are allowed.
It is the same as in the GUI, but the GUI setting is ignored, and the Python description is always valid.

Try changing the number of allowable errors

Let’s try changing the number of allowed errors from 4 to 3.


    AddSoft(sc3.SeqError(4,4,3,vlist),s,4) #min max allowable errors list

Then there is no solution as follows



In the same way, try to predict what will happen when the number of allowable errors is varied.
Here are the results when we set the allowable errors to 0.


    sc3.AddSoft(sc3.SeqError(4,4,0,vlist),s,4) #min max allowable errors list



Breaking up linear → nonlinear

The meaning of allowable errors is to destroy the previous linear soft weights by setting a hard boundary.
In other words, it is the prevention of unlimited softening and the invocation of coercion.
As we saw above, this also means we risk having no solution simultaneously.
In other words, it is a constraint that expresses a person’s feeling of “up to this point, I can forgive, but no more, absolutely not.
The flip side of “never” would be “no solution.”