Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Last active April 5, 2021 20:59
Show Gist options
  • Select an option

  • Save samirsaci/e277740335a6d9a20b098332e84daa9b to your computer and use it in GitHub Desktop.

Select an option

Save samirsaci/e277740335a6d9a20b098332e84daa9b to your computer and use it in GitHub Desktop.
Prep data pulp
import pandas as pd
from pulp import * # pip install pulp
import matplotlib.pyplot as plt
from itertools import chain, repeat
def ncycles(iterable, n):
"Returns the sequence elements n times"
return chain.from_iterable(repeat(tuple(iterable), n))
# Staff needs per Day
n_staff = [31, 45, 40, 40, 48, 30, 25]
# Days of the week
jours = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
# Create circular list of days
n_days = [i for i in range(7)]
n_days_c = list(ncycles(n_days, 3))
# Working days
list_in = [[n_days_c[j] for j in range(i , i + 5)] for i in n_days_c]
# Workers off by shift for each day
list_excl = [[n_days_c[j] for j in range(i + 1, i + 3)] for i in n_days_c]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment