Guest User

CZN nightmare carnival optimisation

a guest
Oct 25th, 2026
120
0
178 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.22 KB | Gaming | 0 0
  1. import pulp
  2.  
  3. # Base score
  4. managerValues = {
  5.     "beryl": 70,
  6.     "sereniel": 23,
  7.     "maribell": 48,
  8.     "narja": 42,
  9.     "tiphera": 54,
  10.     "nine": 50,
  11.     "tenebria": 60,
  12.     "heidemarie": 40,
  13.     "mika": 66,
  14.     "rei": 75,
  15.     "owen": 64,
  16.     "luke": 51,
  17.     "lucas": 32,
  18.     "cassius": 39,
  19.     "yuki": 40,
  20.     "haru": 46,
  21.     "fei": 59,
  22.     "renoa": 54,
  23.     "rossweisse": 90,
  24.     "orlea": 62,
  25.     "hilde": 48,
  26.     "arabella": 100,
  27.     "olga": 64
  28. }
  29.  
  30. # Bonus
  31. managerBonus = {
  32.     ("sereniel", "narja"): 200/5,
  33.     ("sereniel", "heidemarie"): 250/5,
  34.     ("maribell", "nine"): 200/4,
  35.     ("maribell", "beryl"): 100/4,
  36.     ("narja", "sereniel"): 150/4,
  37.     ("tiphera", "nine"): 200/7,
  38.     ("nine", "tiphera"): 200/6,
  39.     ("tenebria", "heidemarie"): 150/5,
  40.     ("heidemarie", "tenebria"): 100/3,
  41.     ("heidemarie", "tiphera"): 100/3,
  42.     ("mika", "renoa"): 180/5,
  43.     ("rei", "renoa"): 200/6,
  44.     ("owen", "renoa"): 150/4,
  45.     ("luke", "lucas"): 200/4,
  46.     ("lucas", "luke"): 300/6,
  47.     ("cassius", "heidemarie"): 100/3,
  48.     ("cassius", "olga"): 100/3,
  49.     ("yuki", "fei"): 200/5,
  50.     ("yuki", "haru"): 100/5,
  51.     ("haru", "rei"): 200/6,
  52.     ("fei", "hilde"): 200/4,
  53.     ("renoa", "rossweisse"): 80/4,
  54.     ("renoa", "orlea"): 80/4,
  55.     ("orlea", "fei"): 120/4,
  56.     ("hilde", "arabella"): 200/7,
  57.     ("hilde", "olga"): 200/7,
  58.     ("olga", "hilde"): 200/6
  59. }
  60.  
  61. SLOTS = 8
  62.  
  63. # Problem definition
  64. prob = pulp.LpProblem("managers", pulp.LpMaximize)
  65.  
  66. # Add variables - adds a variable with a label, keyed against the "for x in selection" part
  67. x = {m: prob.add_variable(f"x_{m}", cat="Binary") for m in managerValues}
  68. y = {p: prob.add_variable(f"y_{p[0]}_{p[1]}", cat="Binary") for p in managerBonus}
  69.  
  70. # Add objective
  71. prob += (pulp.lpSum(x[m]*managerValues[m] for m in managerValues)
  72.          + pulp.lpSum(y[p]*managerBonus[p] for p in managerBonus))
  73.  
  74. # Add constraints
  75. prob += pulp.lpSum(x.values()) <= SLOTS
  76.  
  77. for (i, j) in managerBonus:
  78.     prob += y[(i, j)] <= x[i]
  79.     prob += y[(i, j)] <= x[j]
  80.  
  81. # Solve
  82. result = prob.solve(pulp.HiGHS(msg=False))
  83.  
  84. print("Status:", result.status.name)
  85. print("Score: ", pulp.value(prob.objective))
  86. print("Team:  ", [m for m in managerValues if x[m].value() > 0.5])
Add Comment
Please, Sign In to add comment