fork download
  1. import itertools
  2. #from multiprocessing import Pool
  3.  
  4. problems = [
  5. [8, 4, 26],
  6. [12, 1, 28],
  7. [6, 6, 32],
  8. [10, 5, 35],
  9. [3, 1, 38],
  10. [11, 4, 48],
  11. [9, 5, 50],
  12. [11, 9, 51],
  13. [13, 8, 53],
  14. [7, 1, 64]
  15. ]
  16. process, weight, duedate = 0, 1, 2
  17.  
  18. def f(perm):
  19. flowtime = 0
  20. WT = 0
  21. for prob in perm:
  22. flowtime += prob[process]
  23. if flowtime >= prob[duedate]:
  24. WT += (flowtime - prob[duedate]) * prob[weight]
  25.  
  26. return WT, perm
  27.  
  28.  
  29. if __name__ == '__main__':
  30. #pool = Pool(processes=8)
  31. #WTS = pool.map(f, itertools.permutations(problems, 10))
  32. WTS = (f(x) for x in itertools.permutations(problems, 10))
  33. bestWT, perm = min(WTS, key=lambda item:item[0])
  34.  
  35. print("-"*78)
  36. print("bestWT:", bestWT)
  37. print("problem:", perm)
  38.  
  39.  
  40. """
  41. bestWT: 218
  42. 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])
  43. """
  44.  
Time limit exceeded #stdin #stdout 5s 10256KB
stdin
Standard input is empty
stdout
Standard output is empty