Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import numpy
  2. from binomialPoisson import *
  3.  
  4. hugeNumber = float("inf")
  5. unused = -1000
  6.  
  7. stages = 10
  8. seats = 50
  9. fullFare = 500
  10. discountFare = 250
  11. costOccupied = 8
  12.  
  13. meanFullDemand = numpy.array([unused,
  14. 1.3, 1.4, 1.9, 2.0, 2.2,
  15. 2.8, 2.2, 2.4, 1.8, 3.7])
  16.  
  17. maxCanRelease = [unused, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5]
  18.  
  19.  
  20. f = numpy.zeros([stages+2, seats+1])
  21. x = numpy.zeros([stages+1, seats+1], dtype=int)
  22.  
  23. # Iterate through stages
  24. for t in range(stages, 0, -1):
  25.  
  26. demandProbability = poisson(meanFullDemand[t], seats)
  27.  
  28. # Iterate through possible states (ie, number of seats unoccupied)
  29. for i in range(seats + 1):
  30.  
  31. value = -hugeNumber
  32. maxReleased = min(maxCanRelease[t], seats-i)
  33.  
  34. for d in range(maxReleased):
  35.  
  36. moveValue = -costOccupied*d + 250*d
  37.  
  38. seatsOccupied = i + d
  39. seatsUnoccupied = seats - seatsOccupied
  40.  
  41. for r in range(seatsUnoccupied + 1):
  42.  
  43. moveValue += demandProb[r]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement