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.

292 lines
12 KiB

  1. mdp
  2. // parameters
  3. const int n_resources = 3;
  4. const int n_tasks = 2;
  5. const int n_sensors = 3;
  6. // sensor resources
  7. const int resource1=1;
  8. const int resource2=2;
  9. const int resource3=3;
  10. // network configuration
  11. const int e12=1;
  12. const int e13=1;
  13. const int e21=e12;
  14. const int e23=1;
  15. const int e31=e13;
  16. const int e32=e23;
  17. // agent is committed to some team
  18. formula committed = (m1_t1+m1_t2) > 0;
  19. // formulae to compute team sizes
  20. formula team_size_t1 = m1_t1+m2_t1+m3_t1;
  21. formula team_size_t2 = m1_t2+m2_t2+m3_t2;
  22. // formulae to check whether the agent can join the team
  23. formula can_join_t1 = e12*m2_t1 + e13*m3_t1 > 0;
  24. formula can_join_t2 = e12*m2_t2 + e13*m3_t2 > 0;
  25. // formulae to check whether agent has the resource required by the task
  26. formula has_resource_t1 = ( (t1_r1=1&resource1=1) | (t1_r2=1&resource1=2) | (t1_r3=1&resource1=3) );
  27. formula has_resource_t2 = ( (t2_r1=1&resource1=1) | (t2_r2=1&resource1=2) | (t2_r3=1&resource1=3) );
  28. // formulae to check whether the resource of an agent has been already filled in the team
  29. formula resource_filled_t1 = (m2_t1=1 & resource1=resource2) | (m3_t1=1 & resource1=resource3);
  30. formula resource_filled_t2 = (m2_t2=1 & resource1=resource2) | (m3_t2=1 & resource1=resource3);
  31. // formula to compute team initiation probability (assuming each agent has at least one connection)
  32. formula IP = (e12*(1-((m2_t1+m2_t2)=0?0:1))+e13*(1-((m3_t1+m3_t2)=0?0:1))) / (e12+e13);
  33. module controller // schedules the algorithm
  34. // algorithm status
  35. status : [0..6];
  36. // task resource indicator variables
  37. t1_r1 : [0..1];
  38. t1_r2 : [0..1];
  39. t1_r3 : [0..1];
  40. t2_r1 : [0..1];
  41. t2_r2 : [0..1];
  42. t2_r3 : [0..1];
  43. // schedule placeholders
  44. turn1 : [0..n_sensors];
  45. turn2 : [0..n_sensors];
  46. turn3 : [0..n_sensors];
  47. // selecting schedule uniformly at random
  48. [] status=0 -> 1/6 : (turn1'=1) & (turn2'=2) & (turn3'=3) & (status'=1)
  49. + 1/6 : (turn1'=1) & (turn2'=3) & (turn3'=2) & (status'=1)
  50. + 1/6 : (turn1'=2) & (turn2'=1) & (turn3'=3) & (status'=1)
  51. + 1/6 : (turn1'=2) & (turn2'=3) & (turn3'=1) & (status'=1)
  52. + 1/6 : (turn1'=3) & (turn2'=1) & (turn3'=2) & (status'=1)
  53. + 1/6 : (turn1'=3) & (turn2'=2) & (turn3'=1) & (status'=1);
  54. // initialising non-empty tasks uniformly at random
  55. [] status=1 -> 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  56. + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  57. + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  58. + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  59. + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  60. + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  61. + 1/49 : (t1_r1'=0) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  62. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  63. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  64. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  65. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  66. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  67. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  68. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  69. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  70. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  71. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  72. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  73. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  74. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  75. + 1/49 : (t1_r1'=0) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  76. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  77. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  78. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  79. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  80. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  81. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  82. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  83. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  84. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  85. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  86. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  87. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  88. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  89. + 1/49 : (t1_r1'=1) & (t1_r2'=0) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  90. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  91. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  92. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  93. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  94. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  95. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  96. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=0) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  97. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  98. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  99. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=0) & (t2_r2'=1) & (t2_r3'=1) & (status'=2)
  100. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=0) & (status'=2)
  101. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=0) & (t2_r3'=1) & (status'=2)
  102. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=0) & (status'=2)
  103. + 1/49 : (t1_r1'=1) & (t1_r2'=1) & (t1_r3'=1) & (t2_r1'=1) & (t2_r2'=1) & (t2_r3'=1) & (status'=2);
  104. // executing the schedule
  105. // 1st round
  106. [str1] status=2 & turn1=1 -> (status'=2);
  107. [fin1] status=2 & turn1=1 -> (status'=3);
  108. [str2] status=2 & turn1=2 -> (status'=2);
  109. [fin2] status=2 & turn1=2 -> (status'=3);
  110. [str3] status=2 & turn1=3 -> (status'=2);
  111. [fin3] status=2 & turn1=3 -> (status'=3);
  112. // 2nd round
  113. [str1] status=3 & turn2=1 -> (status'=3);
  114. [fin1] status=3 & turn2=1 -> (status'=4);
  115. [str2] status=3 & turn2=2 -> (status'=3);
  116. [fin2] status=3 & turn2=2 -> (status'=4);
  117. [str3] status=3 & turn2=3 -> (status'=3);
  118. [fin3] status=3 & turn2=3 -> (status'=4);
  119. // 3rd round
  120. [str1] status=4 & turn3=1 -> (status'=4);
  121. [fin1] status=4 & turn3=1 -> (status'=5);
  122. [str2] status=4 & turn3=2 -> (status'=4);
  123. [fin2] status=4 & turn3=2 -> (status'=5);
  124. [str3] status=4 & turn3=3 -> (status'=4);
  125. [fin3] status=4 & turn3=3 -> (status'=5);
  126. [] status=5 -> (status'=6);
  127. [] status=6 -> true;
  128. endmodule
  129. module sensor1
  130. state1 : [0..1];
  131. // team membership indicators
  132. m1_t1 : [0..1];
  133. m1_t2 : [0..1];
  134. // starting turn, selecting order of tasks
  135. [str1] state1=0 -> (state1'=1);
  136. // if there is no team and has required skill - initiating the team
  137. [] state1=1 & !committed & team_size_t1=0 & has_resource_t1 -> (m1_t1'=1);
  138. [] state1=1 & !committed & team_size_t2=0 & has_resource_t2 -> (m1_t2'=1);
  139. // if team already exists and one of the neighbours is in it - joining the team
  140. [] state1=1 & !committed & team_size_t1>0 & can_join_t1 & has_resource_t1 & !resource_filled_t1 -> (m1_t1'=1);
  141. [] state1=1 & !committed & team_size_t2>0 & can_join_t2 & has_resource_t2 & !resource_filled_t2 -> (m1_t2'=1);
  142. [fin1] state1>0 -> (state1'=0);
  143. endmodule
  144. module sensor2 = sensor1
  145. [
  146. state1=state2,
  147. str1=str2,
  148. fin1=fin2,
  149. m1_t1=m2_t1,
  150. m1_t2=m2_t2,
  151. m2_t1=m1_t1,
  152. m2_t2=m1_t2,
  153. resource1=resource2,
  154. resource2=resource1,
  155. e12=e21,
  156. e13=e23,
  157. e14=e24,
  158. e15=e25,
  159. e21=e12,
  160. e23=e13,
  161. e24=e14,
  162. e25=e15
  163. ]
  164. endmodule
  165. module sensor3 = sensor1
  166. [
  167. state1=state3,
  168. str1=str3,
  169. fin1=fin3,
  170. m1_t1=m3_t1,
  171. m1_t2=m3_t2,
  172. m3_t1=m1_t1,
  173. m3_t2=m1_t2,
  174. resource1=resource3,
  175. resource3=resource1,
  176. e12=e32,
  177. e13=e31,
  178. e14=e34,
  179. e15=e35,
  180. e31=e13,
  181. e32=e12,
  182. e34=e14,
  183. e35=e15
  184. ]
  185. endmodule
  186. // labels and formulae for property specification
  187. formula finished = (status=5);
  188. label "end" = (status=6);
  189. formula task1_completed = finished
  190. & ((t1_r1=1)=>((m1_t1=1&resource1=1)|(m2_t1=1&resource2=1)|(m3_t1=1&resource3=1)))
  191. & ((t1_r2=1)=>((m1_t1=1&resource1=2)|(m2_t1=1&resource2=2)|(m3_t1=1&resource3=2)))
  192. & ((t1_r3=1)=>((m1_t1=1&resource1=3)|(m2_t1=1&resource2=3)|(m3_t1=1&resource3=3)));
  193. formula task2_completed = finished
  194. & ((t2_r1=1)=>((m1_t2=1&resource1=1)|(m2_t2=1&resource2=1)|(m3_t2=1&resource3=1)))
  195. & ((t2_r2=1)=>((m1_t2=1&resource1=2)|(m2_t2=1&resource2=2)|(m3_t2=1&resource3=2)))
  196. & ((t2_r3=1)=>((m1_t2=1&resource1=3)|(m2_t2=1&resource2=3)|(m3_t2=1&resource3=3)));
  197. formula agent1_joins_successful_team = (task1_completed & m1_t1=1) | (task2_completed & m1_t2=1);
  198. formula agent1_joins_successful_team_of_1 = (task1_completed & m1_t1=1 & team_size_t1=1) | (task2_completed & m1_t2=1 & team_size_t2=1);
  199. formula agent1_joins_successful_team_of_2 = (task1_completed & m1_t1=1 & team_size_t1=2) | (task2_completed & m1_t2=1 & team_size_t2=2);
  200. formula agent1_joins_successful_team_of_3 = (task1_completed & m1_t1=1 & team_size_t1=3) | (task2_completed & m1_t2=1 & team_size_t2=3);
  201. formula agent2_joins_successful_team = (task1_completed & m2_t1=1) | (task2_completed & m2_t2=1);
  202. formula agent2_joins_successful_team_of_1 = (task1_completed & m2_t1=1 & team_size_t1=1) | (task2_completed & m2_t2=1 & team_size_t2=1);
  203. formula agent2_joins_successful_team_of_2 = (task1_completed & m2_t1=1 & team_size_t1=2) | (task2_completed & m2_t2=1 & team_size_t2=2);
  204. formula agent2_joins_successful_team_of_3 = (task1_completed & m2_t1=1 & team_size_t1=3) | (task2_completed & m2_t2=1 & team_size_t2=3);
  205. formula agent3_joins_successful_team = (task1_completed & m3_t1=1) | (task2_completed & m3_t2=1);
  206. formula agent3_joins_successful_team_of_1 = (task1_completed & m3_t1=1 & team_size_t1=1) | (task2_completed & m3_t2=1 & team_size_t2=1);
  207. formula agent3_joins_successful_team_of_2 = (task1_completed & m3_t1=1 & team_size_t1=2) | (task2_completed & m3_t2=1 & team_size_t2=2);
  208. formula agent3_joins_successful_team_of_3 = (task1_completed & m3_t1=1 & team_size_t1=3) | (task2_completed & m3_t2=1 & team_size_t2=3);
  209. label "task1_compl" = task1_completed;
  210. label "task2_compl" = task2_completed;
  211. // rewards
  212. rewards "w_1_total"
  213. [] agent1_joins_successful_team : 1;
  214. [] agent2_joins_successful_team : 1;
  215. [] agent3_joins_successful_team : 1;
  216. endrewards
  217. rewards "w_2_total"
  218. [] task1_completed : 1;
  219. [] task2_completed : 1;
  220. endrewards