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.

160 lines
3.9 KiB

  1. // power manager example
  2. mdp
  3. const int QMAX =2; // max queue size
  4. // to model the pm making a choice and then a move being made we need
  5. // two clock ticks for each transition
  6. // first the pm decides tick1 and then the system moves tick2
  7. module timer
  8. c : [0..1];
  9. [tick1] c=0 -> (c'=1);
  10. [tick2] c=1 -> (c'=0);
  11. endmodule
  12. //-------------------------------------------------------------------------
  13. // POWER MANAGER
  14. module PM
  15. pm : [0..4] init 4;
  16. // 0 - go to active
  17. // 1 - go to idle
  18. // 2 - go to idlelp
  19. // 3 - go to stby
  20. // 4 - go to sleep
  21. [tick1] true -> (pm'=0);
  22. [tick1] true -> (pm'=1);
  23. [tick1] true -> (pm'=2);
  24. [tick1] true -> (pm'=3);
  25. [tick1] true -> (pm'=4);
  26. endmodule
  27. //-------------------------------------------------------------------------
  28. // SERVICE REQUESTER
  29. module SR
  30. sr : [0..1] init 0;
  31. // 0 idle
  32. // 1 1req
  33. [tick2] sr=0 -> 0.898: (sr'=0) + 0.102: (sr'=1);
  34. [tick2] sr=1 -> 0.454: (sr'=0) + 0.546: (sr'=1);
  35. endmodule
  36. //-------------------------------------------------------------------------
  37. // SERVICE PROVIDER
  38. module SP
  39. sp : [0..10] init 9;
  40. // 0 active
  41. // 1 idle
  42. // 2 active_idlelp
  43. // 3 idlelp
  44. // 4 idlelp_active
  45. // 5 active_stby
  46. // 6 stby
  47. // 7 stby_active
  48. // 8 active_sleep
  49. // 9 sleep
  50. // 10 sleep_active
  51. // states where PM has no control (transient states)
  52. [tick2] sp=2 -> 0.75 : (sp'=2) + 0.25 : (sp'=3); // active_idlelp
  53. [tick2] sp=4 -> 0.25 : (sp'=0) + 0.75 : (sp'=4); // idlelp_active
  54. [tick2] sp=5 -> 0.995 : (sp'=5) + 0.005 : (sp'=6); // active_stby
  55. [tick2] sp=7 -> 0.005 : (sp'=0) + 0.995 : (sp'=7); // stby_active
  56. [tick2] sp=8 -> 0.9983 : (sp'=8) + 0.0017 : (sp'=9); // active_sleep
  57. [tick2] sp=10 -> 0.0017 : (sp'=0) + 0.9983 : (sp'=10); // sleep_active
  58. // states where PM has control
  59. // goto_active
  60. [tick2] sp=0 & pm=0 -> (sp'=0); // active
  61. [tick2] sp=1 & pm=0 -> (sp'=0); // idle
  62. [tick2] sp=3 & pm=0 -> (sp'=4); // idlelp
  63. [tick2] sp=6 & pm=0 -> (sp'=7); // stby
  64. [tick2] sp=9 & pm=0 -> (sp'=10); // sleep
  65. // goto_idle
  66. [tick2] sp=0 & pm=1 -> (sp'=1); // active
  67. [tick2] sp=1 & pm=1 -> (sp'=1); // idle
  68. [tick2] sp=3 & pm=1 -> (sp'=3); // idlelp
  69. [tick2] sp=6 & pm=1 -> (sp'=6); // stby
  70. [tick2] sp=9 & pm=1 -> (sp'=9); // sleep
  71. // goto_idlelp
  72. [tick2] sp=0 & pm=2 -> (sp'=2); // active
  73. [tick2] sp=1 & pm=2 -> (sp'=2); // idle
  74. [tick2] sp=3 & pm=2 -> (sp'=3); // idlelp
  75. [tick2] sp=6 & pm=2 -> (sp'=6); // stby
  76. [tick2] sp=9 & pm=2 -> (sp'=9); // sleep
  77. // goto_stby
  78. [tick2] sp=0 & pm=3 -> (sp'=5); // active
  79. [tick2] sp=1 & pm=3 -> (sp'=5); // idle
  80. [tick2] sp=3 & pm=3 -> (sp'=5); // idlelp
  81. [tick2] sp=6 & pm=3 -> (sp'=6); // stby
  82. [tick2] sp=9 & pm=3 -> (sp'=9); // sleep
  83. // goto_sleep
  84. [tick2] sp=0 & pm=4 -> (sp'=8); // active
  85. [tick2] sp=1 & pm=4 -> (sp'=8); // idle
  86. [tick2] sp=3 & pm=4 -> (sp'=8); // idlelp
  87. [tick2] sp=6 & pm=4 -> (sp'=8); // stby
  88. [tick2] sp=9 & pm=4 -> (sp'=9); // sleep
  89. endmodule
  90. //-------------------------------------------------------------------------
  91. // SQ
  92. module SQ
  93. q : [0..QMAX] init 0;
  94. // serve if busy
  95. [tick2] sr=0 & sp=0 -> (q'=max(q-1,0));
  96. [tick2] sr=1 & sp=0 -> (q'=q);
  97. // otherwise do nothing
  98. [tick2] sr=0 & sp>0 -> (q'=q);
  99. [tick2] sr=1 & sp>0 -> (q'=min(q+1,QMAX));
  100. endmodule
  101. //-------------------------------------------------------------------------
  102. //rewards "time"
  103. // [tick2] bat=1 : 1;
  104. //endrewards
  105. rewards "power"
  106. [tick2] sp=0 & c=1 : 2.5;
  107. [tick2] sp=1 & c=1 : 1.5;
  108. [tick2] sp=2 & c=1 : 2.5;
  109. [tick2] sp=3 & c=1 : 0.8;
  110. [tick2] sp=4 & c=1 : 2.5;
  111. [tick2] sp=5 & c=1 : 2.5;
  112. [tick2] sp=6 & c=1 : 0.3;
  113. [tick2] sp=7 & c=1 : 2.5;
  114. [tick2] sp=8 & c=1 : 2.5;
  115. [tick2] sp=9 & c=1 : 0.1;
  116. [tick2] sp=10 & c=1 : 2.5;
  117. endrewards
  118. // is an instantaneous property but I suppose we can look at average size
  119. // i.e. divide by the expected number of time steps
  120. rewards "queue"
  121. [tick2] c=1 : q;
  122. endrewards
  123. rewards "lost"
  124. [tick2] sr=1 & sp>0 & q=2 : 1;
  125. endrewards