Guest User

Untitled

a guest
Apr 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. require 'pp'
  2.  
  3. # Storing all variables in a Hash so they can be printed in
  4. # a way that shows everything related to the calculation.
  5.  
  6. x = {}
  7.  
  8. x[:task_count] = 1_000
  9. x[:$task] = 0.01
  10. x[:task_redundancy] = 2 # How many different users must do task
  11.  
  12. x[:rate_of_mediation] = 1.0 / 40
  13. x[:rate_failed_mediation] = 1.0 / 20
  14.  
  15.  
  16. # I use $'s in the Symbols to denote a cost value.
  17.  
  18. x[:$minimum] = x[:$task] * x[:task_redundancy] # Minimum cost of a task
  19. x[:$base] = x[:$minimum] * x[:task_count]
  20.  
  21. x[:mediations] = x[:task_count] * x[:rate_of_mediation]
  22. x[:$mediations] = x[:mediations] * x[:$task]
  23.  
  24. x[:failed_medations] = x[:mediations] * x[:rate_failed_mediation]
  25. x[:$failed_medations] = (x[:failed_medations] * x[:$minimum]) + (x[:failed_medations] * x[:$task])
  26.  
  27. x[:$$] = x[:$base] + x[:$mediations] + x[:$failed_medations]
  28.  
  29. puts "TOTAL COST: $%.2f" % x[:$$]
  30. puts
  31. pp x
Add Comment
Please, Sign In to add comment