You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
4.1 KiB

2 months ago
  1. // Translation of the MAPA Specification of a polling system into PRISM code
  2. // http://wwwhome.cs.utwente.nl/~timmer/scoop/papers/qest13/index.html
  3. ma
  4. const int N; // number of job types (should be at most 6)
  5. const int Q; // Maximum queue size in each station
  6. // Formulae to control the LIFO queue of the stations.
  7. // The queue is represented by some integer whose base N representation has at most Q digits, each representing one of the job types 0, 1, ..., N-1.
  8. // In addition, we store the current size of the queue which is needed to distinguish an empty queue from a queue holding job of type 0
  9. formula queue1_empty = q1Size=0;
  10. formula queue1_full = q1Size=Q;
  11. formula queue1_pop = floor(q1/N);
  12. formula queue1_head = q1 - (queue1_pop * N); // i.e. q1 modulo N
  13. formula queue1_push = q1*N;
  14. formula queue2_empty = q2Size=0;
  15. formula queue2_full = q2Size=Q;
  16. formula queue2_pop = floor(q2/N);
  17. formula queue2_head = q2 - (queue2_pop * N); // i.e. q2 modulo N
  18. formula queue2_push = q2*N;
  19. const int queue_maxValue = (N^Q)-1;
  20. const double inRate1 = 3; // = (2 * #station) + 1;
  21. const double inRate2 = 5; // = (2 * #station) + 1;
  22. module pollingsys
  23. // The queues for the stations
  24. q1 : [0..queue_maxValue];
  25. q1Size : [0..Q];
  26. q2 : [0..queue_maxValue];
  27. q2Size : [0..Q];
  28. // Store the job that is currently processed by the server. j=N means that no job is processed.
  29. j : [0..N] init N;
  30. // Flag indicating whether a new job arrived
  31. newJob1 : bool init false;
  32. newJob2 : bool init false;
  33. //<> !newJob1 & !newJob2 & !queue1_full & queue2_full & j=N -> inRate1 : (newJob1'=true);
  34. //<> !newJob1 & !newJob2 & queue1_full & !queue2_full & j=N -> inRate2 : (newJob2'=true);
  35. <> !newJob1 & !newJob2 & !queue1_full & !queue2_full & j=N -> inRate1 : (newJob1'=true) + inRate2 : (newJob2'=true);
  36. <> !newJob1 & !newJob2 & queue1_full & queue2_full & j<N -> 2*(j+1) : (j'=N);
  37. <> !newJob1 & !newJob2 & !queue1_full & queue2_full & j<N -> inRate1 : (newJob1'=true) + 2*(j+1) : (j'=N);
  38. <> !newJob1 & !newJob2 & queue1_full & !queue2_full & j<N -> inRate2 : (newJob2'=true) + 2*(j+1) : (j'=N);
  39. <> !newJob1 & !newJob2 & !queue1_full & !queue2_full & j<N -> inRate1 : (newJob1'=true) + inRate2 : (newJob2'=true) + 2*(j+1) : (j'=N);
  40. [] newJob1 & N>=1 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+0) & (newJob1'=false);
  41. [] newJob1 & N>=2 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+1) & (newJob1'=false);
  42. [] newJob1 & N>=3 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+2) & (newJob1'=false);
  43. [] newJob1 & N>=4 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+3) & (newJob1'=false);
  44. [] newJob1 & N>=5 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+4) & (newJob1'=false);
  45. [] newJob1 & N>=6 -> 1 : (q1Size'=q1Size+1) & (q1'=queue1_push+5) & (newJob1'=false);
  46. [] newJob2 & N>=1 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+0) & (newJob2'=false);
  47. [] newJob2 & N>=2 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+1) & (newJob2'=false);
  48. [] newJob2 & N>=3 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+2) & (newJob2'=false);
  49. [] newJob2 & N>=4 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+3) & (newJob2'=false);
  50. [] newJob2 & N>=5 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+4) & (newJob2'=false);
  51. [] newJob2 & N>=6 -> 1 : (q2Size'=q2Size+1) & (q2'=queue2_push+5) & (newJob2'=false);
  52. [copy1] !newJob1 & !newJob2 & !queue1_empty & j=N -> 0.9 : (j'=queue1_head) & (q1Size'=q1Size-1) & (q1'=queue1_pop) + 0.1 : (j'=queue1_head);
  53. [copy2] !newJob1 & !newJob2 & !queue2_empty & j=N -> 0.9 : (j'=queue2_head) & (q2Size'=q2Size-1) & (q2'=queue2_pop) + 0.1 : (j'=queue2_head);
  54. endmodule
  55. label "q1full" = q1Size=Q;
  56. label "q2full" = q2Size=Q;
  57. label "allqueuesfull" = q1Size=Q & q2Size=Q;
  58. // Rewards adapted from Guck et al.: Modelling and Analysis of Markov Reward Automata
  59. rewards "processedjobs1"
  60. [copy1] true : 0.1;
  61. endrewards
  62. rewards "processedjobs2"
  63. [copy2] true : 0.1;
  64. endrewards
  65. rewards "processedjobs"
  66. [copy1] true : 0.1;
  67. [copy2] true : 0.1;
  68. endrewards
  69. rewards "queuesize1"
  70. true : 0.01 * (q1Size);
  71. endrewards
  72. rewards "queuesize2"
  73. true : 0.01 * (q2Size);
  74. endrewards
  75. rewards "queuesize"
  76. true : 0.01 * (q1Size + q2Size);
  77. endrewards