Skip to content

Assigning consecutive classes for a teacher #3474

Closed Answered by sarthakgaur
sarthakgaur asked this question in Q&A
Discussion options

You must be logged in to vote

Here is the solution to the problem:

def negated_bounded_span(works, start, length):
    sequence = []

    # Left border (start of works, or works[start - 1])
    if start > 0:
        sequence.append(works[start - 1])
    for i in range(length):
        sequence.append(works[start + i].Not())
    # Right border (end of works or works[start + length])
    if start + length < len(works):
        sequence.append(works[start + length])

    return sequence

def add_hard_sequence_constraint(model, works, hard_min, hard_max):
    # Forbid sequences that are too short.
    for length in range(1, hard_min):
        for start in range(len(works) - length + 1):
            model.AddBoolOr(negated…

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
5 replies
@sarthakgaur
Comment options

@Mizux
Comment options

@sarthakgaur
Comment options

@Mizux
Comment options

@sarthakgaur
Comment options

Comment options

You must be logged in to vote
3 replies
@sarthakgaur
Comment options

@Mizux
Comment options

@sarthakgaur
Comment options

Comment options

You must be logged in to vote
1 reply
@sarthakgaur
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by sarthakgaur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants