Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. # doctors Choice Function if True or hospitals otherwise
  2. def C(L, doctors):
  3.   pass
  4.  
  5.  
  6. # Lower Ideal of L
  7. def Li(L):
  8.   lowerIdeal = set()
  9.   for x in AllContracts:
  10.     for y in L:
  11.       if isComparable(x, y) and x <= y:
  12.         lowerIdeal.add(x)
  13.         break
  14.   return lowerIdeal
  15.      
  16.  
  17. # Lower Ideal of C(L, doctors)
  18. def C_star(L, doctors):
  19.   return Li(C(L, doctors))
  20.  
  21.  
  22. # antitone function U for the choice function C_star(L, doctors)
  23. def U_star(L, doctors):
  24.   u = set()
  25.   for x in AllContracts:
  26.     if x in L:
  27.       u.add(x)
  28.     else:
  29.       L.add(x)
  30.       if x in C_star(L, doctors):
  31.         u.add(x)
  32.       L.remove(x)
  33.   return u
  34.  
  35.  
  36. # one mapping of L1 and L2 with antitone function for hospitals/doctors
  37. def f(L1, L2):
  38.   return (U_star(L2, hospitals), U_star(L1, doctors))
  39.  
  40.  
  41. def solve(L1, L2):
  42.   nextL1, nextL2 = f(L1, L2)
  43.   if (L1, L2) == (nextL1, nextL2):
  44.     # (L1, L2) is a fixed Point
  45.     return (L1, L2)
  46.   return solve(nextL1, nextL2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement