import itertools
#from multiprocessing import Pool

problems = [
        [8, 4, 26],
        [12, 1, 28],
        [6, 6, 32],
        [10, 5, 35],
        [3, 1, 38],
        [11, 4, 48],
        [9, 5, 50],
        [11, 9, 51],
        [13, 8, 53],
        [7, 1, 64]
        ]
process, weight, duedate = 0, 1, 2

def f(perm):
    flowtime = 0
    WT = 0
    for prob in perm:
        flowtime += prob[process]
        if flowtime >= prob[duedate]:
            WT += (flowtime - prob[duedate]) * prob[weight]
        
    return WT, perm


if __name__ == '__main__':
    #pool = Pool(processes=8)
    #WTS = pool.map(f, itertools.permutations(problems, 10))
    WTS = (f(x) for x in itertools.permutations(problems, 10))
    bestWT, perm = min(WTS, key=lambda item:item[0])
    
    print("-"*78)
    print("bestWT:", bestWT)
    print("problem:", perm)
    
        
"""
bestWT: 218
problem: ([8, 4, 26], [6, 6, 32], [10, 5, 35], [3, 1, 38], [11, 9, 51], [13, 8, 53], [9, 5, 50], [11, 4, 48], [7, 1, 64], [12, 1, 28])
"""
