-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkfunction.py
More file actions
29 lines (24 loc) · 793 Bytes
/
workfunction.py
File metadata and controls
29 lines (24 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
import os
def complement(a, b):
b = set(b)
return [i for i in a if i not in b]
def workfunction(D,d,T,M,N):
#D is the number of days total
#d is the day of signup
#T is the time required for signup for library j
#M is the number of books per day for library j
#N is the number of books in library j
return np.min([(D-d-T)*M,N])
def maxScore(s,B,Z,D,d,T,M):
#s is the ordered score list for all books remaining
#B is the list of books for library j
#Z is the global worklist of books
#D is the number of days total
#d is the day of signup
#T is the time required for signup for library j
#M is the number of books per day for library j
b = complement(B,Z)
w = workfunction(D,d,T,M,len(b))
dZ = b[:w]
return np.sum([s[i] for i in dZ]),dZ