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.

95 lines
2.9 KiB

  1. mdp
  2. label "tasks_complete" = (task6=3);
  3. const int K=5;
  4. module scheduler
  5. task1 : [0..3];
  6. task2 : [0..3];
  7. task3 : [0..3];
  8. task4 : [0..3];
  9. task5 : [0..3];
  10. task6 : [0..3];
  11. [p1_add] task1=0 -> (task1'=1);
  12. [p2_add] task1=0 -> (task1'=2);
  13. [p1_mult] task2=0 -> (task2'=1);
  14. [p2_mult] task2=0 -> (task2'=2);
  15. [p1_mult] task3=0&task1=3 -> (task3'=1);
  16. [p2_mult] task3=0&task1=3 -> (task3'=2);
  17. [p1_add] task4=0&task1=3&task2=3 -> (task4'=1);
  18. [p2_add] task4=0&task1=3&task2=3 -> (task4'=2);
  19. [p1_mult] task5=0&task3=3 -> (task5'=1);
  20. [p2_mult] task5=0&task3=3 -> (task5'=2);
  21. [p1_add] task6=0&task4=3&task5=3 -> (task6'=1);
  22. [p2_add] task6=0&task4=3&task5=3 -> (task6'=2);
  23. [p1_done] task1=1 -> (task1'=3);
  24. [p1_done] task2=1 -> (task2'=3);
  25. [p1_done] task3=1 -> (task3'=3);
  26. [p1_done] task4=1 -> (task4'=3);
  27. [p1_done] task5=1 -> (task5'=3);
  28. [p1_done] task6=1 -> (task6'=3);
  29. [p2_done] task1=2 -> (task1'=3);
  30. [p2_done] task2=2 -> (task2'=3);
  31. [p2_done] task3=2 -> (task3'=3);
  32. [p2_done] task4=2 -> (task4'=3);
  33. [p2_done] task5=2 -> (task5'=3);
  34. [p2_done] task6=2 -> (task6'=3);
  35. [time] true -> 1.0 : true;
  36. endmodule
  37. module P1
  38. p1 : [0..3];
  39. c1 : [0..2];
  40. x1 : [0..4*K+1];
  41. [p1_add] (p1=0) -> (p1'=1) & (x1'=0);
  42. [] (p1=1)&(x1=1*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0);
  43. [] (p1=1)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0);
  44. [p1_done] (p1=1)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0);
  45. [p1_mult] (p1=0) -> (p1'=2) & (x1'=0);
  46. [] (p1=2)&(x1=2*K)&(c1=0) -> 1/3 : (p1'=3) & (x1'=0) & (c1'=0) + 2/3 : (c1'=1) & (x1'=0);
  47. [] (p1=2)&(x1=1*K)&(c1=1) -> 1/2 : (p1'=3) & (x1'=0) & (c1'=0) + 1/2 : (c1'=2) & (x1'=0);
  48. [p1_done] (p1=2)&(x1=1*K)&(c1=2) -> (p1'=0) & (x1'=0) & (c1'=0);
  49. [p1_done] (p1=3) -> (p1'=0);
  50. [time] (p1=1=>x1+1<=1*K)&((p1=2&c1=0)=>x1+1<=2*K)&((p1=2&c1>0)=>x1+1<=1*K)&(p1=3=>x1+1<=0) -> 1.0 : (x1'=min(x1+1,4*K+1));
  51. endmodule
  52. module P2
  53. p2 : [0..3];
  54. c2 : [0..2];
  55. x2 : [0..6*K+1];
  56. [p2_add] (p2=0) -> (p2'=1) & (x2'=0);
  57. [] (p2=1)&(x2=4*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0);
  58. [] (p2=1)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0);
  59. [p2_done] (p2=1)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0);
  60. [p2_mult] (p2=0) -> (p2'=2) & (x2'=0);
  61. [] (p2=2)&(x2=6*K)&(c2=0) -> 1/3 : (p2'=3) & (x2'=0) & (c2'=0) + 2/3 : (c2'=1) & (x2'=0);
  62. [] (p2=2)&(x2=1)&(c2=1) -> 1/2 : (p2'=3) & (x2'=0) & (c2'=0) + 1/2 : (c2'=2) & (x2'=0);
  63. [p2_done] (p2=2)&(x2=1)&(c2=2) -> (p2'=0) & (x2'=0) & (c2'=0);
  64. [p2_done] (p2=3) -> (p2'=0);
  65. [time] ((p2=1&c2=0)=>x2+1<=4*K)&((p2=1&c2>0)=>x2+1<=1)&((p2=2&c2=0)=>x2+1<=6*K)&((p2=2&c2>0)=>x2+1<=1)&(p2=3=>x2+1<=0) -> 1.0 : (x2'=min(x2+1,6*K+1));
  66. endmodule
  67. rewards "time"
  68. [time] true : 1/K;
  69. endrewards
  70. rewards "energy"
  71. [time] p1=0 : 10/(1000*K);
  72. [time] p1>0 : 90/(1000*K);
  73. [time] p2=0 : 20/(1000*K);
  74. [time] p2>0 : 30/(1000*K);
  75. endrewards