Implements the algorithm of minimal scheduling